overhaul of doors, possible breakage

This commit is contained in:
Andrew Pamment 2017-03-26 20:25:07 +10:00
parent e475ceb395
commit 26e86661ca

74
doors.c
View File

@ -179,6 +179,10 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
struct termios oldot; struct termios oldot;
struct termios oldit2; struct termios oldit2;
char inbuf[256];
char outbuf[256];
int h;
int g;
timeoutpaused = 1; timeoutpaused = 1;
if (write_door32sys(user) != 0) { if (write_door32sys(user) != 0) {
@ -254,57 +258,59 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
ret = select(t, &fdset, NULL, NULL, &thetimeout); ret = select(t, &fdset, NULL, NULL, &thetimeout);
if (ret > 0) { if (ret > 0) {
if (FD_ISSET(door_in, &fdset)) { if (FD_ISSET(door_in, &fdset)) {
len = read(door_in, &c, 1); len = read(door_in, inbuf, 256);
if (len == 0) { if (len == 0) {
close(master); close(master);
disconnect("Socket Closed"); disconnect("Socket Closed");
return; return;
} }
if (!raw) { g = 0;
if (c == '\n' || c == '\0') { for (h=0;h<len;h++) {
c = inbuf[h];
if (!raw) {
if (c == '\n' || c == '\0') {
continue;
}
}
if (!running_door) {
continue; continue;
} }
}
if (!running_door) {
continue;
}
if (c == 255) { if (c == 255) {
if (gotiac == 1) { if (gotiac == 1) {
write(master, &c, 1); outbuf[g++] = c;
gotiac = 0; gotiac = 0;
} else {
gotiac = 1;
}
} else {
if (gotiac == 1) {
if (c == 254 || c == 253 || c == 252 || c == 251) {
gotiac = 2;
} else if (c == 250) {
gotiac = 3;
} else { } else {
gotiac = 0; gotiac = 1;
}
} else if (gotiac == 2) {
gotiac = 0;
} else if (gotiac == 3) {
if (c == 240) {
gotiac = 0;
} }
} else { } else {
write(master, &c, 1); if (gotiac == 1) {
if (c == 254 || c == 253 || c == 252 || c == 251) {
gotiac = 2;
} else if (c == 250) {
gotiac = 3;
} else {
gotiac = 0;
}
} else if (gotiac == 2) {
gotiac = 0;
} else if (gotiac == 3) {
if (c == 240) {
gotiac = 0;
}
} else {
outbuf[g++] = c;
}
} }
} }
write(master, outbuf, g);
} else if (FD_ISSET(master, &fdset)) { } else if (FD_ISSET(master, &fdset)) {
len = read(master, &c, 1); len = read(master, inbuf, 256);
if (len == 0) { if (len == 0) {
close(master); close(master);
break; break;
} }
if (c == 255) { write(door_out, inbuf, len);
write(door_out, &c, 1);
}
write(door_out, &c, 1);
} }
} else { } else {
if (!running_door) { if (!running_door) {
@ -353,7 +359,7 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
} else { } else {
if (!sshBBS) { if (!sshBBS) {
snprintf(buffer, 1024, "%s", cmd); snprintf(buffer, 1024, "%s", cmd);
for (i=0;argv[i] != NULL; i++) { for (i=1;argv[i] != NULL; i++) {
snprintf(&buffer[strlen(buffer)], 1024 - strlen(buffer), " %s", argv[i]); snprintf(&buffer[strlen(buffer)], 1024 - strlen(buffer), " %s", argv[i]);
} }
if (cwd != NULL) { if (cwd != NULL) {