]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/passwd.c
Fix ldaps / TLS processing...
[openldap] / libraries / liblutil / passwd.c
index cd4e42666d6eb3c5e932c7035f8cf072d94ccbe4..a1b3201dd8c06ace913f1acf8f62e8384e85efc2 100644 (file)
@@ -42,6 +42,9 @@
 #ifdef HAVE_PWD_H
 #      include <pwd.h>
 #endif
+#ifdef HAVE_AIX_SECURITY
+#      include <userpw.h>
+#endif
 
 #include <lber.h>
 
@@ -110,8 +113,7 @@ static int chk_crypt(
        const struct berval *passwd,
        const struct berval *cred );
 
-#if defined( HAVE_GETSPNAM ) \
-  || ( defined( HAVE_GETPWNAM ) && defined( HAVE_PW_PASSWD ) )
+#if defined( HAVE_GETPWNAM ) && defined( HAVE_PW_PASSWD )
 static int chk_unix(
        const struct pw_scheme *scheme,
        const struct berval *passwd,
@@ -162,8 +164,7 @@ static const struct pw_scheme pw_schemes[] =
 
 #ifdef SLAPD_CRYPT
        { {sizeof("{CRYPT}")-1, "{CRYPT}"},     chk_crypt, hash_crypt },
-# if defined( HAVE_GETSPNAM ) \
-  || ( defined( HAVE_GETPWNAM ) && defined( HAVE_PW_PASSWD ) )
+# if defined( HAVE_GETPWNAM ) && defined( HAVE_PW_PASSWD )
        { {sizeof("{UNIX}")-1, "{UNIX}"},       chk_unix, NULL },
 # endif
 #endif
@@ -833,8 +834,7 @@ static int chk_crypt(
        return strcmp( passwd->bv_val, cr ) ? 1 : 0;
 }
 
-# if defined( HAVE_GETSPNAM ) \
-  || ( defined( HAVE_GETPWNAM ) && defined( HAVE_PW_PASSWD ) )
+# if defined( HAVE_GETPWNAM ) && defined( HAVE_PW_PASSWD )
 static int chk_unix(
        const struct pw_scheme *sc,
        const struct berval * passwd,
@@ -862,26 +862,31 @@ static int chk_unix(
                return -1;      /* passwd must behave like a string */
        }
 
-#  ifdef HAVE_GETSPNAM
        {
-               struct spwd *spwd = getspnam(passwd->bv_val);
+               struct passwd *pwd = getpwnam(passwd->bv_val);
 
-               if(spwd == NULL) {
+               if(pwd == NULL) {
                        return -1;      /* not found */
                }
 
-               pw = spwd->sp_pwdp;
+               pw = pwd->pw_passwd;
        }
-
-#  else
+#  ifdef HAVE_GETSPNAM
        {
-               struct passwd *pwd = getpwnam(passwd->bv_val);
+               struct spwd *spwd = getspnam(passwd->bv_val);
 
-               if(pwd == NULL) {
-                       return -1;      /* not found */
+               if(spwd != NULL) {
+                       pw = spwd->sp_pwdp;
                }
+       }
+#  endif
+#  ifdef HAVE_AIX_SECURITY
+       {
+               struct userpw *upw = getuserpw(passwd->bv_val);
 
-               pw = pwd->pw_passwd;
+               if (upw != NULL) {
+                       pw = upw->upw_passwd;
+               }
        }
 #  endif