From be79f793e31bd378e6ca584e8ba5710ba2764ee5 Mon Sep 17 00:00:00 2001 From: chombier <> Date: Sat, 17 Mar 2001 13:14:36 +0000 Subject: [PATCH] updated for GUSITTY Sockets --- lsh/MacOS/lsh.mcp | Bin 705228 -> 714344 bytes lsh/MacOS/lshdll.mcp | Bin 198196 -> 198196 bytes lsh/MacOS/lshmaccvs.mcp | Bin 165419 -> 165419 bytes lsh/MacOS/src/GUSIPatches.cp | 3 +- lsh/MacOS/src/lsh_dll.c | 155 +++++++++++++++++++++++++++++++- lsh/MacOS/src/lsh_dll.cp | 72 +-------------- lsh/MacOS/src/lsh_maccvs.cpp | 18 ++++ lsh/MacOS/src/lshprefix.h | 4 +- lsh/MacOS/src/macosmain.c | 61 +++++++++++++ lsh/MacOS/src/werror.c | 4 +- lsh/src/lsh.c | 2 +- lsh/src/unix_interact.c | 4 + macssh/source/ssh/GUSIPatch1.cp | 47 ++-------- macssh/source/ssh/ssh2.c | 9 +- macssh/source/ssh/werror.c | 7 +- 15 files changed, 260 insertions(+), 126 deletions(-) diff --git a/lsh/MacOS/lsh.mcp b/lsh/MacOS/lsh.mcp index bdfcebf5937f85d81dc0a46312f78447bda4208d..01c09c5d62f4162721dc9192193d9bb0a0e6b20e 100755 GIT binary patch delta 1252 zcmYk64NO~A6oBt}_r3nSt<2G~(gJCtOVF?t=a$ehbYmMMEJ*5xI+aLk-H?PrwFOZ~ zfhiLW5}S)&vj{7jE)tWed9ph-B1<$ehMy&yxVbu)ObrQ%3E5BlujjR8a+7oKJ>R+K z^qhO&>2!a|!gPr(*w)rU2%&_)-9&xMM^xVVv8@=k7b5i{Micmmgm&EH`~%8WLhRQG z$ip}#!E$kRBCanR<>q?3w)a2^8jeaOBb!Oo)0_wu9YQr&F~#TDzikXU)BR^ zbrv(Qf0bPAMpe^JxTGBz_*B-`B#fXH4jtdlLc3dJJ^QrxA2SVD=_9jASucRqU2Bo` z%z0cj6tmY^DVy8VsGT@B=vI9CC9=LTH`}n(rOhohtY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E0M@-3!zn z1H=J990J7Alb`SbZP*+yCBeAaUz(qX@yF(9bw<|B2|Amb*d&jE0%4+KN z97&sRZP+C`IYEa-kQeNE1_qvOH-#<(&7HORv}isHYYa%oW_u|M#?7H;b_KAzhX#9w zghWm^^kh`nt{}@O!nEB>o>4Vt^U+fgOdKHBfHX}0FCjkBmvgi1SqaANkts||*|x8l z$~f~jlj!E@?uATlOvffp?=NH$XEdF@ypXAk>BQdY@Yq(Fda z=XC!fCNVa?0wBj>dv+01B)>FccRnz>W&l;^07XGz0R?;;rr&R55|fjB4ipdo%4Y&; RBzej2K)%Cv;U*>t767y9lVkt@ delta 508 zcmZ48!?n7HYlA5hGYbR5Ib?73RpmF#&6rMSO+sOD1~iqy!?xC@L^gr44~>9peQJypn$Jn`u#>GF*&|7Kmh@u Ud?t`amcIk!+iVwZVv=A103pkN$p8QV diff --git a/lsh/MacOS/src/GUSIPatches.cp b/lsh/MacOS/src/GUSIPatches.cp index 4ee1d7e..d467878 100755 --- a/lsh/MacOS/src/GUSIPatches.cp +++ b/lsh/MacOS/src/GUSIPatches.cp @@ -38,7 +38,6 @@ int dup(int s); int socket(int domain, int type, int protocol); int close(int s); -Boolean can_read(); void ssh2_doevent(long sleepTime); void add_one_file(struct lshcontext *context, int fd); void remove_one_file(struct lshcontext *context, int fd); @@ -341,7 +340,7 @@ void ssh2_init() if ( !sGUSISetup ) { GUSIContext::Setup(true); - GUSISetupConsole(); + /*GUSISetupConsole();*/ sGUSISetup = true; } } diff --git a/lsh/MacOS/src/lsh_dll.c b/lsh/MacOS/src/lsh_dll.c index a2985f0..9ec5805 100755 --- a/lsh/MacOS/src/lsh_dll.c +++ b/lsh/MacOS/src/lsh_dll.c @@ -26,6 +26,7 @@ #include "werror.h" #include +/*#include */ #include #include #include @@ -36,9 +37,12 @@ #include #include + #include #include + + #include "MemPool.h" @@ -48,8 +52,6 @@ extern pascal void __terminate(void); pascal OSErr __lsh_initialize(const CFragInitBlock * theInitBlock); pascal void __lsh_terminate(void); - - FSSpec gDLLFileSpec; Boolean gLogStdIO = 0; @@ -537,6 +539,152 @@ pascal Ptr PLstrrchr(ConstStr255Param s, short c) } +#pragma mark - + +/* + * InstallTTY + */ +int InstallTTY(int fd, int flags) +{ +#pragma unused (fd) + return 0; +} + +/* + * RemoveTTY + */ +void RemoveTTY(int fd, int flags) +{ +#pragma unused (fd) +} + +/* + * WriteCharsToTTY + */ +int WriteCharsToTTY(int fd, int flags, char *buffer, int n) +{ + long written = 0; + lshcontext *context = (lshcontext *)pthread_getspecific(ssh2threadkey); + char *buf = buffer; + char c; + + if ( !context ) { + return 0; + } + + if ( context->_gConsoleOutBufMax ) { + if ( context->_socket == -1 ) { + while (n > 0) { + if ( context->_gConsoleOutBufLen < context->_gConsoleOutBufMax ) { + long len = n; + if ( len > context->_gConsoleOutBufMax - context->_gConsoleOutBufLen ) { + len = context->_gConsoleOutBufMax - context->_gConsoleOutBufLen; + } + if ( context->_convertLFs ) { + long inlen = 0; + long outlen = context->_gConsoleOutBufLen; +/* + while (inlen < len && outlen < context->_gConsoleOutBufMax - 1) { + c = buf[inlen++]; + if ( c == 0x0a ) { + context->_gConsoleOutBuf[outlen++] = 0x0d; + } + context->_gConsoleOutBuf[outlen++] = c; + } +*/ + while (inlen < len && outlen < context->_gConsoleOutBufMax - 1) { + c = buf[inlen++]; + if ( context->_lastCR ) { + if ( c != 0x0a && c != 0x1b ) + context->_gConsoleOutBuf[outlen++] = 0x0a; + } else { + if ( c == 0x0a ) + context->_gConsoleOutBuf[outlen++] = 0x0d; + } + context->_gConsoleOutBuf[outlen++] = c; + context->_lastCR = (c == 0x0d); + } + + context->_gConsoleOutBufLen = outlen; + buf += inlen; + written += inlen; + n -= inlen; + } else { + BlockMoveData( buf, context->_gConsoleOutBuf + context->_gConsoleOutBufLen, len); + /*context->_lastCR = (buf[len-1] == 0x0d);*/ + context->_gConsoleOutBufLen += len; + buf += len; + written += len; + n -= len; + } + } + ssh2_sched(); + } + } + } else { + written = n; + } +/* + syslog( 0, "write\n"); + dumpln(0, 0, buffer, written); +*/ + return written; +} + +/* + * ReadCharsFromTTY + */ +int ReadCharsFromTTY(int fd, int flags, char *buffer, int n) +{ + long len = 0; + lshcontext *context = (lshcontext *)pthread_getspecific(ssh2threadkey); + + if ( !context ) { + return 0; + } + + if ( context->_gConsoleInBufMax ) { + while (!len && n > 0) { + if (context->_gConsoleInEOF) { + buffer[0] = EOF; + return 0; + } + if (context->_gConsoleInBufLen && context->_socket == -1 ) { + len = context->_gConsoleInBufLen; + if ( len > n ) { + len = n; + } + BlockMoveData( context->_gConsoleInBuf, buffer, len ); + context->_gConsoleInBufLen -= len; + if ( context->_gConsoleInBufLen ) { + BlockMoveData( context->_gConsoleInBuf + len, context->_gConsoleInBuf, context->_gConsoleInBufLen ); + } + } + ssh2_sched(); + } + } else { + buffer[0] = EOF; + } +/* + syslog( 0, "read\n"); + dumpln(0, 0, buffer, len); +*/ + return len; +} + +/* + * AvailableFromTTY + */ +int AvailableFromTTY(int id, int flags) +{ + lshcontext *context = (lshcontext *)pthread_getspecific(ssh2threadkey); + + if ( !context ) { + return 0; + } + return context->_gConsoleInBufLen || context->_gConsoleInEOF; +} + #pragma mark - /* @@ -634,7 +782,6 @@ void ssh2_doevent(long sleepTime) } } - #pragma mark - @@ -1183,7 +1330,7 @@ pascal void __lsh_terminate(void) { __terminate(); - /* kill pending threads in local thread poll */ + /* kill pending threads in local thread pool */ /* TODO */ } diff --git a/lsh/MacOS/src/lsh_dll.cp b/lsh/MacOS/src/lsh_dll.cp index 9552253..ba3a0f0 100755 --- a/lsh/MacOS/src/lsh_dll.cp +++ b/lsh/MacOS/src/lsh_dll.cp @@ -2,33 +2,19 @@ #include "lsh_context.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include #include #include -#ifndef __CONSOLE__ -#include -#endif - #ifdef __cplusplus extern "C" { #endif void ssh2_sched(); -Boolean can_read(); -void ssh2_doevent(long sleepTime); char *getprefsd(char *name, char *buf, size_t size, short *vRefNum, long *dirID); #ifdef __cplusplus @@ -36,60 +22,6 @@ char *getprefsd(char *name, char *buf, size_t size, short *vRefNum, long *dirID) #endif -/* - * default GUSIHandleNextEvent is GUSI's main event loop - */ - -void GUSIHandleNextEvent(long sleepTime) -{ - ssh2_doevent( sleepTime ); -} - - -/* - * default GUSISIOUXSocket::select checks for keyDown or - * autoKey events from MacOS's EventQueue. - * we use an internal buffer. - */ - -class GUSISIOUXSocket : public GUSISocket { -public: - ~GUSISIOUXSocket(); - - ssize_t read(const GUSIScatterer & buffer); - ssize_t write(const GUSIGatherer & buffer); - virtual int ioctl(unsigned int request, va_list arg); - virtual int fstat(struct stat * buf); - virtual int isatty(); - bool select(bool * canRead, bool * canWrite, bool *); - - static GUSISIOUXSocket * Instance(); -private: - static GUSISIOUXSocket * sInstance; - - GUSISIOUXSocket(); -}; - -bool GUSISIOUXSocket::select(bool * canRead, bool * canWrite, bool *) -{ - bool cond = false; - - if (canRead) { - if (*canRead = can_read()) - cond = true; - } - if (canWrite) - cond = *canWrite = true; - return cond; -} - -/* we don't use SIOUX event handler */ -GUSISIOUXSocket::GUSISIOUXSocket() -{ - InstallConsole(0); -} - - /* * ssh2_sched */ @@ -99,8 +31,6 @@ void ssh2_sched() sched_yield(); } - - /* * getprefsd return the full path of prefs directory */ diff --git a/lsh/MacOS/src/lsh_maccvs.cpp b/lsh/MacOS/src/lsh_maccvs.cpp index efde56c..1cc6c04 100644 --- a/lsh/MacOS/src/lsh_maccvs.cpp +++ b/lsh/MacOS/src/lsh_maccvs.cpp @@ -6,6 +6,7 @@ #include "lsh_context.h" #include +#include #include #include "GUSIMSLSetup.h" @@ -14,6 +15,8 @@ extern "C" { #endif +void GUSIwithTTYSockets(); + void ssh2_init(); void add_one_file(struct lshcontext *context, int fd); @@ -23,6 +26,11 @@ void remove_one_file(struct lshcontext *context, int fd); } #endif +/* +GusiMSLWriteConsole sWriteConsole = 0L; +GusiMSLWriteConsole sInConsole = 0L; +*/ + static void myGusiMSLAddFile(int fd) { lshcontext *context = (lshcontext *)pthread_getspecific(ssh2threadkey); @@ -48,8 +56,18 @@ void ssh2_init() static Boolean sGUSISetup = false; if ( !sGUSISetup ) { + + GUSIwithTTYSockets(); + GusiMSLSetAddFile(myGusiMSLAddFile); GusiMSLSetRemoveFile(myGusiMSLRemoveFile); +/* + sWriteConsole = GusiMSLGetWriteConsole(); + sInConsole = GusiMSLGetInConsole(); + + GusiMSLSetWriteConsole(WriteCharsToConsole); + GusiMSLSetInConsole(ReadCharsFromConsole); +*/ } } diff --git a/lsh/MacOS/src/lshprefix.h b/lsh/MacOS/src/lshprefix.h index 7ec6af5..d92c933 100755 --- a/lsh/MacOS/src/lshprefix.h +++ b/lsh/MacOS/src/lshprefix.h @@ -306,8 +306,8 @@ #define MACOS 1 #define LSH 1 -#define HAVE_STDTTY_FILENO 1 -#define STDTTY_FILENO 0 +/*#define HAVE_STDTTY_FILENO 1*/ +/*#define STDTTY_FILENO 0*/ #define SIOUX_USE_WASTE 1 #define exit macosexit diff --git a/lsh/MacOS/src/macosmain.c b/lsh/MacOS/src/macosmain.c index 1409988..a4db78c 100755 --- a/lsh/MacOS/src/macosmain.c +++ b/lsh/MacOS/src/macosmain.c @@ -11,6 +11,7 @@ #include "werror.h" #include +#include #include #include #include @@ -21,7 +22,10 @@ #include #include +#include #include +#include +#include #include "PasswordDialog.h" #include "MemPool.h" @@ -483,6 +487,63 @@ pascal Ptr PLstrrchr(ConstStr255Param s, short c) return NULL; } +#pragma mark - + +/* + * InstallTTY + */ +int InstallTTY(int id, int flags) +{ +#pragma unused (id, flags) + return 0; +} + +/* + * RemoveTTY + */ +void RemoveTTY(int id, int flags) +{ +#pragma unused (id, flags) +} + +/* + * WriteCharsToTTY + */ +int WriteCharsToTTY(int id, int flags, char *buffer, int n) +{ +#pragma unused (id, flags) + return WriteCharsToConsole(buffer, n); +} + +/* + * ReadCharsFromTTY + */ +int ReadCharsFromTTY(int id, int flags, char *buffer, int n) +{ +#pragma unused (id, flags) + return ReadCharsFromConsole(buffer, n); +} + +/* + * AvailableFromTTY + */ +int AvailableFromTTY(int id, int flags) +{ +#pragma unused (id, flags) + extern short gSIOUXBufSize; + if ( !gSIOUXBufSize ) { + QHdrPtr eventQueue = LMGetEventQueue(); + EvQElPtr element = (EvQElPtr)eventQueue->qHead; + // now, count the number of pending keyDown events. + while (element != nil) { + if (element->evtQWhat == keyDown || element->evtQWhat == autoKey) + return true; + element = (EvQElPtr)element->qLink; + } + return false; + } + return true; +} #pragma mark - diff --git a/lsh/MacOS/src/werror.c b/lsh/MacOS/src/werror.c index 81c465a..79f21b0 100755 --- a/lsh/MacOS/src/werror.c +++ b/lsh/MacOS/src/werror.c @@ -568,7 +568,7 @@ werror(const char *format, ...) if (gLogStdIO || (!context->_tracing && !context->_verbosing && !context->_debugging)) { if (!gLogStdIO) { werror_flush(); - set_error_stream(STDOUT_FILENO, 0); + set_error_stream(STDERR_FILENO, 0); } } va_start(args, format); @@ -651,7 +651,7 @@ fatal(const char *format, ...) if (context) { werror_flush(); - set_error_stream(STDOUT_FILENO, 0); + set_error_stream(STDERR_FILENO, 0); va_start(args, format); werror_vformat(format, args); va_end(args); diff --git a/lsh/src/lsh.c b/lsh/src/lsh.c index a81dbfe..86b7302 100755 --- a/lsh/src/lsh.c +++ b/lsh/src/lsh.c @@ -1080,7 +1080,7 @@ char *applname = "lsh"; //char *defargstr = "-lnono --debug --verbose --trace 192.168.1.41"; //char *defargstr = "-ljps -z --debug --verbose --trace 192.168.1.41"; //char *defargstr = "-ljps -zzlib --verbose -L22:192.168.1.41:22 192.168.1.41"; -char *defargstr = "-ljps -zzlib --verbose 192.168.1.41"; +char *defargstr = "-ljps -mmd5 -zzlib --stdin dev:tty --stdout dev:tty --sloppy-host-authentication --verbose 192.168.1.41"; //char *defargstr = "-ljps -zzlib --debug --verbose --trace -L23:192.168.1.41:22 192.168.1.41"; //char *defargstr = "-ljps -znone 192.168.1.41"; //char *defargstr = "-lwebmaster -znone --debug --verbose --trace --sloppy-host-authentication www.tldnames.com"; diff --git a/lsh/src/unix_interact.c b/lsh/src/unix_interact.c index 45e5bfc..036849d 100755 --- a/lsh/src/unix_interact.c +++ b/lsh/src/unix_interact.c @@ -385,7 +385,11 @@ make_unix_interact(struct io_backend *backend) if (isatty(STDTTY_FILENO)) self->tty_fd = STDTTY_FILENO; #else /* ! HAVE_STDTTY_FILENO */ +#if MACOS + self->tty_fd = open("dev:tty", O_RDWR); +#else self->tty_fd = open("/dev/tty", O_RDWR); +#endif #endif if (backend && (self->tty_fd >= 0)) diff --git a/macssh/source/ssh/GUSIPatch1.cp b/macssh/source/ssh/GUSIPatch1.cp index a16efa5..caf6d41 100755 --- a/macssh/source/ssh/GUSIPatch1.cp +++ b/macssh/source/ssh/GUSIPatch1.cp @@ -64,7 +64,6 @@ int socket(int domain, int type, int protocol); int accept(int s, struct sockaddr *addr, socklen_t *addrlen); int close(int s); -Boolean can_read(); void ssh2_doevent(long sleepTime); void add_one_file(struct lshcontext *context, int fd); void remove_one_file(struct lshcontext *context, int fd); @@ -74,6 +73,7 @@ void remove_one_file(struct lshcontext *context, int fd); #endif extern pthread_key_t ssh2threadkey; +extern int g_error_fd; /* * ssh2_init @@ -89,10 +89,11 @@ void ssh2_init() /* this call initializes the resolver with current context */ gethostid(); - GUSISetupConsole(); + /*GUSISetupConsole();*/ sGUSISetup = true; - } + g_error_fd = open("dev:ttyerr", O_WRONLY ); + } } /* @@ -162,49 +163,13 @@ void GUSIHandleNextEvent(long sleepTime) } -/* - * default GUSISIOUXSocket::select checks for keyDown or - * autoKey events from MacOS's EventQueue. - * we use an internal buffer. - */ - -class GUSISIOUXSocket : public GUSISocket { -public: - ~GUSISIOUXSocket(); - - ssize_t read(const GUSIScatterer & buffer); - ssize_t write(const GUSIGatherer & buffer); - virtual int ioctl(unsigned int request, va_list arg); - virtual int fstat(struct stat * buf); - virtual int isatty(); - bool select(bool * canRead, bool * canWrite, bool *); - - static GUSISIOUXSocket * Instance(); -private: - static GUSISIOUXSocket * sInstance; - - GUSISIOUXSocket(); -}; - -bool GUSISIOUXSocket::select(bool * canRead, bool * canWrite, bool *) -{ - bool cond = false; - - if (canRead) { - if (*canRead = can_read()) - cond = true; - } - if (canWrite) - cond = *canWrite = true; - return cond; -} - /* we don't use SIOUX event handler */ +/* GUSISIOUXSocket::GUSISIOUXSocket() { InstallConsole(0); } - +*/ /* * default GUSIProcess::Yield has 20 ticks to remain in same state diff --git a/macssh/source/ssh/ssh2.c b/macssh/source/ssh/ssh2.c index 51a7156..f9cb0b1 100755 --- a/macssh/source/ssh/ssh2.c +++ b/macssh/source/ssh/ssh2.c @@ -153,6 +153,8 @@ const struct termios defaulttermios = { /* true if we log werror/trace... to stdio, false => log to syslog */ Boolean gLogStdIO = 0; +int g_error_fd = -1; + pthread_key_t ssh2threadkey = NULL; char homepath[256]; @@ -1095,7 +1097,10 @@ void init_context(lshcontext *context, short port) context->_verbose_flag = 0; context->_trace_flag = 0; context->_debug_flag = 0; - context->_error_fd = STDERR_FILENO; + + /*context->_error_fd = STDERR_FILENO;*/ + context->_error_fd = g_error_fd; + context->_error_pos = 0; context->_error_write = write_raw; context->_tracing = 0; @@ -1267,6 +1272,8 @@ static int build_cmdline(WindRec*w, char *argstr) strcat(argstr, getenv("HOME")); /* 256 */ strcat(argstr, "known_hosts\""); + strcat(argstr, " --stdin dev:ttyin --stdout dev:ttyout --stderr dev:ttyerr"); + if (!w->restricted) strcat(argstr, " --sloppy-host-authentication"); diff --git a/macssh/source/ssh/werror.c b/macssh/source/ssh/werror.c index 81c465a..5b27551 100755 --- a/macssh/source/ssh/werror.c +++ b/macssh/source/ssh/werror.c @@ -68,6 +68,7 @@ int verbose_flag = 0; int syslog_flag = 0; #else extern Boolean gLogStdIO; +extern int g_error_fd; #endif #define WERROR_TRACE -1 @@ -568,7 +569,8 @@ werror(const char *format, ...) if (gLogStdIO || (!context->_tracing && !context->_verbosing && !context->_debugging)) { if (!gLogStdIO) { werror_flush(); - set_error_stream(STDOUT_FILENO, 0); + /*set_error_stream(STDOUT_FILENO, 0);*/ + set_error_stream(g_error_fd, 0); } } va_start(args, format); @@ -651,7 +653,8 @@ fatal(const char *format, ...) if (context) { werror_flush(); - set_error_stream(STDOUT_FILENO, 0); + /*set_error_stream(STDOUT_FILENO, 0);*/ + set_error_stream(g_error_fd, 0); va_start(args, format); werror_vformat(format, args); va_end(args);