aboutsummaryrefslogtreecommitdiff
path: root/src/jail.c
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2018-04-23 16:51:19 +0200
committerToni Uhlig <matzeton@googlemail.com>2018-04-23 16:51:19 +0200
commit8be43bc691b38b582aca2f8c3bbf232fbb4d495e (patch)
treedfd870b2932310e5f46c756de4f15be6a603f3e0 /src/jail.c
parent10023e21207d9cdd0c299efeca116a1bae6cad1c (diff)
POTD sekelton #25.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/jail.c')
-rw-r--r--src/jail.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/jail.c b/src/jail.c
index cf6dfc0..a086e22 100644
--- a/src/jail.c
+++ b/src/jail.c
@@ -2,9 +2,11 @@
#include <stdlib.h>
#include <sched.h>
#include <signal.h>
+#include <sys/epoll.h>
#include <assert.h>
#include "jail.h"
+#include "utils.h"
#include "log.h"
static int jail_daemonfn(jail_ctx *ctx);
@@ -17,7 +19,7 @@ void jail_init(jail_ctx **ctx, size_t stacksize)
if (stacksize > BUFSIZ)
stacksize = BUFSIZ;
if (!*ctx)
- *ctx = calloc(1, sizeof(**ctx));
+ *ctx = (jail_ctx *) calloc(1, sizeof(**ctx));
assert(*ctx);
(*ctx)->stacksize = stacksize;
@@ -57,9 +59,17 @@ static int jail_daemonfn(jail_ctx *ctx)
{
int clone_flags = CLONE_NEWUTS|CLONE_NEWPID|CLONE_NEWIPC|
CLONE_NEWNS|CLONE_NEWNET;
+ int fd;
assert(ctx);
+ set_procname("[potd] jaild");
+ assert( set_child_sighandler() == 0 );
+ fd = epoll_create1(0);
+ if (fd < 0) {
+ E_STRERR("Jail epoll create");
+ exit(EXIT_FAILURE);
+ }
while (1) {
ctx->jail_pid = clone(jail_childfn, ctx->stack_beg,
SIGCHLD|clone_flags, ctx);