#ifndef POTD_JAIL_H #define POTD_JAIL_H 1 #include #include #include "socket.h" #define MIN_STACKSIZE 2048 #define MAX_STACKSIZE BUFSIZ typedef struct jail_ctx { psocket sock; char host_buf[NI_MAXHOST], service_buf[NI_MAXSERV]; size_t stacksize; void *stack_ptr; void *stack_beg; } jail_ctx; void jail_init_ctx(jail_ctx **ctx, size_t stacksize); int jail_setup(jail_ctx *ctx, const char *listen_addr, const char *listen_port); int jail_validate_ctx(const jail_ctx *ctx); int jail_setup_epoll(jail_ctx *ctx[], size_t siz); pid_t jail_daemonize_epoll(int epoll_fd, jail_ctx *ctx[], size_t siz); #endif