]> andersk Git - openssh.git/blobdiff - openbsd-compat/port-uw.c
- djm@cvs.openbsd.org 2010/01/30 02:54:53
[openssh.git] / openbsd-compat / port-uw.c
index cbc3f686b8bd0818599154ae5b631286088b886d..be9905a6af9b1b3fb3be504565dbfaec650db2b3 100644 (file)
 
 #include "includes.h"
 
-#ifdef UNIXWARE_LONG_PASSWORDS
+#if defined(HAVE_LIBIAF)  &&  !defined(HAVE_SECUREWARE)
+#include <sys/types.h>
 #ifdef HAVE_CRYPT_H
-#include <crypt.h>
+# include <crypt.h>
 #endif
+#include <pwd.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "xmalloc.h"
 #include "packet.h"
 #include "buffer.h"
+#include "auth-options.h"
 #include "log.h"
 #include "servconf.h"
+#include "key.h"
+#include "hostfile.h"
 #include "auth.h"
-#include "auth-options.h"
+#include "ssh.h"
 
 int nischeck(char *);
 
@@ -42,8 +53,8 @@ int
 sys_auth_passwd(Authctxt *authctxt, const char *password)
 {
        struct passwd *pw = authctxt->pw;
-       char *encrypted_password;
        char *salt;
+       int result;
 
        /* Just use the supplied fake password if authctxt is invalid */
        char *pw_password = authctxt->valid ? shadow_pw(pw) : pw->pw_passwd;
@@ -52,13 +63,30 @@ sys_auth_passwd(Authctxt *authctxt, const char *password)
        if (strcmp(pw_password, "") == 0 && strcmp(password, "") == 0)
                return (1);
 
+       /* Encrypt the candidate password using the proper salt. */
        salt = (pw_password[0] && pw_password[1]) ? pw_password : "xx";
-       if (nischeck(pw->pw_name))
-               return(strcmp(crypt(password, salt), pw_password) == 0);
+
+       /*
+        * Authentication is accepted if the encrypted passwords
+        * are identical.
+        */
+#ifdef UNIXWARE_LONG_PASSWORDS
+       if (!nischeck(pw->pw_name)) {
+               result = ((strcmp(bigcrypt(password, salt), pw_password) == 0)
+               ||  (strcmp(osr5bigcrypt(password, salt), pw_password) == 0));
+       }
        else
-               return(strcmp(bigcrypt(password, salt), pw_password) == 0);
+#endif /* UNIXWARE_LONG_PASSWORDS */
+               result = (strcmp(xcrypt(password, salt), pw_password) == 0);
+
+#ifdef USE_LIBIAF
+       if (authctxt->valid)
+               free(pw_password);
+#endif
+       return(result);
 }
 
+#ifdef UNIXWARE_LONG_PASSWORDS
 int
 nischeck(char *namep)
 {
@@ -94,7 +122,12 @@ nischeck(char *namep)
 
 #endif /* UNIXWARE_LONG_PASSWORDS */
 
-#ifdef HAVE_LIBIAF
+/*
+       NOTE: ia_get_logpwd() allocates memory for arg 2
+       functions that call shadow_pw() will need to free
+ */
+
+#ifdef USE_LIBIAF
 char *
 get_iaf_password(struct passwd *pw)
 {
@@ -104,12 +137,13 @@ get_iaf_password(struct passwd *pw)
        if (!ia_openinfo(pw->pw_name,&uinfo)) {
                ia_get_logpwd(uinfo, &pw_password);
                if (pw_password == NULL)
-                       fatal("Unable to get the shadow passwd");
+                       fatal("ia_get_logpwd: Unable to get the shadow passwd");
                ia_closeinfo(uinfo);
                return pw_password;
        }
        else
-               fatal("Unable to open the shadow passwd file");
+               fatal("ia_openinfo: Unable to open the shadow passwd file");
 }
-#endif /* HAVE_LIBIAF */
+#endif /* USE_LIBIAF */
+#endif /* HAVE_LIBIAF and not HAVE_SECUREWARE */
 
This page took 0.036418 seconds and 4 git commands to generate.