[openssh-commits] [openssh] 07/13: assert that SCRATCH_DIR is a writable directory
git+noreply at mindrot.org
git+noreply at mindrot.org
Sat Aug 17 11:22:25 AEST 2024
This is an automated email from the git hooks/post-receive script.
dtucker pushed a commit to branch master
in repository openssh.
commit eb5aafa1ffaeee75799141ec5ded406a65ec7d18
Author: Philip Hands <phil at hands.com>
AuthorDate: Wed Jul 31 23:19:03 2024 +0200
assert that SCRATCH_DIR is a writable directory
SSH-Copy-ID-Upstream: ecb2b9d10883b9a16df56c83896c9bb47a80cde2
---
contrib/ssh-copy-id | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id
index ceadcca8..dfecc744 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" "$@"
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list