From f82558216b5676e2fcc8725b348e1c094b10f151 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Fri, 9 Mar 2012 20:58:42 +0100 Subject: [PATCH] Try a different CreateCryptSalt approach --- Util.pm | 21 ++++++++++----------- update.cgi | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Util.pm b/Util.pm index 2b230ab..27060d7 100644 --- a/Util.pm +++ b/Util.pm @@ -33,27 +33,26 @@ sub CreateKey { } sub CreateCryptSalt { + # CreateCryptSalt(type = 0, skip_header = 0) # this can create either a DES type salt or a MD5 salt - # 0 for DES, 1 for MD5 salt and 2 for apache MD5 salt - my $type = shift; + # 0 for DES, 1 for MD5 salt + # if skip_header is 0, does not add $1$ for md5 salts. + my $md5 = shift; # do we want a MD5 salt? + my $no_crypttype_header = shift; my $validstr = './0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; my @valid = split(//,$validstr); my ($in, $out); - - my $cryptsaltlen = 2; - if (($type == 1)||($type == 2)) { - $cryptsaltlen = 8; - } - + + my $cryptsaltlen = ($md5 ? 8 : 2); + open (F, "param('doupdate'))) { } # create a md5 crypted password - $newwebpassword = apache_md5_crypt($query->param('newwebpass'), &Util::CreateCryptSalt(2)); + $newwebpassword = apache_md5_crypt($query->param('newwebpass'), &Util::CreateCryptSalt(1, 1)); &Util::LDAPUpdate($ldap, $editdn, 'webPassword', $newwebpassword); } -- 2.20.1