diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2018-05-21 20:22:49 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2018-05-21 20:22:49 +0200 |
commit | 15dccd91c589cd3f376650759b42319f0f712205 (patch) | |
tree | a001d18b376f0c85ff6335a9d369684872f70605 /src/jail.c | |
parent | fff7c41f6208c8572f34af2f0ad7160c2d9cb9c5 (diff) |
POTD skeleton #71.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/jail.c')
-rw-r--r-- | src/jail.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -29,6 +29,8 @@ typedef struct server_event { typedef struct client_event { psocket *client_sock; + char *host_buf; + char *service_buf; int tty_fd; int signal_fd; char tty_logbuf[BUFSIZ]; @@ -399,7 +401,7 @@ finalise: static int jail_socket_tty(prisoner_process *ctx, int tty_fd) { - static client_event ev_cli = {NULL, -1, -1, {0}, 0, 0, 0}; + static client_event ev_cli = {NULL, NULL, NULL, -1, -1, {0}, 0, 0, 0}; int s, rc = 1; event_ctx *ev_ctx = NULL; sigset_t mask; @@ -448,6 +450,8 @@ static int jail_socket_tty(prisoner_process *ctx, int tty_fd) } ev_cli.client_sock = &ctx->client_psock; + ev_cli.host_buf = &ctx->host_buf[0]; + ev_cli.service_buf = &ctx->service_buf[0]; rc = event_loop(ev_ctx, jail_socket_tty_io, &ev_cli); finish: close(ev_cli.signal_fd); @@ -508,7 +512,8 @@ static int jail_log_input(event_ctx *ev_ctx, int src_fd, int dst_fd, if (slen == 0) { escape_ascii_string(ev_cli->tty_logbuf, ev_cli->off_logbuf, &ev_cli->tty_logbuf_escaped, &ev_cli->tty_logbuf_size); - C("%s", ev_cli->tty_logbuf_escaped); + C("[%s:%s] %s", ev_cli->host_buf, ev_cli->service_buf, + ev_cli->tty_logbuf_escaped); ev_cli->off_logbuf = 0; ev_cli->tty_logbuf[0] = 0; continue; @@ -521,7 +526,8 @@ static int jail_log_input(event_ctx *ev_ctx, int src_fd, int dst_fd, if (buf[siz-1] == '\r' || buf[siz-1] == '\n') { escape_ascii_string(ev_cli->tty_logbuf, ev_cli->off_logbuf, &ev_cli->tty_logbuf_escaped, &ev_cli->tty_logbuf_size); - C("%s", ev_cli->tty_logbuf_escaped); + C("[%s:%s] %s", ev_cli->host_buf, ev_cli->service_buf, + ev_cli->tty_logbuf_escaped); ev_cli->off_logbuf = 0; ev_cli->tty_logbuf[0] = 0; } |