Ensure that old password is requested before new one is sent

This commit is contained in:
Jamie Cameron
2026-09-20 09:20:31 -07:00
parent 5a03eafaa8
commit cc95d6285a
2 changed files with 4 additions and 0 deletions

View File

@@ -314,6 +314,7 @@ password_enew2=Your new passwords do not match
password_epam=PAM error : $1
password_emodpam=The Authen::PAM perl module needed to do password changes is not installed!
password_enewpass=New password is not allowed : $1
password_enotold=Password change commit did not prompt for old password!
ui_mandatory=This field is mandatory
ui_checkmandatory=Nothing was selected

View File

@@ -58,6 +58,7 @@ elsif ($gconfig{'passwd_cmd'}) {
$passwd_cmd .= " ".quotemeta($in{'user'});
($fh, $fpid) = &proc::pty_process_exec($passwd_cmd, 0, 0);
&reset_environment();
my $sent_old = 0;
while(1) {
local $rv = &wait_for($fh,
'(new|re-enter).*:',
@@ -70,11 +71,13 @@ elsif ($gconfig{'passwd_cmd'}) {
sleep(1);
if ($rv == 0) {
# Prompt for the new password
$sent_old || &error($text{'password_enotold'});
syswrite($fh, $in{'new1'}."\n", length($in{'new1'})+1);
}
elsif ($rv == 1) {
# Prompt for the old password
syswrite($fh, $in{'old'}."\n", length($in{'old'})+1);
$sent_old = 1;
}
elsif ($rv == 2) {
# Request for a menu option (SCO?)