aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox
diff options
context:
space:
mode:
Diffstat (limited to 'main/busybox')
-rw-r--r--main/busybox/APKBUILD23
-rw-r--r--main/busybox/acpid.patch143
-rw-r--r--main/busybox/bbsuid.c105
3 files changed, 260 insertions, 11 deletions
diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD
index e942e696a1..d692046c3f 100644
--- a/main/busybox/APKBUILD
+++ b/main/busybox/APKBUILD
@@ -1,8 +1,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=busybox
pkgver=1.19.3
-pkgrel=3
-_bbsuidver=0.6
+pkgrel=4
pkgdesc="Size optimized toolbox of many common UNIX utilities"
url=http://busybox.net
arch="all"
@@ -12,22 +11,24 @@ install="$pkgname.post-install $pkgname.post-upgrade"
subpackages="$pkgname-static"
triggers="busybox.trigger=/bin:/usr/bin:/sbin:/usr/sbin:/lib/modules/*"
source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2
- http://git.alpinelinux.org/cgit/bbsuid.git/snapshot/bbsuid-$_bbsuidver.tar.bz2
+ bbsuid.c
+
$pkgname-1.11.1-bb.patch
busybox-uname-is-not-gnu.patch
bb-app-location.patch
0001-loginutils-use-sha512.patch
+ acpid.patch
http://busybox.net/downloads/fixes-1.19.3/busybox-1.19.3-getty.patch
http://busybox.net/downloads/fixes-1.19.3/busybox-1.19.3-modinfo.patch
http://busybox.net/downloads/fixes-1.19.3/busybox-1.19.3-wget.patch
+ http://busybox.net/downloads/fixes-1.19.3/busybox-1.19.3-mdev.patch
busyboxconfig"
_sdir="$srcdir"/$pkgname-$pkgver
_staticdir="$srcdir"/build-static
_dyndir="$srcdir"/build-dynamic
-_bbsuid="$srcdir"/bbsuid-$_bbsuidver
_config="$srcdir"/busyboxconfig
prepare() {
mkdir -p "$_staticdir" "$_dyndir"
@@ -42,9 +43,9 @@ prepare() {
}
build() {
+ # build bbsuid
msg "Building bbsuid"
- cd "$_bbsuid"
- make || return 1
+ ${CC:-gcc} $CFLAGS "$srcdir"/bbsuid.c $LDFLAGS -o "$_dyndir"/bbsuid || return 1
cd "$_staticdir"
msg "Building static busybox"
@@ -64,14 +65,12 @@ build() {
}
package() {
- cd "$_bbsuid"
- make install DESTDIR="$pkgdir" || return 1
-
cd "$_dyndir"
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
+ install -m755 busybox "$pkgdir"/bin/busybox || return 1
+ install -m4111 bbsuid "$pkgdir"/bin/bbsuid || return 1
# we need /bin/sh to be able to execute post-install
ln -s /bin/busybox "$pkgdir"/bin/sh
}
@@ -84,12 +83,14 @@ static() {
}
md5sums="c3938e1ac59602387009bbf1dd1af7f6 busybox-1.19.3.tar.bz2
-968b3a058db04f95e9c4cdb44d7d3ddb bbsuid-0.6.tar.bz2
+b7b06c7d5cff6935e4ff68a245cc64b5 bbsuid.c
4c0f3b486eaa0674961b7ddcd0c60a9b busybox-1.11.1-bb.patch
b5375210f13fd6e1ca61a565e8fabd35 busybox-uname-is-not-gnu.patch
754916e52fa11d3fe7c29c93248b6707 bb-app-location.patch
784383013b8f015fb0d214618c46b4b8 0001-loginutils-use-sha512.patch
+361a26d690e6f1585c6710b3afeb10a6 acpid.patch
5ed72ca85b8fba4598d64a550210b31f busybox-1.19.3-getty.patch
41636628e481f22b8774b6bee1eebfb1 busybox-1.19.3-modinfo.patch
cb48bffc0e1e3be527cd4ff67324a2a2 busybox-1.19.3-wget.patch
+7c809b9cd30f40354be90663d5f18bef busybox-1.19.3-mdev.patch
453614d903ed3f39aa0a4b78f94bc7a5 busyboxconfig"
diff --git a/main/busybox/acpid.patch b/main/busybox/acpid.patch
new file mode 100644
index 0000000000..494bf45757
--- /dev/null
+++ b/main/busybox/acpid.patch
@@ -0,0 +1,143 @@
+From 982fdaf4b2f335506e570a06d5eab09068da3f61 Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <vda.linux@googlemail.com>
+Date: Mon, 09 Jan 2012 04:01:25 +0000
+Subject: acpid: close fds which are reported as dead (POLLERR/POLLHUP/POLLNVAL) by poll.
+
+function old new delta
+acpid_main 1159 1229 +70
+packed_usage 28977 28980 +3
+
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+---
+(limited to 'util-linux/acpid.c')
+
+diff --git a/util-linux/acpid.c b/util-linux/acpid.c
+index 6e7321b..361a2b2 100644
+--- a/util-linux/acpid.c
++++ b/util-linux/acpid.c
+@@ -8,13 +8,13 @@
+ */
+
+ //usage:#define acpid_trivial_usage
+-//usage: "[-d] [-c CONFDIR] [-l LOGFILE] [-a ACTIONFILE] [-M MAPFILE] [-e PROC_EVENT_FILE] [-p PIDFILE]"
++//usage: "[-df] [-c CONFDIR] [-l LOGFILE] [-a ACTIONFILE] [-M MAPFILE] [-e PROC_EVENT_FILE] [-p PIDFILE]"
+ //usage:#define acpid_full_usage "\n\n"
+ //usage: "Listen to ACPI events and spawn specific helpers on event arrival\n"
++//usage: "\n -d Log to stderr, not log file (implies -f)"
++//usage: "\n -f Run in foreground"
+ //usage: "\n -c DIR Config directory [/etc/acpi]"
+-//usage: "\n -d Don't daemonize, (implies -f)"
+ //usage: "\n -e FILE /proc event file [/proc/acpi/event]"
+-//usage: "\n -f Run in foreground"
+ //usage: "\n -l FILE Log file [/var/log/acpid.log]"
+ //usage: "\n -p FILE Pid file [/var/run/acpid.pid]"
+ //usage: "\n -a FILE Action file [/etc/acpid.conf]"
+@@ -225,7 +225,6 @@ static void parse_map_file(const char *filename)
+ int acpid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+ int acpid_main(int argc UNUSED_PARAM, char **argv)
+ {
+- struct input_event ev;
+ int nfd;
+ int opts;
+ struct pollfd *pfd;
+@@ -248,15 +247,21 @@ int acpid_main(int argc UNUSED_PARAM, char **argv)
+ );
+
+ if (!(opts & OPT_f)) {
++ /* No -f "Foreground", we go to background */
+ bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv);
+ }
+
+ if (!(opts & OPT_d)) {
++ /* No -d "Debug", we log to log file.
++ * This includes any output from children.
++ */
++ xmove_fd(xopen(opt_logfile, O_WRONLY | O_CREAT | O_TRUNC), STDOUT_FILENO);
++ xdup2(STDOUT_FILENO, STDERR_FILENO);
++ /* Also, acpid's messages (but not children) will go to syslog too */
+ openlog(applet_name, LOG_PID, LOG_DAEMON);
+ logmode = LOGMODE_SYSLOG | LOGMODE_STDIO;
+- } else {
+- xmove_fd(xopen(opt_logfile, O_WRONLY | O_CREAT | O_TRUNC), STDOUT_FILENO);
+ }
++ /* else: -d "Debug", log is not redirected */
+
+ parse_conf_file(opt_action);
+ parse_map_file(opt_map);
+@@ -272,13 +277,14 @@ int acpid_main(int argc UNUSED_PARAM, char **argv)
+ int fd;
+ char *dev_event;
+
+- dev_event = xasprintf((option_mask32 & OPT_e) ? "%s" : "%s%u", opt_input, nfd);
++ dev_event = xasprintf((opts & OPT_e) ? "%s" : "%s%u", opt_input, nfd);
+ fd = open(dev_event, O_RDONLY | O_NONBLOCK);
+ if (fd < 0) {
+ if (nfd == 0)
+ bb_simple_perror_msg_and_die(dev_event);
+ break;
+ }
++ free(dev_event);
+ pfd = xrealloc_vector(pfd, 1, nfd);
+ pfd[nfd].fd = fd;
+ pfd[nfd].events = POLLIN;
+@@ -287,16 +293,26 @@ int acpid_main(int argc UNUSED_PARAM, char **argv)
+
+ write_pidfile(opt_pidfile);
+
+- while (poll(pfd, nfd, -1) > 0) {
++ while (safe_poll(pfd, nfd, -1) > 0) {
+ int i;
+ for (i = 0; i < nfd; i++) {
+- const char *event = NULL;
+-
+- memset(&ev, 0, sizeof(ev));
+-
+- if (!(pfd[i].revents & POLLIN))
+- continue;
++ const char *event;
++
++ if (!(pfd[i].revents & POLLIN)) {
++ if (pfd[i].revents == 0)
++ continue; /* this fd has nothing */
++
++ /* Likely POLLERR, POLLHUP, POLLNVAL.
++ * Do not listen on this fd anymore.
++ */
++ close(pfd[i].fd);
++ nfd--;
++ for (; i < nfd; i++)
++ pfd[i].fd = pfd[i + 1].fd;
++ break; /* do poll() again */
++ }
+
++ event = NULL;
+ if (option_mask32 & OPT_e) {
+ char *buf;
+ int len;
+@@ -307,7 +323,10 @@ int acpid_main(int argc UNUSED_PARAM, char **argv)
+ if (len >= 0)
+ buf[len] = '\0';
+ event = find_action(NULL, buf);
++ free(buf);
+ } else {
++ struct input_event ev;
++
+ if (sizeof(ev) != full_read(pfd[i].fd, &ev, sizeof(ev)))
+ continue;
+
+@@ -324,11 +343,8 @@ int acpid_main(int argc UNUSED_PARAM, char **argv)
+ }
+
+ if (ENABLE_FEATURE_CLEAN_UP) {
+- while (nfd--) {
+- if (pfd[nfd].fd) {
+- close(pfd[nfd].fd);
+- }
+- }
++ while (nfd--)
++ close(pfd[nfd].fd);
+ free(pfd);
+ }
+ remove_pidfile(opt_pidfile);
+--
+cgit v0.9.0.1-2-gef13
diff --git a/main/busybox/bbsuid.c b/main/busybox/bbsuid.c
new file mode 100644
index 0000000000..a970b01e71
--- /dev/null
+++ b/main/busybox/bbsuid.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2008 Natanael Copa <natanael.copa@gmail.com>
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation. See http://www.gnu.org/ for details.
+ *
+ */
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <libgen.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define BBSUID_PATH "/bin/bbsuid"
+
+const static char * applets[] = {
+ "/bin/mount",
+ "/bin/ping",
+ "/bin/umount",
+ "/usr/bin/crontab",
+ "/usr/bin/passwd",
+ "/usr/bin/su",
+ "/usr/bin/traceroute",
+ NULL
+};
+
+
+static const char *applet_from_path(const char *str)
+{
+ const char *p = strrchr(str, '/');
+ if (p == NULL)
+ p = str;
+ else
+ p++;
+ return p;
+}
+
+static int is_valid_applet(const char *str)
+{
+ int i;
+ for (i = 0; applets[i] != NULL; i++) {
+ const char *a = applet_from_path(applets[i]);
+ if (strcmp(applet_from_path(str), a) == 0)
+ return 1;
+ }
+ return 0;
+}
+
+int exec_busybox(const char *app, int argc, char **argv)
+{
+ char **newargv = malloc((argc + 2) * sizeof(char *));
+ int i;
+ newargv[0] = "/bin/busybox";
+ newargv[1] = (char *)app;
+ for (i = 1; i < argc; i++)
+ newargv[i+1] = argv[i];
+ newargv[argc+1] = NULL;
+ execv(newargv[0], newargv);
+ perror(newargv[0]);
+ free(newargv);
+ return 1;
+}
+
+static int install_links(void)
+{
+ int i, r = 0;
+ /* we don't want others than root to install the symlinks */
+ if (getuid() != 0)
+ errx(1, "Only root can install symlinks");
+
+ for (i = 0; applets[i] != NULL; i++) {
+ const char *a = applets[i];
+ struct stat st;
+ if (lstat(a, &st) == 0 && S_ISLNK(st.st_mode))
+ unlink(a);
+ if (symlink(BBSUID_PATH, a) < 0)
+ r++;
+ }
+
+ return r;
+}
+
+int main(int argc, char **argv)
+{
+ const char *app = applet_from_path(argv[0]);
+
+ if (strcmp(app, "bbsuid") == 0) {
+ if (argc == 2 && strcmp(argv[1], "--install") == 0)
+ return install_links();
+ errx(1, "Use --install to install symlinks");
+ }
+
+ if (is_valid_applet(app))
+ return exec_busybox(app, argc, argv);
+
+ errx(1, "%s is not a valid applet", app);
+ return 1;
+}
+