]> andersk Git - openssh.git/blobdiff - auth.c
- (stevesk) [auth1.c] fix password auth for protocol 1 when
[openssh.git] / auth.c
diff --git a/auth.c b/auth.c
index de004515fa99dd9e22a2e52640c3170bfefc5be3..a9f981d18e1bfd7a39b0a357a8e023acbdc1e9c6 100644 (file)
--- a/auth.c
+++ b/auth.c
@@ -23,7 +23,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: auth.c,v 1.36 2002/03/15 11:00:38 itojun Exp $");
+RCSID("$OpenBSD: auth.c,v 1.41 2002/03/19 15:31:47 markus Exp $");
 
 #ifdef HAVE_LOGIN_H
 #include <login.h>
@@ -48,6 +48,7 @@ RCSID("$OpenBSD: auth.c,v 1.36 2002/03/15 11:00:38 itojun Exp $");
 #include "bufaux.h"
 #include "uidswap.h"
 #include "tildexpand.h"
+#include "misc.h"
 
 /* import */
 extern ServerOptions options;
@@ -125,17 +126,17 @@ allowed_user(struct passwd * pw)
        /* Return false if user is listed in DenyUsers */
        if (options.num_deny_users > 0) {
                for (i = 0; i < options.num_deny_users; i++)
-                       if (match_user(pw->pw_name, hostname, ipaddr,
+                       if (match_user(pw->pw_name, hostname, ipaddr,
                            options.deny_users[i])) {
-                               log("User %.100s not allowed because listed in DenyUsers",
-                                   pw->pw_name);
+                               log("User %.100s not allowed because listed in DenyUsers",
+                                   pw->pw_name);
                                return 0;
                        }
        }
        /* Return false if AllowUsers isn't empty and user isn't listed there */
        if (options.num_allow_users > 0) {
                for (i = 0; i < options.num_allow_users; i++)
-                       if (match_user(pw->pw_name, hostname, ipaddr,
+                       if (match_user(pw->pw_name, hostname, ipaddr,
                            options.allow_users[i]))
                                break;
                /* i < options.num_allow_users iff we break for loop */
@@ -439,3 +440,37 @@ secure_filename(FILE *f, const char *file, struct passwd *pw,
        }
        return 0;
 }
+
+struct passwd *
+getpwnamallow(const char *user)
+{
+#ifdef HAVE_LOGIN_CAP
+       extern login_cap_t *lc;
+#ifdef BSD_AUTH
+       auth_session_t *as;
+#endif
+#endif
+       struct passwd *pw;
+
+       pw = getpwnam(user);
+       if (pw == NULL || !allowed_user(pw))
+               return (NULL);
+#ifdef HAVE_LOGIN_CAP
+       if ((lc = login_getclass(pw->pw_class)) == NULL) {
+               debug("unable to get login class: %s", user);
+               return (NULL);
+       }
+#ifdef BSD_AUTH
+       if ((as = auth_open()) == NULL || auth_setpwd(as, pw) != 0 ||
+           auth_approval(NULL, lc, pw->pw_name, "ssh") <= 0) {
+               debug("Approval failure for %s", user);
+               pw = NULL;
+       }
+       if (as != NULL)
+               auth_close(as);
+#endif
+#endif
+       if (pw != NULL)
+               return (pwcopy(pw));
+       return (NULL);
+}
This page took 0.049565 seconds and 4 git commands to generate.