From bcbf7c6c9fc7d8a96b1d5c4cc9247b85fe3da2ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=81LI=20G=C3=A1bor=20J=C3=A1nos?= Date: Sun, 10 Apr 2022 18:17:21 +0200 Subject: Move towards custom packages. Change the build image process in a way that custom-built packages can be utilized. This means a simpler `Makefile` since every modification is implemented on the level of packages. Include the sources for every customized package. --- ...ault-to-sbin-nologin-as-shell-for-system-.patch | 23 + ...-ash-add-built-in-BB_ASH_VERSION-variable.patch | 83 ++ ...dd-support-for-ignore-devno-like-GNU-cpio.patch | 88 ++ ...ddr2str-ensure-only-printable-characters-.patch | 40 + ...ck-ELF-header-before-calling-finit_module.patch | 152 +++ ...nstall-applet-to-sbin-instead-of-usr-sbin.patch | 27 + ...support-for-matching-against-UID-and-RUID.patch | 138 +++ .../0001-properly-fix-wget-https-support.patch | 69 ++ ...1-rev-correct-output-for-long-input-lines.patch | 91 ++ ...support-for-renumber-inodes-like-GNU-cpio.patch | 129 +++ ...sck-resolve-LABEL-.-UUID-.-spec-to-device.patch | 56 + ...nitize-all-printed-strings-with-printable.patch | 68 ++ aports/busybox/0003-ash-exec-busybox.static.patch | 22 + .../0004-app-location-for-cpio-vi-and-lspci.patch | 51 + ...-udhcpc-set-default-discover-retries-to-5.patch | 55 + ...ng-make-ping-work-without-root-privileges.patch | 206 ++++ .../0007-fbsplash-support-console-switching.patch | 179 +++ ...pport-image-and-bar-alignment-and-positio.patch | 176 +++ ...upport-generating-kmod-binary-index-files.patch | 507 ++++++++ ...for-not-following-symlinks-when-recursing.patch | 56 + ...012-udhcpc-Don-t-background-if-n-is-given.patch | 96 ++ aports/busybox/APKBUILD | 210 ++++ aports/busybox/acpid.initd | 14 + aports/busybox/acpid.logrotate | 8 + aports/busybox/config | 1210 ++++++++++++++++++++ aports/busybox/crond.confd | 2 + aports/busybox/crond.initd | 11 + aports/busybox/default.script | 177 +++ aports/busybox/mdev.conf | 134 +++ aports/busybox/mdev.initd | 39 + aports/busybox/persistent-storage | 68 ++ aports/busybox/syslog.confd | 1 + aports/busybox/syslog.initd | 14 + aports/busybox/udhcpd.initd | 11 + 34 files changed, 4211 insertions(+) create mode 100644 aports/busybox/0001-adduser-default-to-sbin-nologin-as-shell-for-system-.patch create mode 100644 aports/busybox/0001-ash-add-built-in-BB_ASH_VERSION-variable.patch create mode 100644 aports/busybox/0001-cpio-add-support-for-ignore-devno-like-GNU-cpio.patch create mode 100644 aports/busybox/0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch create mode 100644 aports/busybox/0001-modutils-check-ELF-header-before-calling-finit_module.patch create mode 100644 aports/busybox/0001-nologin-Install-applet-to-sbin-instead-of-usr-sbin.patch create mode 100644 aports/busybox/0001-pgrep-add-support-for-matching-against-UID-and-RUID.patch create mode 100644 aports/busybox/0001-properly-fix-wget-https-support.patch create mode 100644 aports/busybox/0001-rev-correct-output-for-long-input-lines.patch create mode 100644 aports/busybox/0002-cpio-add-support-for-renumber-inodes-like-GNU-cpio.patch create mode 100644 aports/busybox/0002-fsck-resolve-LABEL-.-UUID-.-spec-to-device.patch create mode 100644 aports/busybox/0002-nslookup-sanitize-all-printed-strings-with-printable.patch create mode 100644 aports/busybox/0003-ash-exec-busybox.static.patch create mode 100644 aports/busybox/0004-app-location-for-cpio-vi-and-lspci.patch create mode 100644 aports/busybox/0005-udhcpc-set-default-discover-retries-to-5.patch create mode 100644 aports/busybox/0006-ping-make-ping-work-without-root-privileges.patch create mode 100644 aports/busybox/0007-fbsplash-support-console-switching.patch create mode 100644 aports/busybox/0008-fbsplash-support-image-and-bar-alignment-and-positio.patch create mode 100644 aports/busybox/0009-depmod-support-generating-kmod-binary-index-files.patch create mode 100644 aports/busybox/0010-Add-flag-for-not-following-symlinks-when-recursing.patch create mode 100644 aports/busybox/0012-udhcpc-Don-t-background-if-n-is-given.patch create mode 100644 aports/busybox/APKBUILD create mode 100644 aports/busybox/acpid.initd create mode 100644 aports/busybox/acpid.logrotate create mode 100644 aports/busybox/config create mode 100644 aports/busybox/crond.confd create mode 100644 aports/busybox/crond.initd create mode 100644 aports/busybox/default.script create mode 100644 aports/busybox/mdev.conf create mode 100644 aports/busybox/mdev.initd create mode 100644 aports/busybox/persistent-storage create mode 100644 aports/busybox/syslog.confd create mode 100644 aports/busybox/syslog.initd create mode 100644 aports/busybox/udhcpd.initd (limited to 'aports/busybox') diff --git a/aports/busybox/0001-adduser-default-to-sbin-nologin-as-shell-for-system-.patch b/aports/busybox/0001-adduser-default-to-sbin-nologin-as-shell-for-system-.patch new file mode 100644 index 0000000..47f9f9a --- /dev/null +++ b/aports/busybox/0001-adduser-default-to-sbin-nologin-as-shell-for-system-.patch @@ -0,0 +1,23 @@ +From eceebc4fbf064ca04d0f0a639c8a7c600190170f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Sun, 13 Jan 2019 19:07:16 +0100 +Subject: [PATCH] adduser: default to /sbin/nologin as shell for system + accounts + +--- + loginutils/adduser.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/loginutils/adduser.c b/loginutils/adduser.c +index b2b5be5b3..9326a9795 100644 +--- a/loginutils/adduser.c ++++ b/loginutils/adduser.c +@@ -235,7 +235,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) + usegroup = "nogroup"; + } + if (!(opts & OPT_SHELL)) { +- pw.pw_shell = (char *) "/bin/false"; ++ pw.pw_shell = (char *) "/sbin/nologin"; + } + } + pw.pw_gid = usegroup ? xgroup2gid(usegroup) : -1; /* exits on failure */ diff --git a/aports/busybox/0001-ash-add-built-in-BB_ASH_VERSION-variable.patch b/aports/busybox/0001-ash-add-built-in-BB_ASH_VERSION-variable.patch new file mode 100644 index 0000000..f7f901f --- /dev/null +++ b/aports/busybox/0001-ash-add-built-in-BB_ASH_VERSION-variable.patch @@ -0,0 +1,83 @@ +From cf95fcc20717e4c0906109b13565fdd06d874ee0 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Wed, 10 Mar 2021 23:38:57 -0700 +Subject: [PATCH] ash: add built-in $BB_ASH_VERSION variable + +This is helpful for detecting if the shell is busybox ash or not, +which is necessary for enabling ash-specific features in /etc/profile +and Alpine's default $ENV. + +https://gitlab.alpinelinux.org/alpine/aports/-/issues/12398 outlines +the rationale for detecting what shell is running in /etc/profile and +similar. + +function old new delta +.rodata 77899 77925 +26 +varinit_data 360 384 +24 +------------------------------------------------------------------------------ +(add/remove: 0/0 grow/shrink: 2/0 up/down: 50/0) Total: 50 bytes + +Signed-off-by: Ariadne Conill +--- + shell/ash.c | 26 +++++++++++++++++++------- + 1 file changed, 19 insertions(+), 7 deletions(-) + +diff --git a/shell/ash.c b/shell/ash.c +index 6a16833b1..b8525dd57 100644 +--- a/shell/ash.c ++++ b/shell/ash.c +@@ -153,6 +153,14 @@ + //config: you to run the specified command or builtin, + //config: even when there is a function with the same name. + //config: ++//config:config ASH_VERSION_VAR ++//config: bool "declare $BB_ASH_VERSION variable" ++//config: default y ++//config: depends on SHELL_ASH ++//config: help ++//config: Enable support for declaring the $BB_ASH_VERSION variable, ++//config: which is set as the busybox version. ++//config: + //config:endif # ash options + + //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) +@@ -2109,6 +2117,9 @@ static const struct { + { VSTRFIXED|VTEXTFIXED , "PS1=$ " , NULL }, + { VSTRFIXED|VTEXTFIXED , "PS2=> " , NULL }, + { VSTRFIXED|VTEXTFIXED , "PS4=+ " , NULL }, ++#if ENABLE_ASH_VERSION_VAR ++ { VSTRFIXED|VTEXTFIXED , "BB_ASH_VERSION=" BB_VER, NULL }, ++#endif + #if ENABLE_ASH_GETOPTS + { VSTRFIXED|VTEXTFIXED , defoptindvar, getoptsreset }, + #endif +@@ -2159,18 +2170,19 @@ extern struct globals_var *BB_GLOBAL_CONST ash_ptr_to_globals_var; + #define vps1 varinit[VAR_OFFSET1 + 2] + #define vps2 varinit[VAR_OFFSET1 + 3] + #define vps4 varinit[VAR_OFFSET1 + 4] ++#define VAR_OFFSET2 (VAR_OFFSET1 + ENABLE_ASH_VERSION_VAR) + #if ENABLE_ASH_GETOPTS +-# define voptind varinit[VAR_OFFSET1 + 5] ++# define voptind varinit[VAR_OFFSET2 + 5] + #endif +-#define VAR_OFFSET2 (VAR_OFFSET1 + ENABLE_ASH_GETOPTS) +-#define vlineno varinit[VAR_OFFSET2 + 5] ++#define VAR_OFFSET3 (VAR_OFFSET2 + ENABLE_ASH_GETOPTS) ++#define vlineno varinit[VAR_OFFSET3 + 5] + #if ENABLE_ASH_RANDOM_SUPPORT +-# define vrandom varinit[VAR_OFFSET2 + 6] ++# define vrandom varinit[VAR_OFFSET3 + 6] + #endif +-#define VAR_OFFSET3 (VAR_OFFSET2 + ENABLE_ASH_RANDOM_SUPPORT) ++#define VAR_OFFSET4 (VAR_OFFSET2 + ENABLE_ASH_RANDOM_SUPPORT) + #if BASH_EPOCH_VARS +-# define vepochs varinit[VAR_OFFSET3 + 6] +-# define vepochr varinit[VAR_OFFSET3 + 7] ++# define vepochs varinit[VAR_OFFSET4 + 6] ++# define vepochr varinit[VAR_OFFSET4 + 7] + #endif + #define INIT_G_var() do { \ + unsigned i; \ +-- +2.30.2 + diff --git a/aports/busybox/0001-cpio-add-support-for-ignore-devno-like-GNU-cpio.patch b/aports/busybox/0001-cpio-add-support-for-ignore-devno-like-GNU-cpio.patch new file mode 100644 index 0000000..a9b0b8f --- /dev/null +++ b/aports/busybox/0001-cpio-add-support-for-ignore-devno-like-GNU-cpio.patch @@ -0,0 +1,88 @@ +From 808d176a4da607ed3187d58605d089b373694ba2 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Mon, 28 Jun 2021 07:09:25 -0600 +Subject: [PATCH 1/2] cpio: add support for --ignore-devno like GNU cpio + +The --ignore-devno option is used to set device numbers to (0, 0). +This can be useful in verifying whether a CPIO archive is reproducible. + +function old new delta +cpio_o 922 961 +39 +.rodata 78407 78422 +15 +bbconfig_config_bz2 6161 6167 +6 +packed_usage 25770 25764 -6 +------------------------------------------------------------------------------ +(add/remove: 0/0 grow/shrink: 3/1 up/down: 60/-6) Total: 54 bytes + +Signed-off-by: Ariadne Conill +--- + archival/cpio.c | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/archival/cpio.c b/archival/cpio.c +index d84f6937d..4d386d38d 100644 +--- a/archival/cpio.c ++++ b/archival/cpio.c +@@ -38,6 +38,13 @@ + //config: depends on FEATURE_CPIO_O + //config: help + //config: Passthrough mode. Rarely used. ++//config: ++//config:config FEATURE_CPIO_IGNORE_DEVNO ++//config: bool "Support --ignore-devno like GNU cpio" ++//config: default y ++//config: depends on FEATURE_CPIO_O && LONG_OPTS ++//config: help ++//config: Optionally ignore device numbers when creating archives. + + //applet:IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP)) + +@@ -75,6 +82,9 @@ + //usage: "\n -R USER[:GRP] Set owner of created files" + //usage: "\n -L Dereference symlinks" + //usage: "\n -0 Input is separated by NULs" ++//usage: IF_FEATURE_CPIO_IGNORE_DEVNO( ++//usage: "\n --ignore-devno" ++//usage: ) + + /* GNU cpio 2.9 --help (abridged): + +@@ -162,11 +172,13 @@ enum { + IF_FEATURE_CPIO_P(OPTBIT_PASSTHROUGH,) + IF_LONG_OPTS( OPTBIT_QUIET ,) + IF_LONG_OPTS( OPTBIT_2STDOUT ,) ++ IF_FEATURE_CPIO_IGNORE_DEVNO(OPTBIT_IGNORE_DEVNO,) + OPT_CREATE = IF_FEATURE_CPIO_O((1 << OPTBIT_CREATE )) + 0, + OPT_FORMAT = IF_FEATURE_CPIO_O((1 << OPTBIT_FORMAT )) + 0, + OPT_PASSTHROUGH = IF_FEATURE_CPIO_P((1 << OPTBIT_PASSTHROUGH)) + 0, + OPT_QUIET = IF_LONG_OPTS( (1 << OPTBIT_QUIET )) + 0, + OPT_2STDOUT = IF_LONG_OPTS( (1 << OPTBIT_2STDOUT )) + 0, ++ OPT_IGNORE_DEVNO = IF_FEATURE_CPIO_IGNORE_DEVNO((1 << OPTBIT_IGNORE_DEVNO)) + 0, + }; + + #define OPTION_STR "it0uvdmLF:R:" +@@ -304,6 +316,11 @@ static NOINLINE int cpio_o(void) + } + } + ++#if ENABLE_FEATURE_CPIO_IGNORE_DEVNO ++ if (option_mask32 & OPT_IGNORE_DEVNO) ++ st.st_dev = st.st_rdev = 0; ++#endif ++ + bytes += printf("070701" + "%08X%08X%08X%08X%08X%08X%08X" + "%08X%08X%08X%08X" /* GNU cpio uses uppercase hex */ +@@ -379,6 +396,9 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) + "null\0" No_argument "0" + "quiet\0" No_argument "\xff" + "to-stdout\0" No_argument "\xfe" ++#if ENABLE_FEATURE_CPIO_IGNORE_DEVNO ++ "ignore-devno\0" No_argument "\xfd" ++#endif + ; + #endif + +-- +2.32.0 + diff --git a/aports/busybox/0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch b/aports/busybox/0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch new file mode 100644 index 0000000..1d1716e --- /dev/null +++ b/aports/busybox/0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch @@ -0,0 +1,40 @@ +From 0c8da1bead8ffaf270b4b723ead2c517371405d7 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Sun, 3 Apr 2022 12:14:33 +0000 +Subject: [PATCH 1/2] libbb: sockaddr2str: ensure only printable characters are + returned for the hostname part + +CVE: Pending +Upstream-Status: Pending +Signed-off-by: Ariadne Conill +--- + libbb/xconnect.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/libbb/xconnect.c b/libbb/xconnect.c +index 0e0b247b8..02c061e67 100644 +--- a/libbb/xconnect.c ++++ b/libbb/xconnect.c +@@ -497,8 +497,9 @@ static char* FAST_FUNC sockaddr2str(const struct sockaddr *sa, int flags) + ); + if (rc) + return NULL; ++ /* ensure host contains only printable characters */ + if (flags & IGNORE_PORT) +- return xstrdup(host); ++ return xstrdup(printable_string(host)); + #if ENABLE_FEATURE_IPV6 + if (sa->sa_family == AF_INET6) { + if (strchr(host, ':')) /* heh, it's not a resolved hostname */ +@@ -509,7 +510,7 @@ static char* FAST_FUNC sockaddr2str(const struct sockaddr *sa, int flags) + #endif + /* For now we don't support anything else, so it has to be INET */ + /*if (sa->sa_family == AF_INET)*/ +- return xasprintf("%s:%s", host, serv); ++ return xasprintf("%s:%s", printable_string(host), serv); + /*return xstrdup(host);*/ + } + +-- +2.35.1 + diff --git a/aports/busybox/0001-modutils-check-ELF-header-before-calling-finit_module.patch b/aports/busybox/0001-modutils-check-ELF-header-before-calling-finit_module.patch new file mode 100644 index 0000000..813010e --- /dev/null +++ b/aports/busybox/0001-modutils-check-ELF-header-before-calling-finit_module.patch @@ -0,0 +1,152 @@ +Patch-Source: http://lists.busybox.net/pipermail/busybox/2021-January/088398.html +Patch-Source: http://lists.busybox.net/pipermail/busybox/2021-January/088399.html +See-Also: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13427 + +The purpose of this patch is to remove confusing error messages +"Module has invalid ELF structures" produced by kernel when loading gzip +compressed kernel modules using busybox modprobe. +-- +From: Qu Wenruo +Date: Sun, 03 Jan 2021 04:10:52 +0000 +Subject: [PATCH v2] modutils: check ELF header before calling finit_module() + +finit_module() and init_module() system calls have clear specification +to only accept valid ELF image. + +Although we try finit_module() on compressed modules to let the kernel +determine if it's an ELF image, but it's not ideal, especially when +newer kernel will complain when some invalid files/memory is passed in. + +Treat the kernel better by just doing a very basic ELF header check +before calling finit_module(). + +Signed-off-by: Qu Wenruo + +diff --git a/modutils/modutils.c b/modutils/modutils.c +index f7ad5e8058fe..037d609e42df 100644 +--- a/modutils/modutils.c ++++ b/modutils/modutils.c +@@ -7,6 +7,7 @@ + */ + #include "modutils.h" + ++#include + #include + + #define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts) +@@ -186,6 +187,33 @@ void* FAST_FUNC try_to_mmap_module(const char *filename, size_t *image_size_p) + } + #endif + ++#ifdef __NR_finit_module ++/* ++ * Return: ++ * 0 on success, ++ * <0 for error. ++ * ++ * finit_module()/init_module() only accepts ELF format. ++ * Do basic ELF check to avoid calling finit_module() with compressed module. ++ */ ++static int check_elf_header(int fd) ++{ ++ unsigned char buf[EI_NIDENT]; ++ int ret; ++ ++ ret = pread(fd, buf, sizeof(buf), 0); ++ if (ret < sizeof(buf)) ++ return -EIO; ++ if (buf[EI_MAG0] != ELFMAG0 || ++ buf[EI_MAG1] != ELFMAG1 || ++ buf[EI_MAG2] != ELFMAG2 || ++ buf[EI_MAG3] != ELFMAG3) ++ return -EINVAL; ++ /* Other more comprehensive check will be done inside kernel */ ++ return 0; ++} ++#endif ++ + /* Return: + * 0 on success, + * -errno on open/read error, +@@ -212,12 +240,19 @@ int FAST_FUNC bb_init_module(const char *filename, const char *options) + * to only allow loading of modules off of secure storage (like a read- + * only rootfs) which needs the finit_module call. If it fails, we fall + * back to normal module loading to support compressed modules. ++ * ++ * Note that finit_module()/init_module() only accept ELF image, do ++ * basic check before calling finit_module() to avoid kernel ++ * complaining. + */ + # ifdef __NR_finit_module + { + int fd = open(filename, O_RDONLY | O_CLOEXEC); + if (fd >= 0) { +- rc = finit_module(fd, options, 0) != 0; ++ if (!check_elf_header(fd)) ++ rc = finit_module(fd, options, 0) != 0; ++ else ++ rc = 1; + close(fd); + if (rc == 0) + return rc; + +diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c +index db44a2ed0ab5..d2cd6a64c1d0 100644 +--- a/modutils/modprobe-small.c ++++ b/modutils/modprobe-small.c +@@ -24,6 +24,7 @@ + //kbuild:lib-$(CONFIG_MODPROBE_SMALL) += modprobe-small.o + + #include "libbb.h" ++#include /* for ELF header magic */ + /* After libbb.h, since it needs sys/types.h on some systems */ + #include /* uname() */ + #include +@@ -249,6 +250,33 @@ static const char *moderror(int err) + } + } + ++#ifdef __NR_finit_module ++/* ++ * Return: ++ * 0 on success, ++ * <0 for error. ++ * ++ * finit_module()/init_module() only accepts ELF format. ++ * Do basic ELF check to avoid calling finit_module() with compressed module. ++ */ ++static int check_elf_header(int fd) ++{ ++ unsigned char buf[EI_NIDENT]; ++ int ret; ++ ++ ret = pread(fd, buf, sizeof(buf), 0); ++ if (ret < sizeof(buf)) ++ return -EIO; ++ if (buf[EI_MAG0] != ELFMAG0 || ++ buf[EI_MAG1] != ELFMAG1 || ++ buf[EI_MAG2] != ELFMAG2 || ++ buf[EI_MAG3] != ELFMAG3) ++ return -EINVAL; ++ /* Other more comprehensive check will be done inside kernel */ ++ return 0; ++} ++#endif ++ + static int load_module(const char *fname, const char *options) + { + #if 1 +@@ -272,7 +300,10 @@ static int load_module(const char *fname, const char *options) + { + int fd = open(fname, O_RDONLY | O_CLOEXEC); + if (fd >= 0) { +- r = finit_module(fd, options, 0) != 0; ++ if (!check_elf_header(fd)) ++ r = finit_module(fd, options, 0) != 0; ++ else ++ r = 1; + close(fd); + } + } +-- +2.29.2 diff --git a/aports/busybox/0001-nologin-Install-applet-to-sbin-instead-of-usr-sbin.patch b/aports/busybox/0001-nologin-Install-applet-to-sbin-instead-of-usr-sbin.patch new file mode 100644 index 0000000..0cc4db9 --- /dev/null +++ b/aports/busybox/0001-nologin-Install-applet-to-sbin-instead-of-usr-sbin.patch @@ -0,0 +1,27 @@ +From fa5c4b2e60a98944863097b448960d0744916b1f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Wed, 13 Feb 2019 22:32:44 +0100 +Subject: [PATCH] nologin: Install applet to /sbin instead of /usr/sbin + +This is required to retain compatibility with our old custom nologin +applet written in C which was also installed to /sbin. + +Compatibility with the old path is required because login shell paths +are hardcoded in /etc/passwd. +--- + util-linux/nologin.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/util-linux/nologin.c b/util-linux/nologin.c +index 5e5e42305..b03470ac6 100644 +--- a/util-linux/nologin.c ++++ b/util-linux/nologin.c +@@ -19,7 +19,7 @@ + //config: If you know these will be available externally you can + //config: disable this option. + +-//applet:IF_NOLOGIN(APPLET_SCRIPTED(nologin, scripted, BB_DIR_USR_SBIN, BB_SUID_DROP, nologin)) ++//applet:IF_NOLOGIN(APPLET_SCRIPTED(nologin, scripted, BB_DIR_SBIN, BB_SUID_DROP, nologin)) + + //usage:#define nologin_trivial_usage + //usage: "" diff --git a/aports/busybox/0001-pgrep-add-support-for-matching-against-UID-and-RUID.patch b/aports/busybox/0001-pgrep-add-support-for-matching-against-UID-and-RUID.patch new file mode 100644 index 0000000..7abfb09 --- /dev/null +++ b/aports/busybox/0001-pgrep-add-support-for-matching-against-UID-and-RUID.patch @@ -0,0 +1,138 @@ +From 648255c510f9a3f668651842b58798f07ad4c64a Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Mon, 22 Nov 2021 18:33:02 -0600 +Subject: [PATCH] pgrep: add support for matching against UID and RUID + +This is standard functionality on every other pgrep implementation I +found, namely the ones in Illumos, FreeBSD, Linux procps, and macOS. + +Additionally, real world scripts like pipewire-session are dependent +on it being present. + +function old new delta +pgrep_main 818 1007 +189 +packed_usage 26001 26032 +31 +.rodata 78544 78548 +4 +------------------------------------------------------------------------------ +(add/remove: 0/0 grow/shrink: 3/0 up/down: 224/0) Total: 224 bytes + +Signed-off-by: Ariadne Conill +--- + procps/pgrep.c | 37 +++++++++++++++++++++++++++++++++---- + 1 file changed, 33 insertions(+), 4 deletions(-) + +diff --git a/procps/pgrep.c b/procps/pgrep.c +index 6d25c247e..6a12ac23b 100644 +--- a/procps/pgrep.c ++++ b/procps/pgrep.c +@@ -42,6 +42,8 @@ + //usage: "\n -x Match whole name (not substring)" + //usage: "\n -s Match session ID (0 for current)" + //usage: "\n -P Match parent process ID" ++//usage: "\n -u EUID Match against effective UID" ++//usage: "\n -U UID Match against UID" + //usage: + //usage:#define pkill_trivial_usage + //usage: "[-l|-SIGNAL] [-xfvno] [-s SID|-P PPID|PATTERN]" +@@ -55,6 +57,8 @@ + //usage: "\n -v Negate the match" + //usage: "\n -n Signal the newest process only" + //usage: "\n -o Signal the oldest process only" ++//usage: "\n -u EUID Match against effective UID" ++//usage: "\n -U UID Match against UID" + + #include "libbb.h" + #include "xregex.h" +@@ -64,7 +68,7 @@ + #define pkill (ENABLE_PKILL && (!ENABLE_PGREP || applet_name[1] == 'k')) + + enum { +- /* "vlafxons:+P:+" */ ++ /* "vlafxonu:U:s:+P:+" */ + OPTBIT_V = 0, /* must be first, we need OPT_INVERT = 0/1 */ + OPTBIT_L, + OPTBIT_A, +@@ -72,6 +76,8 @@ enum { + OPTBIT_X, + OPTBIT_O, + OPTBIT_N, ++ OPTBIT_U, ++ OPTBIT_UL, + OPTBIT_S, + OPTBIT_P, + }; +@@ -85,6 +91,8 @@ enum { + #define OPT_LAST (opt & (1 << OPTBIT_N)) + #define OPT_SID (opt & (1 << OPTBIT_S)) + #define OPT_PPID (opt & (1 << OPTBIT_P)) ++#define OPT_EUID (opt & (1 << OPTBIT_UL)) ++#define OPT_RUID (opt & (1 << OPTBIT_U)) + + static void act(unsigned pid, char *cmd, int signo) + { +@@ -105,7 +113,8 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv) + unsigned opt; + int scan_mask; + int matched_pid; +- int sid2match, ppid2match; ++ int sid2match, ppid2match, uid2match, euid2match; ++ char *uid_arg = NULL, *euid_arg = NULL; + char *cmd_last; + procps_status_t *proc; + /* These are initialized to 0 */ +@@ -131,7 +140,9 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv) + /* Parse remaining options */ + ppid2match = -1; + sid2match = -1; +- opt = getopt32(argv, "vlafxons:+P:+", &sid2match, &ppid2match); ++ uid2match = -1; ++ euid2match = -1; ++ opt = getopt32(argv, "vlafxonu:U:s:+P:+", &euid_arg, &uid_arg, &sid2match, &ppid2match); + argv += optind; + + if (pkill && OPT_LIST) { /* -l: print the whole signal list */ +@@ -147,8 +158,18 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv) + if (OPT_FULL) + scan_mask |= PSSCAN_ARGVN; + ++ if (euid_arg) { ++ scan_mask |= PSSCAN_UIDGID; ++ euid2match = get_ug_id(euid_arg, xuname2uid); ++ } ++ ++ if (uid_arg) { ++ scan_mask |= PSSCAN_RUIDGID; ++ uid2match = get_ug_id(uid_arg, xuname2uid); ++ } ++ + /* One pattern is required, if no -s and no -P */ +- if ((sid2match & ppid2match) < 0 && (!argv[0] || argv[1])) ++ if ((sid2match & ppid2match) < 0 && uid2match < 0 && euid2match < 0 && (!argv[0] || argv[1])) + bb_show_usage(); + + if (argv[0]) +@@ -170,6 +191,10 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv) + continue; + if (sid2match >= 0 && sid2match != proc->sid) + continue; ++ if (euid2match >= 0 && euid2match != proc->uid) ++ continue; ++ if (uid2match >= 0 && uid2match != proc->ruid) ++ continue; + } + + cmdlen = -1; +@@ -202,6 +227,10 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv) + goto got_it; + if (sid2match >= 0 && sid2match != proc->sid) + goto got_it; ++ if (euid2match >= 0 && euid2match != proc->uid) ++ goto got_it; ++ if (uid2match >= 0 && uid2match != proc->ruid) ++ goto got_it; + } + + match = !argv[0]; /* if no PATTERN, then it's a match, else... */ +-- +2.34.0 + diff --git a/aports/busybox/0001-properly-fix-wget-https-support.patch b/aports/busybox/0001-properly-fix-wget-https-support.patch new file mode 100644 index 0000000..7e59be7 --- /dev/null +++ b/aports/busybox/0001-properly-fix-wget-https-support.patch @@ -0,0 +1,69 @@ +From ad8843a3df89aabfa6ebae841de32f22a48c2166 Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Wed, 30 May 2018 09:52:20 +0000 +Subject: [PATCH] properly fix wget https support + +See: https://git.alpinelinux.org/cgit/aports/commit/?id=1d0560a9b6b5597b191e5aff69a31c2fe0aba273 +--- + networking/wget.c | 21 ++++++++++++--------- + 1 file changed, 12 insertions(+), 9 deletions(-) + +diff --git a/networking/wget.c b/networking/wget.c +index 6a9604421..96dd4c403 100644 +--- a/networking/wget.c ++++ b/networking/wget.c +@@ -57,7 +57,6 @@ + //config: bool "Support HTTPS using internal TLS code" + //config: default y + //config: depends on WGET +-//config: select TLS + //config: help + //config: wget will use internal TLS code to connect to https:// URLs. + //config: It also enables FTPS support, but it's not well tested yet. +@@ -760,10 +759,8 @@ static void spawn_ssl_client(const char *host, int network_fd, int flags) + int pid; + char *servername, *p; + +- if (!(option_mask32 & WGET_OPT_NO_CHECK_CERT)) { +- option_mask32 |= WGET_OPT_NO_CHECK_CERT; +- bb_simple_error_msg("note: TLS certificate validation not implemented"); +- } ++ if (ENABLE_SSL_CLIENT && !(option_mask32 & WGET_OPT_NO_CHECK_CERT)) ++ bb_simple_error_msg_and_die("note: TLS certificate validation not implemented"); + + servername = xstrdup(host); + p = strrchr(servername, ':'); +@@ -780,14 +777,14 @@ static void spawn_ssl_client(const char *host, int network_fd, int flags) + close(sp[0]); + xmove_fd(sp[1], 0); + xdup2(0, 1); +- if (BB_MMU) { ++ if (BB_MMU && ENABLE_TLS && (option_mask32 & WGET_OPT_NO_CHECK_CERT)) { + tls_state_t *tls = new_tls_state(); + tls->ifd = tls->ofd = network_fd; + tls_handshake(tls, servername); + tls_run_copy_loop(tls, flags); + exit(0); + } else { +- char *argv[6]; ++ char *argv[7], **a; + + xmove_fd(network_fd, 3); + argv[0] = (char*)"ssl_client"; +@@ -795,8 +792,14 @@ static void spawn_ssl_client(const char *host, int network_fd, int flags) + //TODO: if (!is_ip_address(servername))... + argv[2] = (char*)"-n"; + argv[3] = servername; +- argv[4] = (flags & TLSLOOP_EXIT_ON_LOCAL_EOF ? (char*)"-e" : NULL); +- argv[5] = NULL; ++ ++ a = &argv[4]; ++ if (flags & TLSLOOP_EXIT_ON_LOCAL_EOF) ++ *a++ = (char*)"-e"; ++ if (!ENABLE_SSL_CLIENT && (option_mask32 & WGET_OPT_NO_CHECK_CERT)) ++ *a++= (char*)"-I"; ++ *a = NULL; ++ + BB_EXECVP(argv[0], argv); + bb_perror_msg_and_die("can't execute '%s'", argv[0]); + } diff --git a/aports/busybox/0001-rev-correct-output-for-long-input-lines.patch b/aports/busybox/0001-rev-correct-output-for-long-input-lines.patch new file mode 100644 index 0000000..ba40a2f --- /dev/null +++ b/aports/busybox/0001-rev-correct-output-for-long-input-lines.patch @@ -0,0 +1,91 @@ +From 4357569fdc7bc482dea0ef0bff57a70e7f06523c Mon Sep 17 00:00:00 2001 +From: Ron Yorston +Date: Sat, 21 Aug 2021 09:36:27 +0100 +Subject: rev: correct output for long input lines + +The input buffer is initialised to a reasonable size and extended +if necessary. When this happened the offset into the buffer wasn't +reset to zero so subsequent lines were appended to the long line. + +Fix this and add some tests. + +function old new delta +rev_main 377 368 -9 +------------------------------------------------------------------------------ +(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-9) Total: -9 bytes + +Signed-off-by: Ron Yorston +Signed-off-by: Denys Vlasenko +--- + testsuite/rev.tests | 46 ++++++++++++++++++++++++++++++++++++++++++++++ + util-linux/rev.c | 1 + + 2 files changed, 47 insertions(+) + create mode 100755 testsuite/rev.tests + +diff --git a/testsuite/rev.tests b/testsuite/rev.tests +new file mode 100755 +index 000000000..dd65dcd3b +--- /dev/null ++++ b/testsuite/rev.tests +@@ -0,0 +1,46 @@ ++#!/bin/sh ++# Copyright 2021 by Ron Yorston ++# Licensed under GPLv2, see file LICENSE in this source tree. ++ ++. ./testing.sh ++ ++# testing "test name" "commands" "expected result" "file input" "stdin" ++ ++testing "rev works" \ ++ "rev input" \ ++"\ ++1 enil ++ ++3 enil ++" \ ++ "line 1\n\nline 3\n" \ ++ "" ++ ++testing "rev file with missing newline" \ ++ "rev input" \ ++"\ ++1 enil ++ ++3 enil" \ ++ "line 1\n\nline 3" \ ++ "" ++ ++testing "rev file with NUL character" \ ++ "rev input" \ ++"\ ++nil ++3 enil ++" \ ++ "lin\000e 1\n\nline 3\n" \ ++ "" ++ ++testing "rev file with long line" \ ++ "rev input" \ ++"\ +++--------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+--------------- ++cba ++" \ ++ "---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+--------------+\nabc\n" \ ++ "" ++ ++exit $FAILCOUNT +diff --git a/util-linux/rev.c b/util-linux/rev.c +index d439b4da8..63b005c67 100644 +--- a/util-linux/rev.c ++++ b/util-linux/rev.c +@@ -109,6 +109,7 @@ int rev_main(int argc UNUSED_PARAM, char **argv) + strrev(buf, strlen(buf)); + #endif + fputs_stdout(buf); ++ pos = 0; + } + fclose(fp); + } while (*argv); +-- +cgit v1.2.3 + diff --git a/aports/busybox/0002-cpio-add-support-for-renumber-inodes-like-GNU-cpio.patch b/aports/busybox/0002-cpio-add-support-for-renumber-inodes-like-GNU-cpio.patch new file mode 100644 index 0000000..9febb66 --- /dev/null +++ b/aports/busybox/0002-cpio-add-support-for-renumber-inodes-like-GNU-cpio.patch @@ -0,0 +1,129 @@ +From 67240ede641cdda29ef74a373bc9f5aa8a18f4e8 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Mon, 28 Jun 2021 08:23:09 -0600 +Subject: [PATCH 2/2] cpio: add support for --renumber-inodes like GNU cpio + +The --renumber-inodes option renumbers the inodes starting from 1, +so that the sequence of inodes is always stable. This helps with +reproducibility. + +function old new delta +cpio_o 961 1045 +84 +.rodata 78422 78440 +18 +bbconfig_config_bz2 6168 6164 -4 +packed_usage 25764 25756 -8 +------------------------------------------------------------------------------ +(add/remove: 0/0 grow/shrink: 2/2 up/down: 102/-12) Total: 90 bytes + +Signed-off-by: Ariadne Conill +--- + archival/cpio.c | 32 ++++++++++++++++++++++++++++++++ + 1 file changed, 32 insertions(+) + +diff --git a/archival/cpio.c b/archival/cpio.c +index 4d386d38d..14f0b5b84 100644 +--- a/archival/cpio.c ++++ b/archival/cpio.c +@@ -45,6 +45,13 @@ + //config: depends on FEATURE_CPIO_O && LONG_OPTS + //config: help + //config: Optionally ignore device numbers when creating archives. ++//config: ++//config:config FEATURE_CPIO_RENUMBER_INODES ++//config: bool "Support --renumber-inodes like GNU cpio" ++//config: default y ++//config: depends on FEATURE_CPIO_O && LONG_OPTS ++//config: help ++//config: Optionally renumber inodes when creating archives. + + //applet:IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP)) + +@@ -85,6 +92,9 @@ + //usage: IF_FEATURE_CPIO_IGNORE_DEVNO( + //usage: "\n --ignore-devno" + //usage: ) ++//usage: IF_FEATURE_CPIO_RENUMBER_INODES( ++//usage: "\n --renumber-inodes" ++//usage: ) + + /* GNU cpio 2.9 --help (abridged): + +@@ -173,18 +183,21 @@ enum { + IF_LONG_OPTS( OPTBIT_QUIET ,) + IF_LONG_OPTS( OPTBIT_2STDOUT ,) + IF_FEATURE_CPIO_IGNORE_DEVNO(OPTBIT_IGNORE_DEVNO,) ++ IF_FEATURE_CPIO_RENUMBER_INODES(OPTBIT_RENUMBER_INODES,) + OPT_CREATE = IF_FEATURE_CPIO_O((1 << OPTBIT_CREATE )) + 0, + OPT_FORMAT = IF_FEATURE_CPIO_O((1 << OPTBIT_FORMAT )) + 0, + OPT_PASSTHROUGH = IF_FEATURE_CPIO_P((1 << OPTBIT_PASSTHROUGH)) + 0, + OPT_QUIET = IF_LONG_OPTS( (1 << OPTBIT_QUIET )) + 0, + OPT_2STDOUT = IF_LONG_OPTS( (1 << OPTBIT_2STDOUT )) + 0, + OPT_IGNORE_DEVNO = IF_FEATURE_CPIO_IGNORE_DEVNO((1 << OPTBIT_IGNORE_DEVNO)) + 0, ++ OPT_RENUMBER_INODES = IF_FEATURE_CPIO_RENUMBER_INODES((1 << OPTBIT_RENUMBER_INODES)) + 0, + }; + + #define OPTION_STR "it0uvdmLF:R:" + + struct globals { + struct bb_uidgid_t owner_ugid; ++ ino_t next_inode; + } FIX_ALIASING; + #define G (*(struct globals*)bb_common_bufsiz1) + void BUG_cpio_globals_too_big(void); +@@ -218,6 +231,9 @@ static NOINLINE int cpio_o(void) + struct inodes_s *next; + struct name_s *names; + struct stat st; ++#if ENABLE_FEATURE_CPIO_RENUMBER_INODES ++ ino_t mapped_inode; ++#endif + }; + + struct inodes_s *links = NULL; +@@ -272,6 +288,10 @@ static NOINLINE int cpio_o(void) + l = xzalloc(sizeof(*l)); + l->st = st; + l->next = links; ++#if ENABLE_FEATURE_CPIO_RENUMBER_INODES ++ if (option_mask32 & OPT_RENUMBER_INODES) ++ l->mapped_inode = ++G.next_inode; ++#endif + links = l; + break; + } +@@ -290,6 +310,11 @@ static NOINLINE int cpio_o(void) + free(line); + continue; + } ++#if ENABLE_FEATURE_CPIO_RENUMBER_INODES ++ else if (option_mask32 & OPT_RENUMBER_INODES) { ++ st.st_ino = ++G.next_inode; ++ } ++#endif + } else { /* line == NULL: EOF */ + next_link: + if (links) { +@@ -297,6 +322,10 @@ static NOINLINE int cpio_o(void) + st = links->st; + name = links->names->name; + links->names = links->names->next; ++#if ENABLE_FEATURE_CPIO_RENUMBER_INODES ++ if (links->mapped_inode) ++ st.st_ino = links->mapped_inode; ++#endif + /* GNU cpio is reported to emit file data + * only for the last instance. Mimic that. */ + if (links->names == NULL) +@@ -398,6 +427,9 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) + "to-stdout\0" No_argument "\xfe" + #if ENABLE_FEATURE_CPIO_IGNORE_DEVNO + "ignore-devno\0" No_argument "\xfd" ++#endif ++#if ENABLE_FEATURE_CPIO_RENUMBER_INODES ++ "renumber-inodes\0" No_argument "\xfc" + #endif + ; + #endif +-- +2.32.0 + diff --git a/aports/busybox/0002-fsck-resolve-LABEL-.-UUID-.-spec-to-device.patch b/aports/busybox/0002-fsck-resolve-LABEL-.-UUID-.-spec-to-device.patch new file mode 100644 index 0000000..fd2503e --- /dev/null +++ b/aports/busybox/0002-fsck-resolve-LABEL-.-UUID-.-spec-to-device.patch @@ -0,0 +1,56 @@ +From 2e673aac06d661038001286fd389d1b45c511c66 Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Tue, 28 Nov 2017 13:23:17 +0100 +Subject: [PATCH] fsck: resolve LABEL=.../UUID=... spec to device + +--- + e2fsprogs/fsck.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c +index f5aa3dbe4..e2edc9747 100644 +--- a/e2fsprogs/fsck.c ++++ b/e2fsprogs/fsck.c +@@ -60,6 +60,7 @@ + //usage: "\n -t TYPE List of filesystem types to check" + + #include "libbb.h" ++#include "volume_id.h" + #include "common_bufsiz.h" + + /* "progress indicator" code is somewhat buggy and ext[23] specific. +@@ -524,12 +525,13 @@ static int wait_many(int flags) + * Execute a particular fsck program, and link it into the list of + * child processes we are waiting for. + */ +-static void execute(const char *type, const char *device, ++static void execute(const char *type, const char *spec, + const char *mntpt /*, int interactive */) + { + int i; + struct fsck_instance *inst; + pid_t pid; ++ char *device = (char *)spec; + + G.args[0] = xasprintf("fsck.%s", type); + +@@ -544,7 +546,8 @@ static void execute(const char *type, const char *device, + } + #endif + +- G.args[G.num_args - 2] = (char*)device; ++ resolve_mount_spec(&device); ++ G.args[G.num_args - 2] = device; + /* G.args[G.num_args - 1] = NULL; - already is */ + + if (G.verbose || G.noexecute) { +@@ -973,9 +976,6 @@ int fsck_main(int argc UNUSED_PARAM, char **argv) + + /* "/dev/blk" or "/path" or "UUID=xxx" or "LABEL=xxx" */ + if ((arg[0] == '/' && !opts_for_fsck) || strchr(arg, '=')) { +-// FIXME: must check that arg is a blkdev, or resolve +-// "/path", "UUID=xxx" or "LABEL=xxx" into block device name +-// ("UUID=xxx"/"LABEL=xxx" can probably shifted to fsck.auto duties) + devices = xrealloc_vector(devices, 2, num_devices); + devices[num_devices++] = arg; + continue; diff --git a/aports/busybox/0002-nslookup-sanitize-all-printed-strings-with-printable.patch b/aports/busybox/0002-nslookup-sanitize-all-printed-strings-with-printable.patch new file mode 100644 index 0000000..01c45c9 --- /dev/null +++ b/aports/busybox/0002-nslookup-sanitize-all-printed-strings-with-printable.patch @@ -0,0 +1,68 @@ +From 812b407e545b70b16cf32aade135b5c32eaf674f Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Sun, 3 Apr 2022 12:16:45 +0000 +Subject: [PATCH 2/2] nslookup: sanitize all printed strings with + printable_string + +Otherwise, terminal sequences can be injected, which enables various terminal injection +attacks from DNS results. + +CVE: Pending +Upstream-Status: Pending +Signed-off-by: Ariadne Conill +--- + networking/nslookup.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/networking/nslookup.c b/networking/nslookup.c +index 6da97baf4..4bdcde1b8 100644 +--- a/networking/nslookup.c ++++ b/networking/nslookup.c +@@ -407,7 +407,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len) + //printf("Unable to uncompress domain: %s\n", strerror(errno)); + return -1; + } +- printf(format, ns_rr_name(rr), dname); ++ printf(format, ns_rr_name(rr), printable_string(dname)); + break; + + case ns_t_mx: +@@ -422,7 +422,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len) + //printf("Cannot uncompress MX domain: %s\n", strerror(errno)); + return -1; + } +- printf("%s\tmail exchanger = %d %s\n", ns_rr_name(rr), n, dname); ++ printf("%s\tmail exchanger = %d %s\n", ns_rr_name(rr), n, printable_string(dname)); + break; + + case ns_t_txt: +@@ -434,7 +434,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len) + if (n > 0) { + memset(dname, 0, sizeof(dname)); + memcpy(dname, ns_rr_rdata(rr) + 1, n); +- printf("%s\ttext = \"%s\"\n", ns_rr_name(rr), dname); ++ printf("%s\ttext = \"%s\"\n", ns_rr_name(rr), printable_string(dname)); + } + break; + +@@ -454,7 +454,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len) + } + + printf("%s\tservice = %u %u %u %s\n", ns_rr_name(rr), +- ns_get16(cp), ns_get16(cp + 2), ns_get16(cp + 4), dname); ++ ns_get16(cp), ns_get16(cp + 2), ns_get16(cp + 4), printable_string(dname)); + break; + + case ns_t_soa: +@@ -483,7 +483,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len) + return -1; + } + +- printf("\tmail addr = %s\n", dname); ++ printf("\tmail addr = %s\n", printable_string(dname)); + cp += n; + + printf("\tserial = %lu\n", ns_get32(cp)); +-- +2.35.1 + diff --git a/aports/busybox/0003-ash-exec-busybox.static.patch b/aports/busybox/0003-ash-exec-busybox.static.patch new file mode 100644 index 0000000..8247e35 --- /dev/null +++ b/aports/busybox/0003-ash-exec-busybox.static.patch @@ -0,0 +1,22 @@ +From d06a13f4cd81aeda9b02d4da90ef2b941899d6c5 Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Thu, 4 Aug 2016 11:03:07 +0200 +Subject: [PATCH] ash: exec busybox.static + +--- + shell/ash.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/shell/ash.c b/shell/ash.c +index 051cc671f..73470eab2 100644 +--- a/shell/ash.c ++++ b/shell/ash.c +@@ -7991,6 +7991,8 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c + } + /* re-exec ourselves with the new arguments */ + execve(bb_busybox_exec_path, argv, envp); ++ execve("/bin/busybox.static",argv,envp); ++ execve("/bin/busybox",argv,envp); + /* If they called chroot or otherwise made the binary no longer + * executable, fall through */ + } diff --git a/aports/busybox/0004-app-location-for-cpio-vi-and-lspci.patch b/aports/busybox/0004-app-location-for-cpio-vi-and-lspci.patch new file mode 100644 index 0000000..964db5df --- /dev/null +++ b/aports/busybox/0004-app-location-for-cpio-vi-and-lspci.patch @@ -0,0 +1,51 @@ +From 3f44fe588d0d68ff5897928b65c0749505937d8d Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Tue, 27 Dec 2016 20:46:59 +0100 +Subject: [PATCH] app location for cpio, vi and lspci + +Adjust location to where alpine linux installs them +--- + archival/cpio.c | 2 +- + editors/vi.c | 2 +- + util-linux/lspci.c | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/archival/cpio.c b/archival/cpio.c +index d84f6937d..29e7d396a 100644 +--- a/archival/cpio.c ++++ b/archival/cpio.c +@@ -39,7 +39,7 @@ + //config: help + //config: Passthrough mode. Rarely used. + +-//applet:IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP)) ++//applet:IF_CPIO(APPLET(cpio, BB_DIR_USR_BIN, BB_SUID_DROP)) + + //kbuild:lib-$(CONFIG_CPIO) += cpio.o + +diff --git a/editors/vi.c b/editors/vi.c +index 3e1bd0820..774da291f 100644 +--- a/editors/vi.c ++++ b/editors/vi.c +@@ -176,7 +176,7 @@ + //config: Enable more verbose reporting of the results of yank, change, + //config: delete, undo and substitution commands. + +-//applet:IF_VI(APPLET(vi, BB_DIR_BIN, BB_SUID_DROP)) ++//applet:IF_VI(APPLET(vi, BB_DIR_USR_BIN, BB_SUID_DROP)) + + //kbuild:lib-$(CONFIG_VI) += vi.o + +diff --git a/util-linux/lspci.c b/util-linux/lspci.c +index c22cbcc1e..70a623650 100644 +--- a/util-linux/lspci.c ++++ b/util-linux/lspci.c +@@ -15,7 +15,7 @@ + //config: + //config: This version uses sysfs (/sys/bus/pci/devices) only. + +-//applet:IF_LSPCI(APPLET_NOEXEC(lspci, lspci, BB_DIR_USR_BIN, BB_SUID_DROP, lspci)) ++//applet:IF_LSPCI(APPLET_NOEXEC(lspci, lspci, BB_DIR_USR_SBIN, BB_SUID_DROP, lspci)) + + //kbuild:lib-$(CONFIG_LSPCI) += lspci.o + diff --git a/aports/busybox/0005-udhcpc-set-default-discover-retries-to-5.patch b/aports/busybox/0005-udhcpc-set-default-discover-retries-to-5.patch new file mode 100644 index 0000000..ea15834 --- /dev/null +++ b/aports/busybox/0005-udhcpc-set-default-discover-retries-to-5.patch @@ -0,0 +1,55 @@ +From 7f626404022bb69cd314e2eea33a721d75cc933d Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Thu, 4 Aug 2016 12:46:55 +0200 +Subject: [PATCH] udhcpc: set default discover retries to 5 + +Some slower nics needs more attempts to get a lease +--- + networking/udhcp/d6_dhcpc.c | 4 ++-- + networking/udhcp/dhcpc.c | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c +index 8d11a7539..794441953 100644 +--- a/networking/udhcp/d6_dhcpc.c ++++ b/networking/udhcp/d6_dhcpc.c +@@ -1135,7 +1135,7 @@ static void client_background(void) + //usage: "\n -s PROG Run PROG at DHCP events (default "CONFIG_UDHCPC_DEFAULT_SCRIPT")" + //usage: "\n -B Request broadcast replies" + //usage: "\n -t N Send up to N discover packets" +-//usage: "\n -T SEC Pause between packets (default 3)" ++//usage: "\n -T SEC Pause between packets (default 5)" + //usage: "\n -A SEC Wait if lease is not obtained (default 20)" + //usage: USE_FOR_MMU( + //usage: "\n -b Background if lease is not obtained" +@@ -1180,7 +1180,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) + llist_t *list_x = NULL; + int tryagain_timeout = 20; + int discover_timeout = 3; +- int discover_retries = 3; ++ int discover_retries = 5; + struct in6_addr srv6_buf; + struct in6_addr ipv6_buf; + struct in6_addr *requested_ipv6; +diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c +index 331f13a8c..0c1b58d7c 100644 +--- a/networking/udhcp/dhcpc.c ++++ b/networking/udhcp/dhcpc.c +@@ -1173,7 +1173,7 @@ static void client_background(void) + //usage: "\n -p FILE Create pidfile" + //usage: "\n -B Request broadcast replies" + //usage: "\n -t N Send up to N discover packets (default 3)" +-//usage: "\n -T SEC Pause between packets (default 3)" ++//usage: "\n -T SEC Pause between packets (default 5)" + //usage: "\n -A SEC Wait if lease is not obtained (default 20)" + //usage: USE_FOR_MMU( + //usage: "\n -b Background if lease is not obtained" +@@ -1217,7 +1217,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) + llist_t *list_x = NULL; + int tryagain_timeout = 20; + int discover_timeout = 3; +- int discover_retries = 3; ++ int discover_retries = 5; + uint32_t server_id = server_id; /* for compiler */ + uint32_t requested_ip = 0; + int packet_num; diff --git a/aports/busybox/0006-ping-make-ping-work-without-root-privileges.patch b/aports/busybox/0006-ping-make-ping-work-without-root-privileges.patch new file mode 100644 index 0000000..ed35229 --- /dev/null +++ b/aports/busybox/0006-ping-make-ping-work-without-root-privileges.patch @@ -0,0 +1,206 @@ +From 278c73292f2cfc1ecef2dac71efdc7201c021211 Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Tue, 29 Mar 2016 18:59:22 +0200 +Subject: [PATCH] ping: make ping work without root privileges + +--- + networking/ping.c | 115 +++++++++++++++++++++++++++++++++++++--------- + 1 file changed, 94 insertions(+), 21 deletions(-) + +diff --git a/networking/ping.c b/networking/ping.c +index c4a15e06e..a2dccb57f 100644 +--- a/networking/ping.c ++++ b/networking/ping.c +@@ -170,6 +170,7 @@ enum { + pingsock = 0, + }; + ++static int using_dgram; + static void + #if ENABLE_PING6 + create_icmp_socket(len_and_sockaddr *lsa) +@@ -186,9 +187,23 @@ create_icmp_socket(void) + #endif + sock = socket(AF_INET, SOCK_RAW, 1); /* 1 == ICMP */ + if (sock < 0) { +- if (errno == EPERM) +- bb_simple_error_msg_and_die(bb_msg_perm_denied_are_you_root); +- bb_simple_perror_msg_and_die(bb_msg_can_not_create_raw_socket); ++ if (errno != EPERM) ++ bb_simple_perror_msg_and_die(bb_msg_can_not_create_raw_socket); ++#if defined(__linux__) || defined(__APPLE__) ++ /* We don't have root privileges. Try SOCK_DGRAM instead. ++ * Linux needs net.ipv4.ping_group_range for this to work. ++ * MacOSX allows ICMP_ECHO, ICMP_TSTAMP or ICMP_MASKREQ ++ */ ++#if ENABLE_PING6 ++ if (lsa->u.sa.sa_family == AF_INET6) ++ sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_ICMPV6); ++ else ++#endif ++ sock = socket(AF_INET, SOCK_DGRAM, 1); /* 1 == ICMP */ ++ if (sock < 0) ++#endif ++ bb_simple_error_msg_and_die(bb_msg_perm_denied_are_you_root); ++ using_dgram = 1; + } + + xmove_fd(sock, pingsock); +@@ -241,10 +256,12 @@ static void ping4(len_and_sockaddr *lsa) + bb_simple_perror_msg("recvfrom"); + continue; + } +- if (c >= 76) { /* ip + icmp */ +- struct iphdr *iphdr = (struct iphdr *) G.packet; ++ if (c >= 76 || using_dgram && (c == 64)) { /* ip + icmp */ ++ if(!using_dgram) { ++ struct iphdr *iphdr = (struct iphdr *) G.packet; + +- pkt = (struct icmp *) (G.packet + (iphdr->ihl << 2)); /* skip ip hdr */ ++ pkt = (struct icmp *) (G.packet + (iphdr->ihl << 2)); /* skip ip hdr */ ++ } else pkt = (struct icmp *) G.packet; + if (pkt->icmp_id != G.myid) + continue; /* not our ping */ + if (pkt->icmp_type == ICMP_ECHOREPLY) +@@ -653,19 +670,21 @@ static void unpack_tail(int sz, uint32_t *tp, + } + static int unpack4(char *buf, int sz, struct sockaddr_in *from) + { +- struct icmp *icmppkt; + struct iphdr *iphdr; ++ struct icmp *icmppkt; + int hlen; + + /* discard if too short */ + if (sz < (datalen + ICMP_MINLEN)) + return 0; ++ if(!using_dgram) { ++ /* check IP header */ ++ iphdr = (struct iphdr *) buf; ++ hlen = iphdr->ihl << 2; ++ sz -= hlen; ++ icmppkt = (struct icmp *) (buf + hlen); ++ } else icmppkt = (struct icmp *) buf; + +- /* check IP header */ +- iphdr = (struct iphdr *) buf; +- hlen = iphdr->ihl << 2; +- sz -= hlen; +- icmppkt = (struct icmp *) (buf + hlen); + if (icmppkt->icmp_id != myid) + return 0; /* not our ping */ + +@@ -677,7 +696,7 @@ static int unpack4(char *buf, int sz, struct sockaddr_in *from) + tp = (uint32_t *) icmppkt->icmp_data; + unpack_tail(sz, tp, + inet_ntoa(*(struct in_addr *) &from->sin_addr.s_addr), +- recv_seq, iphdr->ttl); ++ recv_seq, using_dgram ? 42 : iphdr->ttl); + return 1; + } + if (icmppkt->icmp_type != ICMP_ECHO) { +@@ -727,11 +746,31 @@ static void ping4(len_and_sockaddr *lsa) + int sockopt; + + pingaddr.sin = lsa->u.sin; +- if (source_lsa) { ++ if (source_lsa && !using_dgram) { + if (setsockopt(pingsock, IPPROTO_IP, IP_MULTICAST_IF, + &source_lsa->u.sa, source_lsa->len)) + bb_simple_error_msg_and_die("can't set multicast source interface"); + xbind(pingsock, &source_lsa->u.sa, source_lsa->len); ++ } else if(using_dgram) { ++ struct sockaddr_in sa; ++ socklen_t sl; ++ ++ sa.sin_family = AF_INET; ++ sa.sin_port = 0; ++ sa.sin_addr.s_addr = source_lsa ? ++ source_lsa->u.sin.sin_addr.s_addr : 0; ++ sl = sizeof(sa); ++ ++ if (bind(pingsock, (struct sockaddr *) &sa, sl) == -1) { ++ perror("bind"); ++ exit(2); ++ } ++ ++ if (getsockname(pingsock, (struct sockaddr *) &sa, &sl) == -1) { ++ perror("getsockname"); ++ exit(2); ++ } ++ myid = sa.sin_port; + } + + /* enable broadcast pings */ +@@ -748,6 +787,15 @@ static void ping4(len_and_sockaddr *lsa) + setsockopt_int(pingsock, IPPROTO_IP, IP_MULTICAST_TTL, opt_ttl); + } + ++ if(using_dgram) { ++ int hold = 65536; ++ if (setsockopt(pingsock, SOL_IP, IP_RECVTTL, (char *)&hold, sizeof(hold))) ++ perror("WARNING: setsockopt(IP_RECVTTL)"); ++ if (setsockopt(pingsock, SOL_IP, IP_RETOPTS, (char *)&hold, sizeof(hold))) ++ perror("WARNING: setsockopt(IP_RETOPTS)"); ++ ++ } ++ + signal(SIGINT, print_stats_and_exit); + + /* start the ping's going ... */ +@@ -785,10 +833,33 @@ static void ping6(len_and_sockaddr *lsa) + char control_buf[CMSG_SPACE(36)]; + + pingaddr.sin6 = lsa->u.sin6; +- if (source_lsa) ++ if (source_lsa && !using_dgram) + xbind(pingsock, &source_lsa->u.sa, source_lsa->len); ++ else if(using_dgram) { ++ struct sockaddr_in6 sa = {0}; ++ socklen_t sl; ++ ++ sa.sin6_family = AF_INET6; ++ sa.sin6_port = 0; ++ if(source_lsa) { ++ memcpy(&sa.sin6_addr, &source_lsa->u.sin6.sin6_addr, sizeof(struct in6_addr)); ++ } ++ sl = sizeof(sa); ++ ++ if (bind(pingsock, (struct sockaddr *) &sa, sl) == -1) { ++ perror("bind"); ++ exit(2); ++ } ++ ++ if (getsockname(pingsock, (struct sockaddr *) &sa, &sl) == -1) { ++ perror("getsockname"); ++ exit(2); ++ } ++ myid = sa.sin6_port; ++ } + + #ifdef ICMP6_FILTER ++ if(!using_dgram) + { + struct icmp6_filter filt; + if (!(option_mask32 & OPT_VERBOSE)) { +@@ -934,12 +1005,14 @@ static int common_ping_main(int opt, char **argv) + interval = INT_MAX/1000000; + G.interval_us = interval * 1000000; + +- myid = (uint16_t) getpid(); +- /* we can use native-endian ident, but other Unix ping/traceroute +- * utils use *big-endian pid*, and e.g. traceroute on our machine may be +- * *not* from busybox, idents may collide. Follow the convention: +- */ +- myid = htons(myid); ++ if (!using_dgram) { ++ myid = (uint16_t) getpid(); ++ /* we can use native-endian ident, but other Unix ping/traceroute ++ * utils use *big-endian pid*, and e.g. traceroute on our machine may be ++ * *not* from busybox, idents may collide. Follow the convention: ++ */ ++ myid = htons(myid); ++ } + hostname = argv[optind]; + #if ENABLE_PING6 + { diff --git a/aports/busybox/0007-fbsplash-support-console-switching.patch b/aports/busybox/0007-fbsplash-support-console-switching.patch new file mode 100644 index 0000000..8d19505 --- /dev/null +++ b/aports/busybox/0007-fbsplash-support-console-switching.patch @@ -0,0 +1,179 @@ +From 8fb815ec846d9ac64c89ac21cededc17f0b804c3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= +Date: Mon, 24 Sep 2012 07:58:29 +0300 +Subject: [PATCH] fbsplash: support console switching + +--- + miscutils/fbsplash.c | 82 ++++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 75 insertions(+), 7 deletions(-) + +diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c +index bc3c61055..1c206ef53 100644 +--- a/miscutils/fbsplash.c ++++ b/miscutils/fbsplash.c +@@ -47,7 +47,7 @@ + //kbuild:lib-$(CONFIG_FBSPLASH) += fbsplash.o + + //usage:#define fbsplash_trivial_usage +-//usage: "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD]" ++//usage: "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD] [-T tty]" + //usage:#define fbsplash_full_usage "\n\n" + //usage: " -s Image" + //usage: "\n -c Hide cursor" +@@ -57,11 +57,17 @@ + //usage: "\n BAR_R,BAR_G,BAR_B,IMG_LEFT,IMG_TOP" + //usage: "\n -f Control pipe (else exit after drawing image)" + //usage: "\n commands: 'NN' (% for progress bar) or 'exit'" ++//usage: "\n -T Switch to TTY to hide all console messages" + + #include "libbb.h" + #include "common_bufsiz.h" + #include + ++#include ++#include ++#include ++#include ++ + /* If you want logging messages on /tmp/fbsplash.log... */ + #define DEBUG 0 + +@@ -75,6 +81,8 @@ struct globals { + unsigned char *addr; // pointer to framebuffer memory + unsigned ns[9]; // n-parameters + const char *image_filename; ++ int silent_tty, fd_tty_s; ++ bool do_not_draw; + struct fb_var_screeninfo scr_var; + struct fb_fix_screeninfo scr_fix; + unsigned bytes_per_pixel; +@@ -488,6 +496,11 @@ static void init(const char *cfg_filename) + config_close(parser); + } + ++static void sighandler(int sig) ++{ ++ ioctl(G.fd_tty_s, VT_RELDISP, sig == SIGUSR1 ? 1 : 2); ++ G.do_not_draw = (sig != SIGUSR2); ++} + + int fbsplash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; + int fbsplash_main(int argc UNUSED_PARAM, char **argv) +@@ -497,6 +510,9 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + char *num_buf; + unsigned num; + bool bCursorOff; ++ int fd_tty0, active_vt; ++ struct vt_stat vtstat; ++ struct vt_mode vt; + + INIT_G(); + +@@ -504,8 +520,9 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + fb_device = "/dev/fb0"; + cfg_filename = NULL; + fifo_filename = NULL; +- bCursorOff = 1 & getopt32(argv, "cs:d:i:f:", +- &G.image_filename, &fb_device, &cfg_filename, &fifo_filename); ++ bCursorOff = 1 & getopt32(argv, "cs:d:i:f:T:+", ++ &G.image_filename, &fb_device, &cfg_filename, &fifo_filename, ++ &G.silent_tty); + + // parse configuration file + if (cfg_filename) +@@ -515,11 +532,43 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + if (!G.image_filename) + bb_show_usage(); + ++ fd_tty0 = get_console_fd_or_die(); ++ if (G.silent_tty) { ++ char buf[16]; ++ ++ /* Initialize TTY */ ++ bb_signals((1LL << SIGUSR1) | (1LL << SIGUSR2), sighandler); ++ snprintf(buf, sizeof(buf), "/dev/tty%d", G.silent_tty); ++ G.fd_tty_s = xopen(buf, O_RDWR | O_NOCTTY); ++ ++ /* Activate TTY */ ++ xioctl(fd_tty0, VT_GETSTATE, &vtstat); ++ active_vt = vtstat.v_active; ++ console_make_active(fd_tty0, G.silent_tty); ++ ++ /* Get notifications on console changes */ ++ vt.mode = VT_PROCESS; ++ vt.waitv = 0; ++ vt.relsig = SIGUSR1; ++ vt.acqsig = SIGUSR2; ++ ioctl(G.fd_tty_s, VT_SETMODE, &vt); ++ ++ /* Redirect all kernel messages to tty1 so that they don't get ++ * printed over our silent splash image. And clear it. */ ++ buf[0] = TIOCL_SETKMSGREDIRECT; ++ buf[1] = 1; ++ ioctl(G.fd_tty_s, TIOCLINUX, buf); ++ full_write(G.fd_tty_s, "\e[H\e[2J" "\e[?17;0c", 7+8); ++ ioctl(G.fd_tty_s, KDSETMODE, KD_GRAPHICS); ++ } else { ++ G.fd_tty_s = STDOUT_FILENO; ++ } ++ + fb_open(fb_device); + + if (fifo_filename && bCursorOff) { + // hide cursor (BEFORE any fb ops) +- full_write(STDOUT_FILENO, ESC"[?25l", 6); ++ full_write(G.fd_tty_s, ESC"[?25l", 6); + } + + fb_drawimage(); +@@ -527,6 +576,7 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + if (!fifo_filename) + return EXIT_SUCCESS; + ++ sig_block(SIGUSR1); + fp = xfopen_stdin(fifo_filename); + if (fp != stdin) { + // For named pipes, we want to support this: +@@ -542,8 +592,9 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + // and become an additional writer :) + open(fifo_filename, O_WRONLY); // errors are ignored + } +- + fb_drawprogressbar(0); ++ sig_unblock(SIGUSR1); ++ + // Block on read, waiting for some input. + // Use of style I/O allows to correctly + // handle a case when we have many buffered lines +@@ -558,12 +609,29 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + #if DEBUG + DEBUG_MESSAGE(itoa(num)); + #endif +- fb_drawprogressbar(num); ++ sig_block(SIGUSR1); ++ if (!G.do_not_draw) ++ fb_drawprogressbar(num); ++ sig_unblock(SIGUSR1); + } + free(num_buf); + } + +- if (bCursorOff) // restore cursor ++ if (G.silent_tty) { ++ usleep(100*1000); ++ ++ ioctl(G.fd_tty_s, VT_RELDISP, 1); ++ ioctl(G.fd_tty_s, KDSETMODE, KD_TEXT); ++ vt.mode = VT_AUTO; ++ vt.waitv = 0; ++ ioctl(G.fd_tty_s, VT_SETMODE, &vt); ++ close(G.fd_tty_s); ++ ++ xioctl(fd_tty0, VT_GETSTATE, &vtstat); ++ if (vtstat.v_active == G.silent_tty) ++ console_make_active(fd_tty0, active_vt); ++ ioctl(fd_tty0, VT_DISALLOCATE, (void *)(ptrdiff_t)G.silent_tty); ++ } else if (bCursorOff) // restore cursor + full_write(STDOUT_FILENO, ESC"[?25h", 6); + + return EXIT_SUCCESS; diff --git a/aports/busybox/0008-fbsplash-support-image-and-bar-alignment-and-positio.patch b/aports/busybox/0008-fbsplash-support-image-and-bar-alignment-and-positio.patch new file mode 100644 index 0000000..ab3421e --- /dev/null +++ b/aports/busybox/0008-fbsplash-support-image-and-bar-alignment-and-positio.patch @@ -0,0 +1,176 @@ +From cc005e48ebd831199789d9dfb1a9307e743ecdaa Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= +Date: Fri, 21 Nov 2014 16:06:34 +0200 +Subject: [PATCH] fbsplash: support image and bar alignment and positioning + +Needed to center a splash screen image in the initramfs. +--- + miscutils/fbsplash.c | 93 ++++++++++++++++++++++++++++++++------------ + 1 file changed, 69 insertions(+), 24 deletions(-) + +diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c +index 1c206ef53..500e04fcc 100644 +--- a/miscutils/fbsplash.c ++++ b/miscutils/fbsplash.c +@@ -54,7 +54,7 @@ + //usage: "\n -d Framebuffer device (default /dev/fb0)" + //usage: "\n -i Config file (var=value):" + //usage: "\n BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT" +-//usage: "\n BAR_R,BAR_G,BAR_B,IMG_LEFT,IMG_TOP" ++//usage: "\n BAR_R,BAR_G,BAR_B,IMG_LEFT,IMG_TOP,IMG_ALIGN" + //usage: "\n -f Control pipe (else exit after drawing image)" + //usage: "\n commands: 'NN' (% for progress bar) or 'exit'" + //usage: "\n -T Switch to TTY to hide all console messages" +@@ -73,13 +73,39 @@ + + #define ESC "\033" + ++enum { ++ bar_width, ++ bar_height, ++ bar_posx, ++ bar_posy, ++ bar_colr, ++ bar_colg, ++ bar_colb, ++ nimg_posx, ++ nimg_posy, ++ nimg_align, ++ num_ns_opts, ++ debug = num_ns_opts, ++}; ++ ++#define nbar_width ns[bar_width] ++#define nbar_height ns[bar_height] ++#define nbar_posx ns[bar_posx] ++#define nbar_posy ns[bar_posy] ++#define nbar_colr ns[bar_colr] ++#define nbar_colg ns[bar_colg] ++#define nbar_colb ns[bar_colb] ++#define img_posx ns[nimg_posx] ++#define img_posy ns[nimg_posy] ++#define img_align ns[nimg_align] ++ + struct globals { + #if DEBUG + bool bdebug_messages; // enable/disable logging + FILE *logfile_fd; // log file + #endif + unsigned char *addr; // pointer to framebuffer memory +- unsigned ns[9]; // n-parameters ++ unsigned ns[num_ns_opts]; // n-parameters + const char *image_filename; + int silent_tty, fd_tty_s; + bool do_not_draw; +@@ -96,16 +122,6 @@ struct globals { + SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ + } while (0) + +-#define nbar_width ns[0] // progress bar width +-#define nbar_height ns[1] // progress bar height +-#define nbar_posx ns[2] // progress bar horizontal position +-#define nbar_posy ns[3] // progress bar vertical position +-#define nbar_colr ns[4] // progress bar color red component +-#define nbar_colg ns[5] // progress bar color green component +-#define nbar_colb ns[6] // progress bar color blue component +-#define img_posx ns[7] // image horizontal position +-#define img_posy ns[8] // image vertical position +- + #if DEBUG + #define DEBUG_MESSAGE(strMessage, args...) \ + if (G.bdebug_messages) { \ +@@ -386,7 +402,7 @@ static void fb_drawimage(void) + FILE *theme_file; + char *read_ptr; + unsigned char *pixline; +- unsigned i, j, width, height, line_size; ++ int i, j, width, height, line_size, xoffs, yoffs, xstart; + + if (LONE_DASH(G.image_filename)) { + theme_file = stdin; +@@ -436,18 +452,39 @@ static void fb_drawimage(void) + line_size = width*3; + pixline = xmalloc(line_size); + +- if ((width + G.img_posx) > G.scr_var.xres) +- width = G.scr_var.xres - G.img_posx; +- if ((height + G.img_posy) > G.scr_var.yres) +- height = G.scr_var.yres - G.img_posy; +- for (j = 0; j < height; j++) { ++ xoffs = G.img_posx; ++ switch (G.img_align % 3) { ++ case 1: xoffs += (G.scr_var.xres - width) / 2; break; ++ case 2: xoffs += G.scr_var.xres - width; break; ++ } ++ xstart = 0; ++ if (xoffs < 0) { ++ xstart = -xoffs; ++ xoffs = 0; ++ } ++ if ((width + xoffs) > G.scr_var.xres) ++ width = G.scr_var.xres - xoffs; ++ ++ yoffs = G.img_posy; ++ switch (G.img_align / 3) { ++ case 1: yoffs += (G.scr_var.yres - height) / 2; break; ++ case 2: yoffs += G.scr_var.yres - height; break; ++ } ++ if ((height + yoffs) > G.scr_var.yres) ++ height = G.scr_var.yres - yoffs; ++ ++ for (j = 0; j < height; j++, yoffs++) { + unsigned char *pixel; + unsigned char *src; + + if (fread(pixline, 1, line_size, theme_file) != line_size) + bb_error_msg_and_die("bad PPM file '%s'", G.image_filename); +- pixel = pixline; +- src = G.addr + (G.img_posy + j) * G.scr_fix.line_length + G.img_posx * G.bytes_per_pixel; ++ ++ if (yoffs < 0) ++ continue; ++ ++ pixel = pixline + xstart * 3; ++ src = G.addr + yoffs * G.scr_fix.line_length + xoffs * G.bytes_per_pixel; + for (i = 0; i < width; i++) { + unsigned thispix = fb_pixel_value(pixel[0], pixel[1], pixel[2]); + fb_write_pixel(src, thispix); +@@ -466,11 +503,15 @@ static void fb_drawimage(void) + */ + static void init(const char *cfg_filename) + { ++ static const char align_names[] ALIGN1 = ++ "LT\0" "CT\0" "RT\0" ++ "LM\0" "CM\0" "RM\0" ++ "LB\0" "CB\0" "RB\0"; + static const char param_names[] ALIGN1 = + "BAR_WIDTH\0" "BAR_HEIGHT\0" + "BAR_LEFT\0" "BAR_TOP\0" + "BAR_R\0" "BAR_G\0" "BAR_B\0" +- "IMG_LEFT\0" "IMG_TOP\0" ++ "IMG_LEFT\0" "IMG_TOP\0" "IMG_ALIGN\0" + #if DEBUG + "DEBUG\0" + #endif +@@ -479,14 +520,18 @@ static void init(const char *cfg_filename) + parser_t *parser = config_open2(cfg_filename, xfopen_stdin); + while (config_read(parser, token, 2, 2, "#=", + (PARSE_NORMAL | PARSE_MIN_DIE) & ~(PARSE_TRIM | PARSE_COLLAPSE))) { +- unsigned val = xatoi_positive(token[1]); ++ unsigned val; + int i = index_in_strings(param_names, token[0]); + if (i < 0) + bb_error_msg_and_die("syntax error: %s", token[0]); +- if (i >= 0 && i < 9) ++ if (i == nimg_align) ++ val = index_in_strings(align_names, token[1]); ++ else ++ val = xatoi_positive(token[1]); ++ if (i < num_ns_opts) + G.ns[i] = val; + #if DEBUG +- if (i == 9) { ++ if (i == debug) { + G.bdebug_messages = val; + if (G.bdebug_messages) + G.logfile_fd = xfopen_for_write("/tmp/fbsplash.log"); diff --git a/aports/busybox/0009-depmod-support-generating-kmod-binary-index-files.patch b/aports/busybox/0009-depmod-support-generating-kmod-binary-index-files.patch new file mode 100644 index 0000000..9f697a5 --- /dev/null +++ b/aports/busybox/0009-depmod-support-generating-kmod-binary-index-files.patch @@ -0,0 +1,507 @@ +From 8d76137506e9c65404280694e56d9a7629d58280 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= +Date: Sun, 25 Oct 2015 22:21:41 +0200 +Subject: [PATCH] depmod: support generating kmod binary index files + +This allows to use busybox depmod, and run daemons using libkmod (or +even kmod modprobe if needed). + +About +1500 bytes when enabled. This patch merges some depmod code +paths, so when this is disabled it shrinks the code size a little bit. +--- + modutils/Config.src | 9 ++ + modutils/depmod.c | 281 ++++++++++++++++++++++++++++++++++++-------- + modutils/modprobe.c | 15 --- + modutils/modutils.c | 31 +++++ + modutils/modutils.h | 16 +++ + 5 files changed, 286 insertions(+), 66 deletions(-) + +diff --git a/modutils/Config.src b/modutils/Config.src +index 188296814..7a4c037ad 100644 +--- a/modutils/Config.src ++++ b/modutils/Config.src +@@ -152,6 +152,15 @@ config FEATURE_MODUTILS_ALIAS + + Say Y if unsure. + ++config FEATURE_MODUTILS_BIN ++ bool "Support for the kmod .bin file format" ++ default n ++ depends on DEPMOD && !MODPROBE_SMALL ++ help ++ Generate kmod compatible binary index files for .dep, .alias, ++ .symbols and .builtin files. Allows mixing use of busybox ++ modutils and kmod (binaries and library). ++ + config FEATURE_MODUTILS_SYMBOLS + bool "Support module.symbols file" + default y +diff --git a/modutils/depmod.c b/modutils/depmod.c +index b5244fc60..26e223753 100644 +--- a/modutils/depmod.c ++++ b/modutils/depmod.c +@@ -2,7 +2,7 @@ + /* + * depmod - generate modules.dep + * Copyright (c) 2008 Bernhard Reutner-Fischer +- * Copyrihgt (c) 2008 Timo Teras ++ * Copyrihgt (c) 2008-2015 Timo Teras + * Copyright (c) 2008 Vladimir Dronnikov + * + * Licensed under GPLv2 or later, see file LICENSE in this source tree. +@@ -26,6 +26,24 @@ + #include "modutils.h" + #include /* uname() */ + ++#define INDEX_MINCHAR 32 ++#define INDEX_MAXCHAR 128 ++ ++typedef struct index_node { ++ char *prefix; ++ llist_t *values; ++ struct index_node *children[INDEX_MAXCHAR-INDEX_MINCHAR]; ++} index_node; ++ ++struct globals { ++ module_db db; ++ index_node *root_node; ++} FIX_ALIASING; ++#define G (*ptr_to_globals) ++#define INIT_G() do { \ ++ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ ++} while (0) ++ + /* + * Theory of operation: + * - iterate over all modules and record their full path +@@ -53,18 +71,12 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA + + for (ptr = image; ptr < image + len - 10; ptr++) { + if (is_prefixed_with(ptr, "depends=")) { +- char *u; +- + ptr += 8; +- for (u = ptr; *u; u++) +- if (*u == '-') +- *u = '_'; +- ptr += string_to_llist(ptr, &e->deps, ","); ++ string_to_llist(replace_underscores(ptr), &e->deps, ","); + } else if (ENABLE_FEATURE_MODUTILS_ALIAS + && is_prefixed_with(ptr, "alias=") + ) { +- llist_add_to(&e->aliases, xstrdup(ptr + 6)); +- ptr += strlen(ptr); ++ llist_add_to(&e->aliases, replace_underscores(xstrdup(ptr + 6))); + } else if (ENABLE_FEATURE_MODUTILS_SYMBOLS + && is_prefixed_with(ptr, "__ksymtab_") + ) { +@@ -74,9 +86,10 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA + ) { + continue; + } +- llist_add_to(&e->symbols, xstrdup(ptr)); +- ptr += strlen(ptr); +- } ++ llist_add_to(&e->symbols, xasprintf("symbol:%s", ptr)); ++ } else ++ continue; ++ ptr += strlen(ptr); + } + free(image); + +@@ -108,12 +121,6 @@ static void order_dep_list(module_db *modules, module_entry *start, llist_t *add + } + } + +-static void xfreopen_write(const char *file, FILE *f) +-{ +- if (freopen(file, "w", f) == NULL) +- bb_perror_msg_and_die("can't open '%s'", file); +-} +- + //usage:#if !ENABLE_MODPROBE_SMALL + //usage:#define depmod_trivial_usage "[-n] [-b BASE] [VERSION] [MODFILES]..." + //usage:#define depmod_full_usage "\n\n" +@@ -167,6 +174,169 @@ enum { + OPT_C = (1 << 9), /* -C,--config etc_modules_conf: ignored */ + }; + ++/* Support for the mod binary index generation */ ++ ++static void index_init(const char *filename) ++{ ++ if (ENABLE_FEATURE_MODUTILS_BIN) { ++ index_node *n; ++ ++ n = xzalloc(sizeof(index_node)); ++ n->prefix = xstrdup(""); ++ G.root_node = n; ++ } ++ ++ if (filename && !(option_mask32 & OPT_n)) { ++ if (freopen(filename, "w", stdout) == NULL) ++ bb_perror_msg_and_die("can't open '%s'", filename); ++ } ++} ++ ++static void index_add(const char *key, char *value, const char *prefix) ++{ ++ if (prefix && *prefix) ++ printf("%s%s %s\n", prefix, key, value); ++ else if (prefix) ++ printf("%s\n", value); ++ ++ if (ENABLE_FEATURE_MODUTILS_BIN) { ++ index_node *cur = G.root_node, *n; ++ unsigned i = 0, j, ch; ++ ++ while (1) { ++ /* Ensure node->prefix is a prefix of &str[i]. ++ * If it is not already, then we must split node. */ ++ for (j = 0; cur->prefix[j]; j++) { ++ ch = cur->prefix[j]; ++ if (ch != key[i+j]) { ++ /* New child is copy of node with prefix[j+1..N] */ ++ n = xzalloc(sizeof(index_node)); ++ n->prefix = xstrdup(&cur->prefix[j+1]); ++ n->values = cur->values; ++ memcpy(n->children, cur->children, sizeof(n->children)); ++ ++ /* Parent has prefix[0..j], child at prefix[j] */ ++ cur->prefix[j] = '\0'; ++ cur->values = NULL; ++ memset(cur->children, 0, sizeof(cur->children)); ++ cur->children[ch-INDEX_MINCHAR] = n; ++ break; ++ } ++ } ++ i += j; ++ ++ ch = key[i]; ++ if (ch == 0) ++ break; ++ ++ if (ch < INDEX_MINCHAR || ch >= INDEX_MAXCHAR) ++ bb_simple_error_msg_and_die("bad module name"); ++ ++ ch -= INDEX_MINCHAR; ++ if (!cur->children[ch]) { ++ n = xzalloc(sizeof(index_node)); ++ cur->children[ch] = n; ++ n->prefix = xstrdup(&key[i+1]); ++ cur = n; ++ break; ++ } ++ ++ /* Descend into child node and continue */ ++ cur = cur->children[ch]; ++ i++; ++ } ++ ++ llist_add_to(&cur->values, value); ++ } ++} ++ ++static uint32_t index_write_node(FILE *out, index_node *n, void (*freeit)(void *data)) ++{ ++ uint32_t child_offs[INDEX_MAXCHAR-INDEX_MINCHAR]; ++ uint32_t offset; ++ uint8_t first = 255, last = 0; ++ unsigned i; ++ ++ for (i = 0; i < INDEX_MAXCHAR-INDEX_MINCHAR; i++) { ++ child_offs[i] = 0; ++ if (!n->children[i]) ++ continue; ++ child_offs[i] = index_write_node(out, n->children[i], freeit); ++ if (first > INDEX_MAXCHAR) ++ first = i; ++ last = i; ++ } ++ ++ offset = ftell(out); ++ ++ if (n->prefix[0]) { ++ fputs(n->prefix, out); ++ fputc('\0', out); ++ offset |= INDEX_NODE_PREFIX; ++ } ++ ++ if (first < INDEX_MAXCHAR) { ++ fputc(first + INDEX_MINCHAR, out); ++ fputc(last + INDEX_MINCHAR, out); ++ fwrite(child_offs + first, sizeof(uint32_t), last - first + 1, out); ++ offset |= INDEX_NODE_CHILDS; ++ } ++ ++ if (n->values) { ++ const llist_t *v; ++ unsigned int cnt; ++ uint32_t u; ++ ++ n->values = llist_rev(n->values); ++ for (v = n->values, cnt = 0; v != NULL; v = v->link, cnt++); ++ u = htonl(cnt); ++ fwrite(&u, sizeof(u), 1, out); ++ for (v = n->values, cnt = 0; v != NULL; v = v->link, cnt++) { ++ u = htonl(cnt); ++ fwrite(&u, sizeof(u), 1, out); ++ fputs(v->data, out); ++ fputc('\0', out); ++ } ++ offset |= INDEX_NODE_VALUES; ++ } ++ ++ llist_free(n->values, freeit); ++ free(n->prefix); ++ free(n); ++ ++ return htonl(offset); ++} ++ ++static void index_dump(const char *filename, int deps_file) ++{ ++ if (ENABLE_FEATURE_MODUTILS_BIN) { ++ FILE *out; ++ uint32_t header[3] = { ++ htonl(INDEX_MAGIC), ++ htonl(INDEX_VERSION), ++ }; ++ ++ if (option_mask32 & OPT_n) ++ filename = "/dev/null"; ++ else ++ filename = xasprintf("tmp.%s.bin", filename); ++ ++ out = xfopen_for_write(filename); ++ fwrite(header, sizeof(uint32_t), 3, out); ++ header[2] = index_write_node(out, G.root_node, deps_file ? free : 0); ++ rewind(out); ++ G.root_node = NULL; ++ fwrite(header, sizeof(uint32_t), 3, out); ++ if (fclose(out)) { ++ remove(filename); ++ bb_simple_error_msg_and_die(bb_msg_write_error); ++ } ++ /* .bin files are mmap'ed; not renaming it may crash ++ * long standing daemon using libkmod */ ++ rename_or_warn(filename, filename + 4); ++ } ++} ++ + int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; + int depmod_main(int argc UNUSED_PARAM, char **argv) + { +@@ -178,6 +348,8 @@ int depmod_main(int argc UNUSED_PARAM, char **argv) + unsigned i; + int tmp; + ++ INIT_G(); ++ + getopt32(argv, "aAb:eF:nruqC:", &moddir_base, NULL, NULL); + argv += optind; + +@@ -210,53 +382,60 @@ int depmod_main(int argc UNUSED_PARAM, char **argv) + } + + /* Generate dependency and alias files */ +- if (!(option_mask32 & OPT_n)) +- xfreopen_write(CONFIG_DEFAULT_DEPMOD_FILE, stdout); +- ++ index_init(CONFIG_DEFAULT_DEPMOD_FILE); + moddb_foreach_module(&modules, m, i) { +- printf("%s:", m->name); +- ++ char *buf = xasprintf("%s:", m->name); + order_dep_list(&modules, m, m->deps); ++ + while (m->dnext != m) { + dep = m->dnext; +- printf(" %s", dep->name); +- ++ buf = gather_options_str(buf, dep->name); + /* unlink current entry */ + dep->dnext->dprev = dep->dprev; + dep->dprev->dnext = dep->dnext; + dep->dnext = dep->dprev = dep; + } +- bb_putchar('\n'); ++ index_add(m->modname, buf, ""); + } +- +-#if ENABLE_FEATURE_MODUTILS_ALIAS +- if (!(option_mask32 & OPT_n)) +- xfreopen_write("modules.alias", stdout); +- moddb_foreach_module(&modules, m, i) { +- while (m->aliases) { +- /* +- * Last word used to be a basename +- * (filename with path and .ko.* stripped) +- * at the time of module-init-tools 3.4. +- * kmod v.12 uses module name, i.e., s/-/_/g. +- */ +- printf("alias %s %s\n", +- (char*)llist_pop(&m->aliases), +- m->modname); ++ index_dump(CONFIG_DEFAULT_DEPMOD_FILE, 1); ++ ++ if (ENABLE_FEATURE_MODUTILS_ALIAS) { ++ index_init("modules.alias"); ++ moddb_foreach_module(&modules, m, i) { ++ while (m->aliases) { ++ /* ++ * Last word used to be a basename ++ * (filename with path and .ko.* stripped) ++ * at the time of module-init-tools 3.4. ++ * kmod v.12 uses module name, i.e., s/-/_/g. ++ */ ++ index_add((char*)llist_pop(&m->aliases), m->modname, "alias "); ++ } + } ++ index_dump("modules.alias", 0); + } +-#endif +-#if ENABLE_FEATURE_MODUTILS_SYMBOLS +- if (!(option_mask32 & OPT_n)) +- xfreopen_write("modules.symbols", stdout); +- moddb_foreach_module(&modules, m, i) { +- while (m->symbols) { +- printf("alias symbol:%s %s\n", +- (char*)llist_pop(&m->symbols), +- m->modname); ++ if (ENABLE_FEATURE_MODUTILS_SYMBOLS) { ++ index_init("modules.symbols"); ++ moddb_foreach_module(&modules, m, i) { ++ while (m->symbols) { ++ index_add((char*)llist_pop(&m->symbols), m->modname, "alias "); ++ } ++ } ++ index_dump("modules.symbols", 0); ++ } ++ if (ENABLE_FEATURE_MODUTILS_BIN) { ++ char line[PATH_MAX], modname[MODULE_NAME_LEN]; ++ FILE *in; ++ ++ index_init(NULL); ++ in = xfopen_for_read("modules.builtin"); ++ while (fgets(line, sizeof(line), in) != NULL) { ++ filename2modname(line, modname); ++ index_add(modname, (char *) "", 0); + } ++ fclose(in); ++ index_dump("modules.builtin", 0); + } +-#endif + + if (ENABLE_FEATURE_CLEAN_UP) + moddb_free(&modules); +diff --git a/modutils/modprobe.c b/modutils/modprobe.c +index 0a372a049..20a60c1a6 100644 +--- a/modutils/modprobe.c ++++ b/modutils/modprobe.c +@@ -192,21 +192,6 @@ struct globals { + + static int read_config(const char *path); + +-static char *gather_options_str(char *opts, const char *append) +-{ +- /* Speed-optimized. We call gather_options_str many times. */ +- if (append) { +- if (opts == NULL) { +- opts = xstrdup(append); +- } else { +- int optlen = strlen(opts); +- opts = xrealloc(opts, optlen + strlen(append) + 2); +- sprintf(opts + optlen, " %s", append); +- } +- } +- return opts; +-} +- + static struct module_entry *get_or_add_modentry(const char *module) + { + return moddb_get_or_create(&G.db, module); +diff --git a/modutils/modutils.c b/modutils/modutils.c +index 6f7cd9721..257089af4 100644 +--- a/modutils/modutils.c ++++ b/modutils/modutils.c +@@ -66,6 +66,21 @@ void FAST_FUNC moddb_free(module_db *db) + } + } + ++char * FAST_FUNC gather_options_str(char *opts, const char *append) ++{ ++ /* Speed-optimized. We call gather_options_str many times. */ ++ if (append) { ++ if (opts == NULL) { ++ opts = xstrdup(append); ++ } else { ++ int optlen = strlen(opts); ++ opts = xrealloc(opts, optlen + strlen(append) + 2); ++ sprintf(opts + optlen, " %s", append); ++ } ++ } ++ return opts; ++} ++ + void FAST_FUNC replace(char *s, char what, char with) + { + while (*s) { +@@ -75,6 +90,22 @@ void FAST_FUNC replace(char *s, char what, char with) + } + } + ++char* FAST_FUNC replace_underscores(char *s) ++{ ++ int i; ++ for (i = 0; s[i]; i++) { ++ switch (s[i]) { ++ case '-': ++ s[i] = '_'; ++ break; ++ case '[': ++ i += strcspn(&s[i], "]"); ++ break; ++ } ++ } ++ return s; ++} ++ + int FAST_FUNC string_to_llist(char *string, llist_t **llist, const char *delim) + { + char *tok; +diff --git a/modutils/modutils.h b/modutils/modutils.h +index 4a702e97c..73e816028 100644 +--- a/modutils/modutils.h ++++ b/modutils/modutils.h +@@ -18,6 +18,20 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN + #define MODULE_NAME_LEN 256 + #define MODULE_HASH_SIZE 256 + ++/* .bin index format definitions */ ++#define INDEX_MAGIC 0xB007F457 ++#define INDEX_VERSION_MAJOR 0x0002 ++#define INDEX_VERSION_MINOR 0x0001 ++#define INDEX_VERSION ((INDEX_VERSION_MAJOR<<16)|INDEX_VERSION_MINOR) ++ ++enum node_offset { ++ INDEX_NODE_FLAGS = 0xF0000000, /* Flags in high nibble */ ++ INDEX_NODE_PREFIX = 0x80000000, ++ INDEX_NODE_VALUES = 0x40000000, ++ INDEX_NODE_CHILDS = 0x20000000, ++ INDEX_NODE_MASK = 0x0FFFFFFF, /* Offset value */ ++}; ++ + typedef struct module_entry { + struct module_entry *next; + char *name, *modname; +@@ -47,7 +61,9 @@ module_entry *moddb_get(module_db *db, const char *s) FAST_FUNC; + module_entry *moddb_get_or_create(module_db *db, const char *s) FAST_FUNC; + void moddb_free(module_db *db) FAST_FUNC; + ++char *gather_options_str(char *opts, const char *append) FAST_FUNC; + void replace(char *s, char what, char with) FAST_FUNC; ++char *replace_underscores(char *s) FAST_FUNC; + int string_to_llist(char *string, llist_t **llist, const char *delim) FAST_FUNC; + char *filename2modname(const char *filename, char *modname) FAST_FUNC; + #if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS diff --git a/aports/busybox/0010-Add-flag-for-not-following-symlinks-when-recursing.patch b/aports/busybox/0010-Add-flag-for-not-following-symlinks-when-recursing.patch new file mode 100644 index 0000000..e647d8d --- /dev/null +++ b/aports/busybox/0010-Add-flag-for-not-following-symlinks-when-recursing.patch @@ -0,0 +1,56 @@ +From 03293c16e509501ce7ec952900413138475f125d Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Fri, 25 Jul 2014 15:28:33 +0200 +Subject: [PATCH] Add flag for not following symlinks when recursing + +function old new delta +.rodata 7934 7967 +33 +diff_longopts 253 270 +17 +packed_usage 1704 1720 +16 +diff_main 1665 1662 -3 +------------------------------------------------------------------------------ +(add/remove: 0/0 grow/shrink: 3/1 up/down: 66/-3) Total: 63 bytes +--- + editors/diff.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/editors/diff.c b/editors/diff.c +index 280091756..42a36e2d4 100644 +--- a/editors/diff.c ++++ b/editors/diff.c +@@ -113,6 +113,9 @@ + //usage: "\n -N Treat absent files as empty" + //usage: "\n -q Output only whether files differ" + //usage: "\n -r Recurse" ++//usage: IF_LONG_OPTS( ++//usage: "\n --no-dereference Don't follow symlinks" ++//usage: ) + //usage: "\n -S Start with FILE when comparing directories" + //usage: "\n -T Make tabs line up by prefixing a tab when necessary" + //usage: "\n -s Report when two files are the same" +@@ -154,6 +157,7 @@ enum { /* Commandline flags */ + FLAG_p, /* not implemented */ + FLAG_B, + FLAG_E, /* not implemented */ ++ FLAG_no_deref, + }; + #define FLAG(x) (1 << FLAG_##x) + +@@ -867,7 +871,8 @@ static void diffdir(char *p[2], const char *s_start) + * Using list.len to specify its length, + * add_to_dirlist will remove it. */ + list[i].len = strlen(p[i]); +- recursive_action(p[i], ACTION_RECURSE | ACTION_FOLLOWLINKS, ++ recursive_action(p[i], ACTION_RECURSE | ++ ((option_mask32 & FLAG(no_deref)) ? 0 : ACTION_FOLLOWLINKS), + add_to_dirlist, skip_dir, &list[i]); + /* Sort dl alphabetically. + * GNU diff does this ignoring any number of trailing dots. +@@ -964,6 +969,7 @@ static const char diff_longopts[] ALIGN1 = + "report-identical-files\0" No_argument "s" + "starting-file\0" Required_argument "S" + "minimal\0" No_argument "d" ++ "no-dereference\0" No_argument "\xff" + ; + # define GETOPT32 getopt32long + # define LONGOPTS ,diff_longopts diff --git a/aports/busybox/0012-udhcpc-Don-t-background-if-n-is-given.patch b/aports/busybox/0012-udhcpc-Don-t-background-if-n-is-given.patch new file mode 100644 index 0000000..523768b --- /dev/null +++ b/aports/busybox/0012-udhcpc-Don-t-background-if-n-is-given.patch @@ -0,0 +1,96 @@ +From 0cd01228c1e4173683637c4e582448656b26c05f Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Thu, 6 Jul 2017 11:40:14 +0200 +Subject: [PATCH] udhcpc: Don't background if -n is given + +we need add -b to our udhcpc options to prevent boot forever if there are no +dhcp server. We also need a way for users to disable this behavior by making +it possible to set -n option at runtime. + +Since busybox 1.31.0 -b takes precedence over -n [0]. However, since we +enable -b instead of -n by default (through our busyboxconfig) this is +not desired, this commit therefore also reverts the upstream patch +introducing this change. + +See also: https://bugs.busybox.net/11691 + +[0]: https://git.busybox.net/busybox/commit/?id=87e216294af9eec39c0c1d553555f8a98c15db38 +--- + networking/udhcp/d6_dhcpc.c | 20 +++++++------------- + networking/udhcp/dhcpc.c | 20 +++++++------------- + 2 files changed, 14 insertions(+), 26 deletions(-) + +diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c +index 8d11a7539..0284a0fd8 100644 +--- a/networking/udhcp/d6_dhcpc.c ++++ b/networking/udhcp/d6_dhcpc.c +@@ -1401,25 +1401,19 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) + leasefail: + change_listen_mode(LISTEN_NONE); + d6_run_script_no_option("leasefail"); ++ if (opt & OPT_n) { /* abort if no lease */ ++ bb_simple_info_msg("no lease, failing"); ++ retval = 1; ++ goto ret; ++ } + #if BB_MMU /* -b is not supported on NOMMU */ + if (opt & OPT_b) { /* background if no lease */ + bb_simple_info_msg("no lease, forking to background"); + client_background(); + /* do not background again! */ +- opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f); +- /* ^^^ also disables -n (-b takes priority over -n): +- * ifup's default udhcpc options are -R -n, +- * and users want to be able to add -b +- * (in a config file) to make it background +- * _and not exit_. +- */ +- } else +-#endif +- if (opt & OPT_n) { /* abort if no lease */ +- bb_simple_info_msg("no lease, failing"); +- retval = 1; +- goto ret; ++ opt = ((opt & ~OPT_b) | OPT_f); + } ++#endif + /* Wait before trying again */ + timeout = tryagain_timeout; + packet_num = 0; +diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c +index bbf95caca..8e034ac8a 100644 +--- a/networking/udhcp/dhcpc.c ++++ b/networking/udhcp/dhcpc.c +@@ -1456,25 +1456,19 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) + leasefail: + change_listen_mode(LISTEN_NONE); + d4_run_script(NULL, "leasefail"); ++ if (opt & OPT_n) { /* abort if no lease */ ++ bb_simple_info_msg("no lease, failing"); ++ retval = 1; ++ goto ret; ++ } + #if BB_MMU /* -b is not supported on NOMMU */ + if (opt & OPT_b) { /* background if no lease */ + bb_simple_info_msg("no lease, forking to background"); + client_background(); + /* do not background again! */ +- opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f); +- /* ^^^ also disables -n (-b takes priority over -n): +- * ifup's default udhcpc options are -R -n, +- * and users want to be able to add -b +- * (in a config file) to make it background +- * _and not exit_. +- */ +- } else +-#endif +- if (opt & OPT_n) { /* abort if no lease */ +- bb_simple_info_msg("no lease, failing"); +- retval = 1; +- goto ret; ++ opt = ((opt & ~OPT_b) | OPT_f); + } ++#endif + /* Wait before trying again */ + timeout = tryagain_timeout; + packet_num = 0; diff --git a/aports/busybox/APKBUILD b/aports/busybox/APKBUILD new file mode 100644 index 0000000..a1e83c6 --- /dev/null +++ b/aports/busybox/APKBUILD @@ -0,0 +1,210 @@ +# Maintainer: Gabor Pali +pkgname=busybox +pkgver=1.34.1 +pkgrel=5 +pkgdesc="Size optimized toolbox of many common UNIX utilities" +url="https://busybox.net/" +arch="all" +license="GPL-2.0-only" +makedepends_build="perl" +makedepends_host="linux-headers openssl1.1-compat-dev libretls-dev" +makedepends="$makedepends_build $makedepends_host" +checkdepends= +provides="/bin/sh" +install= +subpackages= +options="!check" +source="https://busybox.net/downloads/busybox-$pkgver.tar.bz2 + 0001-rev-correct-output-for-long-input-lines.patch + + 0001-nologin-Install-applet-to-sbin-instead-of-usr-sbin.patch + 0001-adduser-default-to-sbin-nologin-as-shell-for-system-.patch + 0001-properly-fix-wget-https-support.patch + 0001-modutils-check-ELF-header-before-calling-finit_module.patch + 0002-fsck-resolve-LABEL-.-UUID-.-spec-to-device.patch + 0003-ash-exec-busybox.static.patch + 0004-app-location-for-cpio-vi-and-lspci.patch + 0005-udhcpc-set-default-discover-retries-to-5.patch + 0006-ping-make-ping-work-without-root-privileges.patch + 0007-fbsplash-support-console-switching.patch + 0008-fbsplash-support-image-and-bar-alignment-and-positio.patch + 0009-depmod-support-generating-kmod-binary-index-files.patch + 0010-Add-flag-for-not-following-symlinks-when-recursing.patch + 0012-udhcpc-Don-t-background-if-n-is-given.patch + + 0001-ash-add-built-in-BB_ASH_VERSION-variable.patch + + 0001-cpio-add-support-for-ignore-devno-like-GNU-cpio.patch + 0002-cpio-add-support-for-renumber-inodes-like-GNU-cpio.patch + + 0001-pgrep-add-support-for-matching-against-UID-and-RUID.patch + + 0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch + 0002-nslookup-sanitize-all-printed-strings-with-printable.patch + + acpid.logrotate + config + default.script + + acpid.initd + crond.initd + mdev.initd + syslog.initd + udhcpd.initd + + crond.confd + syslog.confd + mdev.conf + persistent-storage + " + +# secfixes: +# 1.34.1-r5: +# - ALPINE-13661 +# - CVE-2022-28391 +# 1.34.0-r0: +# - CVE-2021-42374 +# - CVE-2021-42375 +# - CVE-2021-42378 +# - CVE-2021-42379 +# - CVE-2021-42380 +# - CVE-2021-42381 +# - CVE-2021-42382 +# - CVE-2021-42383 +# - CVE-2021-42384 +# - CVE-2021-42385 +# - CVE-2021-42386 +# 1.33.0-r5: +# - CVE-2021-28831 +# 1.30.1-r2: +# - CVE-2019-5747 +# 1.29.3-r10: +# - CVE-2018-20679 +# 1.28.3-r2: +# - CVE-2018-1000500 +# 1.27.2-r4: +# - CVE-2017-16544 +# - CVE-2017-15873 +# - CVE-2017-15874 +# 0: +# - CVE-2021-42373 +# - CVE-2021-42376 +# - CVE-2021-42377 + +prepare() { + default_prepare + + mkdir -p "$srcdir"/build +} + +build() { + cd "$srcdir"/build + echo "COPIED CONFIG to $(pwd)/.config" + cp "$srcdir"/config .config + [ "$CLIBC" = musl ] && sed -i \ + -e "s/CONFIG_EXTRA_COMPAT=y/CONFIG_EXTRA_COMPAT=n/" \ + .config + make -C "$builddir" O="$PWD" silentoldconfig + make +} + +package() { + local i + + cd "$srcdir"/build + mkdir -p "$pkgdir"/usr/sbin "$pkgdir"/usr/bin "$pkgdir"/tmp \ + "$pkgdir"/var/cache/misc "$pkgdir"/bin "$pkgdir"/sbin + chmod 1777 "$pkgdir"/tmp + install -m755 busybox "$pkgdir"/bin/busybox + + for target in $("$pkgdir"/bin/busybox --list-full | sort); do + ln -s /bin/busybox "$pkgdir"/"$target" + done + + #ifupdown needs those dirs to be present + mkdir -p \ + "$pkgdir"/etc/network/if-down.d \ + "$pkgdir"/etc/network/if-post-down.d \ + "$pkgdir"/etc/network/if-post-up.d \ + "$pkgdir"/etc/network/if-pre-down.d \ + "$pkgdir"/etc/network/if-pre-up.d \ + "$pkgdir"/etc/network/if-up.d + + install -Dm644 "$srcdir"/acpid.logrotate \ + "$pkgdir/etc/logrotate.d/acpid" + + mkdir -p \ + "$pkgdir"/var/lib/udhcpd \ + "$pkgdir"/etc/udhcpc + + ln -s /media/etc/udhcpd.conf "$pkgdir"/etc + cat >"$pkgdir"/etc/securetty <"$pkgdir"/etc/udhcpc/udhcpc.conf <"$pkgdir"/etc/acpi/PWRF/00000080 < + +UDHCPC="/etc/udhcpc" +UDHCPC_CONF="$UDHCPC/udhcpc.conf" + +RESOLV_CONF="/etc/resolv.conf" +[ -f $UDHCPC_CONF ] && . $UDHCPC_CONF + +export broadcast +export dns +export domain +export interface +export ip +export mask +export metric +export staticroutes +export router +export subnet + +export PATH=/usr/bin:/bin:/usr/sbin:/sbin + +run_scripts() { + local dir=$1 + if [ -d $dir ]; then + for i in $dir/*; do + [ -f $i ] && $i + done + fi +} + +deconfig() { + ip -4 addr flush dev $interface +} + +is_wifi() { + test -e /sys/class/net/$interface/phy80211 +} + +if_index() { + if [ -e /sys/class/net/$interface/ifindex ]; then + cat /sys/class/net/$interface/ifindex + else + ip -4 link show dev $interface | head -n1 | cut -d: -f1 + fi +} + +calc_metric() { + local base= + if is_wifi; then + base=300 + else + base=200 + fi + echo $(( $base + $(if_index) )) +} + +route_add() { + local to=$1 gw=$2 num=$3 + # special case for /32 subnets: + # /32 instructs kernel to always use routing for all outgoing packets + # (they can never be sent to local subnet - there is no local subnet for /32). + # Used in datacenters, avoids the need for private ip-addresses between two hops. + if [ "$subnet" = "255.255.255.255" ]; then + ip -4 route add $gw dev $interface + fi + ip -4 route add $to via $gw dev $interface \ + metric $(( $num + ${IF_METRIC:-$(calc_metric)} )) +} + +routes() { + [ -z "$router" ] && [ -z "$staticroutes" ] && return + for i in $NO_GATEWAY; do + [ "$i" = "$interface" ] && return + done + while ip -4 route del default via dev $interface 2>/dev/null; do + : + done + local num=0 + # RFC3442: + # If the DHCP server returns both a Classless Static Routes option + # and a Router option, the DHCP client MUST ignore the Router option. + if [ -n "$staticroutes" ]; then + # static routes format: dest1/mask gw1 ... destn/mask gwn + set -- $staticroutes + while [ -n "$1" ] && [ -n "$2" ]; do + local dest="$1" gw="$2" + if [ "$gw" != "0.0.0.0" ]; then + route_add $dest $gw $num && num=$(( $num + 1)) + fi + shift 2 + done + else + local gw= + for gw in $router; do + route_add 0.0.0.0/0 $gw $num && num=$(( $num + 1 )) + done + fi +} + +resolvconf() { + local i + [ -n "$IF_PEER_DNS" ] && [ "$IF_PEER_DNS" != "yes" ] && return + if [ "$RESOLV_CONF" = "no" ] || [ "$RESOLV_CONF" = "NO" ] \ + || [ -z "$RESOLV_CONF" ] || [ -z "$dns" ]; then + return + fi + for i in $NO_DNS; do + [ "$i" = "$interface" ] && return + done + echo -n > "$RESOLV_CONF.$$" + if [ -n "$search" ]; then + echo "search $search" >> "$RESOLV_CONF.$$" + elif [ -n "$domain" ]; then + echo "search $domain" >> "$RESOLV_CONF.$$" + fi + for i in $dns; do + echo "nameserver $i" >> "$RESOLV_CONF.$$" + done + chmod a+r "$RESOLV_CONF.$$" + mv "$RESOLV_CONF.$$" "$RESOLV_CONF" +} + +bound() { + ip -4 addr add $ip/$mask ${broadcast:+broadcast $broadcast} dev $interface + ip -4 link set dev $interface up + routes + resolvconf +} + +renew() { + if ! ip -4 addr show dev $interface | grep $ip/$mask; then + ip -4 addr flush dev $interface + ip -4 addr add $ip/$mask ${broadcast:+broadcast $broadcast} dev $interface + fi + + local i + for i in $router; do + if ! ip -4 route show | grep ^default | grep $i; then + routes + break + fi + done + + if ! grep "^search $domain"; then + resolvconf + return + fi + for i in $dns; do + if ! grep "^nameserver $i"; then + resolvconf + return + fi + done +} + +case "$1" in + deconfig|renew|bound) + run_scripts $UDHCPC/pre-$1 + $1 + run_scripts $UDHCPC/post-$1 + ;; + leasefail) + echo "udhcpc failed to get a DHCP lease" >&2 + ;; + nak) + echo "udhcpc received DHCP NAK" >&2 + ;; + *) + echo "Error: this script should be called from udhcpc" >&2 + exit 1 + ;; +esac +exit 0 + diff --git a/aports/busybox/mdev.conf b/aports/busybox/mdev.conf new file mode 100644 index 0000000..903786f --- /dev/null +++ b/aports/busybox/mdev.conf @@ -0,0 +1,134 @@ +# +# This is a sample mdev.conf. +# + +# Devices: +# Syntax: %s %d:%d %s +# devices user:group mode + +$MODALIAS=.* root:root 0660 @modprobe -q -b "$MODALIAS" + +# null does already exist; therefore ownership has to be changed with command +null root:root 0666 @chmod 666 $MDEV +zero root:root 0666 +grsec root:root 0660 +full root:root 0666 + +random root:root 0666 +urandom root:root 0444 +hwrandom root:root 0660 + +console root:tty 0600 + +# load frambuffer console when first frambuffer is found +fb0 root:video 0660 @modprobe -q -b fbcon +vchiq root:video 0660 + +fd0 root:floppy 0660 +kmem root:root 0640 +mem root:root 0640 +port root:root 0640 +ptmx root:tty 0666 + +# Kernel-based Virtual Machine. +kvm root:kvm 660 + +# ram.* +ram([0-9]*) root:disk 0660 >rd/%1 +loop([0-9]+) root:disk 0660 >loop/%1 + +# persistent storage +dasd.* root:disk 0660 */lib/mdev/persistent-storage +mmcblk.* root:disk 0660 */lib/mdev/persistent-storage +nbd.* root:disk 0660 */lib/mdev/persistent-storage +nvme.* root:disk 0660 */lib/mdev/persistent-storage +sd[a-z].* root:disk 0660 */lib/mdev/persistent-storage +sr[0-9]+ root:cdrom 0660 */lib/mdev/persistent-storage +vd[a-z].* root:disk 0660 */lib/mdev/persistent-storage +xvd[a-z].* root:disk 0660 */lib/mdev/persistent-storage + +md[0-9] root:disk 0660 + +tty root:tty 0666 +tty[0-9] root:root 0600 +tty[0-9][0-9] root:tty 0660 +ttyS[0-9]* root:uucp 0660 +pty.* root:tty 0660 +vcs[0-9]* root:tty 0660 +vcsa[0-9]* root:tty 0660 + +# rpi bluetooth +#ttyAMA0 root:tty 660 @btattach -B /dev/$MDEV -P bcm -S 115200 -N & + +ttyACM[0-9] root:dialout 0660 @ln -sf $MDEV modem +ttyUSB[0-9] root:dialout 0660 @ln -sf $MDEV modem +ttyLTM[0-9] root:dialout 0660 @ln -sf $MDEV modem +ttySHSF[0-9] root:dialout 0660 @ln -sf $MDEV modem +slamr root:dialout 0660 @ln -sf $MDEV slamr0 +slusb root:dialout 0660 @ln -sf $MDEV slusb0 +fuse root:root 0666 + +# dri device +dri/.* root:video 0660 +card[0-9] root:video 0660 =dri/ + +# alsa sound devices and audio stuff +pcm.* root:audio 0660 =snd/ +control.* root:audio 0660 =snd/ +midi.* root:audio 0660 =snd/ +seq root:audio 0660 =snd/ +timer root:audio 0660 =snd/ + +adsp root:audio 0660 >sound/ +audio root:audio 0660 >sound/ +dsp root:audio 0660 >sound/ +mixer root:audio 0660 >sound/ +sequencer.* root:audio 0660 >sound/ + +SUBSYSTEM=sound;.* root:audio 0660 + +# virtio-ports +SUBSYSTEM=virtio-ports;vport.* root:root 0600 @mkdir -p virtio-ports; ln -sf ../$MDEV virtio-ports/$(cat /sys/class/virtio-ports/$MDEV/name) + +# misc stuff +agpgart root:root 0660 >misc/ +psaux root:root 0660 >misc/ +rtc root:root 0664 >misc/ + +# input stuff +event[0-9]+ root:input 0640 =input/ +mice root:input 0640 =input/ +mouse[0-9] root:input 0640 =input/ +js[0-9] root:input 0640 =input/ +ts[0-9] root:input 0600 =input/ + +# v4l stuff +vbi[0-9] root:video 0660 >v4l/ +video[0-9]+ root:video 0660 >v4l/ + +# dvb stuff +dvb.* root:video 0660 */lib/mdev/dvbdev + +# load drivers for usb devices +usb[0-9]+ root:root 0660 */lib/mdev/usbdev + +# net devices +# 666 is fine: https://www.kernel.org/doc/Documentation/networking/tuntap.txt +net/tun[0-9]* root:netdev 0666 +net/tap[0-9]* root:netdev 0666 + +# zaptel devices +zap(.*) root:dialout 0660 =zap/%1 +dahdi!(.*) root:dialout 0660 =dahdi/%1 +dahdi/(.*) root:dialout 0660 =dahdi/%1 + +# raid controllers +cciss!(.*) root:disk 0660 =cciss/%1 +cciss/(.*) root:disk 0660 =cciss/%1 +ida!(.*) root:disk 0660 =ida/%1 +ida/(.*) root:disk 0660 =ida/%1 +rd!(.*) root:disk 0660 =rd/%1 +rd/(.*) root:disk 0660 =rd/%1 + +# fallback for any!device -> any/device +(.*)!(.*) root:root 0660 =%1/%2 diff --git a/aports/busybox/mdev.initd b/aports/busybox/mdev.initd new file mode 100644 index 0000000..9dbb994 --- /dev/null +++ b/aports/busybox/mdev.initd @@ -0,0 +1,39 @@ +#!/sbin/openrc-run + +depend() { + provide dev + need sysfs dev-mount + before checkfs fsck + keyword -vserver -lxc +} + +start() { + # check if udev is specified on cmd line + if get_bootparam "udev"; then + ewarn "Skipping mdev as udev requested in kernel cmdline" + return 0 + fi + + ebegin "Starting busybox mdev" + mkdir -p /dev + + # use mdev for hotplug + echo "/sbin/mdev" > /proc/sys/kernel/hotplug + + # mdev -s will not create /dev/usb[1-9] devices with recent kernels + # so we trigger hotplug events for usb for now + for i in $(find /sys/devices -name 'usb[0-9]*'); do + [ -e $i/uevent ] && echo add > $i/uevent + done + + # create devices + mdev -s + eend $? +} + +stop() { + ebegin "Stopping busybox mdev" + echo "" > /proc/sys/kernel/hotplug + eend +} + diff --git a/aports/busybox/persistent-storage b/aports/busybox/persistent-storage new file mode 100644 index 0000000..ea68948 --- /dev/null +++ b/aports/busybox/persistent-storage @@ -0,0 +1,68 @@ +#!/bin/sh + +symlink_action() { + case "$ACTION" in + add) ln -sf "$1" "$2";; + remove) rm -f "$2";; + esac +} + +# cdrom symlink +case "$MDEV" in + sr*|xvd*) + caps="$(cat /sys/block/$MDEV/capability 2>/dev/null)" + if [ $(( 0x${caps:-0} & 8 )) -gt 0 ]; then + symlink_action $MDEV cdrom + fi +esac + +# by-id symlinks +mkdir -p disk/by-id + +partition=$(cat /sys/class/block/$MDEV/partition 2>/dev/null) +case "$partition" in + [0-9]*) partsuffix="-part$partition";; +esac + +wwid=$(cat /sys/class/block/$MDEV/wwid 2>/dev/null) +: ${wwid:=$(cat /sys/class/block/$MDEV/device/wwid 2>/dev/null)} + +if [ -n "$wwid" ]; then + case "$MDEV" in + nvme*) symlink_action ../../$MDEV disk/by-id/nvme-${wwid}${partsuffix};; + esac + case "$wwid" in + naa.*) symlink_action ../../$MDEV disk/by-id/wwn-0x${wwid#naa.};; + esac +fi + +serial=$(sed -E -e 's/^\s+//' -e 's/\s+$//' -e 's/ /_/g' \ + /sys/class/block/$MDEV/device/serial 2>/dev/null) + +model=$(sed -E -e 's/^\s+//' -e 's/\s+$//' -e 's/ /_/g' \ + /sys/class/block/$MDEV/device/model 2>/dev/null) + +if [ -n "$serial" ] && [ -n "$model" ]; then + case "$MDEV" in + nvme*) symlink_action ../../$MDEV disk/by-id/nvme-${model}_${serial}${partsuffix};; + esac +fi + +# virtio-blk +if [ -n "$serial" ]; then + case "$MDEV" in + vd*) symlink_action ../../$MDEV disk/by-id/virtio-${serial}${partsuffix};; + esac +fi + +# by-uuid, by-partuuid +eval $(blkid /dev/$MDEV | cut -d: -f2-) +if [ -n "$UUID" ]; then + mkdir -p disk/by-uuid + symlink_action ../../$MDEV disk/by-uuid/$UUID +fi +if [ -n "$PARTUUID" ]; then + mkdir -p disk/by-partuuid + symlink_action ../../$MDEV disk/by-partuuid/$PARTUUID +fi + diff --git a/aports/busybox/syslog.confd b/aports/busybox/syslog.confd new file mode 100644 index 0000000..2f00667 --- /dev/null +++ b/aports/busybox/syslog.confd @@ -0,0 +1 @@ +SYSLOGD_OPTS="-t" diff --git a/aports/busybox/syslog.initd b/aports/busybox/syslog.initd new file mode 100644 index 0000000..629d868 --- /dev/null +++ b/aports/busybox/syslog.initd @@ -0,0 +1,14 @@ +#!/sbin/openrc-run + +description="Message logging system" + +name="busybox syslog" +command="/sbin/syslogd" +command_args="${SYSLOGD_OPTS}" +pidfile="/var/run/syslogd.pid" +start_stop_daemon_args="-g wheel -k 027" + +depend() { + need clock hostname localmount + provide logger +} diff --git a/aports/busybox/udhcpd.initd b/aports/busybox/udhcpd.initd new file mode 100644 index 0000000..02c7620 --- /dev/null +++ b/aports/busybox/udhcpd.initd @@ -0,0 +1,11 @@ +#!/sbin/openrc-run + +name="busybox $SVCNAME" +command="/usr/sbin/$SVCNAME" +command_args="$UDHCPD_OPTS " +pidfile="/var/run/$SVCNAME.pid" + +depend() { + need net + after firewall +} -- cgit v1.2.3