More fixes for ssh
This commit is contained in:
parent
48b478f9c3
commit
2c11107954
54
doors.c
54
doors.c
@ -194,16 +194,14 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
||||
door_out = gSocket;
|
||||
}
|
||||
|
||||
if (sshBBS && raw) {
|
||||
ttySetRaw(STDIN_FILENO, &oldit);
|
||||
ttySetRaw(STDOUT_FILENO, &oldot);
|
||||
}
|
||||
|
||||
|
||||
ws.ws_row = 24;
|
||||
ws.ws_col = 80;
|
||||
|
||||
running_door = 1;
|
||||
|
||||
if (!sshBBS) {
|
||||
if (openpty(&master, &slave, NULL, NULL, &ws) == 0) {
|
||||
sa.sa_handler = doorchld_handler;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
@ -227,9 +225,6 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
||||
|
||||
dup2(slave, 0);
|
||||
dup2(slave, 1);
|
||||
if (sshBBS) {
|
||||
dup2(bbs_stderr, 2);
|
||||
}
|
||||
|
||||
close(slave);
|
||||
|
||||
@ -243,6 +238,8 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
||||
gotiac = 0;
|
||||
flush = 0;
|
||||
|
||||
close(slave);
|
||||
|
||||
while(running_door || !flush) {
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(master, &fdset);
|
||||
@ -273,7 +270,7 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
||||
if (!running_door) {
|
||||
continue;
|
||||
}
|
||||
if (!sshBBS) {
|
||||
|
||||
if (c == 255) {
|
||||
if (gotiac == 1) {
|
||||
write(master, &c, 1);
|
||||
@ -289,16 +286,13 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
||||
gotiac = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
write(master, &c, 1);
|
||||
}
|
||||
} else if (FD_ISSET(master, &fdset)) {
|
||||
len = read(master, &c, 1);
|
||||
if (len == 0) {
|
||||
close(master);
|
||||
break;
|
||||
}
|
||||
if (c == 255 && !sshBBS) {
|
||||
if (c == 255) {
|
||||
write(door_out, &c, 1);
|
||||
}
|
||||
write(door_out, &c, 1);
|
||||
@ -309,13 +303,45 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
||||
}
|
||||
}
|
||||
}
|
||||
close(master);
|
||||
}
|
||||
}
|
||||
if (sshBBS && raw) {
|
||||
|
||||
} else {
|
||||
|
||||
if (raw) {
|
||||
ttySetRaw(STDIN_FILENO, &oldit);
|
||||
ttySetRaw(STDOUT_FILENO, &oldot);
|
||||
}
|
||||
|
||||
sa.sa_handler = doorchld_handler;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = SA_RESTART | SA_SIGINFO;
|
||||
if (sigaction(SIGCHLD, &sa, NULL) == -1) {
|
||||
perror("sigaction");
|
||||
exit(1);
|
||||
}
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
return;
|
||||
} else if (pid == 0) {
|
||||
if (cwd != NULL) {
|
||||
chdir(cwd);
|
||||
}
|
||||
|
||||
dup2(bbs_stderr, 2);
|
||||
execvp(cmd, argv);
|
||||
} else {
|
||||
while(running_door) {
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (raw) {
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &oldit);
|
||||
tcsetattr(STDOUT_FILENO, TCSANOW, &oldot);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (!sshBBS) {
|
||||
snprintf(buffer, 1024, "%s", cmd);
|
||||
|
Reference in New Issue
Block a user