From 0837391c38987462c3a1787143d631b92e0a0551 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 8 Nov 2024 08:30:07 +0100 Subject: mod/ssh-keys-import: $SSHKeysImportFile: let `:deserialize` split the fields --- mod/ssh-keys-import.rsc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc index 00f443a..f67c0fc 100644 --- a/mod/ssh-keys-import.rsc +++ b/mod/ssh-keys-import.rsc @@ -72,7 +72,6 @@ :local FileName [ :tostr $1 ]; :local User [ :tostr $2 ]; - :global CharacterReplace; :global EitherOr; :global LogPrint; :global ParseKeyValueStore; @@ -90,20 +89,18 @@ } :local Keys [ :tolf [ /file/get $FileName contents ] ]; - :foreach Line in=[ :deserialize $Keys delimiter="\n" from=dsv options=dsv.plain ] do={ - :set Line ($Line->0); + :foreach KeyVal in=[ :deserialize $Keys delimiter=" " from=dsv options=dsv.plain ] do={ :local Continue false; - :local KeyVal [ :toarray [ $CharacterReplace $Line " " "," ] ]; :if ($KeyVal->0 = "ssh-ed25519" || $KeyVal->0 = "ssh-rsa") do={ :do { - $SSHKeysImport $Line $User; + $SSHKeysImport ($KeyVal->0 . " " . $KeyVal->1 . " " . $KeyVal->2) $User; } on-error={ $LogPrint warning $0 ("Failed importing key for user '" . $User . "'."); } :set Continue true; } :if ($Continue = false && $KeyVal->0 = "#") do={ - :set User [ $EitherOr ([ $ParseKeyValueStore [ :pick $Line 2 [ :len $Line ] ] ]->"user") $User ]; + :set User [ $EitherOr ([ $ParseKeyValueStore ($KeyVal->1) ]->"user") $User ]; :set Continue true; } :if ($Continue = false && [ :len ($KeyVal->0) ] > 0) do={ -- cgit v1.2.3-70-g09d2