diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/execute.c | 6 | ||||
| -rw-r--r-- | src/core/execute.h | 3 | ||||
| -rw-r--r-- | src/core/load-fragment.c | 15 | 
3 files changed, 15 insertions, 9 deletions
| diff --git a/src/core/execute.c b/src/core/execute.c index e718c43df9..802f14d575 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1717,7 +1717,7 @@ static int exec_child(          umask(context->umask); -        if (params->apply_permissions) { +        if (params->apply_permissions && !command->privileged) {                  r = enforce_groups(context, username, gid);                  if (r < 0) {                          *exit_status = EXIT_GROUP; @@ -1842,7 +1842,7 @@ static int exec_child(          }  #ifdef HAVE_SELINUX -        if (params->apply_permissions && mac_selinux_use() && params->selinux_context_net && socket_fd >= 0) { +        if (params->apply_permissions && mac_selinux_use() && params->selinux_context_net && socket_fd >= 0 && !command->privileged) {                  r = mac_selinux_get_child_mls_label(socket_fd, command->path, context->selinux_context, &mac_selinux_context_net);                  if (r < 0) {                          *exit_status = EXIT_SELINUX_CONTEXT; @@ -1867,7 +1867,7 @@ static int exec_child(                  return r;          } -        if (params->apply_permissions) { +        if (params->apply_permissions && !command->privileged) {                  bool use_address_families = context->address_families_whitelist ||                          !set_isempty(context->address_families); diff --git a/src/core/execute.h b/src/core/execute.h index 464869d226..cd1f7b36f6 100644 --- a/src/core/execute.h +++ b/src/core/execute.h @@ -81,7 +81,8 @@ struct ExecCommand {          char **argv;          ExecStatus exec_status;          LIST_FIELDS(ExecCommand, command); /* useful for chaining commands */ -        bool ignore; +        bool ignore:1; +        bool privileged:1;  };  struct ExecRuntime { diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 2d8f6296c8..17c72aed88 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -596,7 +596,7 @@ int config_parse_exec(          p = rvalue;          do {                  _cleanup_free_ char *path = NULL, *firstword = NULL; -                bool separate_argv0 = false, ignore = false; +                bool separate_argv0 = false, ignore = false, privileged = false;                  _cleanup_free_ ExecCommand *nce = NULL;                  _cleanup_strv_free_ char **n = NULL;                  size_t nlen = 0, nbufsize = 0; @@ -610,14 +610,18 @@ int config_parse_exec(                          return 0;                  f = firstword; -                for (i = 0; i < 2; i++) { -                        /* We accept an absolute path as first argument, or -                         * alternatively an absolute prefixed with @ to allow -                         * overriding of argv[0]. */ +                for (i = 0; i < 3; i++) { +                        /* We accept an absolute path as first argument. +                         * If it's prefixed with - and the path doesn't exist, +                         * we ignore it instead of erroring out; +                         * if it's prefixed with @, we allow overriding of argv[0]; +                         * and if it's prefixed with !, it will be run with full privileges */                          if (*f == '-' && !ignore)                                  ignore = true;                          else if (*f == '@' && !separate_argv0)                                  separate_argv0 = true; +                        else if (*f == '!' && !privileged) +                                privileged = true;                          else                                  break;                          f++; @@ -715,6 +719,7 @@ int config_parse_exec(                  nce->argv = n;                  nce->path = path;                  nce->ignore = ignore; +                nce->privileged = privileged;                  exec_command_append_list(e, nce); | 
