mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-23 22:15:37 +02:00
Refactored some part of ssh.exe
This commit is contained in:
parent
d061364c5a
commit
b65edccdf6
23
clientloop.c
23
clientloop.c
@ -116,10 +116,6 @@
|
|||||||
#include "hostfile.h"
|
#include "hostfile.h"
|
||||||
|
|
||||||
#ifdef WIN32_FIXME
|
#ifdef WIN32_FIXME
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
//#define isatty(a) WSHELPisatty(a)
|
|
||||||
|
|
||||||
// Windows Console screen size change related
|
// Windows Console screen size change related
|
||||||
extern int ScreenX;
|
extern int ScreenX;
|
||||||
extern int ScrollBottom;
|
extern int ScrollBottom;
|
||||||
@ -168,10 +164,7 @@ static int escape_pending1; /* Last character was an escape (proto1 only) */
|
|||||||
static int last_was_cr; /* Last character was a newline. */
|
static int last_was_cr; /* Last character was a newline. */
|
||||||
static int exit_status; /* Used to store the command exit status. */
|
static int exit_status; /* Used to store the command exit status. */
|
||||||
static int stdin_eof; /* EOF has been encountered on stderr. */
|
static int stdin_eof; /* EOF has been encountered on stderr. */
|
||||||
#ifndef WIN32_FIXME
|
static Buffer stdin_buffer; /* Buffer for stdin data. */
|
||||||
static
|
|
||||||
#endif
|
|
||||||
Buffer stdin_buffer; /* Buffer for stdin data. */
|
|
||||||
static Buffer stdout_buffer; /* Buffer for stdout data. */
|
static Buffer stdout_buffer; /* Buffer for stdout data. */
|
||||||
static Buffer stderr_buffer; /* Buffer for stderr data. */
|
static Buffer stderr_buffer; /* Buffer for stderr data. */
|
||||||
static u_int buffer_high; /* Soft max buffer size. */
|
static u_int buffer_high; /* Soft max buffer size. */
|
||||||
@ -241,9 +234,7 @@ static void
|
|||||||
window_change_handler(int sig)
|
window_change_handler(int sig)
|
||||||
{
|
{
|
||||||
received_window_change_signal = 1;
|
received_window_change_signal = 1;
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
signal(SIGWINCH, window_change_handler);
|
signal(SIGWINCH, window_change_handler);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -360,7 +351,6 @@ client_x11_get_proto(const char *display, const char *xauth_path,
|
|||||||
display = xdisplay;
|
display = xdisplay;
|
||||||
}
|
}
|
||||||
if (trusted == 0) {
|
if (trusted == 0) {
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
xauthdir = xmalloc(PATH_MAX);
|
xauthdir = xmalloc(PATH_MAX);
|
||||||
xauthfile = xmalloc(PATH_MAX);
|
xauthfile = xmalloc(PATH_MAX);
|
||||||
mktemp_proto(xauthdir, PATH_MAX);
|
mktemp_proto(xauthdir, PATH_MAX);
|
||||||
@ -395,7 +385,6 @@ client_x11_get_proto(const char *display, const char *xauth_path,
|
|||||||
if (system(cmd) == 0)
|
if (system(cmd) == 0)
|
||||||
generated = 1;
|
generated = 1;
|
||||||
}
|
}
|
||||||
#endif /* !WIN32_FIXME */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -404,7 +393,6 @@ client_x11_get_proto(const char *display, const char *xauth_path,
|
|||||||
* above.
|
* above.
|
||||||
*/
|
*/
|
||||||
if (trusted || generated) {
|
if (trusted || generated) {
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
snprintf(cmd, sizeof(cmd),
|
snprintf(cmd, sizeof(cmd),
|
||||||
"%s %s%s list %s 2>" _PATH_DEVNULL,
|
"%s %s%s list %s 2>" _PATH_DEVNULL,
|
||||||
xauth_path,
|
xauth_path,
|
||||||
@ -418,7 +406,6 @@ client_x11_get_proto(const char *display, const char *xauth_path,
|
|||||||
got_data = 1;
|
got_data = 1;
|
||||||
if (f)
|
if (f)
|
||||||
pclose(f);
|
pclose(f);
|
||||||
#endif /* !WIN32_FIXME */
|
|
||||||
} else
|
} else
|
||||||
error("Warning: untrusted X11 forwarding setup failed: "
|
error("Warning: untrusted X11 forwarding setup failed: "
|
||||||
"xauth key data not generated");
|
"xauth key data not generated");
|
||||||
@ -937,9 +924,7 @@ process_cmdline(void)
|
|||||||
memset(&fwd, 0, sizeof(fwd));
|
memset(&fwd, 0, sizeof(fwd));
|
||||||
|
|
||||||
leave_raw_mode(options.request_tty == REQUEST_TTY_FORCE);
|
leave_raw_mode(options.request_tty == REQUEST_TTY_FORCE);
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
handler = signal(SIGINT, SIG_IGN);
|
handler = signal(SIGINT, SIG_IGN);
|
||||||
#endif
|
|
||||||
|
|
||||||
cmd = s = read_passphrase("\r\nssh> ", RP_ECHO);
|
cmd = s = read_passphrase("\r\nssh> ", RP_ECHO);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
@ -1245,7 +1230,7 @@ process_escapes(Channel *c, Buffer *bin, Buffer *bout, Buffer *berr,
|
|||||||
buffer_append(berr, string, strlen(string));
|
buffer_append(berr, string, strlen(string));
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#ifndef WIN32_FIXME
|
#ifndef WIN32_FIXME//R
|
||||||
case '&':
|
case '&':
|
||||||
if (c && c->ctl_chan != -1)
|
if (c && c->ctl_chan != -1)
|
||||||
goto noescape;
|
goto noescape;
|
||||||
@ -1605,7 +1590,6 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
|
|||||||
* but don't overwrite SIG_IGN, matches behaviour from rsh(1)
|
* but don't overwrite SIG_IGN, matches behaviour from rsh(1)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
|
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
|
||||||
signal(SIGHUP, signal_handler);
|
signal(SIGHUP, signal_handler);
|
||||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
||||||
@ -1615,7 +1599,6 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
|
|||||||
if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
|
if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
|
||||||
signal(SIGTERM, signal_handler);
|
signal(SIGTERM, signal_handler);
|
||||||
signal(SIGWINCH, window_change_handler);
|
signal(SIGWINCH, window_change_handler);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (have_pty)
|
if (have_pty)
|
||||||
enter_raw_mode(options.request_tty == REQUEST_TTY_FORCE);
|
enter_raw_mode(options.request_tty == REQUEST_TTY_FORCE);
|
||||||
@ -1752,9 +1735,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
|
|||||||
/* Terminate the session. */
|
/* Terminate the session. */
|
||||||
|
|
||||||
/* Stop watching for window change. */
|
/* Stop watching for window change. */
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
signal(SIGWINCH, SIG_DFL);
|
signal(SIGWINCH, SIG_DFL);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (compat20) {
|
if (compat20) {
|
||||||
packet_start(SSH2_MSG_DISCONNECT);
|
packet_start(SSH2_MSG_DISCONNECT);
|
||||||
|
@ -1611,7 +1611,6 @@
|
|||||||
#define HAVE_INET_NTOA 1
|
#define HAVE_INET_NTOA 1
|
||||||
#define HAVE_INNETGR 1
|
#define HAVE_INNETGR 1
|
||||||
#undef HAVE_LIBCRYPT
|
#undef HAVE_LIBCRYPT
|
||||||
#define HAVE_MKDTEMP 1
|
|
||||||
#define HAVE_NANOSLEEP 1
|
#define HAVE_NANOSLEEP 1
|
||||||
#undef HAVE_PATHS_H
|
#undef HAVE_PATHS_H
|
||||||
#undef HAVE_PROC_PID
|
#undef HAVE_PROC_PID
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define SIGPIPE W32_SIGPIPE
|
#define SIGPIPE W32_SIGPIPE
|
||||||
#define SIGCHLD W32_SIGCHLD
|
#define SIGCHLD W32_SIGCHLD
|
||||||
#define SIGALRM W32_SIGALRM
|
#define SIGALRM W32_SIGALRM
|
||||||
#define SIGSTP W32_SIGTSTP
|
#define SIGTSTP W32_SIGTSTP
|
||||||
#define SIGHUP W32_SIGHUP
|
#define SIGHUP W32_SIGHUP
|
||||||
#define SIGQUIT W32_SIGQUIT
|
#define SIGQUIT W32_SIGQUIT
|
||||||
#define SIGTERM W32_SIGTERM
|
#define SIGTERM W32_SIGTERM
|
||||||
|
@ -50,6 +50,10 @@ size_t strncasecmp(const char *left, const char *right, size_t n);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int gettimeofday(struct timeval *tv, void *tz);
|
int gettimeofday(struct timeval *tv, void *tz);
|
||||||
|
|
||||||
|
#define popen _popen
|
||||||
|
#define pclose _pclose
|
||||||
|
|
||||||
/* End of prototypes in the wrong file */
|
/* End of prototypes in the wrong file */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
8
mux.c
8
mux.c
@ -1834,9 +1834,7 @@ mux_client_request_session(int fd)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (stdin_null_flag) {
|
if (stdin_null_flag) {
|
||||||
if ((devnull = open(_PATH_DEVNULL, O_RDONLY)) == -1)
|
if ((devnull = open(_PATH_DEVNULL, O_RDONLY)) == -1)
|
||||||
@ -1918,12 +1916,10 @@ mux_client_request_session(int fd)
|
|||||||
}
|
}
|
||||||
muxclient_request_id++;
|
muxclient_request_id++;
|
||||||
|
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
signal(SIGHUP, control_client_sighandler);
|
signal(SIGHUP, control_client_sighandler);
|
||||||
signal(SIGINT, control_client_sighandler);
|
signal(SIGINT, control_client_sighandler);
|
||||||
signal(SIGTERM, control_client_sighandler);
|
signal(SIGTERM, control_client_sighandler);
|
||||||
signal(SIGWINCH, control_client_sigrelay);
|
signal(SIGWINCH, control_client_sigrelay);
|
||||||
#endif
|
|
||||||
|
|
||||||
rawmode = tty_flag;
|
rawmode = tty_flag;
|
||||||
if (tty_flag)
|
if (tty_flag)
|
||||||
@ -2001,9 +1997,7 @@ mux_client_request_stdio_fwd(int fd)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (stdin_null_flag) {
|
if (stdin_null_flag) {
|
||||||
if ((devnull = open(_PATH_DEVNULL, O_RDONLY)) == -1)
|
if ((devnull = open(_PATH_DEVNULL, O_RDONLY)) == -1)
|
||||||
@ -2066,12 +2060,10 @@ mux_client_request_stdio_fwd(int fd)
|
|||||||
}
|
}
|
||||||
muxclient_request_id++;
|
muxclient_request_id++;
|
||||||
|
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
signal(SIGHUP, control_client_sighandler);
|
signal(SIGHUP, control_client_sighandler);
|
||||||
signal(SIGINT, control_client_sighandler);
|
signal(SIGINT, control_client_sighandler);
|
||||||
signal(SIGTERM, control_client_sighandler);
|
signal(SIGTERM, control_client_sighandler);
|
||||||
signal(SIGWINCH, control_client_sigrelay);
|
signal(SIGWINCH, control_client_sigrelay);
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stick around until the controlee closes the client_fd.
|
* Stick around until the controlee closes the client_fd.
|
||||||
|
12
readconf.c
12
readconf.c
@ -159,12 +159,6 @@ typedef enum {
|
|||||||
oFingerprintHash, oUpdateHostkeys, oHostbasedKeyTypes,
|
oFingerprintHash, oUpdateHostkeys, oHostbasedKeyTypes,
|
||||||
oPubkeyAcceptedKeyTypes,
|
oPubkeyAcceptedKeyTypes,
|
||||||
oIgnoredUnknownOption,
|
oIgnoredUnknownOption,
|
||||||
#ifdef WIN32_FIXME
|
|
||||||
|
|
||||||
oPassInputHandle,
|
|
||||||
oPassOutputHandle,
|
|
||||||
|
|
||||||
#endif
|
|
||||||
oDeprecated, oUnsupported
|
oDeprecated, oUnsupported
|
||||||
} OpCodes;
|
} OpCodes;
|
||||||
|
|
||||||
@ -285,12 +279,6 @@ static struct {
|
|||||||
{ "hostbasedkeytypes", oHostbasedKeyTypes },
|
{ "hostbasedkeytypes", oHostbasedKeyTypes },
|
||||||
{ "pubkeyacceptedkeytypes", oPubkeyAcceptedKeyTypes },
|
{ "pubkeyacceptedkeytypes", oPubkeyAcceptedKeyTypes },
|
||||||
{ "ignoreunknown", oIgnoreUnknown },
|
{ "ignoreunknown", oIgnoreUnknown },
|
||||||
#ifdef WIN32_FIXME
|
|
||||||
|
|
||||||
{"passinputhandle", oPassInputHandle},
|
|
||||||
{"passoutputhandle", oPassOutputHandle},
|
|
||||||
|
|
||||||
#endif
|
|
||||||
{ NULL, oBadOption }
|
{ NULL, oBadOption }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -245,9 +245,7 @@ wait_for_roaming_reconnect(void)
|
|||||||
/* TODO Perhaps we should read from tty here */
|
/* TODO Perhaps we should read from tty here */
|
||||||
while ((c = fgetc(stdin)) != EOF) {
|
while ((c = fgetc(stdin)) != EOF) {
|
||||||
if (c == 'Z' - 64) {
|
if (c == 'Z' - 64) {
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
kill(getpid(), SIGTSTP);
|
kill(getpid(), SIGTSTP);
|
||||||
#endif
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (c != '\n' && c != '\r')
|
if (c != '\n' && c != '\r')
|
||||||
|
@ -17,15 +17,6 @@
|
|||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
/*
|
|
||||||
* We support only client side kerberos on Windows.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef WIN32_FIXME
|
|
||||||
#undef GSSAPI
|
|
||||||
#undef KRB5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
@ -44,13 +35,6 @@
|
|||||||
#include "roaming.h"
|
#include "roaming.h"
|
||||||
#include "digest.h"
|
#include "digest.h"
|
||||||
|
|
||||||
#ifdef WIN32_FIXME
|
|
||||||
|
|
||||||
#define ECONNABORTED WSAECONNABORTED
|
|
||||||
#define ECONNREFUSED WSAECONNREFUSED
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static size_t out_buf_size = 0;
|
static size_t out_buf_size = 0;
|
||||||
static char *out_buf = NULL;
|
static char *out_buf = NULL;
|
||||||
static size_t out_start;
|
static size_t out_start;
|
||||||
|
9
sftp.c
9
sftp.c
@ -2285,14 +2285,7 @@ connect_to_server(char *path, char **args, int *in, int *out)
|
|||||||
|
|
||||||
debug3("Generating ssh-client command...");
|
debug3("Generating ssh-client command...");
|
||||||
|
|
||||||
strncat(fullCmd, path, MAX_PATH);
|
strncat(fullCmd, path, MAX_PATH);
|
||||||
|
|
||||||
//sprintf(ioArg, " -oPassInputHandle=%d -oPassOutputHandle=%d",
|
|
||||||
// childInput, childOutput);
|
|
||||||
|
|
||||||
// sfd_to_handle(sockout[0]), sfd_to_handle(sockin[1]));
|
|
||||||
|
|
||||||
//strncat(fullCmd, ioArg, MAX_PATH);
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 1; args[i]; i++)
|
for (i = 1; args[i]; i++)
|
||||||
|
5
ssh.c
5
ssh.c
@ -117,14 +117,9 @@
|
|||||||
#ifdef WIN32_FIXME
|
#ifdef WIN32_FIXME
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
//#define isatty(a) WSHELPisatty(a)
|
|
||||||
#define mkdir(a, b) _mkdir(a)
|
|
||||||
|
|
||||||
extern HANDLE proxy_command_handle;
|
extern HANDLE proxy_command_handle;
|
||||||
extern DWORD proxy_command_pid;
|
extern DWORD proxy_command_pid;
|
||||||
|
|
||||||
//extern int PassInputFd;
|
|
||||||
//extern int PassOutputFd;
|
|
||||||
|
|
||||||
char dotsshdir[MAX_PATH];
|
char dotsshdir[MAX_PATH];
|
||||||
|
|
||||||
|
9
ssh2.h
9
ssh2.h
@ -115,14 +115,7 @@
|
|||||||
#define SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ 60
|
#define SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ 60
|
||||||
#define SSH2_MSG_USERAUTH_INFO_REQUEST 60
|
#define SSH2_MSG_USERAUTH_INFO_REQUEST 60
|
||||||
#define SSH2_MSG_USERAUTH_INFO_RESPONSE 61
|
#define SSH2_MSG_USERAUTH_INFO_RESPONSE 61
|
||||||
#ifdef WIN32_FIXME
|
|
||||||
#define SSH2_MSG_USERAUTH_JPAKE_CLIENT_STEP1 60
|
|
||||||
#define SSH2_MSG_USERAUTH_JPAKE_SERVER_STEP1 61
|
|
||||||
#define SSH2_MSG_USERAUTH_JPAKE_CLIENT_STEP2 62
|
|
||||||
#define SSH2_MSG_USERAUTH_JPAKE_SERVER_STEP2 63
|
|
||||||
#define SSH2_MSG_USERAUTH_JPAKE_CLIENT_CONFIRM 64
|
|
||||||
#define SSH2_MSG_USERAUTH_JPAKE_SERVER_CONFIRM 65
|
|
||||||
#endif
|
|
||||||
/* connection protocol: generic */
|
/* connection protocol: generic */
|
||||||
|
|
||||||
#define SSH2_MSG_GLOBAL_REQUEST 80
|
#define SSH2_MSG_GLOBAL_REQUEST 80
|
||||||
|
Loading…
x
Reference in New Issue
Block a user