]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/passwd.c
Framework for back-bdb
[openldap] / libraries / liblutil / passwd.c
index a1b3201dd8c06ace913f1acf8f62e8384e85efc2..427af165a02780c2529efda6dd0abc084ab22bb2 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 /*
@@ -48,6 +48,8 @@
 
 #include <lber.h>
 
+#include "ldap_pvt.h"
+
 #include "lutil_md5.h"
 #include "lutil_sha1.h"
 #include "lutil.h"
@@ -288,10 +290,8 @@ lutil_passwd(
                        ? memcmp( passwd->bv_val, cred->bv_val, passwd->bv_len )
                        : 1;
        }
-#else
-       return 1;
 #endif
-
+       return 1;
 }
 
 struct berval * lutil_passwd_generate( ber_len_t len )
@@ -353,8 +353,8 @@ static struct berval * pw_string(
                return NULL;
        }
 
-       memcpy( pw->bv_val, sc->name.bv_val, sc->name.bv_len );
-       memcpy( &pw->bv_val[sc->name.bv_len], passwd->bv_val, passwd->bv_len );
+       AC_MEMCPY( pw->bv_val, sc->name.bv_val, sc->name.bv_len );
+       AC_MEMCPY( &pw->bv_val[sc->name.bv_len], passwd->bv_val, passwd->bv_len );
 
        pw->bv_val[pw->bv_len] = '\0';
        return pw;
@@ -382,9 +382,9 @@ static struct berval * pw_string64(
                        return NULL;
                }
 
-               memcpy( string.bv_val, hash->bv_val,
+               AC_MEMCPY( string.bv_val, hash->bv_val,
                        hash->bv_len );
-               memcpy( &string.bv_val[hash->bv_len], salt->bv_val,
+               AC_MEMCPY( &string.bv_val[hash->bv_len], salt->bv_val,
                        salt->bv_len );
                string.bv_val[string.bv_len] = '\0';
 
@@ -402,7 +402,7 @@ static struct berval * pw_string64(
                return NULL;
        }
 
-       memcpy(b64->bv_val, sc->name.bv_val, sc->name.bv_len);
+       AC_MEMCPY(b64->bv_val, sc->name.bv_val, sc->name.bv_len);
 
        rc = lutil_b64_ntop(
                string.bv_val, string.bv_len,
@@ -728,9 +728,9 @@ static int chk_kerberos(
                }
 
                {
-                       char host[MAXHOSTNAMELEN];
+                       char *host = ldap_pvt_get_fqdn( NULL );
 
-                       if( gethostname( host, MAXHOSTNAMELEN ) != 0 ) {
+                       if( host == NULL ) {
                                krb5_free_principal( context, client );
                                krb5_free_context( context );
                                return 1;
@@ -738,6 +738,8 @@ static int chk_kerberos(
 
                        ret = krb5_sname_to_principal( context,
                                host, "ldap", KRB5_NT_SRV_HST, &server );
+
+                       ber_memfree( host );
                }
 
                if (ret) {
@@ -751,7 +753,7 @@ static int chk_kerberos(
 
                krb5_free_principal( context, client );
                krb5_free_principal( context, server );
-               krb5_free_creds_contents( context, &creds );
+               krb5_free_cred_contents( context, &creds );
                krb5_free_context( context );
 
                rtn = !!ret;
@@ -944,7 +946,7 @@ static struct berval *hash_sha1(
        const struct berval  *passwd )
 {
        lutil_SHA1_CTX  SHA1context;
-       unsigned char   SHA1digest[20];
+       unsigned char   SHA1digest[LUTIL_SHA1_BYTES];
        struct berval digest;
        digest.bv_val = SHA1digest;
        digest.bv_len = sizeof(SHA1digest);
@@ -962,7 +964,7 @@ static struct berval *hash_smd5(
        const struct berval  *passwd )
 {
        lutil_MD5_CTX   MD5context;
-       unsigned char   MD5digest[16];
+       unsigned char   MD5digest[LUTIL_MD5_BYTES];
        unsigned char   saltdata[4];
        struct berval digest;
        struct berval salt;
@@ -991,7 +993,7 @@ static struct berval *hash_md5(
        const struct berval  *passwd )
 {
        lutil_MD5_CTX   MD5context;
-       unsigned char   MD5digest[16];
+       unsigned char   MD5digest[LUTIL_MD5_BYTES];
 
        struct berval digest;