This is useful for allocating a userns fd later on for use in idmapped
mounts.
saved_ssp = &saved_ss;
}
- if (flags & FORK_NEW_MOUNTNS)
- pid = raw_clone(SIGCHLD|CLONE_NEWNS);
+ if ((flags & (FORK_NEW_MOUNTNS|FORK_NEW_USERNS)) != 0)
+ pid = raw_clone(SIGCHLD|
+ (FLAGS_SET(flags, FORK_NEW_MOUNTNS) ? CLONE_NEWNS : 0) |
+ (FLAGS_SET(flags, FORK_NEW_USERNS) ? CLONE_NEWUSER : 0));
else
pid = fork();
if (pid < 0)
FORK_RLIMIT_NOFILE_SAFE = 1 << 10, /* Set RLIMIT_NOFILE soft limit to 1K for select() compat */
FORK_STDOUT_TO_STDERR = 1 << 11, /* Make stdout a copy of stderr */
FORK_FLUSH_STDIO = 1 << 12, /* fflush() stdout (and stderr) before forking */
+ FORK_NEW_USERNS = 1 << 13, /* Run child in its own user namespace */
} ForkFlags;
int safe_fork_full(const char *name, const int except_fds[], size_t n_except_fds, ForkFlags flags, pid_t *ret_pid);