Browse Source

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.
android-5
Fredrik Fornwall 9 years ago
parent
commit
6bbba8f22a
  1. 2
      packages/openssh/build.sh
  2. 34
      packages/openssh/mux.c.patch

2
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:

34
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;
Loading…
Cancel
Save