return true;
}
+void subprocDummyInit()
+{
+ pid_t pid = syscall(__NR_clone, (uintptr_t) 0, NULL, NULL, NULL, (uintptr_t) 0);
+ if (pid == -1) {
+ LOG_F("Couldn't create a dummy init process");
+ }
+ if (pid > 0) {
+ return;
+ }
+ if (prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0) == -1) {
+ LOG_W("(prctl(PR_SET_PDEATHSIG, SIGKILL) failed");
+ }
+ for (;;) {
+ pause();
+ }
+}
+
void subprocRunChild(struct nsjconf_t *nsjconf, int fd_in, int fd_out, int fd_err)
{
if (netLimitConns(nsjconf, fd_in) == false) {
flags |= (nsjconf->clone_newuts ? CLONE_NEWUTS : 0);
if (nsjconf->mode == MODE_STANDALONE_EXECVE) {
- if (nsjconf->clone_newpid) {
- LOG_D("CLONE_NEWPID requested. It causes troubles with unshare() "
- "[ENOMEM with clone/fork/vfork]. Disabling it");
- flags &= ~(CLONE_NEWPID);
- }
LOG_D("Entering namespace with flags: %#lx", flags);
if (unshare(flags) == -1) {
PLOG_E("unshare(%#lx)", flags);
_exit(EXIT_FAILURE);
}
+ if (nsjconf->clone_newpid) {
+ LOG_D
+ ("CLONE_NEWPID requested. We must create a dummy init process, to avoid ENOMEM with clone/fork/vfork");
+ subprocDummyInit();
+ }
subprocNewProc(nsjconf, fd_in, fd_out, fd_err, -1);
}