Browse Source

busybox: update patches

Reorganize patches & do following changes:

 * Enable use of sethostname(2) in utility `hostname`.
 * Enable setting time in utility `date` - busybox already provide own
   implementation of stime(2).

- both features require root.
emacs-27
Leonid Plyushch 5 years ago
parent
commit
4a7c9168be
No known key found for this signature in database GPG Key ID: 45F2964132545795
  1. 12
      packages/busybox/0000-use-clang.patch
  2. 36
      packages/busybox/0001-clang-fix.patch
  3. 85
      packages/busybox/0002-hardcoded-paths-fix.patch
  4. 14
      packages/busybox/0003-strchrnul-fix.patch
  5. 38
      packages/busybox/0004-missing-syscalls.patch
  6. 13
      packages/busybox/0005-no-change-identity.patch
  7. 15
      packages/busybox/0006-no-crypt.h.patch
  8. 22
      packages/busybox/0007-miscutils-crond.patch
  9. 10
      packages/busybox/0008-miscutils-crontab.patch
  10. 15
      packages/busybox/0009-networking-ftpd-no-chroot.patch
  11. 12
      packages/busybox/0010-networking-httpd-default-port.patch
  12. 12
      packages/busybox/0011-networking-telnetd-default-port.patch
  13. 16
      packages/busybox/0012-networking-tftp-no-chroot.patch
  14. 16
      packages/busybox/Makefile.patch
  15. 20
      packages/busybox/coreutils-date.c.patch
  16. 21
      packages/busybox/coreutils-mktemp.c.patch
  17. 12
      packages/busybox/editors-diff.c.patch
  18. 14
      packages/busybox/include-platform.h.patch
  19. 17
      packages/busybox/libbb-change_identity.c.patch
  20. 19
      packages/busybox/libbb-platform.c.patch
  21. 14
      packages/busybox/libbb-pw_encrypt.c.patch
  22. 18
      packages/busybox/libbb.h.patch
  23. 16
      packages/busybox/missing_syscalls.c.patch
  24. 34
      packages/busybox/networking-ftpd.c.patch
  25. 22
      packages/busybox/networking-hostname.c.patch
  26. 24
      packages/busybox/telnetd.patch
  27. 16
      packages/busybox/tftp.c.patch
  28. 23
      packages/busybox/util-linux-getopt.c.patch
  29. 12
      packages/busybox/util-linux-setarch.c.patch

12
packages/busybox/0000-use-clang.patch

@ -0,0 +1,12 @@
diff -uNr busybox-1.31.1/Makefile busybox-1.31.1.mod/Makefile
--- busybox-1.31.1/Makefile 2019-10-25 11:44:52.000000000 +0300
+++ busybox-1.31.1.mod/Makefile 2019-11-11 22:19:06.004778909 +0200
@@ -289,7 +289,7 @@
# Make variables (CC, etc...)
AS = $(CROSS_COMPILE)as
-CC = $(CROSS_COMPILE)gcc
+CC = $(CROSS_COMPILE)clang
LD = $(CC) -nostdlib
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar

36
packages/busybox/build-with-clang.patch → packages/busybox/0001-clang-fix.patch

