--- xscreensaver-5.43/driver/passwd-pwent.c.orig 2016-04-08 04:17:03.000000000 +0200 +++ xscreensaver-5.43/driver/passwd-pwent.c 2019-09-17 19:06:53.759749500 +0200 @@ -81,6 +81,12 @@ # define HAVE_BIGCRYPT +#elif defined(__CYGWIN__) +# include +# include + /* Use the following define to determine the Windows version */ +# define is_winnt (GetVersion() < 0x80000000) + #endif @@ -178,8 +184,16 @@ if (user && *user && !result) { /* Check non-shadow passwords too. */ struct passwd *p = getpwnam(user); +#ifdef __CYGWIN__ + if (p) + /* Patch the typical password test: user will be reused later on */ + if (is_winnt) + result = strdup(user); +#else if (p && passwd_known_p (p->pw_passwd)) + result = strdup(p->pw_passwd); +#endif } /* The manual for passwd(4) on HPUX 10.10 says: @@ -265,6 +279,26 @@ if (s && !strcmp (s, ciphertext)) return True; +#ifdef __CYGWIN__ + /* Patch the typical password test. */ + if (is_winnt) + { + HANDLE token; + struct passwd *user_pwd_entry = getpwnam (ciphertext); /* remember we "saved" username here */ + + /* Try to get the access token from NT. */ + token = cygwin_logon_user (user_pwd_entry, cleartext); + if (token == INVALID_HANDLE_VALUE) + return False; + /* Inform Cygwin about the new impersonation token. + Cygwin is able now, to switch to that user context by + setuid or seteuid calls. */ + cygwin_set_impersonation_token (token); + return True; + } + else +#endif /* CYGWIN */ + #ifdef HAVE_BIGCRYPT /* There seems to be no way to tell at runtime if an HP machine is in "trusted" mode, and thereby, which of crypt() or bigcrypt() we should