aboutsummaryrefslogtreecommitdiff
path: root/toys/pending
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-03-23 12:46:20 -0500
committerElliott Hughes <enh@google.com>2015-03-23 12:46:20 -0500
commitfd1ff92b160b500a0a443bcdbd86a6e1709e9495 (patch)
tree0ea8ae637cd24913394f54fe9d2f22110c3d9b0c /toys/pending
parent845dc93c1a41d03a329d934a96d292541c0435d7 (diff)
downloadtoybox-fd1ff92b160b500a0a443bcdbd86a6e1709e9495.tar.gz
Add runcon(1).
Diffstat (limited to 'toys/pending')
-rw-r--r--toys/pending/runcon.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/toys/pending/runcon.c b/toys/pending/runcon.c
new file mode 100644
index 00000000..bf13442e
--- /dev/null
+++ b/toys/pending/runcon.c
@@ -0,0 +1,29 @@
+/* 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 n
+ 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))
+ error_exit("Could not set context to %s: %s", context, strerror(errno));
+
+ toys.optargs++;
+ xexec(toys.optargs);
+}