Add minor improvements

This commit is contained in:
Ilia Rostovtsev
2021-04-21 14:31:22 +03:00
parent 584d22020e
commit 1c03e37a80

View File

@@ -19,7 +19,6 @@ sub main
pod2usage(0) if ($opt{'help'} || !$opt{'user'});
$opt{'config'} ||= "/etc/webmin";
$opt{'password'} ||= "";
my $sigkill = sub {
system("stty echo");
@@ -39,8 +38,8 @@ sub change_password
{
my ($optref) = @_;
my ($minserv_uconf_file, %lusers, @users, %uinfos, %ulines);
my $user = "$optref->{'user'}";
my $pass = "$optref->{'password'}";
my $user = $optref->{'user'};
my $pass = $optref->{'password'};
my $confdif = $optref->{'config'};
my $conf = "$confdif/config";
my $mconf = "$confdif/miniserv.conf";
@@ -89,11 +88,12 @@ sub change_password
# Check for main user file
&$conf_check([$minserv_uconf_file]);
# Read and parse `miniserv.users` config file
read_file($minserv_uconf_file, \%lusers, undef, undef, ":");
@users = keys %lusers;
map {my @uinfo = split(':', "$lusers{$_}"); $uinfos{$_} = \@uinfo} @users;
# Chech if user exists
# Check if user exists
if (!defined($uinfos{$user})) {
my $user_str = scalar(@users) > 1 ? 'users' : 'user';
my $user_str2 = scalar(@users) > 1 ? 'are' : 'is';
@@ -123,8 +123,8 @@ sub change_password
}
chomp $pass;
if (!$pass) {
$suc_pre_msg = YELLOW . 'Warning:' . RESET;
$suc_msg = "has been removed";
$suc_pre_msg = BOLD BRIGHT_RED ON_WHITE . 'Warning:' . RESET;
$suc_msg = "has been removed, enabling anyone to login without authentication";
}
}