summaryrefslogtreecommitdiff
path: root/auth-passwd.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-09-05 16:13:06 +1100
committerDamien Miller <djm@mindrot.org>2000-09-05 16:13:06 +1100
commitbac2d8aa5e642a70045e713853b13d020b9c5d57 (patch)
tree98ddc81efce2273b3dfaff03b51242c988d30abf /auth-passwd.c
parent676092fad0b6edca8f1fe731d7c3a000465a9bef (diff)
- (djm) Merge cygwin support from Corinna Vinschen <vinschen@cygnus.com>
Diffstat (limited to 'auth-passwd.c')
-rw-r--r--auth-passwd.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/auth-passwd.c b/auth-passwd.c
index 93756e9e6..850e25834 100644
--- a/auth-passwd.c
+++ b/auth-passwd.c
@@ -37,6 +37,13 @@ RCSID("$OpenBSD: auth-passwd.c,v 1.16 2000/06/20 01:39:38 markus Exp $");
37# include "md5crypt.h" 37# include "md5crypt.h"
38#endif /* defined(HAVE_MD5_PASSWORDS) && !defined(HAVE_MD5_CRYPT) */ 38#endif /* defined(HAVE_MD5_PASSWORDS) && !defined(HAVE_MD5_CRYPT) */
39 39
40#ifdef HAVE_CYGWIN
41#undef ERROR
42#include <windows.h>
43#include <sys/cygwin.h>
44#define is_winnt (GetVersion() < 0x80000000)
45#endif
46
40/* 47/*
41 * Tries to authenticate the user using password. Returns true if 48 * Tries to authenticate the user using password. Returns true if
42 * authentication succeeds. 49 * authentication succeeds.
@@ -63,11 +70,31 @@ auth_password(struct passwd * pw, const char *password)
63 /* deny if no user. */ 70 /* deny if no user. */
64 if (pw == NULL) 71 if (pw == NULL)
65 return 0; 72 return 0;
73#ifndef HAVE_CYGWIN
66 if (pw->pw_uid == 0 && options.permit_root_login == 2) 74 if (pw->pw_uid == 0 && options.permit_root_login == 2)
67 return 0; 75 return 0;
76#endif
77#ifdef HAVE_CYGWIN
78 /*
79 * Empty password is only possible on NT if the user has _really_
80 * an empty password and authentication is done, though.
81 */
82 if (!is_winnt)
83#endif
68 if (*password == '\0' && options.permit_empty_passwd == 0) 84 if (*password == '\0' && options.permit_empty_passwd == 0)
69 return 0; 85 return 0;
70 86
87#ifdef HAVE_CYGWIN
88 if (is_winnt) {
89 HANDLE hToken = cygwin_logon_user(pw, password);
90
91 if (hToken == INVALID_HANDLE_VALUE)
92 return 0;
93 cygwin_set_impersonation_token(hToken);
94 return 1;
95 }
96#endif
97
71#ifdef SKEY 98#ifdef SKEY
72 if (options.skey_authentication == 1) { 99 if (options.skey_authentication == 1) {
73 int ret = auth_skey_password(pw, password); 100 int ret = auth_skey_password(pw, password);