openssh: Make ControlMaster feature work
authorFredrik Fornwall <fredrik@fornwall.net>
Fri, 18 Dec 2015 00:32:24 +0000 (19:32 -0500)
committerFredrik Fornwall <fredrik@fornwall.net>
Fri, 18 Dec 2015 00:34:19 +0000 (19:34 -0500)
The ControlMaster feature for multiplexing used hard links, which
does not work on Android starting in Android 6.0. Replace this
with a non-atomic check-then-rename for now. Fixes #91.

packages/openssh/build.sh
packages/openssh/mux.c.patch [new file with mode: 0644]

index ea9e7fc..a126c8b 100755 (executable)
@@ -1,7 +1,7 @@
 TERMUX_PKG_HOMEPAGE=http://www.openssh.com/
 TERMUX_PKG_DESCRIPTION="Secure shell for logging into a remote machine"
 TERMUX_PKG_VERSION=7.1
-TERMUX_PKG_BUILD_REVISION=1
+TERMUX_PKG_BUILD_REVISION=2
 TERMUX_PKG_SRCURL=http://ftp.eu.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${TERMUX_PKG_VERSION}p1.tar.gz
 TERMUX_PKG_DEPENDS="libandroid-support, ldns, openssl"
 # --disable-strip to prevent host "install" command to use "-s", which won't work for target binaries:
diff --git a/packages/openssh/mux.c.patch b/packages/openssh/mux.c.patch
new file mode 100644 (file)
index 0000000..20682c9
--- /dev/null
@@ -0,0 +1,34 @@
+diff -u -r ../openssh-7.1p1/mux.c ./mux.c
+--- ../openssh-7.1p1/mux.c     2015-08-21 00:49:03.000000000 -0400
++++ ./mux.c    2015-12-17 19:20:36.368902909 -0500
+@@ -1295,6 +1295,22 @@
+       }
+       /* Now atomically "move" the mux socket into position */
++#ifdef __ANDROID__
++      /* Android does not support hard links, so use a non-atomic
++         check-then-rename for now. */
++      if (access(orig_control_path, F_OK) == 0) {
++              error("ControlSocket %s already exists, disabling multiplexing",
++                  orig_control_path);
++              unlink(options.control_path);
++              goto disable_mux_master;
++      } else {
++              if (rename(options.control_path, orig_control_path) == -1) {
++                      fatal("%s: link mux listener %s => %s: %s", __func__, 
++                          options.control_path, orig_control_path,
++                          strerror(errno));
++              }
++      }
++#else
+       if (link(options.control_path, orig_control_path) != 0) {
+               if (errno != EEXIST) {
+                       fatal("%s: link mux listener %s => %s: %s", __func__, 
+@@ -1307,6 +1324,7 @@
+               goto disable_mux_master;
+       }
+       unlink(options.control_path);
++#endif
+       free(options.control_path);
+       options.control_path = orig_control_path;