mod/ssh-keys-import: $SSHKeysImport: add check for key type

This commit is contained in:
Christian Hesse 2023-08-18 09:15:44 +02:00
parent ad6825571d
commit 53a80c81b1

View file

@ -17,6 +17,7 @@
:global GetRandom20CharAlNum;
:global LogPrintExit2;
:global MkDir;
:global RequiredRouterOS;
:global WaitForFile;
:if ([ :len $Key ] = 0 || [ :len $User ] = 0) do={
@ -27,6 +28,11 @@
$LogPrintExit2 warning $0 ("User '" . $User . "' does not exist.") true;
}
:local Type [ :pick $Key 0 [ :find $Key " " ] ];
:if (!(([ $RequiredRouterOS $0 "7.12beta1" ] = true && $Type = "ssh-ed25519") || $Type = "ssh-rsa")) do={
$LogPrintExit2 warning $0 ("SSH key of type '" . $Type . "' is not supported.") true;
}
:if ([ $MkDir "tmpfs/ssh-keys-import" ] = false) do={
$LogPrintExit2 warning $0 ("Creating directory 'tmpfs/ssh-keys-import' failed!") true;
}