[openssh-commits] [openssh] 02/05: tidy up test of $SCRATCH_DIR creation

git+noreply at mindrot.org git+noreply at mindrot.org
Tue Oct 13 12:45:48 AEDT 2020


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

commit 108676c3f26be6c873db0dd8754063699908727b
Author: Philip Hands <phil at hands.com>
Date:   Sat Oct 3 21:10:03 2020 +0200

    tidy up test of $SCRATCH_DIR creation
    
    SSH-Copy-ID-Upstream: 2d8b22d96c105d87743ffe8874887b06f8989b93
---
 contrib/ssh-copy-id | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id
index 6b8aca7d..d7c3a61f 100644
--- a/contrib/ssh-copy-id
+++ b/contrib/ssh-copy-id
@@ -290,17 +290,15 @@ installkeys_via_sftp() {
 
 
 # create a scratch dir for any temporary files needed
-SCRATCH_DIR=$(mktemp -d ~/.ssh/ssh-copy-id.XXXXXXXXXX)
-if test $? -ne 0 || test "x$SCRATCH_DIR" = "x" ; then
-  printf '%s: ERROR: mktemp failed\n' "$0" >&2
-  exit 1
-fi
-chmod 0700 $SCRATCH_DIR
-if [ -d "$SCRATCH_DIR" ] ; then
+if SCRATCH_DIR=$(mktemp -d ~/.ssh/ssh-copy-id.XXXXXXXXXX) &&
+    [ "$SCRATCH_DIR" ] && [ -d "$SCRATCH_DIR" ]
+then
+  chmod 0700 "$SCRATCH_DIR"
   SCRATCH_CLEANUP="rm -rf \"$SCRATCH_DIR\""
+  #shellcheck disable=SC2064
   trap "$SCRATCH_CLEANUP" EXIT TERM INT QUIT
 else
-  printf '%s: ERROR: Required scratch directory (%s) was not created\n' "$0" "$SCRATCH_DIR" >&2
+  printf '%s: ERROR: failed to create required temporary directory under ~/.ssh\n' "$0" >&2
   exit 1
 fi
 

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list