aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-11-07 13:34:02 +0100
committerGravatar Christian Hesse <mail@eworm.de>2023-11-09 15:34:10 +0100
commitb22dfbfc948edced83f1eb24e20b4a21f35a85f0 (patch)
tree539426351fe2f6547a2bf87ca84893af56e2f8e1 /mod
parent042ff1cfda2f4832eff4fc7cf161f50aa44fa9bd (diff)
mod/ssh-keys-import: do not import twice
Diffstat (limited to 'mod')
-rw-r--r--mod/ssh-keys-import.rsc7
1 files changed, 7 insertions, 0 deletions
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;