File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -639,7 +639,12 @@ void nsexec(void)
639639 * some old kernel versions where clone(CLONE_PARENT | CLONE_NEWPID)
640640 * was broken, so we'll just do it the long way anyway.
641641 */
642- if (unshare (config .cloneflags ) < 0 )
642+ uint32_t apply_cloneflags = config .cloneflags ;
643+ if ((config .cloneflags & CLONE_NEWUSER ) && (config .cloneflags & CLONE_NEWIPC )) {
644+ apply_cloneflags &= ~CLONE_NEWIPC ;
645+ }
646+
647+ if (unshare (apply_cloneflags ) < 0 )
643648 bail ("failed to unshare namespaces" );
644649
645650 /*
@@ -735,6 +740,11 @@ void nsexec(void)
735740 if (setgroups (0 , NULL ) < 0 )
736741 bail ("setgroups failed" );
737742
743+ if ((config .cloneflags & CLONE_NEWUSER ) && (config .cloneflags & CLONE_NEWIPC )) {
744+ if (unshare (CLONE_NEWIPC ) < 0 )
745+ bail ("unshare ipc failed" );
746+ }
747+
738748 if (consolefd != -1 ) {
739749 if (ioctl (consolefd , TIOCSCTTY , 0 ) < 0 )
740750 bail ("ioctl TIOCSCTTY failed" );
You can’t perform that action at this time.
0 commit comments