aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2018-05-02 16:15:12 +0200
committerToni Uhlig <matzeton@googlemail.com>2018-05-02 16:15:12 +0200
commite6d9e7073ea1e23a3b22440fa69ce92691ca328d (patch)
tree3fb974880b1ba48f06a5ce430ff0d5983008c180 /src/main.c
parent3ef3c65b4d19df39e020c1d5f778dafdf493a635 (diff)
POTD skeleton #40.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index a3b9941..73fb5b2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -23,7 +23,7 @@ int main(int argc, char *argv[])
server_ctx *srv[srv_siz];
jail_ctx *jail[jail_siz];
forward_ctx *ssh_fwd = NULL;
- int epoll_fd, proc_status;
+ int jail_epoll_fd, srv_epoll_fd, proc_status;
pid_t daemon_pid, srv_pid, jail_pid, wpid;
(void) argc;
@@ -48,6 +48,8 @@ int main(int argc, char *argv[])
jail_ports[1] = "33334";
for (size_t i = 0; i < jail_siz; ++i) {
+ D("Initialising jail service on port %s", jail_ports[i]);
+
jail_init_ctx(&jail[i], MAX_STACKSIZE);
jail[i]->newroot = strdup("/home/lns/git/busybox/sysroot");
ABORT_ON_FATAL( jail_setup(jail[i], "127.0.0.1", jail_ports[i]),
@@ -56,11 +58,10 @@ int main(int argc, char *argv[])
"Jail validation" );
}
- D2("%s", "Jail daemon epoll setup");
- epoll_fd = jail_setup_epoll( jail, jail_siz );
- D2("Jail epoll fd: %d", epoll_fd);
- ABORT_ON_FATAL( epoll_fd < 0, "Jail daemon epoll setup" );
- jail_pid = jail_daemonize(epoll_fd, jail, jail_siz);
+ jail_epoll_fd = jail_setup_epoll( jail, jail_siz );
+ D2("Jail epoll fd: %d", jail_epoll_fd);
+ ABORT_ON_FATAL( jail_epoll_fd < 0, "Jail daemon epoll setup" );
+ jail_pid = jail_daemonize(jail_epoll_fd, jail, jail_siz);
ABORT_ON_FATAL( jail_pid < 1, "Jail daemon startup" );
{
@@ -88,16 +89,16 @@ int main(int argc, char *argv[])
}
D2("%s", "Server epoll setup");
- epoll_fd = server_setup_epoll( srv, srv_siz );
- D2("Server epoll fd: %d", epoll_fd);
- ABORT_ON_FATAL( epoll_fd < 0, "Server epoll setup" );
+ srv_epoll_fd = server_setup_epoll( srv, srv_siz );
+ D2("Server epoll fd: %d", srv_epoll_fd);
+ ABORT_ON_FATAL( srv_epoll_fd < 0, "Server epoll setup" );
D2("Server dropping privileges to %s:%s", "nobody", "NULL");
ABORT_ON_FATAL( change_user_group("nobody", NULL),
"Server dropping privileges" );
N("%s", "Server epoll mainloop");
- srv_pid = server_daemonize( epoll_fd, srv, srv_siz );
+ srv_pid = server_daemonize( srv_epoll_fd, srv, srv_siz );
ABORT_ON_FATAL( srv_pid < 1, "Server epoll mainloop" );
while (1) {