diff options
author | Philip Hands <phil@hands.com> | 2024-07-31 23:19:03 +0200 |
---|---|---|
committer | Darren Tucker <dtucker@dtucker.net> | 2024-08-17 03:19:31 +0200 |
commit | eb5aafa1ffaeee75799141ec5ded406a65ec7d18 (patch) | |
tree | 6e9cf8191ba818cb0ab580038ca62395705606a7 /contrib/ssh-copy-id | |
parent | quote to avoid potential for word splitting (diff) | |
download | openssh-eb5aafa1ffaeee75799141ec5ded406a65ec7d18.tar.xz openssh-eb5aafa1ffaeee75799141ec5ded406a65ec7d18.zip |
assert that SCRATCH_DIR is a writable directory
SSH-Copy-ID-Upstream: ecb2b9d10883b9a16df56c83896c9bb47a80cde2
Diffstat (limited to 'contrib/ssh-copy-id')
-rw-r--r-- | contrib/ssh-copy-id | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id index ceadcca88..dfecc744d 100644 --- a/contrib/ssh-copy-id +++ b/contrib/ssh-copy-id @@ -182,10 +182,20 @@ if [ -z "$(eval $GET_ID)" ] ; then exit 1 fi +# assert_scratch_ok() +# ensures that $SCRATCH_DIR is setup. +assert_scratch_ok() { + [ "$SCRATCH_DIR" ] && [ -d "$SCRATCH_DIR" ] && [ -w "$SCRATCH_DIR" ] && return 0 + + printf 'ERROR: Assertion failure: in %s(): scratch_dir was not correctly set up (SCRATCH_DIR = "%s")\n' "$1" "$SCRATCH_DIR" >&2 + return 1 +} + # filter_ids() # tries to log in using the keys piped to it, and filters out any that work filter_ids() { L_SUCCESS="$1" + assert_scratch_ok filter_ids || return L_TMP_ID_FILE="$SCRATCH_DIR"/popids_tmp_id L_OUTPUT_FILE="$SCRATCH_DIR"/popids_output @@ -288,6 +298,7 @@ installkeys_via_sftp() { # repopulate "$@" inside this function eval set -- "$SSH_OPTS" + assert_scratch_ok installkeys_via_sftp || return 1 L_KEYS="$SCRATCH_DIR"/authorized_keys L_SHARED_CON="$SCRATCH_DIR"/master-conn $SSH -f -N -M -S "$L_SHARED_CON" "$@" |