tidy up test of $SCRATCH_DIR creation
SSH-Copy-ID-Upstream: 2d8b22d96c105d87743ffe8874887b06f8989b93
This commit is contained in:
parent
a9c9e91a82
commit
108676c3f2
|
@ -290,17 +290,15 @@ installkeys_via_sftp() {
|
||||||
|
|
||||||
|
|
||||||
# create a scratch dir for any temporary files needed
|
# create a scratch dir for any temporary files needed
|
||||||
SCRATCH_DIR=$(mktemp -d ~/.ssh/ssh-copy-id.XXXXXXXXXX)
|
if SCRATCH_DIR=$(mktemp -d ~/.ssh/ssh-copy-id.XXXXXXXXXX) &&
|
||||||
if test $? -ne 0 || test "x$SCRATCH_DIR" = "x" ; then
|
[ "$SCRATCH_DIR" ] && [ -d "$SCRATCH_DIR" ]
|
||||||
printf '%s: ERROR: mktemp failed\n' "$0" >&2
|
then
|
||||||
exit 1
|
chmod 0700 "$SCRATCH_DIR"
|
||||||
fi
|
|
||||||
chmod 0700 $SCRATCH_DIR
|
|
||||||
if [ -d "$SCRATCH_DIR" ] ; then
|
|
||||||
SCRATCH_CLEANUP="rm -rf \"$SCRATCH_DIR\""
|
SCRATCH_CLEANUP="rm -rf \"$SCRATCH_DIR\""
|
||||||
|
#shellcheck disable=SC2064
|
||||||
trap "$SCRATCH_CLEANUP" EXIT TERM INT QUIT
|
trap "$SCRATCH_CLEANUP" EXIT TERM INT QUIT
|
||||||
else
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue