unshare --user=<file> always fails because we no longer have CAP_SYS_ADMIN
in the parent user namespace after unsharing to create the new one. As with
unshare --mount=<file>, fork a child to make the bind mount instead.
Signed-off-by: Chris Webb <chris@arachsys.com>
/* clear any inherited settings */
signal(SIGCHLD, SIG_DFL);
- if (npersists && (unshare_flags & CLONE_NEWNS))
+ if (npersists && (unshare_flags & (CLONE_NEWNS | CLONE_NEWUSER)))
pid_bind = bind_ns_files_from_child(&fd_bind);
if (usermap || groupmap)
if (npersists && (pid || !forkit)) {
/* run in parent */
- if (pid_bind && (unshare_flags & CLONE_NEWNS))
+ if (pid_bind && (unshare_flags & (CLONE_NEWNS | CLONE_NEWUSER)))
sync_with_child(pid_bind, fd_bind);
else
/* simple way, just bind */