Petr Šabata 81d24c
From 66f16e5425eb881570e82bfef7baeac2e7accc0a Mon Sep 17 00:00:00 2001
Petr Šabata 81d24c
From: Oleg <Fallmay@users.noreply.github.com>
Petr Šabata 81d24c
Date: Thu, 1 Oct 2020 12:09:08 +0300
Petr Šabata 81d24c
Subject: [PATCH] Fix `EOF: command not found` error in ssh-copy-id
Petr Šabata 81d24c
Petr Šabata 81d24c
---
Petr Šabata 81d24c
 contrib/ssh-copy-id | 3 ++-
Petr Šabata 81d24c
 1 file changed, 2 insertions(+), 1 deletion(-)
Petr Šabata 81d24c
Petr Šabata 81d24c
diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id
Petr Šabata 81d24c
index 392f64f94..a76907717 100644
Petr Šabata 81d24c
--- a/contrib/ssh-copy-id
Petr Šabata 81d24c
+++ b/contrib/ssh-copy-id
Petr Šabata 81d24c
@@ -247,7 +247,7 @@ installkeys_sh() {
Petr Šabata 81d24c
   #    the -z `tail ...` checks for a trailing newline. The echo adds one if was missing
Petr Šabata 81d24c
   #    the cat adds the keys we're getting via STDIN
Petr Šabata 81d24c
   #    and if available restorecon is used to restore the SELinux context
Petr Šabata 81d24c
-  INSTALLKEYS_SH=$(tr '\t\n' ' ' <<-EOF)
Petr Šabata 81d24c
+  INSTALLKEYS_SH=$(tr '\t\n' ' ' <<-EOF
Petr Šabata 81d24c
 	cd;
Petr Šabata 81d24c
 	umask 077;
Petr Šabata 81d24c
 	mkdir -p $(dirname "${AUTH_KEY_FILE}") &&
Petr Šabata 81d24c
@@ -258,6 +258,7 @@ installkeys_sh() {
Petr Šabata 81d24c
 	  restorecon -F .ssh ${AUTH_KEY_FILE};
Petr Šabata 81d24c
 	fi
Petr Šabata 81d24c
 EOF
Petr Šabata 81d24c
+  )
Petr Šabata 81d24c
 
Petr Šabata 81d24c
   # to defend against quirky remote shells: use 'exec sh -c' to get POSIX;
Petr Šabata 81d24c
   printf "exec sh -c '%s'" "${INSTALLKEYS_SH}"
Petr Šabata 81d24c
Petr Šabata 81d24c
From de59a431cdec833e3ec15691dd950402b4c052cf Mon Sep 17 00:00:00 2001
Petr Šabata 81d24c
From: Philip Hands <phil@hands.com>
Petr Šabata 81d24c
Date: Sat, 3 Oct 2020 00:20:07 +0200
Petr Šabata 81d24c
Subject: [PATCH] un-nest $() to make ksh cheerful
Petr Šabata 81d24c
Petr Šabata 81d24c
---
Petr Šabata 81d24c
 ssh-copy-id | 3 ++-
Petr Šabata 81d24c
 1 file changed, 2 insertions(+), 1 deletion(-)
Petr Šabata 81d24c
Petr Šabata 81d24c
From 02ac2c3c3db5478a440dfb1b90d15f686f2cbfc6 Mon Sep 17 00:00:00 2001
Petr Šabata 81d24c
From: Philip Hands <phil@hands.com>
Petr Šabata 81d24c
Date: Fri, 2 Oct 2020 21:30:10 +0200
Petr Šabata 81d24c
Subject: [PATCH] ksh doesn't grok 'local'
Petr Šabata 81d24c
Petr Šabata 81d24c
and AFAICT it's not actually doing anything useful in the code, so let's
Petr Šabata 81d24c
see how things go without it.
Petr Šabata 81d24c
---
Petr Šabata 81d24c
 ssh-copy-id | 11 +++++------
Petr Šabata 81d24c
 1 file changed, 5 insertions(+), 6 deletions(-)
Petr Šabata 81d24c
Petr Šabata 81d24c
diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id
Petr Šabata 81d24c
index a769077..11c9463 100755
Petr Šabata 81d24c
--- a/contrib/ssh-copy-id
Petr Šabata 81d24c
+++ b/contrib/ssh-copy-id
Petr Šabata 81d24c
@@ -76,7 +76,7 @@ quote() {
Petr Šabata 81d24c
 }
Petr Šabata 81d24c
 
Petr Šabata 81d24c
 use_id_file() {
Petr Šabata 81d24c
-  local L_ID_FILE="$1"
Petr Šabata 81d24c
+  L_ID_FILE="$1"
Petr Šabata 81d24c
 
Petr Šabata 81d24c
   if [ -z "$L_ID_FILE" ] ; then
Petr Šabata 81d24c
     printf '%s: ERROR: no ID file found\n' "$0"
Petr Šabata 81d24c
@@ -94,7 +94,7 @@ use_id_file() {
Petr Šabata 81d24c
   # check that the files are readable
Petr Šabata 81d24c
   for f in "$PUB_ID_FILE" ${PRIV_ID_FILE:+"$PRIV_ID_FILE"} ; do
Petr Šabata 81d24c
     ErrMSG=$( { : < "$f" ; } 2>&1 ) || {
Petr Šabata 81d24c
-      local L_PRIVMSG=""
Petr Šabata 81d24c
+      L_PRIVMSG=""
Petr Šabata 81d24c
       [ "$f" = "$PRIV_ID_FILE" ] && L_PRIVMSG="	(to install the contents of '$PUB_ID_FILE' anyway, look at the -f option)"
Petr Šabata 81d24c
       printf "\\n%s: ERROR: failed to open ID file '%s': %s\\n" "$0" "$f" "$(printf '%s\n%s\n' "$ErrMSG" "$L_PRIVMSG" | sed -e 's/.*: *//')"
Petr Šabata 81d24c
       exit 1
Petr Šabata 81d24c
@@ -169,7 +169,7 @@ fi
Petr Šabata 81d24c
 # populate_new_ids() uses several global variables ($USER_HOST, $SSH_OPTS ...)
Petr Šabata 81d24c
 # and has the side effect of setting $NEW_IDS
Petr Šabata 81d24c
 populate_new_ids() {
Petr Šabata 81d24c
-  local L_SUCCESS="$1"
Petr Šabata 81d24c
+  L_SUCCESS="$1"
Petr Šabata 81d24c
 
Petr Šabata 81d24c
   # shellcheck disable=SC2086
Petr Šabata 81d24c
   if [ "$FORCED" ] ; then
Petr Šabata 81d24c
@@ -181,13 +181,12 @@ populate_new_ids() {
Petr Šabata 81d24c
   eval set -- "$SSH_OPTS"
Petr Šabata 81d24c
 
Petr Šabata 81d24c
   umask 0177
Petr Šabata 81d24c
-  local L_TMP_ID_FILE
Petr Šabata 81d24c
   L_TMP_ID_FILE=$(mktemp ~/.ssh/ssh-copy-id_id.XXXXXXXXXX)
Petr Šabata 81d24c
   if test $? -ne 0 || test "x$L_TMP_ID_FILE" = "x" ; then
Petr Šabata 81d24c
     printf '%s: ERROR: mktemp failed\n' "$0" >&2
Petr Šabata 81d24c
     exit 1
Petr Šabata 81d24c
   fi
Petr Šabata 81d24c
-  local L_CLEANUP="rm -f \"$L_TMP_ID_FILE\" \"${L_TMP_ID_FILE}.stderr\""
Petr Šabata 81d24c
+  L_CLEANUP="rm -f \"$L_TMP_ID_FILE\" \"${L_TMP_ID_FILE}.stderr\""
Petr Šabata 81d24c
   # shellcheck disable=SC2064
Petr Šabata 81d24c
   trap "$L_CLEANUP" EXIT TERM INT QUIT
Petr Šabata 81d24c
   printf '%s: INFO: attempting to log in with the new key(s), to filter out any that are already installed\n' "$0" >&2
Petr Šabata 81d24c
@@ -237,7 +236,7 @@ populate_new_ids() {
Petr Šabata 81d24c
 #    produce a one-liner to add the keys to remote authorized_keys file
Petr Šabata 81d24c
 #    optionally takes an alternative path for authorized_keys
Petr Šabata 81d24c
 installkeys_sh() {
Petr Šabata 81d24c
-  local AUTH_KEY_FILE=${1:-.ssh/authorized_keys}
Petr Šabata 81d24c
+  AUTH_KEY_FILE=${1:-.ssh/authorized_keys}
Petr Šabata 81d24c
 
Petr Šabata 81d24c
   # In setting INSTALLKEYS_SH:
Petr Šabata 81d24c
   #    the tr puts it all on one line (to placate tcsh)
Petr Šabata 81d24c
-- 
Petr Šabata 81d24c
Petr Šabata 81d24c
diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id
Petr Šabata 81d24c
index 11c9463..ee3f637 100755
Petr Šabata 81d24c
--- a/contrib/ssh-copy-id
Petr Šabata 81d24c
+++ b/contrib/ssh-copy-id
Petr Šabata 81d24c
@@ -237,6 +237,7 @@ populate_new_ids() {
Petr Šabata 81d24c
 #    optionally takes an alternative path for authorized_keys
Petr Šabata 81d24c
 installkeys_sh() {
Petr Šabata 81d24c
   AUTH_KEY_FILE=${1:-.ssh/authorized_keys}
Petr Šabata 81d24c
+  AUTH_KEY_DIR=$(dirname "${AUTH_KEY_FILE}")
Petr Šabata 81d24c
 
Petr Šabata 81d24c
   # In setting INSTALLKEYS_SH:
Petr Šabata 81d24c
   #    the tr puts it all on one line (to placate tcsh)
Petr Šabata 81d24c
@@ -249,7 +250,7 @@ installkeys_sh() {
Petr Šabata 81d24c
   INSTALLKEYS_SH=$(tr '\t\n' ' ' <<-EOF
Petr Šabata 81d24c
 	cd;
Petr Šabata 81d24c
 	umask 077;
Petr Šabata 81d24c
-	mkdir -p $(dirname "${AUTH_KEY_FILE}") &&
Petr Šabata 81d24c
+	mkdir -p "${AUTH_KEY_DIR}" &&
Petr Šabata 81d24c
 	  { [ -z \`tail -1c ${AUTH_KEY_FILE} 2>/dev/null\` ] || echo >> ${AUTH_KEY_FILE} || exit 1; } &&
Petr Šabata 81d24c
 	  cat >> ${AUTH_KEY_FILE} ||
Petr Šabata 81d24c
 	  exit 1;
Petr Šabata 81d24c
--