Skip to content

Commit 764aff6

Browse files
committed
Add option to propagate SIGTERM,SIGINT to child
1 parent 1b0675b commit 764aff6

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

bubblewrap.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static bool opt_unshare_cgroup_try = FALSE;
8686
static bool opt_needs_devpts = FALSE;
8787
static bool opt_new_session = FALSE;
8888
static bool opt_die_with_parent = FALSE;
89+
static bool opt_signal_propogate = FALSE;
8990
static uid_t opt_sandbox_uid = -1;
9091
static gid_t opt_sandbox_gid = -1;
9192
static int opt_sync_fd = -1;
@@ -365,6 +366,7 @@ usage (int ecode, FILE *out)
365366
" --perms OCTAL Set permissions of next argument (--bind-data, --file, etc.)\n"
366367
" --size BYTES Set size of next argument (only for --tmpfs)\n"
367368
" --chmod OCTAL PATH Change permissions of PATH (must already exist)\n"
369+
" --no-int-term Don't handle SIGINT and SIGTERM, but pass them to sandboxed process.\n"
368370
);
369371
exit (ecode);
370372
}
@@ -380,7 +382,7 @@ handle_die_with_parent (void)
380382
}
381383

382384
static void
383-
gate_signals (int action, sigset_t *prevmask)
385+
gate_signals (int action, sigset_t *prevmask) // here
384386
{
385387
sigset_t mask;
386388

@@ -978,7 +980,7 @@ get_newroot_path (const char *path)
978980
return strconcat ("/newroot/", path);
979981
}
980982

981-
static void
983+
static void //fix for uid maps range, instead of single will come here | but that's for later...
982984
write_uid_gid_map (uid_t sandbox_uid,
983985
uid_t parent_uid,
984986
uid_t sandbox_gid,
@@ -2529,6 +2531,10 @@ parse_args_recurse (int *argcp,
25292531
argc -= 1;
25302532
break;
25312533
}
2534+
else if (strcmp (arg, "--no-int-term") == 0)
2535+
{
2536+
opt_signal_propogate = TRUE;
2537+
}
25322538
else if (*arg == '-')
25332539
{
25342540
die ("Unknown option %s", arg);
@@ -2842,7 +2848,8 @@ main (int argc,
28422848
block_sigchild ();
28432849

28442850
/* We block other signals here to avoid leaving an orphan. */
2845-
gate_signals (SIG_BLOCK, &sigmask);
2851+
if (opt_signal_propogate)
2852+
gate_signals (SIG_BLOCK, &sigmask);
28462853

28472854
clone_flags = SIGCHLD | CLONE_NEWNS;
28482855
if (opt_unshare_user)
@@ -2995,7 +3002,8 @@ main (int argc,
29953002
}
29963003

29973004
/* Unblock other signals here to receive signals from the parent. */
2998-
gate_signals (SIG_UNBLOCK, &sigmask);
3005+
if (opt_signal_propogate)
3006+
gate_signals (SIG_UNBLOCK, &sigmask);
29993007

30003008
if (opt_pidns_fd > 0)
30013009
{

0 commit comments

Comments
 (0)