diff options
Diffstat (limited to 'toys/android/runcon.c')
-rw-r--r-- | toys/android/runcon.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/toys/android/runcon.c b/toys/android/runcon.c new file mode 100644 index 00000000..c2f71e2d --- /dev/null +++ b/toys/android/runcon.c @@ -0,0 +1,27 @@ +/* runcon.c - Run command in specified security context + * + * Copyright 2015 The Android Open Source Project + +USE_RUNCON(NEWTOY(runcon, "<2", TOYFLAG_USR|TOYFLAG_SBIN)) + +config RUNCON + bool "runcon" + depends on TOYBOX_SELINUX + default y + help + usage: runcon CONTEXT COMMAND [ARGS...] + + Run a command in a specified security context. +*/ + +#define FOR_runcon +#include "toys.h" + +void runcon_main(void) +{ + char *context = *toys.optargs; + + if (setexeccon(context)) perror_exit("Could not set context to %s", context); + + xexec(++toys.optargs); +} |