From 32a7aec45370ae120ef6f3a3eaa8868822344e5d Mon Sep 17 00:00:00 2001 From: Manoj Ampalam Date: Mon, 2 Apr 2018 22:30:15 -0700 Subject: [PATCH] Ported upstream changes (7.7) --- auth-passwd.c | 3 ++- contrib/win32/openssh/config.h.vs | 6 ++--- contrib/win32/openssh/config.ps1 | 2 +- contrib/win32/openssh/libssh.vcxproj | 1 - contrib/win32/openssh/libssh.vcxproj.filters | 5 +--- contrib/win32/openssh/openbsd_compat.vcxproj | 2 +- .../openssh/openbsd_compat.vcxproj.filters | 6 ++--- contrib/win32/openssh/version.rc | 6 ++--- contrib/win32/openssh/win32iocompat.vcxproj | 2 ++ .../openssh/win32iocompat.vcxproj.filters | 11 +++++++- contrib/win32/win32compat/inc/net/if.h | 1 + contrib/win32/win32compat/inc/signal.h | 4 +-- contrib/win32/win32compat/inc/string.h | 4 ++- contrib/win32/win32compat/inc/time.h | 4 +++ contrib/win32/win32compat/misc.c | 8 ++++++ contrib/win32/win32compat/signal.c | 9 +++++++ openbsd-compat/bsd-misc.c | 27 ------------------- 17 files changed, 51 insertions(+), 50 deletions(-) create mode 100644 contrib/win32/win32compat/inc/net/if.h create mode 100644 contrib/win32/win32compat/inc/time.h diff --git a/auth-passwd.c b/auth-passwd.c index 749205d50..a074ffe5f 100644 --- a/auth-passwd.c +++ b/auth-passwd.c @@ -269,8 +269,9 @@ done: * - If LogonUser fails, then try the LSA (Local Security Authority) authentication. */ int -sys_auth_passwd(Authctxt *authctxt, const char *password) +sys_auth_passwd(struct ssh *ssh, const char *password) { + Authctxt *authctxt = ssh->authctxt; wchar_t *user_utf16 = NULL, *udom_utf16 = NULL, *pwd_utf16 = NULL, *tmp; HANDLE token = NULL; int r = 0; diff --git a/contrib/win32/openssh/config.h.vs b/contrib/win32/openssh/config.h.vs index e0ef8d675..8fd3c4e03 100644 --- a/contrib/win32/openssh/config.h.vs +++ b/contrib/win32/openssh/config.h.vs @@ -1666,15 +1666,13 @@ #define __func__ __FUNCTION__ #endif -/* Windows specific macro added to workaround mysignal implementaion in bsd-misc.c */ -#define HAVE_MYSIGNAL 1 - - +#define HAVE_BZERO 1 #define PATH_MAX MAX_PATH #define S_IFIFO 0x1000 #define HAVE_EXPLICIT_BZERO #define HAVE_MBTOWC 1 #define HAVE_LLABS 1 +#define HAVE_RAISE 1 #include #include diff --git a/contrib/win32/openssh/config.ps1 b/contrib/win32/openssh/config.ps1 index 0d5d8f3e2..1befe6828 100644 --- a/contrib/win32/openssh/config.ps1 +++ b/contrib/win32/openssh/config.ps1 @@ -2,7 +2,7 @@ Param($Config_h_vs, $Config_h, $VCIncludePath, $OutCRTHeader) Copy-Item $Config_h_vs $Config_h -Force if (Test-Path $OutCRTHeader) {exit} -$headers = ("stdio.h", "string.h", "sys\types.h", "ctype.h", "stdlib.h", "sys\stat.h", "fcntl.h") +$headers = ("stdio.h", "string.h", "sys\types.h", "ctype.h", "stdlib.h", "sys\stat.h", "fcntl.h", "time.h") $paths = $VCIncludePath.Split(";") Set-Content -Path $OutCRTHeader -Value "/*`r`n * DO NOT EDIT - AutoGenerated by config.ps1`r`n */`r`n" -Force foreach ($header in $headers) { diff --git a/contrib/win32/openssh/libssh.vcxproj b/contrib/win32/openssh/libssh.vcxproj index 7c0725c55..7d8715559 100644 --- a/contrib/win32/openssh/libssh.vcxproj +++ b/contrib/win32/openssh/libssh.vcxproj @@ -349,7 +349,6 @@ - diff --git a/contrib/win32/openssh/libssh.vcxproj.filters b/contrib/win32/openssh/libssh.vcxproj.filters index 596c95806..158e86d26 100644 --- a/contrib/win32/openssh/libssh.vcxproj.filters +++ b/contrib/win32/openssh/libssh.vcxproj.filters @@ -6,7 +6,6 @@ - @@ -89,6 +88,7 @@ + @@ -259,9 +259,6 @@ Source Files - - Source Files - Source Files diff --git a/contrib/win32/openssh/openbsd_compat.vcxproj b/contrib/win32/openssh/openbsd_compat.vcxproj index d76397e02..55fb12cb4 100644 --- a/contrib/win32/openssh/openbsd_compat.vcxproj +++ b/contrib/win32/openssh/openbsd_compat.vcxproj @@ -44,7 +44,6 @@ - @@ -100,6 +99,7 @@ + diff --git a/contrib/win32/openssh/openbsd_compat.vcxproj.filters b/contrib/win32/openssh/openbsd_compat.vcxproj.filters index 135cbcfd0..64c4bda99 100644 --- a/contrib/win32/openssh/openbsd_compat.vcxproj.filters +++ b/contrib/win32/openssh/openbsd_compat.vcxproj.filters @@ -39,9 +39,6 @@ Source Files - - Source Files - Source Files @@ -207,6 +204,9 @@ Source Files + + Source Files + diff --git a/contrib/win32/openssh/version.rc b/contrib/win32/openssh/version.rc index be0859a4c..d94e8b5b0 100644 --- a/contrib/win32/openssh/version.rc +++ b/contrib/win32/openssh/version.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 7,6,1,0 - PRODUCTVERSION 7,6,1,0 + FILEVERSION 7,7,0,0 + PRODUCTVERSION 7,7,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -67,7 +67,7 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "FileVersion", "7.6.1.0" + VALUE "FileVersion", "7.7.0.0" VALUE "ProductName", "OpenSSH for Windows" VALUE "ProductVersion", "OpenSSH_7.6p1 for Windows" END diff --git a/contrib/win32/openssh/win32iocompat.vcxproj b/contrib/win32/openssh/win32iocompat.vcxproj index d18fe5943..2798ea626 100644 --- a/contrib/win32/openssh/win32iocompat.vcxproj +++ b/contrib/win32/openssh/win32iocompat.vcxproj @@ -348,6 +348,8 @@ + + diff --git a/contrib/win32/openssh/win32iocompat.vcxproj.filters b/contrib/win32/openssh/win32iocompat.vcxproj.filters index 91654b39e..af443af01 100644 --- a/contrib/win32/openssh/win32iocompat.vcxproj.filters +++ b/contrib/win32/openssh/win32iocompat.vcxproj.filters @@ -9,7 +9,7 @@ - + @@ -143,6 +143,12 @@ inc + + inc + + + inc\net + @@ -157,5 +163,8 @@ {d943f1aa-2df9-4df3-b499-4403a899fe8d} + + {b16bbf61-e602-4b0f-832b-190085cbfd5c} + \ No newline at end of file diff --git a/contrib/win32/win32compat/inc/net/if.h b/contrib/win32/win32compat/inc/net/if.h new file mode 100644 index 000000000..6f70f09be --- /dev/null +++ b/contrib/win32/win32compat/inc/net/if.h @@ -0,0 +1 @@ +#pragma once diff --git a/contrib/win32/win32compat/inc/signal.h b/contrib/win32/win32compat/inc/signal.h index abaa5b738..e86d14a5b 100644 --- a/contrib/win32/win32compat/inc/signal.h +++ b/contrib/win32/win32compat/inc/signal.h @@ -52,10 +52,8 @@ typedef int sigset_t; #define W32_SIG_IGN ((sighandler_t)1) sighandler_t w32_signal(int signum, sighandler_t handler); -//#define signal(a,b) w32_signal((a), (b)) -//#define mysignal(a,b) w32_signal((a), (b)) sighandler_t mysignal(int signum, sighandler_t handler); - +char* strsignal(int); int w32_raise(int sig); #define raise(a) w32_raise(a) diff --git a/contrib/win32/win32compat/inc/string.h b/contrib/win32/win32compat/inc/string.h index 21dd92fb9..4765a8e39 100644 --- a/contrib/win32/win32compat/inc/string.h +++ b/contrib/win32/win32compat/inc/string.h @@ -10,4 +10,6 @@ char *w32_strerror(int); #define strdup _strdup #define ERROR_MSG_MAXLEN 94 /* https://msdn.microsoft.com/en-us/library/51sah927.aspx */ -static char errorBuf[ERROR_MSG_MAXLEN]; \ No newline at end of file +static char errorBuf[ERROR_MSG_MAXLEN]; + +char *strndup(const char*, size_t); \ No newline at end of file diff --git a/contrib/win32/win32compat/inc/time.h b/contrib/win32/win32compat/inc/time.h new file mode 100644 index 000000000..1994ea4b8 --- /dev/null +++ b/contrib/win32/win32compat/inc/time.h @@ -0,0 +1,4 @@ +#include "crtheaders.h" +#include TIME_H + +struct tm *localtime_r(const time_t *, struct tm *); diff --git a/contrib/win32/win32compat/misc.c b/contrib/win32/win32compat/misc.c index 976267698..eb3ac90e7 100644 --- a/contrib/win32/win32compat/misc.c +++ b/contrib/win32/win32compat/misc.c @@ -53,6 +53,7 @@ #include "w32fd.h" #include "inc\string.h" #include "inc\grp.h" +#include "inc\time.h" static char* s_programdir = NULL; @@ -1540,3 +1541,10 @@ copy_file(char *source, char *destination) return 0; } +struct tm* +localtime_r(const time_t *timep, struct tm *result) +{ + struct tm *t = localtime(timep); + memcpy(result, t, sizeof(struct tm)); + return t; +} \ No newline at end of file diff --git a/contrib/win32/win32compat/signal.c b/contrib/win32/win32compat/signal.c index 0e4dcad87..01b6ee3fa 100644 --- a/contrib/win32/win32compat/signal.c +++ b/contrib/win32/win32compat/signal.c @@ -130,6 +130,15 @@ mysignal(int signum, sighandler_t handler) { return w32_signal(signum, handler); } +char* +strsignal(int sig) +{ + static char buf[16]; + + (void)snprintf(buf, sizeof(buf), "%d", sig); + return buf; +} + sighandler_t w32_signal(int signum, sighandler_t handler) { diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c index 48c20f4fb..3daf61071 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/bsd-misc.c @@ -211,33 +211,6 @@ tcsendbreak(int fd, int duration) } #endif /* HAVE_TCSENDBREAK */ -mysig_t -mysignal(int sig, mysig_t act) -{ -#ifdef HAVE_SIGACTION - struct sigaction sa, osa; - - if (sigaction(sig, NULL, &osa) == -1) - return (mysig_t) -1; - if (osa.sa_handler != act) { - memset(&sa, 0, sizeof(sa)); - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; -#ifdef SA_INTERRUPT - if (sig == SIGALRM) - sa.sa_flags |= SA_INTERRUPT; -#endif - sa.sa_handler = act; - if (sigaction(sig, &sa, NULL) == -1) - return (mysig_t) -1; - } - return (osa.sa_handler); -#else - #undef signal - return (signal(sig, act)); -#endif -} - #ifndef HAVE_STRDUP char * strdup(const char *str)