Attempt to make doors, chat and files work with ssh
This commit is contained in:
parent
23e3e30af7
commit
56a9505c6a
@ -110,6 +110,13 @@ void chat_system(struct user_record *user) {
|
||||
char *message;
|
||||
char *sep;
|
||||
char *target;
|
||||
int chat_in;
|
||||
|
||||
if (sshBBS) {
|
||||
chat_in = STDIN_FILENO;
|
||||
} else {
|
||||
chat_in = gSocket;
|
||||
}
|
||||
|
||||
memset(inputbuffer, 0, 80);
|
||||
if (conf.irc_server == NULL) {
|
||||
@ -152,20 +159,20 @@ void chat_system(struct user_record *user) {
|
||||
|
||||
while (1) {
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(gSocket, &fds);
|
||||
FD_SET(chat_in, &fds);
|
||||
FD_SET(chat_socket, &fds);
|
||||
|
||||
if (chat_socket > gSocket) {
|
||||
if (chat_socket > chat_in) {
|
||||
t = chat_socket + 1;
|
||||
} else {
|
||||
t = gSocket + 1;
|
||||
t = chat_in + 1;
|
||||
}
|
||||
|
||||
ret = select(t, &fds, NULL, NULL, NULL);
|
||||
|
||||
if (ret > 0) {
|
||||
if (FD_ISSET(gSocket, &fds)) {
|
||||
len = read(gSocket, &c, 1);
|
||||
if (FD_ISSET(chat_in, &fds)) {
|
||||
len = read(chat_in, &c, 1);
|
||||
if (len == 0) {
|
||||
raw("QUIT\r\n");
|
||||
disconnect("Socket closed");
|
||||
|
27
doors.c
27
doors.c
@ -140,6 +140,8 @@ void rundoor(struct user_record *user, char *cmd, int stdio) {
|
||||
int t;
|
||||
struct winsize ws;
|
||||
struct sigaction sa;
|
||||
int door_in;
|
||||
int door_out;
|
||||
|
||||
timeoutpaused = 1;
|
||||
|
||||
@ -148,11 +150,18 @@ void rundoor(struct user_record *user, char *cmd, int stdio) {
|
||||
}
|
||||
|
||||
if (stdio) {
|
||||
if (sshBBS) {
|
||||
door_in = STDIN_FILENO;
|
||||
door_out = STDOUT_FILENO;
|
||||
} else {
|
||||
door_in = gSocket;
|
||||
door_out = gSocket;
|
||||
}
|
||||
|
||||
arguments[0] = strdup(cmd);
|
||||
sprintf(buffer, "%d", mynode);
|
||||
arguments[1] = strdup(buffer);
|
||||
sprintf(buffer, "%d", gSocket);
|
||||
sprintf(buffer, "%d", door_out);
|
||||
arguments[2] = strdup(buffer);
|
||||
arguments[3] = NULL;
|
||||
|
||||
@ -192,16 +201,16 @@ void rundoor(struct user_record *user, char *cmd, int stdio) {
|
||||
while(running_door != 0) {
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(master, &fdset);
|
||||
FD_SET(gSocket, &fdset);
|
||||
if (master > gSocket) {
|
||||
FD_SET(door_in, &fdset);
|
||||
if (master > door_in) {
|
||||
t = master + 1;
|
||||
} else {
|
||||
t = gSocket + 1;
|
||||
t = door_in + 1;
|
||||
}
|
||||
ret = select(t, &fdset, NULL, NULL, NULL);
|
||||
if (ret > 0) {
|
||||
if (FD_ISSET(gSocket, &fdset)) {
|
||||
len = read(gSocket, &c, 1);
|
||||
if (FD_ISSET(door_in, &fdset)) {
|
||||
len = read(door_in, &c, 1);
|
||||
if (len == 0) {
|
||||
close(master);
|
||||
disconnect("Socket Closed");
|
||||
@ -217,7 +226,7 @@ void rundoor(struct user_record *user, char *cmd, int stdio) {
|
||||
close(master);
|
||||
break;
|
||||
}
|
||||
write(gSocket, &c, 1);
|
||||
write(door_out, &c, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -227,8 +236,12 @@ void rundoor(struct user_record *user, char *cmd, int stdio) {
|
||||
free(arguments[1]);
|
||||
free(arguments[2]);
|
||||
} else {
|
||||
if (!sshBBS) {
|
||||
sprintf(buffer, "%s %d %d", cmd, mynode, gSocket);
|
||||
system(buffer);
|
||||
} else {
|
||||
s_printf("Non-STDIO door support on SSH is currently broken...\r\n");
|
||||
}
|
||||
}
|
||||
timeoutpaused = 0;
|
||||
}
|
||||
|
15
files.c
15
files.c
@ -14,6 +14,7 @@
|
||||
#include "lua/lauxlib.h"
|
||||
extern struct bbs_config conf;
|
||||
extern int gSocket;
|
||||
extern int sshBBS;
|
||||
|
||||
struct file_entry {
|
||||
char *filename;
|
||||
@ -29,7 +30,7 @@ int ZXmitStr(u_char *str, int len, ZModem *info) {
|
||||
int i;
|
||||
|
||||
for (i=0;i<len;i++) {
|
||||
if (str[i] == 255) {
|
||||
if (str[i] == 255 && !sshBBS) {
|
||||
if (write(info->ofd, &str[i], 1) == 0) {
|
||||
return ZmErrSys;
|
||||
}
|
||||
@ -168,9 +169,13 @@ void upload_zmodem(struct user_record *user) {
|
||||
zm.windowsize = 0;
|
||||
zm.bufsize = 0;
|
||||
|
||||
if (!sshBBS) {
|
||||
zm.ifd = gSocket;
|
||||
zm.ofd = gSocket;
|
||||
|
||||
} else {
|
||||
zm.ifd = STDIN_FILENO;
|
||||
zm.ofd = STDOUT_FILENO;
|
||||
}
|
||||
zm.zrinitflags = 0;
|
||||
zm.zsinitflags = 0;
|
||||
|
||||
@ -268,9 +273,13 @@ void download_zmodem(struct user_record *user, char *filename) {
|
||||
zm.windowsize = 0;
|
||||
zm.bufsize = 0;
|
||||
|
||||
if (!sshBBS) {
|
||||
zm.ifd = gSocket;
|
||||
zm.ofd = gSocket;
|
||||
|
||||
} else {
|
||||
zm.ifd = STDIN_FILENO;
|
||||
zm.ofd = STDOUT_FILENO;
|
||||
}
|
||||
zm.zrinitflags = 0;
|
||||
zm.zsinitflags = 0;
|
||||
|
||||
|
@ -7,7 +7,6 @@ extern int mynode;
|
||||
extern struct bbs_config conf;
|
||||
|
||||
extern struct user_record *gUser;
|
||||
extern int gSocket;
|
||||
|
||||
int l_bbsWString(lua_State *L) {
|
||||
char *str = (char *)lua_tostring(L, -1);
|
||||
|
Reference in New Issue
Block a user