summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorPhilip Hands <phil@hands.com>2020-10-03 21:45:16 +0200
committerDarren Tucker <dtucker@dtucker.net>2020-10-13 03:45:05 +0200
commitf7c3a39b016dd77709ecbf18da8282f967b86cd7 (patch)
tree118f3ab9d4c2997aae3a83e6b87bd1aa6da03f58 /contrib
parenttidy up test of $SCRATCH_DIR creation (diff)
downloadopenssh-f7c3a39b016dd77709ecbf18da8282f967b86cd7.tar.xz
openssh-f7c3a39b016dd77709ecbf18da8282f967b86cd7.zip
shellcheck tidyage
SSH-Copy-ID-Upstream: 5b08f840e78ac544288b3983010a1b0585e966fd
Diffstat (limited to 'contrib')
-rw-r--r--contrib/ssh-copy-id10
1 files changed, 7 insertions, 3 deletions
diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id
index d7c3a61f6..6cea9935b 100644
--- a/contrib/ssh-copy-id
+++ b/contrib/ssh-copy-id
@@ -262,6 +262,7 @@ EOF
printf "exec sh -c '%s'" "${INSTALLKEYS_SH}"
}
+#shellcheck disable=SC2120 # the 'eval set' confuses this
installkeys_via_sftp() {
# repopulate "$@" inside this function
@@ -269,22 +270,24 @@ installkeys_via_sftp() {
L_KEYS=$SCRATCH_DIR/authorized_keys
L_SHARED_CON=$SCRATCH_DIR/master-conn
- $SSH -f -N -M -S $L_SHARED_CON "$@"
+ $SSH -f -N -M -S "$L_SHARED_CON" "$@"
L_CLEANUP="$SSH -S $L_SHARED_CON -O exit 'ignored' >/dev/null 2>&1 ; $SCRATCH_CLEANUP"
+ #shellcheck disable=SC2064
trap "$L_CLEANUP" EXIT TERM INT QUIT
sftp -b - -o "ControlPath=$L_SHARED_CON" "ignored" <<-EOF || return 1
-get .ssh/authorized_keys $L_KEYS
EOF
# add a newline or create file if it's missing, same like above
- [ -z "$(tail -1c $L_KEYS 2>/dev/null)" ] || echo >> $L_KEYS
+ [ -z "$(tail -1c "$L_KEYS" 2>/dev/null)" ] || echo >> "$L_KEYS"
# append the keys being piped in here
- cat >> $L_KEYS
+ cat >> "$L_KEYS"
sftp -b - -o "ControlPath=$L_SHARED_CON" "ignored" <<-EOF || return 1
-mkdir .ssh
chmod 700 .ssh
put $L_KEYS .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
EOF
+ #shellcheck disable=SC2064
eval "$L_CLEANUP" && trap "$SCRATCH_CLEANUP" EXIT TERM INT QUIT
}
@@ -339,6 +342,7 @@ case "$REMOTE_VERSION" in
if ! [ "$DRY_RUN" ] ; then
printf '%s\n' "$NEW_IDS" | \
if [ "$SFTP" ] ; then
+ #shellcheck disable=SC2119
installkeys_via_sftp
else
$SSH "$@" "$(installkeys_sh)"