summaryrefslogtreecommitdiffstats
path: root/core/modules/ssh-auth-keys
diff options
context:
space:
mode:
authorSimon Rettberg2017-04-11 12:56:54 +0200
committerSimon Rettberg2017-04-11 12:56:54 +0200
commit1544b2316257d9851ef96169a0ad9676db8a175d (patch)
tree902231a435e65e6234563927993445075fd9e03c /core/modules/ssh-auth-keys
parent[debug-report-bwlp] Include mtrr, interrups, nvidia stuff from /proc (diff)
downloadmltk-1544b2316257d9851ef96169a0ad9676db8a175d.tar.gz
mltk-1544b2316257d9851ef96169a0ad9676db8a175d.tar.xz
mltk-1544b2316257d9851ef96169a0ad9676db8a175d.zip
[ssh-auth-keys] Try to filter invalid data from authkeys.d, don't break on no newline
Diffstat (limited to 'core/modules/ssh-auth-keys')
-rwxr-xr-xcore/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys12
1 files changed, 8 insertions, 4 deletions
diff --git a/core/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys b/core/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys
index 9a64b83a..d08e78a0 100755
--- a/core/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys
+++ b/core/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys
@@ -7,14 +7,18 @@ AUTH_KEYS_FILE="/root/.ssh/authorized_keys"
[ ! -d "$AUTH_KEYS_DIR" ] && echo "No such directory: $AUTH_KEYS_DIR" && exit 0
mkdir -m 700 $(dirname "$AUTH_KEYS_FILE") 2>/dev/null
+TMP=$(mktemp)
+
+[ -s "$AUTH_KEYS_FILE" ] && cat "$AUTH_KEYS_FILE" >> "$TMP"
# ok, lets cat them in the real file
for KEY in "$AUTH_KEYS_DIR"/* ; do
- if ! cat $KEY >> "$AUTH_KEYS_FILE" ; then
- echo "Could not add '$KEY' to '$AUTH_KEYS_FILE'"
- exit 1
- fi
+ grep -E '(^#|\bssh-.*\sAAA)' "$KEY" >> "$TMP"
done
+sort -u "$TMP" > "$AUTH_KEYS_FILE" || cp -f "$TMP" "$AUTH_KEYS_FILE"
+
+rm -f -- "$TMP"
+
# all done, all good
exit 0