fixed password changing in tree view

This commit is contained in:
Roland Gruber 2005-07-17 09:27:43 +00:00
parent a4fe603233
commit 78dda09764
3 changed files with 12 additions and 37 deletions

View File

@ -1107,32 +1107,9 @@ function get_enc_type( $user_password )
/* Capture the stuff in the { } to determine if this is crypt, md5, etc. */ /* Capture the stuff in the { } to determine if this is crypt, md5, etc. */
$enc_type = null; $enc_type = null;
if( preg_match( "/{([^}]+)}/", $user_password, $enc_type) ) if( preg_match( "/{([^}]+)}/", $user_password, $enc_type) )
$enc_type = strtolower( $enc_type[1] ); return $enc_type[1];
else else
return null; return null;
/* handle crypt types */
if( 0 == strcasecmp( $enc_type, 'crypt') ) {
$salt = null;
if( preg_match( "/{[^}]+}\\$(.)\\$/", $user_password, $salt) )
$salt = $salt[1];
else
$salt = null;
switch( $salt ) {
case '': // CRYPT_STD_DES
$enc_type = "crypt";
break;
case '1': // CRYPT_MD5
$enc_type = "md5crypt";
break;
case '2': // CRYPT_BLOWFISH
$enc_type = "blowfish";
break;
default:
$enc_type = "crypt";
}
}
return $enc_type;
} }
/** /**

View File

@ -341,7 +341,7 @@ foreach( $attrs as $attr => $vals ) {
<input size="38" <input size="38"
type="hidden" type="hidden"
name="old_enc_type" name="old_enc_type"
value="<?php echo ($enc_type==''?'clear':$enc_type); ?>" /> value="<?php echo ($enc_type==''?'PLAIN':$enc_type); ?>" />
<br /> <br />
<input style="width: 260px" <input style="width: 260px"
@ -350,14 +350,12 @@ foreach( $attrs as $attr => $vals ) {
value="<?php echo htmlspecialchars( $user_password ); ?>" /> value="<?php echo htmlspecialchars( $user_password ); ?>" />
<select name="enc_type"> <select name="enc_type">
<option>clear</option> <option>PLAIN</option>
<option<?php echo $enc_type=='crypt'?' selected="true"':''; ?>>crypt</option> <option<?php echo $enc_type=='CRYPT'?' selected="true"':''; ?>>CRYPT</option>
<option<?php echo $enc_type=='md5'?' selected="true"':''; ?>>md5</option> <option<?php echo $enc_type=='MD5'?' selected="true"':''; ?>>MD5</option>
<option<?php echo $enc_type=='smd5'?' selected="true"':''; ?>>smd5</option> <option<?php echo $enc_type=='SMD5'?' selected="true"':''; ?>>SMD5</option>
<option<?php echo $enc_type=='md5crypt'?' selected="true"':''; ?>>md5crypt</option> <option<?php echo $enc_type=='SHA'?' selected="true"':''; ?>>SHA</option>
<option<?php echo $enc_type=='blowfish'?' selected="true"':''; ?>>blowfish</option> <option<?php echo $enc_type=='SSHA'?' selected="true"':''; ?>>SSHA</option>
<option<?php echo $enc_type=='sha'?' selected="true"':''; ?>>sha</option>
<option<?php echo $enc_type=='ssha'?' selected="true"':''; ?>>ssha</option>
</select> </select>
<br /> <br />

View File

@ -88,7 +88,7 @@ foreach( $old_values as $attr => $old_val )
// special case for userPassword attributes // special case for userPassword attributes
if( 0 == strcasecmp( $attr, 'userPassword' ) && $new_val != '' ) { if( 0 == strcasecmp( $attr, 'userPassword' ) && $new_val != '' ) {
$new_val = password_hash( $new_val, $_POST['enc_type'] ); $new_val = pwd_hash($new_val, true, $_POST['enc_type'] );
$password_already_hashed = true; $password_already_hashed = true;
} }
// special case for samba password // special case for samba password
@ -111,7 +111,7 @@ if( isset( $_POST['enc_type'] ) &&
$_POST['enc_type'] != 'clear' && $_POST['enc_type'] != 'clear' &&
$_POST['new_values']['userpassword'] != '' ) { $_POST['new_values']['userpassword'] != '' ) {
$new_password = password_hash( $_POST['new_values']['userpassword'], $_POST['enc_type'] ); $new_password = pwd_hash( $_POST['new_values']['userpassword'], true, $_POST['enc_type'] );
$update_array[ 'userpassword' ] = $new_password; $update_array[ 'userpassword' ] = $new_password;
} }
@ -160,7 +160,7 @@ foreach( $update_array as $attr => $val ) {
foreach( $old_values[ $attr ] as $v ) foreach( $old_values[ $attr ] as $v )
echo nl2br( htmlspecialchars( $v ) ) . "<br />"; echo nl2br( htmlspecialchars( $v ) ) . "<br />";
else else
if( 0 == strcasecmp( $attr, 'userPassword' ) && ( obfuscate_password_display() || is_null( get_enc_type( $old_values[ $attr ] ) ) ) ) { if( 0 == strcasecmp( $attr, 'userPassword' ) && ( is_null( get_enc_type( $old_values[ $attr ] ) ) ) ) {
echo preg_replace( '/./', '*', $old_values[ $attr ] ) . "<br />"; echo preg_replace( '/./', '*', $old_values[ $attr ] ) . "<br />";
} }
else { else {
@ -190,7 +190,7 @@ foreach( $update_array as $attr => $val ) {
} }
else else
if( $new_val != '' ) if( $new_val != '' )
if( 0 == strcasecmp( $attr, 'userPassword' ) && ( obfuscate_password_display() || is_null( get_enc_type( $new_values[ $attr ] ) ) ) ) { if( 0 == strcasecmp( $attr, 'userPassword' ) && ( is_null( get_enc_type( $new_values[ $attr ] ) ) ) ) {
echo preg_replace( '/./', '*', $new_val ) . "<br />"; echo preg_replace( '/./', '*', $new_val ) . "<br />";
} }
else { else {