rcolebaugh / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
4369a3
diff -up openssh-7.9p1/contrib/ssh-copy-id.ssh-copy-id openssh-7.9p1/contrib/ssh-copy-id
4369a3
--- openssh-7.9p1/contrib/ssh-copy-id.ssh-copy-id	2018-10-17 02:01:20.000000000 +0200
4369a3
+++ openssh-7.9p1/contrib/ssh-copy-id	2019-01-23 20:49:30.513393667 +0100
4369a3
@@ -112,7 +112,8 @@ do
4369a3
         usage
4369a3
   }
4369a3
 
4369a3
-  OPT= OPTARG=
4369a3
+  OPT=
4369a3
+  OPTARG=
4369a3
   # implement something like getopt to avoid Solaris pain
4369a3
   case "$1" in
4369a3
     -i?*|-o?*|-p?*)
152122
@@ -185,8 +185,8 @@
152122
   usage
152122
 fi
152122
 
152122
-# drop trailing colon
152122
-USER_HOST=$(printf "%s\n" "$1" | sed 's/:$//')
152122
+# don't drop trailing colon because it can be a valid ipv6 address
152122
+USER_HOST=$(printf "%s\n" "$1")
152122
 # tack the hostname onto SSH_OPTS
152122
 SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }'$(quote "$USER_HOST")'"
152122
 # and populate "$@" for later use (only way to get proper quoting of options)
4369a3
@@ -261,7 +262,7 @@ populate_new_ids() {
4369a3
   fi
4369a3
   if [ -z "$NEW_IDS" ] ; then
4369a3
     printf '\n%s: WARNING: All keys were skipped because they already exist on the remote system.\n' "$0" >&2
4369a3
-    printf '\t\t(if you think this is a mistake, you may want to use -f option)\n\n' "$0" >&2
4369a3
+    printf '\t\t(if you think this is a mistake, you may want to use -f option)\n\n' >&2
4369a3
     exit 0
4369a3
   fi
4369a3
   printf '%s: INFO: %d key(s) remain to be installed -- if you are prompted now it is to install the new keys\n' "$0" "$(printf '%s\n' "$NEW_IDS" | wc -l)" >&2
4369a3
@@ -296,7 +297,7 @@ case "$REMOTE_VERSION" in
4369a3
     # in ssh below - to defend against quirky remote shells: use 'exec sh -c' to get POSIX;
4369a3
     #     'cd' to be at $HOME; add a newline if it's missing; and all on one line, because tcsh.
4369a3
     [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | \
4369a3
-      ssh "$@" "exec sh -c 'cd ; umask 077 ; mkdir -p .ssh && { [ -z "'`tail -1c .ssh/authorized_keys 2>/dev/null`'" ] || echo >> .ssh/authorized_keys ; } && cat >> .ssh/authorized_keys || exit 1 ; if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi'" \
4369a3
+      ssh "$@" "exec sh -c 'cd ; umask 077 ; mkdir -p .ssh && { [ -z "'`tail -1c .ssh/authorized_keys 2>/dev/null`'" ] || echo >> .ssh/authorized_keys || exit 1; } && cat >> .ssh/authorized_keys || exit 1 ; if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi'" \
4369a3
       || exit 1
4369a3
     ADDED=$(printf '%s\n' "$NEW_IDS" | wc -l)
4369a3
     ;;