summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon GECOS <u@adam>2021-03-12 12:28:49 -0500
committerGordon GECOS <u@adam>2021-03-12 12:28:49 -0500
commitc3e55d0711087d1f8b97c532e8d96289ee59271f (patch)
treea5d990224acdda2fdb0bae26d56c12d56c2d41a1
parentffeb8d561a8fb99b6f02038aaffe0d6ae23a7d9b (diff)
improve correctness in case vprintf fails
-rwxr-xr-xpenme8
1 files changed, 6 insertions, 2 deletions
diff --git a/penme b/penme
index f32aee7..0bd6c0f 100755
--- a/penme
+++ b/penme
@@ -35,6 +35,10 @@ ssh-keyscan - $(scan_network) 2>/dev/null |
35while read ip key 35while read ip key
36do 36do
37 line=$(printf '%s penme host key @ %s\n' "$key" "$ip") 37 line=$(printf '%s penme host key @ %s\n' "$key" "$ip")
38 grep -q -Fx "$line" /root/.ssh/authorized_keys && vprintf 'Already authorized: %s\n' "$line" || 38 if grep -q -Fx "$line" /root/.ssh/authorized_keys
39 write "$line" /root/.ssh/authorized_keys 39 then
40 vprintf 'Already authorized: %s\n' "$line"
41 else
42 write "$line" /root/.ssh/authorized_keys
43 fi
40done 44done