aboutsummaryrefslogtreecommitdiff
path: root/src/server_ssh.c
diff options
context:
space:
mode:
authorlns <matzeton@googlemail.com>2018-04-22 13:00:31 +0200
committerlns <matzeton@googlemail.com>2018-04-22 13:00:31 +0200
commit3778cdb66b7a7fc3e6dd43be0bb0da0c5f3f0d7a (patch)
tree12ee61fe3ff701c83b764c176a3557021206d699 /src/server_ssh.c
parentaaa10f05c673ae2f5893bf54db5660d474b9759c (diff)
POTD skeleton #23.
Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'src/server_ssh.c')
-rw-r--r--src/server_ssh.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/server_ssh.c b/src/server_ssh.c
index c84f718..474b5ab 100644
--- a/src/server_ssh.c
+++ b/src/server_ssh.c
@@ -12,6 +12,7 @@
#include <libssh/server.h>
#include "server_ssh.h"
+#include "jail.h"
#include "log.h"
#if LIBSSH_VERSION_MAJOR != 0 || LIBSSH_VERSION_MINOR < 7 || \
@@ -412,6 +413,12 @@ static int main_loop(ssh_channel chan)
pid_t childpid;
ssh_event event;
short events;
+ jail_ctx jail, *jail_ptr = &jail;
+
+ jail_init(&jail_ptr, BUFSIZ);
+ if (jail_fork(jail_ptr)) {
+ E_STRERR("Jail fork");
+ }
childpid = forkpty(&fd, NULL, term, win);
if (childpid == 0) {
@@ -424,29 +431,27 @@ static int main_loop(ssh_channel chan)
ssh_set_channel_callbacks(chan, &ssh_channel_cb);
events = POLLIN | POLLPRI | POLLERR | POLLHUP | POLLNVAL;
-
event = ssh_event_new();
+
if (event == NULL) {
- printf("Couldn't get a event\n");
- return -1;
+ W("%s", "Couldn't get a event");
+ return 1;
}
if (ssh_event_add_fd(event, fd, events, copy_fd_to_chan, chan) != SSH_OK) {
- printf("Couldn't add an fd to the event\n");
- return -1;
+ W("%s", "Couldn't add an fd to the event");
+ return 1;
}
if (ssh_event_add_session(event, session) != SSH_OK) {
- printf("Couldn't add the session to the event\n");
- return -1;
+ W("%s", "Couldn't add the session to the event");
+ return 1;
}
do {
ssh_event_dopoll(event, 1000);
- } while(!ssh_channel_is_closed(chan));
+ } while (!ssh_channel_is_closed(chan));
ssh_event_remove_fd(event, fd);
-
ssh_event_remove_session(event, session);
-
ssh_event_free(event);
return 0;
}