Mercurial > hg > toybox
changeset 1751:cba1817972b8 draft
Add runcon(1).
author | Elliott Hughes <enh@google.com> |
---|---|
date | Mon, 23 Mar 2015 12:46:20 -0500 |
parents | 8f59893165fa |
children | 2d51d89b9d79 |
files | toys/pending/runcon.c |
diffstat | 1 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toys/pending/runcon.c Mon Mar 23 12:46:20 2015 -0500 @@ -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); +}