diff options
Diffstat (limited to 'pkg/rootless/rootless_linux.c')
-rw-r--r-- | pkg/rootless/rootless_linux.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/pkg/rootless/rootless_linux.c b/pkg/rootless/rootless_linux.c index 1b98f76eb..e894328ce 100644 --- a/pkg/rootless/rootless_linux.c +++ b/pkg/rootless/rootless_linux.c @@ -83,7 +83,37 @@ get_cmd_line_args (pid_t pid) } int -reexec_in_user_namespace(int ready) +reexec_userns_join (int userns) +{ + pid_t ppid = getpid (); + char uid[16]; + char **argv; + int pid; + + sprintf (uid, "%d", geteuid ()); + + argv = get_cmd_line_args (ppid); + if (argv == NULL) + _exit (EXIT_FAILURE); + + pid = fork (); + if (pid) + return pid; + + setenv ("_LIBPOD_USERNS_CONFIGURED", "init", 1); + setenv ("_LIBPOD_ROOTLESS_UID", uid, 1); + + if (setns (userns, 0) < 0) + _exit (EXIT_FAILURE); + close (userns); + + execvp (argv[0], argv); + + _exit (EXIT_FAILURE); +} + +int +reexec_in_user_namespace (int ready) { int ret; pid_t pid; |