From b22dfbfc948edced83f1eb24e20b4a21f35a85f0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 7 Nov 2023 13:34:02 +0100 Subject: mod/ssh-keys-import: do not import twice --- mod/ssh-keys-import.rsc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'mod') diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc index 023407a..dd80fe9 100644 --- a/mod/ssh-keys-import.rsc +++ b/mod/ssh-keys-import.rsc @@ -40,6 +40,13 @@ } :local FingerPrintMD5 [ :convert from=base64 transform=md5 to=hex ($KeyVal->1) ]; + + :if ([ :len [ /user/ssh-keys/find where user=$User key-owner~("\\bmd5=" . $FingerPrintMD5 . "\\b") ] ] > 0) do={ + $LogPrintExit2 warning $0 ("The ssh public key (MD5:" . $FingerPrintMD5 . \ + ") is already available for user '" . $User . "'.") false; + :return false; + } + :local FileName ("tmpfs/ssh-keys-import/key-" . [ $GetRandom20CharAlNum 6 ] . ".pub"); /file/add name=$FileName contents=($Key . ", md5=" . $FingerPrintMD5); $WaitForFile $FileName; -- cgit v1.2.3-70-g09d2