From 73bbae14c19657b6c231ca57a15c007dc5adfda1 Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Mon, 17 Aug 2026 12:13:51 -0400 Subject: [PATCH] Stop resolve_remote_scripts_dir silently returning the local path as the partner's SSH_TIMEOUT comes from the calling script, so a caller without it made timeout fail before ssh ran; with stderr discarded the fallback then named this host's SCRIPTS_DIR as the remote's. --- common.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/common.sh b/common.sh index f9ef3f0..6621b34 100755 --- a/common.sh +++ b/common.sh @@ -848,12 +848,28 @@ read_remote_conf_array() { resolve_remote_scripts_dir() { local ip="$1" ssh_key="${2:-$SSH_KEY}" strict_host_key="${3:-yes}" local probe_cmd result - local -a opts=(-o ConnectTimeout="$SSH_TIMEOUT" -o BatchMode=yes) + # SSH_TIMEOUT is set by the calling script, not by any conf, so a caller that forgets it + # hands `timeout` an empty interval — which fails instantly, before ssh is ever run. With + # stderr discarded the failure is invisible and the fallback below then returns THIS host's + # SCRIPTS_DIR as though it were the partner's. Every use of the result is a remote path, so + # the caller goes on to run commands against a directory that exists here and not there. + # That is how Step 1b ended up pointing at /boot on an appdata mirror. + local _to="${SSH_TIMEOUT:-15}" + local -a opts=(-o ConnectTimeout="$_to" -o BatchMode=yes) [[ "$strict_host_key" == "no" ]] && opts+=(-o StrictHostKeyChecking=no) probe_cmd=$(platform_scripts_dir_probe_cmd) - result=$(timeout "$SSH_TIMEOUT" ssh -i "$ssh_key" "${opts[@]}" root@"$ip" "$probe_cmd" \ + result=$(timeout "$_to" ssh -i "$ssh_key" "${opts[@]}" root@"$ip" "$probe_cmd" \ 2>/dev/null | tr -d '[:space:]') - echo "${result:-$SCRIPTS_DIR}" + + # A probe that answered is the only thing trusted. The fallback stays — callers need a path + # to name in an error message — but it is announced, because "we could not ask the partner + # where it keeps its scripts" and "the partner keeps them where we do" are different facts + # and were being reported identically. + if [[ -z "$result" ]]; then + warn "Could not read SCRIPTS_DIR from $ip — assuming $SCRIPTS_DIR, which is wrong if it runs from appdata" >&2 + result="$SCRIPTS_DIR" + fi + echo "$result" } # ==============================================================================================