aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2018-05-15 14:34:39 +0200
committerToni Uhlig <matzeton@googlemail.com>2018-05-15 14:34:39 +0200
commit58d2689b9b43dfd4341b2eb227c51d89d873b35e (patch)
tree134d89c8387b107bac7ba2e7206acdd8a8c60acd /src
parent19299c4c0cf3f0a0c1fcdda1783f4593245358e6 (diff)
POTD skeleton #54.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r--src/jail.c3
-rw-r--r--src/protocol_ssh.c12
2 files changed, 13 insertions, 2 deletions
diff --git a/src/jail.c b/src/jail.c
index 13040ec..8a2f410 100644
--- a/src/jail.c
+++ b/src/jail.c
@@ -229,9 +229,10 @@ static int jail_childfn(prisoner_process *ctx)
const char *path_devpts = "/dev/pts";
const char *path_proc = "/proc";
const char *path_shell = "/bin/sh";
+ //const char *path_self = "/proc/self/%s";
int s, master_fd;
int unshare_flags = CLONE_NEWUTS|CLONE_NEWPID|CLONE_NEWIPC|
- CLONE_NEWNS|CLONE_NEWNET;
+ CLONE_NEWNS|CLONE_NEWNET/*|CLONE_NEWUSER*/;
pid_t self_pid, child_pid;
assert(ctx);
diff --git a/src/protocol_ssh.c b/src/protocol_ssh.c
index e3c123f..91f2a43 100644
--- a/src/protocol_ssh.c
+++ b/src/protocol_ssh.c
@@ -94,6 +94,11 @@ int ssh_init_cb(protocol_ctx *ctx)
if (!d->sshbind)
return 1;
+ if (ssh_bind_options_set(d->sshbind, SSH_BIND_OPTIONS_BANNER,
+ "OpenSSH_7.4p1"))
+ {
+ return 1;
+ }
if (gen_default_keys())
return 1;
if (set_default_keys(d->sshbind, 0, 0, 0))
@@ -437,6 +442,7 @@ static int client_mainloop(ssh_client *data)
if (fwd_connect_sock(ctx, NULL)) {
E_STRERR("Connection to %s:%s",
ctx->host_buf, ctx->service_buf);
+ ssh_channel_close(chan);
return 1;
}
@@ -486,10 +492,11 @@ static int copy_fd_to_chan(socket_t fd, int revents, void *userdata)
ssh_channel_write(chan, buf, sz);
}
}
- if(revents & POLLHUP) {
+ if(revents & POLLHUP || sz <= 0) {
ssh_channel_close(chan);
sz = -1;
}
+
return sz;
}
@@ -507,6 +514,9 @@ static int copy_chan_to_fd(ssh_session session,
(void)is_stderr;
sz = write(fd, data, len);
+ if (sz <= 0)
+ ssh_channel_close(channel);
+
return sz;
}