Browse Source

busybox: Avoid chroot() in ftpd due to seccomp

In Android 9 chroot() have been addded to the seccomp filter, so the
process is killed if trying to use it. Luckily busybox already contained
fallback if chroot() is not permitted.

See #2789.
android-5
Fredrik Fornwall 6 years ago
parent
commit
94e5ebc021
  1. 2
      packages/busybox/build.sh
  2. 21
      packages/busybox/networking-ftpd.c.patch

2
packages/busybox/build.sh

@ -2,7 +2,7 @@ TERMUX_PKG_HOMEPAGE=https://busybox.net/
TERMUX_PKG_DESCRIPTION="Tiny versions of many common UNIX utilities into a single small executable" TERMUX_PKG_DESCRIPTION="Tiny versions of many common UNIX utilities into a single small executable"
TERMUX_PKG_ESSENTIAL=yes TERMUX_PKG_ESSENTIAL=yes
TERMUX_PKG_VERSION=1.29.2 TERMUX_PKG_VERSION=1.29.2
TERMUX_PKG_REVISION=1 TERMUX_PKG_REVISION=2
TERMUX_PKG_SHA256=67d2fa6e147a45875fe972de62d907ef866fe784c495c363bf34756c444a5d61 TERMUX_PKG_SHA256=67d2fa6e147a45875fe972de62d907ef866fe784c495c363bf34756c444a5d61
TERMUX_PKG_SRCURL=https://busybox.net/downloads/busybox-${TERMUX_PKG_VERSION}.tar.bz2 TERMUX_PKG_SRCURL=https://busybox.net/downloads/busybox-${TERMUX_PKG_VERSION}.tar.bz2
TERMUX_PKG_BUILD_IN_SRC=yes TERMUX_PKG_BUILD_IN_SRC=yes

21
packages/busybox/networking-ftpd.c.patch

@ -1,6 +1,6 @@
diff -uNr busybox-1.29.2/networking/ftpd.c busybox-1.29.2.mod/networking/ftpd.c diff -u -r ../busybox-1.29.2/networking/ftpd.c ./networking/ftpd.c
--- busybox-1.29.2/networking/ftpd.c 2018-07-02 14:23:06.000000000 +0300 --- ../busybox-1.29.2/networking/ftpd.c 2018-07-02 11:23:06.000000000 +0000
+++ busybox-1.29.2.mod/networking/ftpd.c 2018-08-15 12:04:36.418874958 +0300 +++ ./networking/ftpd.c 2018-08-30 09:14:29.299721780 +0000
@@ -177,13 +177,9 @@ @@ -177,13 +177,9 @@
char msg_ok [(sizeof("NNN " MSG_OK ) + 3) & 0xfffc]; char msg_ok [(sizeof("NNN " MSG_OK ) + 3) & 0xfffc];
char msg_err[(sizeof("NNN " MSG_ERR) + 3) & 0xfffc]; char msg_err[(sizeof("NNN " MSG_ERR) + 3) & 0xfffc];
@ -17,3 +17,18 @@ diff -uNr busybox-1.29.2/networking/ftpd.c busybox-1.29.2.mod/networking/ftpd.c
/* Moved to main */ \ /* Moved to main */ \
/*strcpy(G.msg_ok + 4, MSG_OK );*/ \ /*strcpy(G.msg_ok + 4, MSG_OK );*/ \
/*strcpy(G.msg_err + 4, MSG_ERR);*/ \ /*strcpy(G.msg_err + 4, MSG_ERR);*/ \
@@ -1301,7 +1297,14 @@
G.root_fd = xopen("/", O_RDONLY | O_DIRECTORY);
close_on_exec_on(G.root_fd);
#endif
+
+#ifdef __ANDROID__
+ /* Do not try chroot() as seccomp filtering in
+ * android 9 kills the process. */
+ if (false)
+#else
if (chroot(basedir) == 0)
+#endif
basedir = "/";
#if !BB_MMU
else {

Loading…
Cancel
Save