diff options
author | Christian Hesse <mail@eworm.de> | 2024-11-08 08:30:07 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2024-11-08 09:16:18 +0100 |
commit | 0837391c38987462c3a1787143d631b92e0a0551 (patch) | |
tree | 99569df2f969ed651ae5ff95118811a14a0db4e2 | |
parent | 9c945b1a3283bb352707c69630c579cf82484dcb (diff) |
mod/ssh-keys-import: $SSHKeysImportFile: let `:deserialize` split the fields
-rw-r--r-- | mod/ssh-keys-import.rsc | 9 |
1 files 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={ |