1 /* runcon.c - Run command in specified security context
2  *
3  * Copyright 2015 The Android Open Source Project
4 
5 USE_RUNCON(NEWTOY(runcon, "<2", TOYFLAG_USR|TOYFLAG_SBIN))
6 
7 config RUNCON
8   bool "runcon"
9   depends on TOYBOX_SELINUX
10   default y
11   help
12     usage: runcon CONTEXT COMMAND [ARGS...]
13 
14     Run a command in a specified security context.
15 */
16 
17 #define FOR_runcon
18 #include "toys.h"
19 
runcon_main(void)20 void runcon_main(void)
21 {
22   char *context = *toys.optargs;
23 
24   if (setexeccon(context)) perror_exit("Could not set context to %s", context);
25 
26   toys.stacktop = 0;
27   xexec(++toys.optargs);
28 }
29