From 98c7df17fe3ff21fb6d7e686ce0d20e98bf70ee6 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Mon, 6 Jun 2016 18:19:47 -0400 Subject: [PATCH] openssh: Do not try link(2) for sftp-server rename Hard links are not supported on Android from 6.0 on. Fixes #293. --- packages/openssh/build.sh | 2 +- packages/openssh/sftp-server.c.patch | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 packages/openssh/sftp-server.c.patch diff --git a/packages/openssh/build.sh b/packages/openssh/build.sh index 7428e1fb..e907ded0 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.2p2 -TERMUX_PKG_BUILD_REVISION=2 +TERMUX_PKG_BUILD_REVISION=3 TERMUX_PKG_SRCURL=http://ftp.eu.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${TERMUX_PKG_VERSION}.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/sftp-server.c.patch b/packages/openssh/sftp-server.c.patch new file mode 100644 index 00000000..fcdf0bd2 --- /dev/null +++ b/packages/openssh/sftp-server.c.patch @@ -0,0 +1,37 @@ +diff -u -r ../openssh-7.2p2/sftp-server.c ./sftp-server.c +--- ../openssh-7.2p2/sftp-server.c 2016-03-09 13:04:48.000000000 -0500 ++++ ./sftp-server.c 2016-06-06 18:13:28.141236751 -0400 +@@ -1190,7 +1190,9 @@ + if (lstat(oldpath, &sb) == -1) + status = errno_to_portable(errno); + else if (S_ISREG(sb.st_mode)) { ++#ifndef __ANDROID__ + /* Race-free rename of regular files */ ++ /* Do not try this for Android which does not support links */ + if (link(oldpath, newpath) == -1) { + if (errno == EOPNOTSUPP || errno == ENOSYS + #ifdef EXDEV +@@ -1200,6 +1202,7 @@ + || errno == LINK_OPNOTSUPP_ERRNO + #endif + ) { ++#endif + struct stat st; + + /* +@@ -1213,6 +1216,7 @@ + else + status = SSH2_FX_OK; + } ++#ifndef __ANDROID__ + } else { + status = errno_to_portable(errno); + } +@@ -1222,6 +1226,7 @@ + unlink(newpath); + } else + status = SSH2_FX_OK; ++#endif + } else if (stat(newpath, &sb) == -1) { + if (rename(oldpath, newpath) == -1) + status = errno_to_portable(errno); -- 2.11.0