fixes for disconnecting ssh without logging out

This commit is contained in:
Andrew Pamment 2016-08-07 15:43:29 +10:00
parent 005bb33767
commit 8e6667ed4f
2 changed files with 9 additions and 4 deletions

6
bbs.c
View File

@ -15,7 +15,7 @@
#include "lua/lualib.h"
#include "lua/lauxlib.h"
int mynode;
int mynode = 0;
struct bbs_config conf;
struct user_record *gUser;
@ -508,8 +508,7 @@ void runbbs_real(int socket, char *ip, int ssh) {
s_printf("Magicka BBS v%d.%d (%s), Loading...\r\n", VERSION_MAJOR, VERSION_MINOR, VERSION_STR);
// find out which node we are
mynode = 0;
for (i=1;i<=conf.nodes;i++) {
for (i=1;i<=conf.nodes;i++) {
sprintf(buffer, "%s/nodeinuse.%d", conf.bbs_path, i);
if (stat(buffer, &s) != 0) {
mynode = i;
@ -710,6 +709,7 @@ void runbbs(int socket, char *ip) {
}
void runbbs_ssh(char *ip) {
setbuf(stdin, NULL);
setbuf(stdout, NULL);
runbbs_real(-1, ip, 1);
}

7
main.c
View File

@ -28,6 +28,7 @@
extern struct bbs_config conf;
extern struct user_record *gUser;
extern int mynode;
int ssh_pid = -1;
@ -446,10 +447,14 @@ static int ssh_copy_chan_to_fd(ssh_session session,
}
static void ssh_chan_close(ssh_session session, ssh_channel channel, void *userdata) {
int fd = *(int*)userdata;
int fd = *(int*)userdata;
(void)session;
(void)channel;
if (mynode != 0) {
disconnect("Channel Closed");
}
close(fd);
}