Implement --skip_setsid

This commit is contained in:
Robert Swiecki 2016-01-25 18:09:32 +01:00
parent d36deb5d0d
commit 87829e3f6e
3 changed files with 9 additions and 1 deletions

View File

@ -270,6 +270,7 @@ bool cmdlineParse(int argc, char *argv[], struct nsjconf_t * nsjconf)
.mode = MODE_LISTEN_TCP,
.is_root_rw = false,
.is_silent = false,
.skip_setsid = false,
.iface = NULL,
.inside_uid = getuid(),
.inside_gid = getgid(),
@ -314,6 +315,7 @@ bool cmdlineParse(int argc, char *argv[], struct nsjconf_t * nsjconf)
{{"keep_caps", no_argument, NULL, 0x0501}, "Don't drop capabilities (DANGEROUS) (default: false)"},
{{"silent", no_argument, NULL, 0x0502}, "Redirect child's fd:0/1/2 to /dev/null (default: false)"},
{{"disable_sandbox", no_argument, NULL, 0x0503}, "Don't enable the seccomp-bpf sandboxing (default: false)"},
{{"skip_setsid", no_argument, NULL, 0x0504}, "Don't call setsid(), allows for terminal signal handling in the sandboxed process (default: false)"},
{{"rlimit_as", required_argument, NULL, 0x0201}, "RLIMIT_AS in MB, 'max' for RLIM_INFINITY, 'def' for the current value (default: 512)"},
{{"rlimit_core", required_argument, NULL, 0x0202}, "RLIMIT_CORE in MB, 'max' for RLIM_INFINITY, 'def' for the current value (default: 0)"},
{{"rlimit_cpu", required_argument, NULL, 0x0203}, "RLIMIT_CPU, 'max' for RLIM_INFINITY, 'def' for the current value (default: 600)"},
@ -461,6 +463,9 @@ bool cmdlineParse(int argc, char *argv[], struct nsjconf_t * nsjconf)
case 0x0503:
nsjconf->apply_sandbox = false;
break;
case 0x0504:
nsjconf->skip_setsid = true;
break;
case 0x0601:
nsjconf->is_root_rw = true;
break;

View File

@ -84,6 +84,7 @@ struct nsjconf_t {
const char *chroot;
bool is_root_rw;
bool is_silent;
bool skip_setsid;
char *iface;
uid_t outside_uid;
gid_t outside_gid;

View File

@ -179,7 +179,9 @@ bool containPrepareEnv(struct nsjconf_t * nsjconf)
if (setpriority(PRIO_PROCESS, 0, 19) == -1 && errno != 0) {
PLOG_W("setpriority(19)");
}
setsid();
if (nsjconf->skip_setsid == false) {
setsid();
}
return true;
}