]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/authpasswd.c
Fix up abandon merge. Hallvard will holler if I get this wrong. :-)
[openldap] / libraries / liblutil / authpasswd.c
index fafd56549ca15158d55ff5f535ef6a6cf9b81d4c..d6286c6ca11e45cf3eb8d5e39bdee476c1ff5a67 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 /*
@@ -15,6 +15,8 @@
 
 #include "portable.h"
 
+#ifdef SLAP_AUTHPASSWD
+
 #include <stdio.h>
 #include <ac/stdlib.h>
 #include <ac/string.h>
@@ -67,11 +69,13 @@ static int chk_md5(
        const struct berval *salt,
        const struct berval *cred );
 
+#ifdef LUTIL_SHA1_BYTES
 static int chk_sha1(
        const struct pw_scheme *scheme,
        const struct berval *passwd,
        const struct berval *salt,
        const struct berval *cred );
+#endif
 
 static int chk_crypt(
        const struct pw_scheme *scheme,
@@ -95,7 +99,7 @@ static int chk_ext_unix(
        const struct berval *passwd,
        const struct berval *cred );
 
-
+#ifdef LUTIL_SHA1_BYTES
 /* password hash routines */
 static int *hash_sha1(
        const struct pw_scheme *scheme,
@@ -103,6 +107,7 @@ static int *hash_sha1(
        const struct berval *salt,
        struct berval **passwd_out,
        struct berval **salt_out );
+#endif
 
 static int *hash_md5(
        const struct pw_scheme *scheme,
@@ -128,7 +133,9 @@ struct pw_scheme {
 
 static const struct pw_scheme pw_schemes[] =
 {
+#ifdef LUTIL_SHA1_BYTES
        { {sizeof("SHA1")-1, "SHA1"},   chk_sha1, 0 /* hash_sha1 */, 4 },
+#endif
        { {sizeof("MD5")-1, "MD5"},             chk_md5, 0 /* hash_md5 */, 4 },
 
 #ifdef SLAPD_CRYPT
@@ -364,6 +371,7 @@ static struct berval * base64(
 
 /* PASSWORD CHECK ROUTINES */
 
+#ifdef LUTIL_SHA1_BYTES
 static int chk_sha1(
        const struct pw_scheme *sc,
        const struct berval * passwd,
@@ -431,6 +439,7 @@ done:
        ber_memfree(orig_salt);
        return rc;
 }
+#endif
 
 static int chk_md5(
        const struct pw_scheme *sc,
@@ -609,9 +618,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;
@@ -619,6 +628,8 @@ static int chk_kerberos(
 
                        ret = krb5_sname_to_principal( context,
                                host, "ldap", KRB5_NT_SRV_HST, &server );
+
+                       ber_memfree( host );
                }
 
                if (ret) {
@@ -789,6 +800,7 @@ static int chk_unix(
 
 #ifdef SLAPD_GENERATE
 
+#ifdef LUTIL_SHA1_BYTES
 static struct berval *hash_ssha1(
        const struct pw_scheme *scheme,
        const struct berval *passwd )
@@ -823,7 +835,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);
@@ -835,13 +847,14 @@ static struct berval *hash_sha1(
             
        return pw_string64( scheme, &digest, NULL);
 }
+#endif
 
 static struct berval *hash_smd5(
        const struct pw_scheme *scheme,
        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;
@@ -870,7 +883,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;
 
@@ -926,4 +939,5 @@ static struct berval *hash_crypt(
        return pw_string( scheme, &hash );
 }
 #endif
-#endif
\ No newline at end of file
+#endif
+#endif /* SLAPD_AUTHPASSWD */