X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fslappasswd.c;h=1bfdb768f1dda2ecc3108d2447c4e136141ba677;hb=f3c2c7ba48e67468e4052cea4699ffabad59a741;hp=c90e811d04f881c6a7311f7ed8eb7406f64274b8;hpb=57ba4cac66401c191279435b84e115ca6a446a53;p=openldap diff --git a/servers/slapd/slappasswd.c b/servers/slapd/slappasswd.c index c90e811d04..1bfdb768f1 100644 --- a/servers/slapd/slappasswd.c +++ b/servers/slapd/slappasswd.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2004 The OpenLDAP Foundation. + * Copyright 1998-2006 The OpenLDAP Foundation. * Portions Copyright 1998-2003 Kurt D. Zeilenga. * All rights reserved. * @@ -33,6 +33,7 @@ #include #include +#include #include "ldap_defaults.h" @@ -57,7 +58,12 @@ usage(const char *s) int slappasswd( int argc, char *argv[] ) { +#ifdef LUTIL_SHA1_BYTES char *scheme = "{SSHA}"; +#else + char *scheme = "{SMD5}"; +#endif + char *newpw = NULL; char *pwfile = NULL; const char *text; @@ -65,7 +71,7 @@ slappasswd( int argc, char *argv[] ) int i; struct berval passwd; - struct berval *hash = NULL; + struct berval hash; while( (i = getopt( argc, argv, "c:d:h:s:T:vu" )) != EOF ) @@ -131,20 +137,20 @@ slappasswd( int argc, char *argv[] ) passwd.bv_len = strlen(passwd.bv_val); } - hash = lutil_passwd_hash( &passwd, scheme, &text ); - if( hash == NULL || hash->bv_val == NULL ) { + lutil_passwd_hash( &passwd, scheme, &hash, &text ); + if( hash.bv_val == NULL ) { fprintf( stderr, "Password generation failed for scheme %s: %s\n", scheme, text ? text : "" ); return EXIT_FAILURE; } - if( lutil_passwd( hash, &passwd, NULL, &text ) ) { + if( lutil_passwd( &hash, &passwd, NULL, &text ) ) { fprintf( stderr, "Password verification failed. %s\n", text ? text : "" ); return EXIT_FAILURE; } - printf( "%s\n" , hash->bv_val ); + printf( "%s\n" , hash.bv_val ); return EXIT_SUCCESS; }