fix check_ssh_key
This commit is contained in:
parent
cc1b765e58
commit
41ac95c878
@ -16,9 +16,11 @@ use ACU::Log;
|
||||
|
||||
sub check_key($)
|
||||
{
|
||||
my $filename = shift;
|
||||
# Call ssh-keygen
|
||||
if (`ssh-keygen -l -f ".shift." 2> /dev/null` =~ /^([0-9]+) [0-9a-f:]+ [a-zA-Z0-9\/_-]+ \(([A-Z]+)\)$/)
|
||||
if (`ssh-keygen -l -f $filename 2> /dev/null` =~ /^([0-9]+) [0-9a-f:]+ [a-zA-Z0-9\/_-]+ \(([A-Z]+)\)$/)
|
||||
{
|
||||
log INFO, "Receive valid key: type $2, size $1";
|
||||
if ($2 eq "RSA") {
|
||||
if ($1 >= 4096) {
|
||||
return API::Base::make_response("0", "Clef RSA valide.");
|
||||
@ -34,7 +36,7 @@ sub check_key($)
|
||||
return API::Base::make_response("3", "Veuillez utiliser ssh-keygen -t rsa ou ssh-keygen -t ecdsa");
|
||||
}
|
||||
else {
|
||||
do_warn("");
|
||||
do_warn("Unknown type: $2");
|
||||
return API::Base::make_response("3", "Veuillez utiliser ssh-keygen -t rsa ou ssh-keygen -t ecdsa");
|
||||
}
|
||||
}
|
||||
@ -52,13 +54,15 @@ sub process
|
||||
print $fh $args->{param}{key};
|
||||
close $fh;
|
||||
|
||||
check_key $filename;
|
||||
my $msg = check_key $filename;
|
||||
|
||||
unlink $filename;
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
if (@ARGV) {
|
||||
check_key
|
||||
check_key shift;
|
||||
}
|
||||
else {
|
||||
Process::register("check_ssh_key", \&process);
|
||||
|
Reference in New Issue
Block a user