mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 08:40:24 +00:00
Add minor improvements
This commit is contained in:
12
bin/passwd
12
bin/passwd
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user