init: change exec parsing to make SECLABEL optional

(cherry pick from commit 17fff893c0)

Allow SECLABEL to be - to denote default

Change-Id: I58cdc6c805dc6e50dc42b7e13e72d0eaf4864f11
This commit is contained in:
Mark Salyzyn 2015-06-02 11:11:02 -07:00
parent 473a50f168
commit cdb73b034d
3 changed files with 5 additions and 3 deletions

View file

@ -380,7 +380,8 @@ void service_start(struct service *svc, const char *dynamic_args)
if ((svc->flags & SVC_EXEC) != 0) { if ((svc->flags & SVC_EXEC) != 0) {
INFO("SVC_EXEC pid %d (uid %d gid %d+%zu context %s) started; waiting...\n", INFO("SVC_EXEC pid %d (uid %d gid %d+%zu context %s) started; waiting...\n",
svc->pid, svc->uid, svc->gid, svc->nr_supp_gids, svc->seclabel); svc->pid, svc->uid, svc->gid, svc->nr_supp_gids,
svc->seclabel ? : "default");
waiting_for_exec = true; waiting_for_exec = true;
} }

View file

@ -666,6 +666,7 @@ int action_queue_empty()
service* make_exec_oneshot_service(int nargs, char** args) { service* make_exec_oneshot_service(int nargs, char** args) {
// Parse the arguments: exec [SECLABEL [UID [GID]*] --] COMMAND ARGS... // Parse the arguments: exec [SECLABEL [UID [GID]*] --] COMMAND ARGS...
// SECLABEL can be a - to denote default
int command_arg = 1; int command_arg = 1;
for (int i = 1; i < nargs; ++i) { for (int i = 1; i < nargs; ++i) {
if (strcmp(args[i], "--") == 0) { if (strcmp(args[i], "--") == 0) {
@ -691,7 +692,7 @@ service* make_exec_oneshot_service(int nargs, char** args) {
return NULL; return NULL;
} }
if (command_arg > 2) { if ((command_arg > 2) && strcmp(args[1], "-")) {
svc->seclabel = args[1]; svc->seclabel = args[1];
} }
if (command_arg > 3) { if (command_arg > 3) {

View file

@ -180,7 +180,7 @@ exec [ <seclabel> [ <user> [ <group> ]* ] ] -- <command> [ <argument> ]*
Fork and execute command with the given arguments. The command starts Fork and execute command with the given arguments. The command starts
after "--" so that an optional security context, user, and supplementary after "--" so that an optional security context, user, and supplementary
groups can be provided. No other commands will be run until this one groups can be provided. No other commands will be run until this one
finishes. finishes. <seclabel> can be a - to denote default.
export <name> <value> export <name> <value>
Set the environment variable <name> equal to <value> in the Set the environment variable <name> equal to <value> in the