aboutsummaryrefslogtreecommitdiff
path: root/src/jail.c
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2018-05-13 13:41:37 +0200
committerToni Uhlig <matzeton@googlemail.com>2018-05-13 13:41:37 +0200
commitd336c8771f617df35c43f28feae6c3f83512deaf (patch)
tree3e227ed11408e89a34afa3cc35771773781bee5f /src/jail.c
parentaebb4b9fa16bd82fc78d850dc47484c6d733b223 (diff)
parent9b1eccdee52a0c8972eb60cb18710bc2f07ca695 (diff)
Merge branch 'master' of ssh://git.lan:/git/potd
Diffstat (limited to 'src/jail.c')
-rw-r--r--src/jail.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/jail.c b/src/jail.c
index 3de4d85..6e14b7a 100644
--- a/src/jail.c
+++ b/src/jail.c
@@ -137,7 +137,7 @@ pid_t jail_daemonize(event_ctx **ev_ctx, jail_ctx *ctx[], size_t siz)
W_STRERR("%s", "Jail daemonize");
return -1;
case 0:
- N("%s", "Jail daemon mainloop");
+ N("Jail daemon child pid %d", getpid());
jail_mainloop(ev_ctx, (const jail_ctx **) ctx, siz);
}
D2("Jail daemon pid: %d", p);
@@ -236,6 +236,8 @@ static int jail_childfn(prisoner_process *ctx)
assert(ctx);
self_pid = getpid();
+ if (set_child_sighandler())
+ FATAL("Set sighandler for pid %d", self_pid);
if (setpgrp())
FATAL("Jail set process group for pid %d", self_pid);
if (prctl(PR_SET_PDEATHSIG, SIGKILL) != 0)
@@ -282,8 +284,6 @@ static int jail_childfn(prisoner_process *ctx)
S_IROTH|S_IXOTH);
if (s && errno != EEXIST)
FATAL("Create directory '%s'", path_proc);
- if (!dir_is_mountpoint(path_proc) && mount_proc(path_proc))
- FATAL("Mount devpts to '%s%s'", ctx->newroot, path_proc)
D2("Creating device files in '%s%s'", ctx->newroot, path_dev);
if (create_device_files(path_dev)) {
@@ -302,16 +302,20 @@ static int jail_childfn(prisoner_process *ctx)
self_pid);
break;
case 0:
+ if (mount_proc(path_proc))
+ exit(EXIT_FAILURE);
+ if (close_fds_except(0, 1, 2, -1))
+ exit(EXIT_FAILURE);
if (execl(path_shell, path_shell, (char *) NULL))
exit(EXIT_FAILURE);
default:
if (set_fd_nonblock(master_fd))
FATAL("Pty master fd nonblock for prisoner pid %d",
child_pid);
- N("Socket to tty I/O loop for prisoner pid %d",
+ N("Socket to tty I/O for prisoner pid %d",
child_pid);
if (jail_socket_tty(ctx, master_fd))
- FATAL("Socket to tty I/O loop for prisoner pid %d",
+ FATAL("Socket to tty I/O for prisoner pid %d",
child_pid);
waitpid(child_pid, &s, 0);
}