mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 06:03:28 +00:00
Add stdout support for passwd sub-command based on system hash type
This commit is contained in:
15
bin/passwd
15
bin/passwd
@@ -18,7 +18,8 @@ sub main
|
||||
GetOptions('help|h' => \$opt{'help'},
|
||||
'config|c=s' => \$opt{'config'},
|
||||
'user|u=s' => \$opt{'user'},
|
||||
'password|p=s' => \$opt{'password'});
|
||||
'password|p=s' => \$opt{'password'},
|
||||
'stdout|o!' => \$opt{'stdout'});
|
||||
|
||||
# If username passed as regular param
|
||||
my $user = scalar(@ARGV) == 1 && $ARGV[0];
|
||||
@@ -71,8 +72,9 @@ sub change_password
|
||||
my $root = root($confdif, \&$conf_check);
|
||||
|
||||
# Use pre-defined encryption (forced by Webmin config)
|
||||
if ($gconfig->{'md5pass'} == 1 ||
|
||||
$gconfig->{'md5pass'} == 2)
|
||||
if (!$optref->{'stdout'} &&
|
||||
($gconfig->{'md5pass'} == 1 ||
|
||||
$gconfig->{'md5pass'} == 2))
|
||||
{
|
||||
do "$root/acl/md5-lib.pl";
|
||||
|
||||
@@ -160,6 +162,12 @@ sub change_password
|
||||
|
||||
# Update with new password and store timestamp
|
||||
$uinfos{$user}->[0] = &$encrypt_password($pass, \%gconfig, \%config);
|
||||
|
||||
# Print the hash and exit
|
||||
if ($optref->{'stdout'}) {
|
||||
say $uinfos{$user}->[0];
|
||||
exit 0;
|
||||
}
|
||||
$uinfos{$user}->[5] = time() if ($uinfos{$user}->[5]);
|
||||
map {$ulines{$_} = join(":", @{ $uinfos{$_} })} keys %uinfos;
|
||||
|
||||
@@ -232,6 +240,7 @@ sub root
|
||||
- webmin passwd --user root
|
||||
- webmin passwd --user root --password ycwyMQRVAZY
|
||||
- webmin passwd --config /usr/local/etc/webmin --user root --password ycwyMQRVAZY
|
||||
- webmin passwd --config /usr/local/etc/webmin --user root --password ycwyMQRVAZY --stdout
|
||||
|
||||
=item --config, -c
|
||||
|
||||
|
||||
Reference in New Issue
Block a user