aboutsummaryrefslogtreecommitdiffstats
path: root/mod/ssh-keys-import.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-11-06 10:03:19 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-11-08 09:15:45 +0100
commit9c945b1a3283bb352707c69630c579cf82484dcb (patch)
tree186712b3b2efe0af73a4db377e2d9d2cf4ab2472 /mod/ssh-keys-import.rsc
parent084c246ef0cab329fe981732089277fa8398800b (diff)
mod/ssh-keys-import: $SSHKeysImportFile: simplify looping linesrouteros-7.16-2
Diffstat (limited to 'mod/ssh-keys-import.rsc')
-rw-r--r--mod/ssh-keys-import.rsc9
1 files changed, 4 insertions, 5 deletions
diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc
index 8cafa95..00f443a 100644
--- a/mod/ssh-keys-import.rsc
+++ b/mod/ssh-keys-import.rsc
@@ -88,12 +88,11 @@
$LogPrint warning $0 ("File '" . $FileName . "' does not exist.");
:return false;
}
- :local Keys ([ /file/get $FileName contents ] . "\n");
+ :local Keys [ :tolf [ /file/get $FileName contents ] ];
- :do {
+ :foreach Line in=[ :deserialize $Keys delimiter="\n" from=dsv options=dsv.plain ] do={
+ :set Line ($Line->0);
:local Continue false;
- :local Line [ :pick $Keys 0 [ :find $Keys "\n" ] ];
- :set Keys [ :pick $Keys ([ :find $Keys "\n" ] + 1) [ :len $Keys ] ];
:local KeyVal [ :toarray [ $CharacterReplace $Line " " "," ] ];
:if ($KeyVal->0 = "ssh-ed25519" || $KeyVal->0 = "ssh-rsa") do={
:do {
@@ -110,5 +109,5 @@
:if ($Continue = false && [ :len ($KeyVal->0) ] > 0) do={
$LogPrint warning $0 ("SSH key of type '" . $KeyVal->0 . "' is not supported.");
}
- } while=([ :len $Keys ] > 0);
+ }
}