Commit Diff


commit - 3a9f646cf520cb09e23e74cf150460e7c159cd0c
commit + 9050e62864d044b4ed8dd17b06587d67cc6296f9
blob - 25818843508a92cf65312408fee40abe2028abc0
blob + aa7a9534a58d2c80e103a87a08936d9cfc8eca26
--- configure
+++ configure
@@ -57,6 +57,7 @@ The options are as follows:
 
 Variables available:
 
+    SSH_PROG               absolute path to the ssh(1) binary
     LDADD                  generic linker flags
     LDADD_LIBEVENT         linker flags for libevent
     LDADD_LIBEVENT2        linker flags for libevent2
@@ -147,6 +148,7 @@ INSTALL_LIB=
 INSTALL_MAN=
 INSTALL_DATA=
 PKG_CONFIG=
+SSH_PROG=
 
 # SunOS sets "cc", but this doesn't exist.
 # It does have gcc, so try that instead.
@@ -225,6 +227,8 @@ while [ $# -gt 0 ]; do
 		INCLUDEDIR="$val" ;;
 	PKG_CONFIG)
 		PKG_CONFIG="$val" ;;
+	SSH_PROG)
+		SSH_PROG="$val" ;;
 	*)
 		echo "$0: invalid key: $key" 1>&2
 		exit 1
@@ -243,6 +247,19 @@ test -z "${PKG_CONFIG}" && {
 	}
 }
 
+test -z "${SSH_PROG}" && {
+	command -v ssh 2>/dev/null 1>&2 && {
+		SSH_PROG="$(command -v ssh)"
+		echo "found ssh: $SSH_PROG" 1>&2
+		echo "found ssh: $SSH_PROG" 1>&3
+	} || {
+		echo "ssh not found: giving up" >&2
+		echo "ssh not found: giving up" >&3
+		exit 1
+	}
+}
+
+
 #----------------------------------------------------------------------
 # These are the values that will be pushed into config.h after we test
 # for whether they're supported or not.
@@ -570,6 +587,8 @@ extern long long strtonum(const char *, long long, lon
 # define __dead __attribute__((noreturn))
 #endif
 
+#define SSH_PROG "${SSH_PROG}"
+
 #endif /*!OCONFIGURE_CONFIG_H*/
 EOF
 
blob - 76d1c926a07fddfea1512f3aa474e861975525e1
blob + 5165c214553938162adbd3ec9fade118a9ecd5d8
--- lstun.c
+++ lstun.c
@@ -35,10 +35,6 @@
 
 #include "log.h"
 
-#ifndef SSH_PATH
-#define SSH_PATH "/usr/bin/ssh"
-#endif
-
 #define MAXSOCK 32
 #define BACKOFF 1
 #define RETRIES 16
@@ -121,7 +117,7 @@ spawn_ssh(void)
 		log_warnx("fork");
 		return -1;
 	case 0:
-		execl(SSH_PATH, "ssh", "-L", ssh_tflag, "-NTq", ssh_dest,
+		execl(SSH_PROG, "ssh", "-L", ssh_tflag, "-NTq", ssh_dest,
 		    NULL);
 		fatal("exec");
 	default:
@@ -523,8 +519,8 @@ main(int argc, char **argv)
 		event_add(&sockev[i], NULL);
 	}
 
-	if (unveil(SSH_PATH, "x") == -1)
-		fatal("unveil(%s)", SSH_PATH);
+	if (unveil(SSH_PROG, "x") == -1)
+		fatal("unveil(%s)", SSH_PROG);
 
 	/*
 	 * dns, inet: bind the socket and connect to the childs.