fix: skip wrappers dirs in SSH PATH scan; verify symlink with which

This commit is contained in:
2026-07-06 20:39:59 +02:00
parent c2bdf68429
commit e099dc4843
+20 -16
View File
@@ -381,27 +381,31 @@ def check_ssh_localhost():
r = subprocess.run(["ssh", "-o", "BatchMode=yes", "-o", "ConnectTimeout=5", r = subprocess.run(["ssh", "-o", "BatchMode=yes", "-o", "ConnectTimeout=5",
"localhost", "which", "fastsync-server"], "localhost", "which", "fastsync-server"],
capture_output=True, timeout=10) capture_output=True, timeout=10)
if r.returncode != 0: if r.returncode == 0:
SSH_AVAILABLE = True
return
SSH_AVAILABLE = False SSH_AVAILABLE = False
# Try common directories that are typically in PATH # Try each PATH dir: create symlink, then verify with which
for d in ["~/.local/bin", "~/bin", "~/.local/state/nix/profile/bin"]: r = subprocess.run(
install = subprocess.run(
["ssh", "-o", "BatchMode=yes", "localhost", ["ssh", "-o", "BatchMode=yes", "localhost",
f"mkdir -p {d} && ln -sf {server_path} {d}/fastsync-server && test -f {d}/fastsync-server"], 'echo "$PATH"'],
capture_output=True, timeout=10) capture_output=True, timeout=10, text=True)
if install.returncode == 0: if r.returncode != 0:
SSH_AVAILABLE = True return
break for d in r.stdout.strip().split(":"):
if not SSH_AVAILABLE: d = d.strip()
# Last resort: find a writable dir in PATH if not d:
r2 = subprocess.run( continue
if "wrappers" in d:
continue
test = subprocess.run(
["ssh", "-o", "BatchMode=yes", "localhost", ["ssh", "-o", "BatchMode=yes", "localhost",
'd=$(echo $PATH | tr ":" "\\n" | while read p; do [ -w "$p" ] && echo "$p" && break; done) && ' f'test -w "{d}" && ln -sf {server_path} "{d}/fastsync-server" && which fastsync-server'],
f'ln -sf {server_path} "$d"/fastsync-server && test -f "$d"/fastsync-server'],
capture_output=True, timeout=10) capture_output=True, timeout=10)
SSH_AVAILABLE = r2.returncode == 0 if test.returncode == 0:
else:
SSH_AVAILABLE = True SSH_AVAILABLE = True
return
def preflight_checks(): def preflight_checks():