test for fixing filetransfers over ssh

This commit is contained in:
Andrew Pamment 2016-08-07 16:37:55 +10:00
parent 77edc6ee0a
commit 7c5ab56fc0

30
files.c
View File

@ -7,6 +7,7 @@
#include <libgen.h> #include <libgen.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <termios.h>
#include "Xmodem/zmodem.h" #include "Xmodem/zmodem.h"
#include "bbs.h" #include "bbs.h"
#include "lua/lua.h" #include "lua/lua.h"
@ -26,6 +27,27 @@ struct file_entry {
char **tagged_files; char **tagged_files;
int tagged_count = 0; 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 ZXmitStr(u_char *str, int len, ZModem *info) {
int i; int i;
@ -204,8 +226,15 @@ void upload(struct user_record *user) {
int rc; int rc;
struct stat s; struct stat s;
char *err_msg = NULL; char *err_msg = NULL;
struct termios oldt;
if (sshBBS) {
ttySetRaw(STDIN_FILENO, &oldt);
}
upload_zmodem(user); upload_zmodem(user);
if (sshBBS) {
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
}
s_printf("\r\nPlease enter a description:\r\n"); s_printf("\r\nPlease enter a description:\r\n");
buffer[0] = '\0'; buffer[0] = '\0';
@ -339,6 +368,7 @@ void download(struct user_record *user) {
int rc; int rc;
for (i=0;i<tagged_count;i++) { for (i=0;i<tagged_count;i++) {
download_zmodem(user, tagged_files[i]); download_zmodem(user, tagged_files[i]);
sprintf(buffer, "%s/%s.sq3", conf.bbs_path, conf.file_directories[user->cur_file_dir]->file_subs[user->cur_file_sub]->database); sprintf(buffer, "%s/%s.sq3", conf.bbs_path, conf.file_directories[user->cur_file_dir]->file_subs[user->cur_file_sub]->database);