From 6bbba8f22a14ec12e942950417414be0e67620ea Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 17 Dec 2015 19:32:24 -0500 Subject: [PATCH] openssh: Make ControlMaster feature work 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 | 2 +- packages/openssh/mux.c.patch | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 packages/openssh/mux.c.patch diff --git a/packages/openssh/build.sh b/packages/openssh/build.sh index ea9e7fc8..a126c8b9 100755 --- a/packages/openssh/build.sh +++ b/packages/openssh/build.sh @@ -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 index 00000000..20682c99 --- /dev/null +++ b/packages/openssh/mux.c.patch @@ -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; + -- 2.11.0