@ -1,6 +1,6 @@
diff -uNr busybox-1.30.1/miscutils/less.c busybox-1.30.1.mod/miscutils/less.c diff -uNr busybox-1.31.1/miscutils/less.c busybox-1.31.1.mod/miscutils/less.c
--- busybox-1.30.1/miscutils/less.c 2018-12-30 17:14:20.000000000 +0200 --- busybox-1.31.1/miscutils/less.c 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.30.1.mod/miscutils/less.c 2019-11-11 17:13:12.850557374 +0200 +++ busybox-1.31.1.mod/miscutils/less.c 2019-11-11 21:31:58.406733857 +0200
@@ -278,6 +278,7 @@ @@ -278,6 +278,7 @@
#define kbd_input (G.kbd_input ) #define kbd_input (G.kbd_input )
#define INIT_G() do { \ #define INIT_G() do { \
@ -9,10 +9,10 @@ diff -uNr busybox-1.30.1/miscutils/less.c busybox-1.30.1.mod/miscutils/less.c
less_gets_pos = -1; \ less_gets_pos = -1; \
empty_line_marker = "~"; \ empty_line_marker = "~"; \
current_file = 1; \ current_file = 1; \
diff -uNr busybox-1.30.1/networking/httpd.c busybox-1.30.1.mod/networking/httpd.c diff -uNr busybox-1.31.1/networking/httpd.c busybox-1.31.1.mod/networking/httpd.c
--- busybox-1.30.1/networking/httpd.c 2018-12-05 16:44:34.000000000 +0200 --- busybox-1.31.1/networking/httpd.c 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.30.1.mod/networking/httpd.c 2019-11-11 17:13:12.850557374 +0200 +++ busybox-1.31.1.mod/networking/httpd.c 2019-11-11 21:31:58.406733857 +0200
@@ -488,6 +488,7 @@ @@ -485,6 +485,7 @@
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \ setup_common_bufsiz(); \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
@ -20,9 +20,9 @@ diff -uNr busybox-1.30.1/networking/httpd.c busybox-1.30.1.mod/networking/httpd.
IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \ IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \
IF_FEATURE_HTTPD_RANGES(range_start = -1;) \ IF_FEATURE_HTTPD_RANGES(range_start = -1;) \
bind_addr_or_port = "80"; \ bind_addr_or_port = "80"; \
diff -uNr busybox-1.30.1/runit/svlogd.c busybox-1.30.1.mod/runit/svlogd.c diff -uNr busybox-1.31.1/runit/svlogd.c busybox-1.31.1.mod/runit/svlogd.c
--- busybox-1.30.1/runit/svlogd.c 2018-12-30 17:14:20.000000000 +0200 --- busybox-1.31.1/runit/svlogd.c 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.30.1.mod/runit/svlogd.c 2019-11-11 17:13:12.850557374 +0200 +++ busybox-1.31.1.mod/runit/svlogd.c 2019-11-11 21:31:58.406733857 +0200
@@ -244,6 +244,7 @@ @@ -244,6 +244,7 @@
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \ setup_common_bufsiz(); \
@ -31,10 +31,10 @@ diff -uNr busybox-1.30.1/runit/svlogd.c busybox-1.30.1.mod/runit/svlogd.c
linemax = 1000; \ linemax = 1000; \
/*buflen = 1024;*/ \ /*buflen = 1024;*/ \
linecomplete = 1; \ linecomplete = 1; \
diff -uNr busybox-1.30.1/shell/ash.c busybox-1.30.1.mod/shell/ash.c diff -uNr busybox-1.31.1/shell/ash.c busybox-1.31.1.mod/shell/ash.c
--- busybox-1.30.1/shell/ash.c 2018-12-30 17:14:20.000000000 +0200 --- busybox-1.31.1/shell/ash.c 2019-10-21 17:54:40.000000000 +0300
+++ busybox-1.30.1.mod/shell/ash.c 2019-11-11 17:54:04.403592056 +0200 +++ busybox-1.31.1.mod/shell/ash.c 2019-11-11 21:31:58.410067203 +0200
@@ -465,6 +465,7 @@ @@ -490,6 +490,7 @@
#define backgndpid (G_misc.backgndpid ) #define backgndpid (G_misc.backgndpid )
#define INIT_G_misc() do { \ #define INIT_G_misc() do { \
(*(struct globals_misc**)&ash_ptr_to_globals_misc) = xzalloc(sizeof(G_misc)); \ (*(struct globals_misc**)&ash_ptr_to_globals_misc) = xzalloc(sizeof(G_misc)); \
@ -42,7 +42,7 @@ diff -uNr busybox-1.30.1/shell/ash.c busybox-1.30.1.mod/shell/ash.c
barrier(); \ barrier(); \
curdir = nullstr; \ curdir = nullstr; \
physdir = nullstr; \ physdir = nullstr; \
@@ -1518,6 +1519,7 @@ @@ -1543,6 +1544,7 @@
#define stackbase (G_memstack.stackbase ) #define stackbase (G_memstack.stackbase )
#define INIT_G_memstack() do { \ #define INIT_G_memstack() do { \
(*(struct globals_memstack**)&ash_ptr_to_globals_memstack) = xzalloc(sizeof(G_memstack)); \ (*(struct globals_memstack**)&ash_ptr_to_globals_memstack) = xzalloc(sizeof(G_memstack)); \
@ -50,7 +50,7 @@ diff -uNr busybox-1.30.1/shell/ash.c busybox-1.30.1.mod/shell/ash.c
barrier(); \ barrier(); \
g_stackp = &stackbase; \ g_stackp = &stackbase; \
g_stacknxt = stackbase.space; \ g_stacknxt = stackbase.space; \
@@ -2133,6 +2135,7 @@ @@ -2166,6 +2168,7 @@
#define INIT_G_var() do { \ #define INIT_G_var() do { \
unsigned i; \ unsigned i; \
(*(struct globals_var**)&ash_ptr_to_globals_var) = xzalloc(sizeof(G_var)); \ (*(struct globals_var**)&ash_ptr_to_globals_var) = xzalloc(sizeof(G_var)); \
@ -58,7 +58,7 @@ diff -uNr busybox-1.30.1/shell/ash.c busybox-1.30.1.mod/shell/ash.c
barrier(); \ barrier(); \
for (i = 0; i < ARRAY_SIZE(varinit_data); i++) { \ for (i = 0; i < ARRAY_SIZE(varinit_data); i++) { \
varinit[i].flags = varinit_data[i].flags; \ varinit[i].flags = varinit_data[i].flags; \
@@ -3311,6 +3314,7 @@ @@ -3348,6 +3351,7 @@
static struct alias **atab; // [ATABSIZE]; static struct alias **atab; // [ATABSIZE];
#define INIT_G_alias() do { \ #define INIT_G_alias() do { \
@ -66,7 +66,7 @@ diff -uNr busybox-1.30.1/shell/ash.c busybox-1.30.1.mod/shell/ash.c
atab = xzalloc(ATABSIZE * sizeof(atab[0])); \ atab = xzalloc(ATABSIZE * sizeof(atab[0])); \
} while (0) } while (0)
@@ -7995,6 +7999,7 @@ @@ -8073,6 +8077,7 @@
static struct tblentry **cmdtable; static struct tblentry **cmdtable;
#define INIT_G_cmdtable() do { \ #define INIT_G_cmdtable() do { \

