Add extra check to make sure the sudo-capable user is actually capable

This commit is contained in:
Jamie Cameron
2025-05-07 14:26:41 -07:00
parent ea151bebfd
commit d029b1c165
2 changed files with 7 additions and 0 deletions

View File

@@ -19,7 +19,11 @@ $in{'email_def'} || $in{'email'} =~ /^\S+\@\S+$/ ||
&error($text{'forgot_eemail'}); &error($text{'forgot_eemail'});
my $unixuser; my $unixuser;
if (defined($in{'unix_def'}) && !$in{'unix_def'}) { if (defined($in{'unix_def'}) && !$in{'unix_def'}) {
&foreign_require("useradmin");
getpwnam($in{'unix'}) || &error($text{'forgot_eunix'}); getpwnam($in{'unix'}) || &error($text{'forgot_eunix'});
my $sudo = &useradmin::can_user_sudo_root($in{'user'});
&error($text{'forgot_enosudo'}) if ($sudo < 0);
&error($text{'forgot_ecansudo'}) if (!$sudo);
$unixuser = $in{'unix'}; $unixuser = $in{'unix'};
} }

View File

@@ -531,5 +531,8 @@ forgot_adminmsg=You are receiving this email from the administrator of the Webmi
forgot_sending=Sending password reset email for $2 to $1 .. forgot_sending=Sending password reset email for $2 to $1 ..
forgot_sent=.. sent! forgot_sent=.. sent!
forgot_link=The link below can be used to reset the Webmin password for $1 for the next $2 minutes : forgot_link=The link below can be used to reset the Webmin password for $1 for the next $2 minutes :
forgot_enosudo=Sudo is not available on this system!
forgot_ecansudo=The user entered does not have sudo permissions
forgot_eunix=The sudo-capable user entered does not exist!
__norefs=1 __norefs=1