From 53a80c81b18a01dadaef967fd52e2fc2474714fa Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 18 Aug 2023 09:15:44 +0200 Subject: mod/ssh-keys-import: $SSHKeysImport: add check for key type --- mod/ssh-keys-import.rsc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'mod') diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc index 170139d..31bb3e6 100644 --- a/mod/ssh-keys-import.rsc +++ b/mod/ssh-keys-import.rsc @@ -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; } -- cgit v1.2.3-70-g09d2