85
packages/busybox/0002-hardcoded-paths-fix.patch

@ -0,0 +1,85 @@
diff -uNr busybox-1.31.1/coreutils/mktemp.c busybox-1.31.1.mod/coreutils/mktemp.c
--- busybox-1.31.1/coreutils/mktemp.c 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.31.1.mod/coreutils/mktemp.c 2019-11-11 21:46:00.848464330 +0200
@@ -50,7 +50,7 @@
//usage: "\n -p DIR Use DIR as a base directory (implies -t)"
//usage: "\n -u Do not create anything; print a name"
//usage: "\n"
-//usage: "\nBase directory is: -p DIR, else $TMPDIR, else /tmp"
+//usage: "\nBase directory is: -p DIR, else $TMPDIR, else @TERMUX_PREFIX@/tmp"
//usage:
//usage:#define mktemp_example_usage
//usage: "$ mktemp /tmp/temp.XXXXXX\n"
@@ -76,7 +76,7 @@
path = getenv("TMPDIR");
if (!path || path[0] == '\0')
- path = "/tmp";
+ path = "@TERMUX_PREFIX@/tmp";
opts = getopt32(argv, "^" "dqtp:u" "\0" "?1"/*1 arg max*/, &path);
diff -uNr busybox-1.31.1/editors/diff.c busybox-1.31.1.mod/editors/diff.c
--- busybox-1.31.1/editors/diff.c 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.31.1.mod/editors/diff.c 2019-11-11 21:46:33.625316185 +0200
@@ -730,7 +730,7 @@
* When we meet non-seekable file, we must make a temp copy.
*/
if (lseek(fd, 0, SEEK_SET) == -1 && errno == ESPIPE) {
- char name[] = "/tmp/difXXXXXX";
+ char name[] = "@TERMUX_PREFIX@/tmp/difXXXXXX";
int fd_tmp = xmkstemp(name);
unlink(name);
diff -uNr busybox-1.31.1/include/libbb.h busybox-1.31.1.mod/include/libbb.h
--- busybox-1.31.1/include/libbb.h 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.31.1.mod/include/libbb.h 2019-11-11 21:55:22.141411848 +0200
@@ -2126,12 +2126,12 @@
* use bb_default_login_shell and following defines.
* If you change LIBBB_DEFAULT_LOGIN_SHELL,
* don't forget to change increment constant. */
-#define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh"
+#define LIBBB_DEFAULT_LOGIN_SHELL "-@TERMUX_PREFIX@/bin/sh"
extern const char bb_default_login_shell[] ALIGN1;
-/* "/bin/sh" */
+/* "@TERMUX_PREFIX@/bin/sh" */
#define DEFAULT_SHELL (bb_default_login_shell+1)
/* "sh" */
-#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+6)
+#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+1+sizeof("@TERMUX_PREFIX@/bin"))
/* The following devices are the same on all systems. */
#define CURRENT_TTY "/dev/tty"
diff -uNr busybox-1.31.1/networking/telnetd.c busybox-1.31.1.mod/networking/telnetd.c
--- busybox-1.31.1/networking/telnetd.c 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.31.1.mod/networking/telnetd.c 2019-11-11 22:00:22.799539737 +0200
@@ -99,7 +99,7 @@
//usage: "Handle incoming telnet connections"
//usage: IF_NOT_FEATURE_TELNETD_STANDALONE(" via inetd") "\n"
//usage: "\n -l LOGIN Exec LOGIN on connect"
-//usage: "\n -f ISSUE_FILE Display ISSUE_FILE instead of /etc/issue"
+//usage: "\n -f ISSUE_FILE Display ISSUE_FILE instead of @TERMUX_PREFIX@/etc/issue.net"
//usage: "\n -K Close connection as soon as login exits"
//usage: "\n (normally wait until all programs close slave pty)"
//usage: IF_FEATURE_TELNETD_STANDALONE(
@@ -160,7 +160,7 @@
#define INIT_G() do { \
setup_common_bufsiz(); \
G.loginpath = "/bin/login"; \
- G.issuefile = "/etc/issue.net"; \
+ G.issuefile = "@TERMUX_PREFIX@/etc/issue.net"; \
} while (0)
diff -uNr busybox-1.31.1/util-linux/setarch.c busybox-1.31.1.mod/util-linux/setarch.c
--- busybox-1.31.1/util-linux/setarch.c 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.31.1.mod/util-linux/setarch.c 2019-11-11 21:56:31.521753610 +0200
@@ -98,7 +98,7 @@
argv += optind;
if (!argv[0])
- (--argv)[0] = (char*)"/bin/sh";
+ (--argv)[0] = (char*)"@TERMUX_PREFIX@/bin/sh";
/* Try to execute the program */
BB_EXECVP_or_die(argv);

14
packages/busybox/0003-strchrnul-fix.patch

