diff options
author | Karel Kočí <cynerd@email.cz> | 2019-04-28 17:56:30 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2019-04-28 17:56:30 +0200 |
commit | 68f78d914b221763476e6f17a0d0c48183eeb8cb (patch) | |
tree | 9f65bcd596ed9dbc551e6a8b39067f5e4169db7d /main.c | |
parent | 3f0fa5587f6e69e8957e674d3ccde6ff8873302e (diff) | |
download | uroot-68f78d914b221763476e6f17a0d0c48183eeb8cb.tar.gz uroot-68f78d914b221763476e6f17a0d0c48183eeb8cb.tar.bz2 uroot-68f78d914b221763476e6f17a0d0c48183eeb8cb.zip |
child: allow binfmt_misc to be preserved
This should allow chrooting to non-native systems using qemu.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -41,10 +41,16 @@ static const char doc[] = "Tool using Linux namespaces to provide root like func struct opts { char **child_argv; size_t child_argc; + bool binfmt; +}; + +enum option_key { + OPT_BINFMT = 260, }; static struct argp_option options[] = { {"debug", 'd', NULL, 0, "Report uroot operations.", 0}, + {"binfmt", OPT_BINFMT, NULL, 0, "Preserve registered misc binary format handlers.", 0}, {NULL} }; @@ -54,6 +60,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { case 'd': // TODO logging break; + case OPT_BINFMT: + opts->binfmt = true; + break; case ARGP_KEY_ARGS: opts->child_argc = state->argc - state->next; opts->child_argv = malloc((opts->child_argc + 1) * sizeof *opts->child_argv); @@ -64,6 +73,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { case ARGP_KEY_INIT: opts->child_argv = NULL; opts->child_argc = 0; + opts->binfmt = false; break; default: return ARGP_ERR_UNKNOWN; @@ -87,7 +97,8 @@ int main(int argc, char **argv) { .ppid = getpid(), .argc = opts.child_argc, .argv = opts.child_argv, - .sigpipe = sigpipe_new() + .sigpipe = sigpipe_new(), + .binfmt = opts.binfmt, }; uint8_t stack[STACK_SIZE]; |