Properly return password change error

This commit is contained in:
Jamie Cameron
2009-07-08 20:48:25 +00:00
parent 8a88a53aeb
commit e2a441d3ee
2 changed files with 7 additions and 6 deletions

View File

@ -651,7 +651,7 @@ else {
return join(":", @u)."\n"; return join(":", @u)."\n";
} }
# set_password(user, password) # set_password(user, password, [&output])
# Changes the password of a user in the encrypted password file # Changes the password of a user in the encrypted password file
sub set_password sub set_password
{ {
@ -659,10 +659,11 @@ local $qu = quotemeta($_[0]);
local $qp = quotemeta($_[1]); local $qp = quotemeta($_[1]);
if ($samba_version >= 2) { if ($samba_version >= 2) {
local $passin = "$_[1]\n$_[1]\n"; local $passin = "$_[1]\n$_[1]\n";
local $ex = &execute_command("$config{'samba_password_program'} -c $config{'smb_conf'} -s $qu", \$passin, undef, undef); local $ex = &execute_command("$config{'samba_password_program'} -c $config{'smb_conf'} -s $qu", \$passin, $_[1], $_[1]);
if ($ex) { if ($ex) {
# Try without -c # Try without -c
$rv = &execute_command("$config{'samba_password_program'} -s $qu", \$passin, undef, undef); ${$_[1]} = '' if ($_[1]);
$rv = &execute_command("$config{'samba_password_program'} -s $qu", \$passin, $_[1], $_[1]);
} }
unlink($temp); unlink($temp);
return !$rv; return !$rv;
@ -670,7 +671,7 @@ if ($samba_version >= 2) {
else { else {
local $out; local $out;
&execute_command("$config{'samba_password_program'} $qu $qp", &execute_command("$config{'samba_password_program'} $qu $qp",
undef, \$out, \$out); undef, $_[1], $_[1]);
return $out =~ /changed/i; return $out =~ /changed/i;
} }
} }

View File

@ -49,8 +49,8 @@ elsif ($in{ptype} == 3) {
# Call password change program if necessary # Call password change program if necessary
if ($set_passwd) { if ($set_passwd) {
&set_password($u->{'name'}, $in{'pass'}) || &set_password($u->{'name'}, $in{'pass'}, \$err) ||
&error(&text('saveuser_pass', $error)); &error(&text('saveuser_pass', $err));
} }
&unlock_file($config{'smb_passwd'}); &unlock_file($config{'smb_passwd'});
&webmin_log("save", "euser", $u->{'name'}, $u); &webmin_log("save", "euser", $u->{'name'}, $u);