smack: introduce new SmackProcessLabel option
In service file, if the file has some of special SMACK label in ExecStart= and systemd has no permission for the special SMACK label then permission error will occurred. To resolve this, systemd should be able to set its SMACK label to something accessible of ExecStart=. So introduce new SmackProcessLabel. If label is specified with SmackProcessLabel= then the child systemd will set its label to that. To successfully execute the ExecStart=, accessible label should be specified with SmackProcessLabel=. Additionally, by SMACK policy, if the file in ExecStart= has no SMACK64EXEC then the executed process will have given label by SmackProcessLabel=. But if the file has SMACK64EXEC then the SMACK64EXEC label will be overridden. [zj: reword man page]
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
8086ffacdb
commit
2ca620c4ed
@@ -83,6 +83,7 @@
|
||||
#include "af-list.h"
|
||||
#include "mkdir.h"
|
||||
#include "apparmor-util.h"
|
||||
#include "smack-util.h"
|
||||
#include "bus-kernel.h"
|
||||
#include "label.h"
|
||||
|
||||
@@ -1618,6 +1619,16 @@ static int exec_child(ExecCommand *command,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_SMACK
|
||||
if (context->smack_process_label) {
|
||||
err = mac_smack_apply_pid(0, context->smack_process_label);
|
||||
if (err < 0) {
|
||||
*error = EXIT_SMACK_PROCESS_LABEL;
|
||||
return err;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (context->user) {
|
||||
err = enforce_user(context, uid);
|
||||
if (err < 0) {
|
||||
|
||||
Reference in New Issue
Block a user