rcolebaugh / rpms / openssh

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