-static const Hash hashes[] =
-{
-#ifdef SLAPD_CLEARTEXT
- {"none", 4, hash_none, 0, HASHTYPE_NONE, HASHTYPE_NONE, 0},
-#endif
-#ifdef SLAPD_CRYPT
- {"crypt", 5, hash_crypt, 1, HASHTYPE_CRYPT, HASHTYPE_CRYPT, 2},
-#endif
- {"md5", 3, hash_md5, 0, HASHTYPE_MD5, HASHTYPE_SMD5, 0},
- {"smd5", 4, hash_md5, 1, HASHTYPE_SMD5, HASHTYPE_SMD5, 4},
- {"sha", 3, hash_sha1, 0, HASHTYPE_SHA1, HASHTYPE_SSHA1, 0},
- {"ssha", 4, hash_sha1, 1, HASHTYPE_SSHA1, HASHTYPE_SSHA1, 4},
- {NULL, 0, NULL, 0, HASHTYPE_NONE, HASHTYPE_NONE, 0}
-};
-
-static int
-modify_dn (LDAP * ld, char *targetdn, char *pwattr, char *oldpw,
- char *newpw, HashTypes htype, Salt * salt)
-{
- int ret = 0;
- int salted = salt->salt ? 1 : 0;
- int want_salt = salt->len && !salted;
- char *buf = NULL;
- char *hashed_pw = NULL;
- char *strvals[2];
- LDAPMod mod, *mods[2];
-
- if (!ld || !targetdn || !newpw)
- return (1);
-
- /* auto-generate password */
- if (auto_gen_pw)
- newpw = gen_pass (auto_gen_pw);
-
- /* handle salt */
- if (want_salt)
- {
- make_salt (salt, salt->len);
- htype = hashes[htype].type_salted;
- }
- else if (hashes[htype].default_salt_len)
- {
- /* user chose a salted hash and needs a salt */
- if (!salted)
- {
- want_salt++;
- salt->len = hashes[htype].default_salt_len;
- make_salt (salt, salt->len);
- }