From 7c5ab56fc01d7e9e8e816125e32d8a281e076f76 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sun, 7 Aug 2016 16:37:55 +1000 Subject: [PATCH] test for fixing filetransfers over ssh --- files.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/files.c b/files.c index 77eed56..a5a55ff 100644 --- a/files.c +++ b/files.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "Xmodem/zmodem.h" #include "bbs.h" #include "lua/lua.h" @@ -26,6 +27,27 @@ struct file_entry { char **tagged_files; int tagged_count = 0; +int ttySetRaw(int fd, struct termios *prevTermios) { + struct termios t; + + if (tcgetattr(fd, &t) == -1) + return -1; + + if (prevTermios != NULL) + *prevTermios = t; + + t.c_lflag &= ~(ICANON | ISIG | IEXTEN | ECHO); + t.c_iflag &= ~(BRKINT | ICRNL | IGNBRK | IGNCR | INLCR | INPCK | ISTRIP | IXON | PARMRK); + t.c_oflag &= ~OPOST; + t.c_cc[VMIN] = 1; + t.c_cc[VTIME] = 0; + + if (tcsetattr(fd, TCSAFLUSH, &t) == -1) + return -1; + + return 0; +} + int ZXmitStr(u_char *str, int len, ZModem *info) { int i; @@ -204,8 +226,15 @@ void upload(struct user_record *user) { int rc; struct stat s; char *err_msg = NULL; + struct termios oldt; + if (sshBBS) { + ttySetRaw(STDIN_FILENO, &oldt); + } upload_zmodem(user); + if (sshBBS) { + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); + } s_printf("\r\nPlease enter a description:\r\n"); buffer[0] = '\0'; @@ -339,6 +368,7 @@ void download(struct user_record *user) { int rc; for (i=0;icur_file_dir]->file_subs[user->cur_file_sub]->database);