From 31c7448e63a27ecec038cf32fb45f38bf2a9d078 Mon Sep 17 00:00:00 2001 From: Manoj Ampalam Date: Fri, 25 Mar 2016 09:49:03 -0700 Subject: [PATCH] Removed more unsupported code in sshd.exe --- contrib/win32/win32compat/inc/sys/wait.h | 4 ++ ssh.c | 76 ++---------------------- sshconnect.c | 8 +-- 3 files changed, 12 insertions(+), 76 deletions(-) diff --git a/contrib/win32/win32compat/inc/sys/wait.h b/contrib/win32/win32compat/inc/sys/wait.h index e5100eb..b7eeb25 100644 --- a/contrib/win32/win32compat/inc/sys/wait.h +++ b/contrib/win32/win32compat/inc/sys/wait.h @@ -7,4 +7,8 @@ #define WIFSIGNALED(w) (!WIFEXITED(w) && !WIFSTOPPED(w)) #define WEXITSTATUS(w) (int)(WIFEXITED(w) ? ((_W_INT(w) >> 8) & 0377) : -1) #define WTERMSIG(w) (int)(WIFSIGNALED(w) ? (_W_INT(w) & 0177) : -1) + +/* wait pid options */ +#define WNOHANG 1 + pid_t waitpid(pid_t pid, int *status, int options); \ No newline at end of file diff --git a/ssh.c b/ssh.c index daaf1e0..2915bb8 100644 --- a/ssh.c +++ b/ssh.c @@ -118,9 +118,6 @@ #include - extern HANDLE proxy_command_handle; - extern DWORD proxy_command_pid; - char dotsshdir[MAX_PATH]; #endif /* WIN32_FIXME */ @@ -249,49 +246,6 @@ tilde_expand_paths(char **paths, u_int num_paths) #ifdef WIN32_FIXME -/* - * This function send CTRL_BREAK_EVENT (equivalent of SIGINT) to - * child proxy process. - * - * If process still alive terminates it. - */ - -static void CleanUpProxyProcess() -{ - if (proxy_command_handle) - { - if (GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, proxy_command_pid) == FALSE) - { - debug("ERROR. Cannot send exit signal to childs (%u).", - (unsigned int) GetLastError()); - } - - /* - * Try wait up to 100 ms until proxy process finished. - */ - - if (WaitForSingleObject(proxy_command_handle, 100) == WAIT_TIMEOUT) - { - /* - * If still not closed, kill proxy process. - */ - - if (TerminateProcess(proxy_command_handle, 1) == TRUE) - { - debug("Process %u terminated.", (unsigned int) proxy_command_pid); - } - else - { - debug("ERROR. Cannot terminate proxy process (pid = %u).", - (unsigned int) proxy_command_pid); - } - } - - CloseHandle(proxy_command_handle); - } -} - -extern Buffer stdin_buffer; /* Buffer for stdin data. */ /* * This function handles exit signal. */ @@ -325,10 +279,6 @@ BOOL WINAPI CtrlHandlerRoutine(DWORD dwCtrlType) debug("Exit signal received..."); - CleanUpProxyProcess(); - - UninitMitKerberos(); - cleanup_exit(0); return TRUE; @@ -1473,10 +1423,8 @@ main(int ac, char **av) options.num_system_hostfiles); tilde_expand_paths(options.user_hostfiles, options.num_user_hostfiles); -#ifndef WIN32_FIXME signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE early */ signal(SIGCHLD, main_sigchld_handler); -#endif /* Log into the remote system. Never returns if the login fails. */ ssh_login(&sensitive_data, host, (struct sockaddr *)&hostaddr, @@ -1533,20 +1481,14 @@ main(int ac, char **av) * Windows specific Cleanup. */ - #ifdef WIN32_FIXME +#ifdef WIN32_FIXME if (tty_flag) ConUnInitWithRestore(); // restore terminal to previous settings if it was a tty session - - CleanUpProxyProcess(); - - UninitMitKerberos(); - - #else +#endif /* Kill ProxyCommand if it is running. */ ssh_kill_proxy_command(); -#endif return exit_status; } @@ -1554,7 +1496,7 @@ main(int ac, char **av) static void control_persist_detach(void) { -#ifndef WIN32_FIXME +#ifndef WIN32_FIXME//R pid_t pid; int devnull; @@ -1595,6 +1537,8 @@ control_persist_detach(void) } daemon(1, 1); setproctitle("%s [mux]", options.control_path); +#else + fatal("not supported in Windows"); #endif } @@ -2037,13 +1981,6 @@ ssh_session2_open(void) window >>= 1; packetmax >>= 1; } - #ifdef WIN32_FIXME - else { - // make stdio duplicated ports of above binary mode so no CRLF xlate - //_setmode(sfd_to_fd(in), O_BINARY); - //_setmode(sfd_to_fd(out), O_BINARY); - } - #endif c = channel_new( "session", SSH_CHANNEL_OPENING, in, out, err, @@ -2250,7 +2187,6 @@ load_public_identity_files(void) free(pwdir); } -#ifndef WIN32_FIXME static void main_sigchld_handler(int sig) { @@ -2265,6 +2201,6 @@ main_sigchld_handler(int sig) signal(sig, main_sigchld_handler); errno = save_errno; } -#endif + diff --git a/sshconnect.c b/sshconnect.c index 32c041d..8161d69 100644 --- a/sshconnect.c +++ b/sshconnect.c @@ -74,14 +74,10 @@ static int matching_host_key_dns = 0; #ifdef WIN32_FIXME #define FAIL(X) if (X) goto fail - - HANDLE proxy_command_handle = NULL; - DWORD proxy_command_pid = 0; - -#else -static pid_t proxy_command_pid = 0; #endif +static pid_t proxy_command_pid = 0; + /* import */ extern Options options; extern char *__progname;