/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga.
* All rights reserved.
*
#include <ldap.h>
#include <lutil.h>
+#include <lutil_sha1.h>
#include "ldap_defaults.h"
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;
int i;
struct berval passwd;
- struct berval *hash = NULL;
+ struct berval hash;
while( (i = getopt( argc, argv,
"c:d:h:s:T:vu" )) != EOF )
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;
}