mirror of
https://github.com/ovh/the-bastion.git
synced 2025-09-11 15:34:18 +08:00
update of --force-password: code style cleanup
This commit is contained in:
parent
e9841b89bc
commit
98c1c79382
1 changed files with 17 additions and 5 deletions
|
@ -1158,19 +1158,31 @@ if ($userPasswordClue) {
|
||||||
# FIXME: force-password and force-key don't work yet for guest accesses, see #256
|
# FIXME: force-password and force-key don't work yet for guest accesses, see #256
|
||||||
# fetch the hashes of the main password and all its fallbacks
|
# fetch the hashes of the main password and all its fallbacks
|
||||||
my $fnrethashes;
|
my $fnrethashes;
|
||||||
if ($userPasswordContext eq 'self') { $fnrethashes = OVH::Bastion::get_hashes_list(context => 'account', account => $userPasswordClue); }
|
if ($userPasswordContext eq 'self') {
|
||||||
else { $fnrethashes = OVH::Bastion::get_hashes_list(context => 'group', group => $userPasswordClue); }
|
$fnrethashes = OVH::Bastion::get_hashes_list(context => 'account', account => $userPasswordClue);
|
||||||
if (!$fnrethashes) { main_exit(OVH::Bastion::EXIT_GET_HASH_FAILED, "get_hashes_list", $fnrethashes->msg); }
|
}
|
||||||
|
else {
|
||||||
|
$fnrethashes = OVH::Bastion::get_hashes_list(context => 'group', group => $userPasswordClue);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$fnrethashes) {
|
||||||
|
main_exit(OVH::Bastion::EXIT_GET_HASH_FAILED, "get_hashes_list", $fnrethashes->msg);
|
||||||
|
}
|
||||||
|
|
||||||
# is our forced password's hash one of them ?
|
# is our forced password's hash one of them ?
|
||||||
for my $id (0 .. $#{$fnrethashes->value}) {
|
for my $id (0 .. $#{$fnrethashes->value}) {
|
||||||
foreach my $hash (values(%{$fnrethashes->value->[$id]->{'hashes'}})) {
|
foreach my $hash (values(%{$fnrethashes->value->[$id]->{'hashes'}})) {
|
||||||
if ($grant->{'forcePassword'} eq $hash) { $forcePasswordId = $id; print " forcing password with hash: " . $grant->{'forcePassword'} . "\n\n" unless $quiet }
|
if ($grant->{'forcePassword'} eq $hash) {
|
||||||
|
$forcePasswordId = $id;
|
||||||
|
print " forcing password with hash: " . $grant->{'forcePassword'} . "\n\n" unless $quiet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# if the password was not found, abort
|
# if the password was not found, abort
|
||||||
if ($forcePasswordId == -1) { main_exit(OVH::Bastion::EXIT_PASSFILE_NOT_FOUND, "forced-password-not-found", "The forced password could not be found"); }
|
if ($forcePasswordId == -1) {
|
||||||
|
main_exit(OVH::Bastion::EXIT_PASSFILE_NOT_FOUND, "forced-password-not-found", "The forced password could not be found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue