vishalmishra434 / rpms / openssh

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