Archived
1
0
Fork 0

New logging system

This commit is contained in:
Mercier Pierre-Olivier 2013-09-04 02:56:29 +02:00
parent 0c5e95b469
commit 495202128e
8 changed files with 260 additions and 165 deletions

View file

@ -12,17 +12,12 @@ BEGIN {
use ACU::Process;
use ACU::API::Base;
use ACU::Log;
sub process
sub check_key($)
{
my ($given_args, $args) = @_;
my ($fh, $filename) = tempfile();
# Write key to file
print $fh $args->{param}{key};
# Call ssh-keygen
if (`ssh-keygen -l -f $filename 2> /dev/null` =~ /^([0-9]+) [0-9a-f:]+ [a-zA-Z0-9\/_-]+ \(([A-Z]+)\)$/)
if (`ssh-keygen -l -f ".shift." 2> /dev/null` =~ /^([0-9]+) [0-9a-f:]+ [a-zA-Z0-9\/_-]+ \(([A-Z]+)\)$/)
{
if ($2 eq "RSA") {
if ($1 >= 4096) {
@ -38,13 +33,33 @@ sub process
elsif ($2 eq "DSA") {
return API::Base::make_response("3", "Veuillez utiliser ssh-keygen -t rsa ou ssh-keygen -t ecdsa");
}
else {
do_warn("");
return API::Base::make_response("3", "Veuillez utiliser ssh-keygen -t rsa ou ssh-keygen -t ecdsa");
}
}
else {
return API::Base::make_response("4", "Veuillez utiliser ssh-keygen -t rsa ou ssh-keygen -t ecdsa");
}
}
sub process
{
my ($given_args, $args) = @_;
my ($fh, $filename) = tempfile();
# Write key to file
print $fh $args->{param}{key};
close $fh;
check_key $filename;
unlink $filename;
}
Process::register("check_ssh_key", \&process);
if (@ARGV) {
check_key
}
else {
Process::register("check_ssh_key", \&process);
}