diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2018-04-24 23:33:59 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2018-04-24 23:33:59 +0200 |
commit | 6e7b5102c33a510f93b7b418d0bfc082ae2595f7 (patch) | |
tree | 86f08ae3138d6be89cad0a4cc05fd19ea78d2648 /src/main.c | |
parent | b14059ea3a1f2e0a41d90ababf27473c026042d0 (diff) |
POTD skeleton #27.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -15,10 +15,12 @@ int main(int argc, char *argv[]) { const size_t srv_siz = 3; + const size_t jail_siz = 2; const char *ssh_ports[srv_siz]; + const char *jail_ports[jail_siz]; server_ctx *srv[srv_siz]; + jail_ctx *jail[jail_siz]; forward_ctx *ssh_fwd = NULL; - jail_ctx *jail = NULL; int epoll_fd; pid_t daemon_pid; @@ -41,16 +43,25 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - { - jail_init_ctx(&jail, MAX_STACKSIZE); - ABORT_ON_FATAL( jail_setup(jail, "127.0.0.1", "33333"), + memset(jail, 0, sizeof(jail)); + jail_ports[0] = "33333"; + jail_ports[1] = "33334"; + + for (size_t i = 0; i < jail_siz; ++i) { + jail_init_ctx(&jail[i], MAX_STACKSIZE); + ABORT_ON_FATAL( jail_setup(jail[i], "127.0.0.1", jail_ports[i]), "Jail daemon setup" ); - ABORT_ON_FATAL( jail_validate_ctx(jail), + ABORT_ON_FATAL( jail_validate_ctx(jail[i]), "Jail validation" ); - ABORT_ON_FATAL( jail_daemonize(jail), - "Jail daemon startup" ); } + D2("%s", "Jail daemon epoll setup"); + epoll_fd = jail_setup_epoll( jail, jail_siz ); + D2("epoll_fd: %d", epoll_fd); + ABORT_ON_FATAL( epoll_fd < 0, "Jail daemon epoll setup" ); + ABORT_ON_FATAL( jail_daemonize_epoll(epoll_fd, jail, jail_siz), + "Jail daemon startup" ); + { ABORT_ON_FATAL( fwd_init_ctx(&ssh_fwd, ssh_init_cb), "Forwarder initialisation" ); |