@ -0,0 +1,14 @@
diff -uNr busybox-1.31.1/include/platform.h busybox-1.31.1.mod/include/platform.h
--- busybox-1.31.1/include/platform.h 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.31.1.mod/include/platform.h 2019-11-12 02:43:11.833640516 +0200
@@ -526,7 +526,9 @@
# undef HAVE_STPCPY
# endif
# undef HAVE_MEMPCPY
-# undef HAVE_STRCHRNUL
+# if __ANDROID_API__ < 24
+# undef HAVE_STRCHRNUL
+# endif
# undef HAVE_STRVERSCMP
# undef HAVE_UNLOCKED_LINE_OPS
# undef HAVE_NET_ETHERNET_H

38
packages/busybox/0004-missing-syscalls.patch

@ -0,0 +1,38 @@
diff -uNr busybox-1.31.1/libbb/missing_syscalls.c busybox-1.31.1.mod/libbb/missing_syscalls.c
--- busybox-1.31.1/libbb/missing_syscalls.c 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.31.1.mod/libbb/missing_syscalls.c 2019-11-11 22:56:16.433805825 +0200
@@ -10,10 +10,13 @@
#if defined(ANDROID) || defined(__ANDROID__)
/*# include <linux/timex.h> - for struct timex, but may collide with <time.h> */
# include <sys/syscall.h>
+
+#if __ANDROID_API__ < 17
pid_t getsid(pid_t pid)
{
return syscall(__NR_getsid, pid);
}
+#endif
int stime(const time_t *t)
{
@@ -23,16 +26,20 @@
return settimeofday(&tv, NULL);
}
+#if __ANDROID_API__ < 23
int sethostname(const char *name, size_t len)
{
return syscall(__NR_sethostname, name, len);
}
+#endif
+#if __ANDROID_API__ < 24
struct timex;
int adjtimex(struct timex *buf)
{
return syscall(__NR_adjtimex, buf);
}
+#endif
int pivot_root(const char *new_root, const char *put_old)
{

13
packages/busybox/0005-no-change-identity.patch

@ -0,0 +1,13 @@
diff -uNr busybox-1.31.1/libbb/change_identity.c busybox-1.31.1.mod/libbb/change_identity.c
--- busybox-1.31.1/libbb/change_identity.c 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.31.1.mod/libbb/change_identity.c 2019-11-11 22:12:18.976233196 +0200
@@ -32,6 +32,9 @@
/* Become the user and group(s) specified by PW. */
void FAST_FUNC change_identity(const struct passwd *pw)
{
+#ifdef __ANDROID__
+ return;
+#endif
int res;
res = initgroups(pw->pw_name, pw->pw_gid);

15
packages/busybox/0006-no-crypt.h.patch

@ -0,0 +1,15 @@
diff -uNr busybox-1.31.1/libbb/pw_encrypt.c busybox-1.31.1.mod/libbb/pw_encrypt.c
--- busybox-1.31.1/libbb/pw_encrypt.c 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.31.1.mod/libbb/pw_encrypt.c 2019-11-11 22:16:44.990795793 +0200
@@ -6,7 +6,10 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
-#include <crypt.h>
+#if !ENABLE_USE_BB_CRYPT
+# include <crypt.h>
+#endif
+
#include "libbb.h"
/* static const uint8_t ascii64[] ALIGN1 =

22
packages/busybox/crond.c.patch → packages/busybox/0007-miscutils-crond.patch

@ -1,7 +1,7 @@
diff -u -r ../busybox-1.23.1/miscutils/crond.c ./miscutils/crond.c diff -uNr busybox-1.31.1/miscutils/crond.c busybox-1.31.1.mod/miscutils/crond.c
--- ../busybox-1.23.1/miscutils/crond.c 2015-01-27 03:48:58.000000000 -0500 --- busybox-1.31.1/miscutils/crond.c 2019-06-10 13:50:53.000000000 +0300
+++ ./miscutils/crond.c 2015-02-06 16:43:24.238473247 -0500 +++ busybox-1.31.1.mod/miscutils/crond.c 2019-11-11 22:04:10.820622087 +0200
@@ -415,7 +415,7 @@ @@ -435,7 +435,7 @@
maxLines = (strcmp(fileName, "root") == 0) ? 65535 : MAXLINES; maxLines = (strcmp(fileName, "root") == 0) ? 65535 : MAXLINES;
@ -10,19 +10,13 @@ diff -u -r ../busybox-1.23.1/miscutils/crond.c ./miscutils/crond.c
CronFile *file = xzalloc(sizeof(CronFile)); CronFile *file = xzalloc(sizeof(CronFile));
CronLine **pline; CronLine **pline;
int n; int n;
@@ -571,6 +571,7 @@ @@ -655,6 +655,9 @@
static void set_env_vars(struct passwd *pas, const char *shell) static void set_env_vars(struct passwd *pas, const char *shell)
{ {
+#ifndef __ANDROID__ +#ifdef __ANDROID__
+ return;
+#endif
/* POSIX requires crond to set up at least HOME, LOGNAME, PATH, SHELL. /* POSIX requires crond to set up at least HOME, LOGNAME, PATH, SHELL.
* We assume crond inherited suitable PATH. * We assume crond inherited suitable PATH.
*/ */
@@ -585,6 +586,7 @@
xsetenv("HOME", pas->pw_dir);
xsetenv("SHELL", shell);
#endif
+#endif
}
static void change_user(struct passwd *pas)

10
packages/busybox/crontab.c.patch → packages/busybox/0008-miscutils-crontab.patch

@ -1,7 +1,7 @@
diff -u -r ../busybox-1.22.1/miscutils/crontab.c ./miscutils/crontab.c diff -uNr busybox-1.31.1/miscutils/crontab.c busybox-1.31.1.mod/miscutils/crontab.c
--- ../busybox-1.22.1/miscutils/crontab.c 2014-01-09 19:15:44.000000000 +0100 --- busybox-1.31.1/miscutils/crontab.c 2019-06-10 13:50:53.000000000 +0300
+++ ./miscutils/crontab.c 2014-07-01 09:47:30.000000000 +0200 +++ busybox-1.31.1.mod/miscutils/crontab.c 2019-11-11 22:08:19.115118798 +0200
@@ -40,10 +40,12 @@ @@ -53,10 +53,12 @@
/* CHILD - change user and run editor */ /* CHILD - change user and run editor */
/* initgroups, setgid, setuid */ /* initgroups, setgid, setuid */
@ -14,7 +14,7 @@ diff -u -r ../busybox-1.22.1/miscutils/crontab.c ./miscutils/crontab.c
ptr = getenv("VISUAL"); ptr = getenv("VISUAL");
if (!ptr) { if (!ptr) {
ptr = getenv("EDITOR"); ptr = getenv("EDITOR");
@@ -168,7 +168,8 @@ @@ -167,7 +169,8 @@
} }
close_on_exec_on(src_fd); /* don't want editor to see this fd */ close_on_exec_on(src_fd); /* don't want editor to see this fd */
edit_file(pas, tmp_fname); edit_file(pas, tmp_fname);

15
packages/busybox/0009-networking-ftpd-no-chroot.patch

@ -0,0 +1,15 @@
diff -uNr busybox-1.31.1/networking/ftpd.c busybox-1.31.1.mod/networking/ftpd.c
--- busybox-1.31.1/networking/ftpd.c 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.31.1.mod/networking/ftpd.c 2019-11-11 22:26:50.216912741 +0200
@@ -1301,8 +1301,11 @@
G.root_fd = xopen("/", O_RDONLY | O_DIRECTORY);
close_on_exec_on(G.root_fd);
#endif
+#ifndef __ANDROID__
+ /* Do not try chroot() on Android because it may trigger seccomp. */
if (chroot(basedir) == 0)
basedir = "/";
+#endif
#if !BB_MMU
else {
close(G.root_fd);

12
packages/busybox/networking-httpd.c.patch → packages/busybox/0010-networking-httpd-default-port.patch

@ -1,6 +1,6 @@
diff -uNr busybox-1.31.1/networking/httpd.c busybox-1.31.1.mod/networking/httpd.c diff -uNr busybox-1.31.1/networking/httpd.c busybox-1.31.1.mod/networking/httpd.c
--- busybox-1.31.1/networking/httpd.c 2019-06-10 13:50:53.000000000 +0300 --- busybox-1.31.1/networking/httpd.c 2019-11-11 21:31:58.406733857 +0200
+++ busybox-1.31.1.mod/networking/httpd.c 2019-11-11 21:27:40.912339505 +0200 +++ busybox-1.31.1.mod/networking/httpd.c 2019-11-11 22:29:16.534250966 +0200
@@ -232,7 +232,7 @@ @@ -232,7 +232,7 @@
//usage: "\n -i Inetd mode" //usage: "\n -i Inetd mode"
//usage: "\n -f Don't daemonize" //usage: "\n -f Don't daemonize"
@ -10,8 +10,8 @@ diff -uNr busybox-1.31.1/networking/httpd.c busybox-1.31.1.mod/networking/httpd.
//usage: IF_FEATURE_HTTPD_SETUID( //usage: IF_FEATURE_HTTPD_SETUID(
//usage: "\n -u USER[:GRP] Set uid/gid after binding to port") //usage: "\n -u USER[:GRP] Set uid/gid after binding to port")
//usage: IF_FEATURE_HTTPD_BASIC_AUTH( //usage: IF_FEATURE_HTTPD_BASIC_AUTH(
@@ -487,7 +487,7 @@ @@ -488,7 +488,7 @@
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ asm volatile("":::"memory"); \
IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \ IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \
IF_FEATURE_HTTPD_RANGES(range_start = -1;) \ IF_FEATURE_HTTPD_RANGES(range_start = -1;) \
- bind_addr_or_port = "80"; \ - bind_addr_or_port = "80"; \
@ -19,7 +19,7 @@ diff -uNr busybox-1.31.1/networking/httpd.c busybox-1.31.1.mod/networking/httpd.
index_page = index_html; \ index_page = index_html; \
file_size = -1; \ file_size = -1; \
} while (0) } while (0)
@@ -1003,7 +1003,7 @@ @@ -1004,7 +1004,7 @@
if (!errno && n && n <= 0xffff) if (!errno && n && n <= 0xffff)
n = create_and_bind_stream_or_die(NULL, n); n = create_and_bind_stream_or_die(NULL, n);
else else
@ -28,7 +28,7 @@ diff -uNr busybox-1.31.1/networking/httpd.c busybox-1.31.1.mod/networking/httpd.
xlisten(n, 9); xlisten(n, 9);
return n; return n;
} }
@@ -2208,7 +2208,7 @@ @@ -2209,7 +2209,7 @@
if (proxy_entry) { if (proxy_entry) {
if (verbose > 1) if (verbose > 1)
bb_error_msg("proxy:%s", urlcopy); bb_error_msg("proxy:%s", urlcopy);

12
packages/busybox/0011-networking-telnetd-default-port.patch

@ -0,0 +1,12 @@
diff -uNr busybox-1.31.1/networking/telnetd.c busybox-1.31.1.mod/networking/telnetd.c
--- busybox-1.31.1/networking/telnetd.c 2019-11-11 22:00:22.799539737 +0200
+++ busybox-1.31.1.mod/networking/telnetd.c 2019-11-11 22:32:02.268344626 +0200
@@ -707,7 +707,7 @@
} else {
master_fd = 0;
if (!(opt & OPT_WAIT)) {
- unsigned portnbr = 23;
+ unsigned portnbr = 8023;
if (opt & OPT_PORT)
portnbr = xatou16(opt_portnbr);
master_fd = create_and_bind_stream_or_die(opt_bindaddr, portnbr);

16
packages/busybox/0012-networking-tftp-no-chroot.patch

@ -0,0 +1,16 @@
diff -uNr busybox-1.31.1/networking/tftp.c busybox-1.31.1.mod/networking/tftp.c
--- busybox-1.31.1/networking/tftp.c 2019-06-10 13:50:53.000000000 +0300
+++ busybox-1.31.1.mod/networking/tftp.c 2019-11-11 22:36:27.592894669 +0200
@@ -907,7 +907,12 @@
G.pw = xgetpwnam(user_opt);
}
if (argv[0]) {
+#ifdef __ANDROID__
+ // chroot may trigger seccomp and is allowed only for root anyway.
+ xchdir(argv[0]);
+#else
xchroot(argv[0]);
+#endif
}
result = recv_from_to(STDIN_FILENO,

16
packages/busybox/Makefile.patch

@ -1,16 +0,0 @@
Building with clang causes 'busybox less' to
segfault in INIT_G() on arm, see
https://github.com/termux/termux-packages/issues/1245
diff -u -r ../busybox-1.26.2/Makefile ./Makefile
--- ../busybox-1.26.2/Makefile 2017-01-10 17:01:16.000000000 +0100
+++ ./Makefile 2017-06-27 23:34:15.465534834 +0200
@@ -289,7 +289,7 @@
# Make variables (CC, etc...)
AS = $(CROSS_COMPILE)as
-CC = $(CROSS_COMPILE)gcc
+CC ?= $(CROSS_COMPILE)gcc
LD = $(CC) -nostdlib
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar

20
packages/busybox/coreutils-date.c.patch

@ -1,20 +0,0 @@
diff -u -r ../busybox-1.26.2/coreutils/date.c ./coreutils/date.c
--- ../busybox-1.26.2/coreutils/date.c 2016-12-10 17:46:36.000000000 +0000
+++ ./coreutils/date.c 2017-07-06 22:15:17.528119028 +0000
@@ -293,9 +293,16 @@
maybe_set_utc(opt);
/* if setting time, set it */
+#ifdef __ANDROID__
+ if (opt & OPT_SET) {
+ /* stime(2) is not available on Android and is not allowed anyway. */
+ bb_error_msg("can't set date: Operation not permitted");
+ }
+#else
if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) {
bb_perror_msg("can't set date");
}
+#endif
}
/* Display output */

21
packages/busybox/coreutils-mktemp.c.patch

@ -1,21 +0,0 @@
diff -u -r ../busybox-1.27.1/coreutils/mktemp.c ./coreutils/mktemp.c
--- ../busybox-1.27.1/coreutils/mktemp.c 2017-07-06 15:14:57.000000000 +0000
+++ ./coreutils/mktemp.c 2017-07-24 23:44:41.384345896 +0000
@@ -52,7 +52,7 @@
//usage: "\n -p DIR Use DIR as a base directory (implies -t)"
//usage: "\n -u Do not create anything; print a name"
//usage: "\n"
-//usage: "\nBase directory is: -p DIR, else $TMPDIR, else /tmp"
+//usage: "\nBase directory is: -p DIR, else $TMPDIR, else @TERMUX_PREFIX@/tmp"
//usage:
//usage:#define mktemp_example_usage
//usage: "$ mktemp /tmp/temp.XXXXXX\n"
@@ -78,7 +78,7 @@
path = getenv("TMPDIR");
if (!path || path[0] == '\0')
- path = "/tmp";
+ path = "@TERMUX_PREFIX@/tmp";
opt_complementary = "?1"; /* 1 argument max */
opts = getopt32(argv, "dqtp:u", &path);

12
packages/busybox/editors-diff.c.patch

@ -1,12 +0,0 @@
diff -u -r ../busybox-1.24.1/editors/diff.c ./editors/diff.c
--- ../busybox-1.24.1/editors/diff.c 2015-10-11 09:31:50.000000000 -0400
+++ ./editors/diff.c 2016-02-08 05:23:45.890302334 -0500
@@ -734,7 +734,7 @@
* When we meet non-seekable file, we must make a temp copy.
*/
if (lseek(fd, 0, SEEK_SET) == -1 && errno == ESPIPE) {
- char name[] = "/tmp/difXXXXXX";
+ char name[] = "@TERMUX_PREFIX@/tmp/difXXXXXX";
int fd_tmp = xmkstemp(name);
unlink(name);

14
packages/busybox/include-platform.h.patch

@ -1,14 +0,0 @@
diff -uNr busybox-1.29.3/include/platform.h busybox-1.29.3.mod/include/platform.h
--- busybox-1.29.3/include/platform.h 2018-07-02 14:23:06.000000000 +0300
+++ busybox-1.29.3.mod/include/platform.h 2019-02-08 16:01:14.437858554 +0200
@@ -579,10 +579,6 @@
extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC;
#endif
-#ifndef HAVE_STRCHRNUL
-extern char *strchrnul(const char *s, int c) FAST_FUNC;
-#endif
-
#ifndef HAVE_STRSEP
extern char *strsep(char **stringp, const char *delim) FAST_FUNC;
#endif

17
packages/busybox/libbb-change_identity.c.patch

@ -1,17 +0,0 @@
diff -u -r ../busybox-1.24.1/libbb/change_identity.c ./libbb/change_identity.c
--- ../busybox-1.24.1/libbb/change_identity.c 2015-07-12 22:18:47.000000000 -0400
+++ ./libbb/change_identity.c 2015-10-26 19:29:18.972044695 -0400
@@ -33,6 +33,7 @@
/* Become the user and group(s) specified by PW. */
void FAST_FUNC change_identity(const struct passwd *pw)
{
+#ifndef __ANDROID__
int res;
res = initgroups(pw->pw_name, pw->pw_gid);
@@ -57,4 +58,5 @@
xsetgid(pw->pw_gid);
xsetuid(pw->pw_uid);
+#endif
}

19
packages/busybox/libbb-platform.c.patch

@ -1,19 +0,0 @@
diff -uNr busybox-1.29.3/libbb/platform.c busybox-1.29.3.mod/libbb/platform.c
--- busybox-1.29.3/libbb/platform.c 2018-07-02 14:23:06.000000000 +0300
+++ busybox-1.29.3.mod/libbb/platform.c 2019-02-08 16:10:54.101961593 +0200
@@ -8,15 +8,6 @@
*/
#include "libbb.h"
-#ifndef HAVE_STRCHRNUL
-char* FAST_FUNC strchrnul(const char *s, int c)
-{
- while (*s != '\0' && *s != c)
- s++;
- return (char*)s;
-}
-#endif
-
#ifndef HAVE_USLEEP
int FAST_FUNC usleep(unsigned usec)
{

14
packages/busybox/libbb-pw_encrypt.c.patch

@ -1,14 +0,0 @@
diff -u -r ../busybox-1.29.1/libbb/pw_encrypt.c ./libbb/pw_encrypt.c
--- ../busybox-1.29.1/libbb/pw_encrypt.c 2018-07-02 11:23:06.000000000 +0000
+++ ./libbb/pw_encrypt.c 2018-07-22 23:43:48.620188017 +0000
@@ -6,7 +6,9 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
-#include <crypt.h>
+#if !ENABLE_USE_BB_CRYPT
+# include <crypt.h>
+#endif
#include "libbb.h"
/* static const uint8_t ascii64[] ALIGN1 =

18
packages/busybox/libbb.h.patch

@ -1,18 +0,0 @@
diff -u -r ../busybox-1.22.1/include/libbb.h ./include/libbb.h
--- ../busybox-1.22.1/include/libbb.h 2014-01-09 19:15:44.000000000 +0100
+++ ./include/libbb.h 2014-07-01 10:27:23.000000000 +0200
@@ -1785,12 +1785,12 @@
* use bb_default_login_shell and following defines.
* If you change LIBBB_DEFAULT_LOGIN_SHELL,
* don't forget to change increment constant. */
-#define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh"
+#define LIBBB_DEFAULT_LOGIN_SHELL "-/system/bin/sh"
extern const char bb_default_login_shell[] ALIGN1;
/* "/bin/sh" */
#define DEFAULT_SHELL (bb_default_login_shell+1)
/* "sh" */
-#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+6)
+#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+13)
/* The following devices are the same on all systems. */
#define CURRENT_TTY "/dev/tty"

16
packages/busybox/missing_syscalls.c.patch

@ -1,16 +0,0 @@
We have patched the ndk header to include getsid().
diff -u -r ../busybox-1.29.1/libbb/missing_syscalls.c ./libbb/missing_syscalls.c
--- ../busybox-1.29.1/libbb/missing_syscalls.c 2018-07-02 11:23:06.000000000 +0000
+++ ./libbb/missing_syscalls.c 2018-07-22 23:12:25.751499056 +0000
@@ -10,10 +10,6 @@
#if defined(ANDROID) || defined(__ANDROID__)
/*# include <linux/timex.h> - for struct timex, but may collide with <time.h> */
# include <sys/syscall.h>
-pid_t getsid(pid_t pid)
-{
- return syscall(__NR_getsid, pid);
-}
int stime(const time_t *t)
{

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

@ -1,34 +0,0 @@
diff -u -r ../busybox-1.29.2/networking/ftpd.c ./networking/ftpd.c
--- ../busybox-1.29.2/networking/ftpd.c 2018-07-02 11:23:06.000000000 +0000
+++ ./networking/ftpd.c 2018-08-30 09:14:29.299721780 +0000
@@ -177,13 +177,9 @@
char msg_ok [(sizeof("NNN " MSG_OK ) + 3) & 0xfffc];
char msg_err[(sizeof("NNN " MSG_ERR) + 3) & 0xfffc];
} FIX_ALIASING;
-#define G (*ptr_to_globals)
-/* ^^^ about 75 bytes smaller code than this: */
-//#define G (*(struct globals*)bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
- SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
- /*setup_common_bufsiz();*/ \
- \
+ setup_common_bufsiz(); \
/* Moved to main */ \
/*strcpy(G.msg_ok + 4, MSG_OK );*/ \
/*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 {

22
packages/busybox/networking-hostname.c.patch

@ -1,22 +0,0 @@
diff -u -r ../busybox-1.26.2/networking/hostname.c ./networking/hostname.c
--- ../busybox-1.26.2/networking/hostname.c 2016-12-10 18:46:36.000000000 +0100
+++ ./networking/hostname.c 2017-07-07 00:19:07.993535998 +0200
@@ -58,11 +58,18 @@
}
if (ENABLE_FEATURE_CLEAN_UP)
config_close(parser);
+#ifdef __ANDROID__
+ } else {
+ /* sethostname() is not available on Android pre android-23 and not allowed anyway. */
+ bb_error_msg_and_die("can't set hostname: Operation not permitted");
+ }
+#else
} else if (sethostname(s, strlen(s))) {
// if (errno == EPERM)
// bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
bb_perror_msg_and_die("sethostname");
}
+#endif
}
/* Manpage circa 2009:

24
packages/busybox/telnetd.patch

@ -1,24 +0,0 @@
diff -u -r ../busybox-1.25.1/networking/telnetd.c ./networking/telnetd.c
--- ../busybox-1.25.1/networking/telnetd.c 2016-10-07 10:47:47.000000000 -0400
+++ ./networking/telnetd.c 2016-10-08 17:49:55.717890508 -0400
@@ -86,8 +86,9 @@
#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
setup_common_bufsiz(); \
- G.loginpath = "/bin/login"; \
- G.issuefile = "/etc/issue.net"; \
+ struct passwd* pwd = getpwuid(getuid()); \
+ G.loginpath = pwd->pw_shell; \
+ G.issuefile = "@TERMUX_PREFIX@/etc/issue.net"; \
} while (0)
@@ -529,7 +530,7 @@
} else {
master_fd = 0;
if (!(opt & OPT_WAIT)) {
- unsigned portnbr = 23;
+ unsigned portnbr = 8023;
if (opt & OPT_PORT)
portnbr = xatou16(opt_portnbr);
master_fd = create_and_bind_stream_or_die(opt_bindaddr, portnbr);

16
packages/busybox/tftp.c.patch

@ -1,16 +0,0 @@
We disable security, because chroot() does not work with our environment.
With chdir() this can be used for bootstrapping on a local network.
diff -u -r ../busybox-1.22.1/networking/tftp.c ./networking/tftp.c
--- ../busybox-1.22.1/networking/tftp.c 2014-01-09 19:15:44.000000000 +0100
+++ ./networking/tftp.c 2014-07-01 08:42:48.000000000 +0200
@@ -790,7 +790,7 @@
G.pw = xgetpwnam(user_opt);
}
if (argv[0]) {
- xchroot(argv[0]);
+ xchdir(argv[0]);
}
result = recv_from_to(STDIN_FILENO, G.block_buf, sizeof(G.block_buf),

23
packages/busybox/util-linux-getopt.c.patch

@ -1,23 +0,0 @@
diff -u -r ../busybox-1.25.1/util-linux/getopt.c ./util-linux/getopt.c
--- ../busybox-1.25.1/util-linux/getopt.c 2016-10-07 10:47:47.000000000 -0400
+++ ./util-linux/getopt.c 2016-11-30 17:46:48.000185295 -0500
@@ -358,6 +358,10 @@
;
#endif
+#ifdef __ANDROID__
+extern char* __progname;
+#endif
+
int getopt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int getopt_main(int argc, char **argv)
{
@@ -423,5 +427,8 @@
}
argv[n] = name ? name : argv[0];
+#ifdef __ANDROID__
+ __progname = argv[n];
+#endif
return generate_output(argv + n, argc - n, optstr, long_options);
}

12
packages/busybox/util-linux-setarch.c.patch

@ -1,12 +0,0 @@
diff -uNr busybox-1.30.1/util-linux/setarch.c busybox-1.30.1.mod/util-linux/setarch.c
--- busybox-1.30.1/util-linux/setarch.c 2018-12-30 17:14:20.000000000 +0200
+++ busybox-1.30.1.mod/util-linux/setarch.c 2019-03-02 14:06:38.150442254 +0200
@@ -98,7 +98,7 @@
argv += optind;
if (!argv[0])
- (--argv)[0] = (char*)"/bin/sh";
+ (--argv)[0] = (char*)"@TERMUX_PREFIX@/bin/sh";
/* Try to execute the program */
BB_EXECVP_or_die(argv);
Loading…
Cancel
Save