fixed problem with disabled Unix passwords

This commit is contained in:
Roland Gruber 2004-02-21 13:26:52 +00:00
parent d201671bd9
commit c1fbe22ee9
2 changed files with 18 additions and 24 deletions

View File

@ -1573,20 +1573,14 @@ function modifyuser($values,$values_old,$uselamdaemon=true) { // Will modify the
// Check if shadow expire has changed
if ($values->unix_pwdexpire != $values_old->unix_pwdexpire) $attr['shadowExpire'] = intval($values->unix_pwdexpire / 86400) ;
// Set unix password
if ($values->unix_password=='') {
// $values->unix_password=='' means use old password
if ($values->unix_deactivated != $values_old->unix_deactivated) {
// (de)activate password
// Split old password hash in {CRYPT} and password-hash
$i = 0;
while ($values_old->unix_password{$i} != '}') $i++;
$passwd = substr($values_old->unix_password, $i+1 );
$crypt = substr($values_old->unix_password, 0, $i+1 );
// remove trailing ! from password hash
if ($passwd{0} == '!') $passwd = substr($passwd, 1);
// Write new password
if ($values->unix_deactivated) $attr['userPassword'] = $crypt.'!'.$passwd;
else $attr['userPassword'] = $crypt.$passwd;
if ($values->unix_password=='') { // $values->unix_password=='' means use old password
if ($values->unix_deactivated != $values_old->unix_deactivated) { // check if password was enabled/disabled
if ($values->unix_deactivated) {
$attr['userPassword'] = pwd_disable($values_old->unix_password);
}
else {
$attr['userPassword'] = pwd_enable($values_old->unix_password);
}
}
if ($values->unix_password_no) {
// use no password

View File

@ -133,6 +133,10 @@ class posixAccount {
return _('posixAccount');
}
function is_base_module() {
return true;
}
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {
@ -256,16 +260,12 @@ class posixAccount {
else { // No new password but old password
// (un)lock password
if ($this->userPassword_lock == pwd_is_enabled($this->orig['userPassword'][0])) {
// Split old password hash in {CRYPT} and password-hash
$i = 0;
while ($this->orig['userPassword'][0]{$i} != '}') $i++;
$passwd = substr($this->orig['userPassword'][0], $i+1 );
$crypt = substr($this->orig['userPassword'][0], 0, $i+1 );
// remove trailing ! from password hash
if ($passwd{0} == '!') $passwd = substr($passwd, 1);
// Write new password
if ($this->userPassword_lock) $return[$_SESSION[$this->base]->dn]['modify']['userPassword'][0] = utf8_encode("$crypt!$passwd");
else $return[$_SESSION[$this->base]->dn]['modify']['userPassword'][0] = utf8_encode("$crypt$passwd");
if ($this->userPassword_lock) {
$return[$_SESSION[$this->base]->dn]['modify']['userPassword'][0] = utf8_encode(pwd_disable($this->orig['userPassword'][0]));
}
else {
$return[$_SESSION[$this->base]->dn]['modify']['userPassword'][0] = utf8_encode(pwd_enable($this->orig['userPassword'][0]));
}
}
}
}