/* $OpenLDAP$ */
/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/*
#include "portable.h"
+#ifdef SLAP_AUTHPASSWD
+
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/string.h>
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,
const struct berval *passwd,
const struct berval *cred );
-
+#ifdef LUTIL_SHA1_BYTES
/* password hash routines */
static int *hash_sha1(
const struct pw_scheme *scheme,
const struct berval *salt,
struct berval **passwd_out,
struct berval **salt_out );
+#endif
static int *hash_md5(
const struct pw_scheme *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
/* PASSWORD CHECK ROUTINES */
+#ifdef LUTIL_SHA1_BYTES
static int chk_sha1(
const struct pw_scheme *sc,
const struct berval * passwd,
ber_memfree(orig_salt);
return rc;
}
+#endif
static int chk_md5(
const struct pw_scheme *sc,
}
{
- 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;
ret = krb5_sname_to_principal( context,
host, "ldap", KRB5_NT_SRV_HST, &server );
+
+ ber_memfree( host );
}
if (ret) {
#ifdef SLAPD_GENERATE
+#ifdef LUTIL_SHA1_BYTES
static struct berval *hash_ssha1(
const struct pw_scheme *scheme,
const struct berval *passwd )
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);
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;
const struct berval *passwd )
{
lutil_MD5_CTX MD5context;
- unsigned char MD5digest[16];
+ unsigned char MD5digest[LUTIL_MD5_BYTES];
struct berval digest;
return pw_string( scheme, &hash );
}
#endif
-#endif
\ No newline at end of file
+#endif
+#endif /* SLAPD_AUTHPASSWD */