diff options
author | lns <matzeton@googlemail.com> | 2018-05-29 20:27:53 +0200 |
---|---|---|
committer | lns <matzeton@googlemail.com> | 2018-05-29 20:27:53 +0200 |
commit | ac567dfe566d582fb59297487822a3afadff1974 (patch) | |
tree | 65595a7076756b9caddd7410c160b3a184a716c3 | |
parent | a8416237f30f77c5e78b06a58298442245911fb5 (diff) |
POTD skeleton #80.
Signed-off-by: lns <matzeton@googlemail.com>
-rw-r--r-- | src/jail.c | 1 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/pevent.c | 2 | ||||
-rw-r--r-- | src/redirector.c | 12 | ||||
-rw-r--r-- | src/redirector.h | 2 | ||||
-rw-r--r-- | src/utils.c | 4 |
6 files changed, 12 insertions, 13 deletions
@@ -157,7 +157,6 @@ pid_t jail_daemonize(event_ctx **ev_ctx, jail_ctx *ctx[], size_t siz) case 0: caps_jail_filter(); jail_mainloop(ev_ctx, (const jail_ctx **) ctx, siz); - break; } D2("Jail daemon pid: %d", p); @@ -35,7 +35,7 @@ static void jail_preinit(const char *jail_ports[], jail_ctx *ctx[], D("Initialising jail service on port %s", jail_ports[i]); jail_init_ctx(&ctx[i], MAX_STACKSIZE); - //jail[i]->newroot = strdup("/home/lns/git/busybox/sysroot"); + //ctx[i]->newroot = strdup("/home/lns/git/busybox/sysroot"); ctx[i]->newroot = strdup("/home/toni/git/busybox/_install"); ABORT_ON_FATAL( jail_setup(ctx[i], "127.0.0.1", jail_ports[i]), "Jail daemon setup" ); @@ -103,7 +103,7 @@ static pid_t rdr_init(redirector_ctx *ctx[], const size_t siz) "Redirector event setup" ); N("%s", "Redirector epoll mainloop"); - rdr_pid = redirector_daemonize( event, ctx, siz ); + rdr_pid = redirector_daemonize( &event, ctx, siz ); ABORT_ON_FATAL( rdr_pid < 1, "Server epoll mainloop" ); return rdr_pid; diff --git a/src/pevent.c b/src/pevent.c index ddb5a03..7ed9b55 100644 --- a/src/pevent.c +++ b/src/pevent.c @@ -49,7 +49,7 @@ int event_add_sock(event_ctx *ctx, psocket *sock) assert(ctx && sock); ev.data.fd = sock->fd; - ev.events = EPOLLIN | EPOLLET; + ev.events = EPOLLIN /*| EPOLLET*/; /* EPOLLET: broken */ s = epoll_ctl(ctx->epoll_fd, EPOLL_CTL_ADD, sock->fd, &ev); if (s) return 1; diff --git a/src/redirector.c b/src/redirector.c index d4d8d41..664aa9a 100644 --- a/src/redirector.c +++ b/src/redirector.c @@ -32,7 +32,7 @@ static forward_state fwd_state_string(const forward_state c_state, const client_thread *args, const psocket *fwd); static int -redirector_mainloop(event_ctx *ev_ctx, redirector_ctx *rdr_ctx[], size_t siz) +redirector_mainloop(event_ctx **ev_ctx, redirector_ctx *rdr_ctx[], size_t siz) __attribute__((noreturn)); static int redirector_accept_client(event_ctx *ev_ctx, int fd, void *user_data); static void * @@ -143,7 +143,7 @@ int redirector_setup_event(redirector_ctx *rdr_ctx[], size_t siz, event_ctx **ev return 0; } -pid_t redirector_daemonize(event_ctx *ev_ctx, redirector_ctx *rdr_ctx[], size_t siz) +pid_t redirector_daemonize(event_ctx **ev_ctx, redirector_ctx *rdr_ctx[], size_t siz) { pid_t p; int s; @@ -178,7 +178,7 @@ pid_t redirector_daemonize(event_ctx *ev_ctx, redirector_ctx *rdr_ctx[], size_t } D2("Server daemon pid: %d", p); - event_free(&ev_ctx); + event_free(ev_ctx); for (i = 0; i < siz; ++i) redirector_free_ctx(&rdr_ctx[i]); @@ -219,7 +219,7 @@ fwd_state_string(const forward_state c_state, const client_thread *args, return c_state; } -static int redirector_mainloop(event_ctx *ev_ctx, redirector_ctx *rdr_ctx[], size_t siz) +static int redirector_mainloop(event_ctx **ev_ctx, redirector_ctx *rdr_ctx[], size_t siz) { int rc; server_event ev_srv = { rdr_ctx, siz }; @@ -227,8 +227,8 @@ static int redirector_mainloop(event_ctx *ev_ctx, redirector_ctx *rdr_ctx[], siz set_procname("[potd] redirector"); assert( set_child_sighandler() == 0 ); - rc = event_loop(ev_ctx, redirector_accept_client, &ev_srv); - event_free(&ev_ctx); + rc = event_loop(*ev_ctx, redirector_accept_client, &ev_srv); + event_free(ev_ctx); exit(rc); } diff --git a/src/redirector.h b/src/redirector.h index d63c8ba..c9170cb 100644 --- a/src/redirector.h +++ b/src/redirector.h @@ -26,6 +26,6 @@ int redirector_validate_ctx(const redirector_ctx *rdr_ctx); int redirector_setup_event(redirector_ctx *rdr_ctx[], size_t siz, event_ctx **ev_ctx); -pid_t redirector_daemonize(event_ctx *ev_ctx, redirector_ctx *rdr_ctx[], size_t siz); +pid_t redirector_daemonize(event_ctx **ev_ctx, redirector_ctx *rdr_ctx[], size_t siz); #endif diff --git a/src/utils.c b/src/utils.c index 6c9873b..96ea0cd 100644 --- a/src/utils.c +++ b/src/utils.c @@ -262,9 +262,9 @@ int change_user_group(const char *user, const char *group) gid = grp->gr_gid; } - if (setregid(gid, gid)) + if (setresgid(gid, gid, gid)) return 1; - if (setreuid(pwd->pw_uid, pwd->pw_uid)) + if (setresuid(pwd->pw_uid, pwd->pw_uid, pwd->pw_uid)) return 1; return 0; |