process-util: add option for cloning with CLONE_NEWUSER

This is useful for allocating a userns fd later on for use in idmapped
mounts.
This commit is contained in:
Lennart Poettering
2021-05-07 22:43:42 +02:00
parent 14a25e1fae
commit 5f9687363a
2 changed files with 5 additions and 2 deletions
+4 -2
View File
@@ -1306,8 +1306,10 @@ int safe_fork_full(
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)