]> andersk Git - openssh.git/blobdiff - auth-passwd.c
- djm@cvs.openbsd.org 2010/01/30 02:54:53
[openssh.git] / auth-passwd.c
index 2e5fbc73a8efb843e64f71b6fea86f26ba974bea..b1c6ce092894afa890b09a1566183bd743df54e5 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenBSD: auth-passwd.c,v 1.43 2007/09/21 08:15:29 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: auth-passwd.c,v 1.32 2005/01/21 08:32:02 otto Exp $");
+
+#include <sys/types.h>
+
+#include <pwd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
 
 #include "packet.h"
 #include "buffer.h"
 #include "log.h"
 #include "servconf.h"
+#include "key.h"
+#include "hostfile.h"
 #include "auth.h"
 #include "auth-options.h"
 
 extern Buffer loginmsg;
 extern ServerOptions options;
-int sys_auth_passwd(Authctxt *, const char *);
 
 #ifdef HAVE_LOGIN_CAP
 extern login_cap_t *lc;
@@ -73,7 +81,7 @@ int
 auth_password(Authctxt *authctxt, const char *password)
 {
        struct passwd * pw = authctxt->pw;
-       int ok = authctxt->valid;
+       int result, ok = authctxt->valid;
 #if defined(USE_SHADOW) && defined(HAS_SHADOW_EXPIRE)
        static int expire_checked = 0;
 #endif
@@ -94,7 +102,7 @@ auth_password(Authctxt *authctxt, const char *password)
        }
 #endif
 #ifdef HAVE_CYGWIN
-       if (is_winnt) {
+       {
                HANDLE hToken = cygwin_logon_user(pw, password);
 
                if (hToken == INVALID_HANDLE_VALUE)
@@ -110,14 +118,14 @@ auth_password(Authctxt *authctxt, const char *password)
 #if defined(USE_SHADOW) && defined(HAS_SHADOW_EXPIRE)
        if (!expire_checked) {
                expire_checked = 1;
-               if (auth_shadow_pwexpired(authctxt)) {
-                       disable_forwarding();
+               if (auth_shadow_pwexpired(authctxt))
                        authctxt->force_pwchange = 1;
-               }
        }
 #endif
-               
-       return (sys_auth_passwd(authctxt, password) && ok);
+       result = sys_auth_passwd(authctxt, password);
+       if (authctxt->force_pwchange)
+               disable_forwarding();
+       return (result && ok);
 }
 
 #ifdef BSD_AUTH
@@ -131,7 +139,7 @@ warn_expiry(Authctxt *authctxt, auth_session_t *as)
 
        pwtimeleft = auth_check_change(as);
        actimeleft = auth_check_expire(as);
-#if HAVE_LOGIN_CAP
+#ifdef HAVE_LOGIN_CAP
        if (authctxt->valid) {
                pwwarntime = login_getcaptime(lc, "password-warn", TWO_WEEKS,
                    TWO_WEEKS);
@@ -164,6 +172,8 @@ sys_auth_passwd(Authctxt *authctxt, const char *password)
 
        as = auth_usercheck(pw->pw_name, authctxt->style, "auth-ssh",
            (char *)password);
+       if (as == NULL)
+               return (0);
        if (auth_getstate(as) & AUTH_PWEXPIRED) {
                auth_close(as);
                disable_forwarding();
This page took 0.053772 seconds and 4 git commands to generate.