From 73ea099b69161647e2b7fbc90918b89ef6617e87 Mon Sep 17 00:00:00 2001 From: "Jory A. Pratt" Date: Mon, 8 Oct 2012 12:12:52 -0500 Subject: Basic busy hack until fix in tree to support libselinux-2.1.12 --- sys-apps/busybox/files/busybox-1.19.0-bb.patch | 22 ++++ .../files/busybox-1.20.0-udhcpc6-ipv6.patch | 33 ++++++ .../files/busybox-1.20.2-glibc-sys-resource.patch | 109 ++++++++++++++++++ .../busybox-1.20.2-libselinux-2.1.12-support.patch | 12 ++ sys-apps/busybox/files/ginit.c | 124 +++++++++++++++++++++ sys-apps/busybox/files/mdev.rc.1 | 98 ++++++++++++++++ sys-apps/busybox/files/mdev/dvbdev | 18 +++ sys-apps/busybox/files/mdev/ide_links | 23 ++++ sys-apps/busybox/files/mdev/usbdev | 62 +++++++++++ sys-apps/busybox/files/mdev/usbdisk_link | 34 ++++++ 10 files changed, 535 insertions(+) create mode 100644 sys-apps/busybox/files/busybox-1.19.0-bb.patch create mode 100644 sys-apps/busybox/files/busybox-1.20.0-udhcpc6-ipv6.patch create mode 100644 sys-apps/busybox/files/busybox-1.20.2-glibc-sys-resource.patch create mode 100644 sys-apps/busybox/files/busybox-1.20.2-libselinux-2.1.12-support.patch create mode 100644 sys-apps/busybox/files/ginit.c create mode 100755 sys-apps/busybox/files/mdev.rc.1 create mode 100644 sys-apps/busybox/files/mdev/dvbdev create mode 100644 sys-apps/busybox/files/mdev/ide_links create mode 100644 sys-apps/busybox/files/mdev/usbdev create mode 100644 sys-apps/busybox/files/mdev/usbdisk_link (limited to 'sys-apps/busybox/files') diff --git a/sys-apps/busybox/files/busybox-1.19.0-bb.patch b/sys-apps/busybox/files/busybox-1.19.0-bb.patch new file mode 100644 index 0000000..a66b45a --- /dev/null +++ b/sys-apps/busybox/files/busybox-1.19.0-bb.patch @@ -0,0 +1,22 @@ +--- a/shell/ash.c ++++ b/shell/ash.c +@@ -75,6 +75,8 @@ + //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) + //applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, sh)) + //applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, bash)) ++//applet:IF_ASH(APPLET_ODDNAME(bb, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) ++//applet:IF_ASH(APPLET_ODDNAME(bbsh, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) + + //kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o + //kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o +--- a/shell/ash.c ++++ b/shell/ash.c +@@ -7255,6 +7255,8 @@ + } + /* 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/sys-apps/busybox/files/busybox-1.20.0-udhcpc6-ipv6.patch b/sys-apps/busybox/files/busybox-1.20.0-udhcpc6-ipv6.patch new file mode 100644 index 0000000..0148809 --- /dev/null +++ b/sys-apps/busybox/files/busybox-1.20.0-udhcpc6-ipv6.patch @@ -0,0 +1,33 @@ +From 3da46c8163ecf14a02f8317d0b76b225eceaf28c Mon Sep 17 00:00:00 2001 +From: Mike Frysinger +Date: Wed, 2 May 2012 21:45:35 -0400 +Subject: [PATCH] udhcpc6: depend on ipv6 + +Signed-off-by: Mike Frysinger +--- + networking/udhcp/d6_dhcpc.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c +index a792a9d..7c9f52a 100644 +--- a/networking/udhcp/d6_dhcpc.c ++++ b/networking/udhcp/d6_dhcpc.c +@@ -12,10 +12,11 @@ + */ + + //config:config UDHCPC6 +-//config: bool "udhcp client for DHCPv6 (udhcpc6)" +-//config: default n # not yet ready +-//config: help +-//config: udhcpc6 is a DHCPv6 client ++//config: bool "udhcp client for DHCPv6 (udhcpc6)" ++//config: default n # not yet ready ++//config: depends on FEATURE_IPV6 ++//config: help ++//config: udhcpc6 is a DHCPv6 client + + //applet:IF_UDHCPC6(APPLET(udhcpc6, BB_DIR_USR_BIN, BB_SUID_DROP)) + +-- +1.7.9.7 + diff --git a/sys-apps/busybox/files/busybox-1.20.2-glibc-sys-resource.patch b/sys-apps/busybox/files/busybox-1.20.2-glibc-sys-resource.patch new file mode 100644 index 0000000..f682d00 --- /dev/null +++ b/sys-apps/busybox/files/busybox-1.20.2-glibc-sys-resource.patch @@ -0,0 +1,109 @@ +https://bugs.gentoo.org/424954 + +From c5fe9f7b723f949457263ef8e22ab807d5b549ce Mon Sep 17 00:00:00 2001 +From: Mike Frysinger +Date: Thu, 5 Jul 2012 23:19:09 -0400 +Subject: [PATCH] include sys/resource.h where needed + +We use functions from sys/resource.h in misc applets, but don't include +the header. This breaks building with newer glibc versions, so add the +include where needed. + +Signed-off-by: Mike Frysinger +--- + loginutils/passwd.c | 1 + + miscutils/time.c | 1 + + networking/inetd.c | 1 + + networking/ntpd.c | 1 + + networking/ntpd_simple.c | 1 + + runit/chpst.c | 1 + + shell/shell_common.c | 1 + + 7 files changed, 7 insertions(+) + +diff --git a/loginutils/passwd.c b/loginutils/passwd.c +index b83db00..a7006f0 100644 +--- a/loginutils/passwd.c ++++ b/loginutils/passwd.c +@@ -15,6 +15,7 @@ + + #include "libbb.h" + #include ++#include /* setrlimit */ + + static void nuke_str(char *str) + { +diff --git a/miscutils/time.c b/miscutils/time.c +index 945f15f..ffed386 100644 +--- a/miscutils/time.c ++++ b/miscutils/time.c +@@ -16,6 +16,7 @@ + //usage: "\n -v Verbose" + + #include "libbb.h" ++#include /* getrusage */ + + /* Information on the resources used by a child process. */ + typedef struct { +diff --git a/networking/inetd.c b/networking/inetd.c +index 1308d74..00baf69 100644 +--- a/networking/inetd.c ++++ b/networking/inetd.c +@@ -165,6 +165,7 @@ + //usage: "\n (default: 0 - disabled)" + + #include ++#include /* setrlimit */ + #include + + #include "libbb.h" +diff --git a/networking/ntpd.c b/networking/ntpd.c +index 72e9d0b..5b92db6 100644 +--- a/networking/ntpd.c ++++ b/networking/ntpd.c +@@ -46,6 +46,7 @@ + #include "libbb.h" + #include + #include /* For IPTOS_LOWDELAY definition */ ++#include /* setpriority */ + #include + #ifndef IPTOS_LOWDELAY + # define IPTOS_LOWDELAY 0x10 +diff --git a/networking/ntpd_simple.c b/networking/ntpd_simple.c +index 4ad44e4..1b7c66b 100644 +--- a/networking/ntpd_simple.c ++++ b/networking/ntpd_simple.c +@@ -7,6 +7,7 @@ + */ + #include "libbb.h" + #include /* For IPTOS_LOWDELAY definition */ ++#include /* setpriority */ + #ifndef IPTOS_LOWDELAY + # define IPTOS_LOWDELAY 0x10 + #endif +diff --git a/runit/chpst.c b/runit/chpst.c +index ac296ba..ed72c8b 100644 +--- a/runit/chpst.c ++++ b/runit/chpst.c +@@ -91,6 +91,7 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + //usage: "\n a SIGXCPU after N seconds" + + #include "libbb.h" ++#include /* getrlimit */ + + /* + Five applets here: chpst, envdir, envuidgid, setuidgid, softlimit. +diff --git a/shell/shell_common.c b/shell/shell_common.c +index 51c92d6..780e27e 100644 +--- a/shell/shell_common.c ++++ b/shell/shell_common.c +@@ -18,6 +18,7 @@ + */ + #include "libbb.h" + #include "shell_common.h" ++#include /* getrlimit */ + + const char defifsvar[] ALIGN1 = "IFS= \t\n"; + +-- +1.7.9.7 + diff --git a/sys-apps/busybox/files/busybox-1.20.2-libselinux-2.1.12-support.patch b/sys-apps/busybox/files/busybox-1.20.2-libselinux-2.1.12-support.patch new file mode 100644 index 0000000..bf90a20 --- /dev/null +++ b/sys-apps/busybox/files/busybox-1.20.2-libselinux-2.1.12-support.patch @@ -0,0 +1,12 @@ +diff -urN a/Makefile.flags b/Makefile.flags +--- a/Makefile.flags 2012-06-26 08:35:45.000000000 -0500 ++++ b/Makefile.flags 2012-10-08 11:58:39.575277969 -0500 +@@ -127,7 +127,7 @@ + endif + + ifeq ($(CONFIG_SELINUX),y) +-LDLIBS += selinux sepol ++LDLIBS += pcre selinux sepol + endif + + ifeq ($(CONFIG_EFENCE),y) diff --git a/sys-apps/busybox/files/ginit.c b/sys-apps/busybox/files/ginit.c new file mode 100644 index 0000000..355ae48 --- /dev/null +++ b/sys-apps/busybox/files/ginit.c @@ -0,0 +1,124 @@ +/* + * simple init to bootstrap sep-/usr + * + * Copyright (C) 2012 Mike Frysinger + * + * Licensed under GPLv2 or later + */ + +//applet:IF_INIT(APPLET(ginit, BB_DIR_SBIN, BB_SUID_DROP)) + +//kbuild:lib-$(CONFIG_GINIT) += ginit.o + +//config:config GINIT +//config: bool "ginit" +//config: default y +//config: select MKDIR +//config: select MDEV +//config: select MOUNT +//config: select MOUNTPOINT +//config: help +//config: sep-/usr bootstrapper + +//usage:#define ginit_trivial_usage NOUSAGE_STR +//usage:#define ginit_full_usage "" + +#include "libbb.h" + +#define eprintf(fmt, args...) printf("%s" fmt, "sep-usr init: ", ## args) + +static void process_args(char **args) +{ + size_t i; + + eprintf("running: "); + for (i = 0; args[i]; ++i) { + /* String needs to be writable, so dupe it */ + args[i] = xstrdup(args[i]); + printf("'%s' ", args[i]); + } + printf("\n"); +} + +int ginit_main(int argc UNUSED_PARAM, char **argv) MAIN_EXTERNALLY_VISIBLE; +int ginit_main(int argc UNUSED_PARAM, char **argv) +{ + FILE *mntlist; + bool ismnted_dev, ismnted_sys, ismnted_usr; + struct mntent *mntent; + + /* + int fd = open("/dev/console", O_RDWR); + if (fd >= 0) { + dup2(fd, 0); + dup2(fd, 1); + dup2(fd, 2); + } + */ + + /* If given an argv[] with an applet name, run it instead. + * Makes recovering simple by doing: init=/ginit bb + */ + if (argv[1] && argv[1][0] != '/') { + eprintf("running user requested applet %s\n", argv[1]); + return spawn_and_wait(argv+1); + } + +#define saw(argv...) \ + ({ \ + static const char *args[] = { argv, NULL }; \ + /* These casts are fine -- see process_args for mem setup */ \ + process_args((void *)args); \ + spawn_and_wait((void *)args); \ + }) + + /* First setup basic /dev */ + if (saw("mountpoint", "-q", "/dev") != 0) { + /* Try /etc/fstab */ + if (saw("mount", "-n", "/dev")) + /* Then devtmpfs */ + if (saw("mount", "-n", "-t", "devtmpfs", "devtmpfs", "/dev")) + /* Finally normal tmpfs */ + saw("mount", "-n", "-t", "tmpfs", "dev", "/dev"); + } else { + eprintf("%s appears to be mounted; skipping its setup\n", "/dev"); + } + + /* If /dev is empty (e.g. tmpfs), run mdev to seed things */ + if (access("/dev/console", F_OK) != 0) { + if (saw("mountpoint", "-q", "/sys") != 0) { + if (saw("mount", "-n", "/sys")) + saw("mount", "-n", "-t", "sysfs", "sysfs", "/sys"); + } else { + eprintf("%s appears to be mounted; skipping its setup\n", "/sys"); + } + + /* Mount /proc as mdev will fork+exec /proc/self/exe */ + if (saw("mountpoint", "-q", "/proc") != 0) { + /* Try /etc/fstab */ + if (saw("mount", "-n", "/proc")) + saw("mount", "-n", "-t", "proc", "proc", "/proc"); + } + + saw("mdev", "-s"); + } + + /* Then seed the stuff we care about */ + saw("mkdir", "-p", "/dev/pts", "/dev/shm"); + + /* Then mount /usr */ + if (saw("mountpoint", "-q", "/usr") != 0) { + saw("mount", "-n", "/usr", "-o", "ro"); + } else { + eprintf("%s appears to be mounted; skipping its setup\n", "/usr"); + } + + /* Now that we're all done, exec the real init */ + if (!argv[1]) { + argv[0] = (void *)"/sbin/init"; + argv[1] = NULL; + } else + ++argv; + process_args(argv); + return execv(argv[0], argv); +} diff --git a/sys-apps/busybox/files/mdev.rc.1 b/sys-apps/busybox/files/mdev.rc.1 new file mode 100755 index 0000000..569d540 --- /dev/null +++ b/sys-apps/busybox/files/mdev.rc.1 @@ -0,0 +1,98 @@ +#!/sbin/runscript +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/files/mdev.rc.1,v 1.2 2012/09/26 21:25:23 robbat2 Exp $ + +depend() +{ + provide dev dev-mount + need sysfs +} + +find_mdev() +{ + if [ -x /sbin/mdev ] ; then + echo "/sbin/mdev" + else + echo "/bin/busybox mdev" + fi +} + +populate_mdev() +{ + # populate /dev with devices already found by the kernel + + if get_bootparam "nocoldplug" ; then + RC_COLDPLUG="no" + ewarn "Skipping mdev coldplug as requested in kernel cmdline" + fi + + ebegin "Populating /dev with existing devices with mdev -s" + $(find_mdev) -s + eend $? + + return 0 +} + +seed_dev() +{ + # Seed /dev with some things that we know we need + + # creating /dev/console and /dev/tty1 to be able to write + # to $CONSOLE with/without bootsplash before mdev creates it + [ -c /dev/console ] || mknod /dev/console c 5 1 + [ -c /dev/tty1 ] || mknod /dev/tty1 c 4 1 + + # udevd will dup its stdin/stdout/stderr to /dev/null + # and we do not want a file which gets buffered in ram + [ -c /dev/null ] || mknod /dev/null c 1 3 + + # copy over any persistant things + if [ -d /lib/mdev/devices ] ; then + cp -RPp /lib/mdev/devices/* /dev 2>/dev/null + fi + + # Not provided by sysfs but needed + ln -snf /proc/self/fd /dev/fd + ln -snf fd/0 /dev/stdin + ln -snf fd/1 /dev/stdout + ln -snf fd/2 /dev/stderr + [ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core + + # Create problematic directories + mkdir -p /dev/pts /dev/shm +} + +mount_it() +{ + if fstabinfo --quiet /dev ; then + mount -n /dev + else + # Some devices require exec, Bug #92921 + mount -n -t tmpfs -o "exec,nosuid,mode=0755,size=10M" mdev /dev + fi +} + +start() +{ + # Setup temporary storage for /dev + ebegin "Mounting /dev for mdev" + mount_it + eend $? + + # Create a file so that our rc system knows it's still in sysinit. + # Existance means init scripts will not directly run. + # rc will remove the file when done with sysinit. + touch /dev/.rcsysinit + + seed_dev + + # Setup hotplugging (if possible) + if [ -e /proc/sys/kernel/hotplug ] ; then + ebegin "Setting up mdev as hotplug agent" + echo $(find_mdev) > /proc/sys/kernel/hotplug + eend 0 + fi + + populate_mdev +} diff --git a/sys-apps/busybox/files/mdev/dvbdev b/sys-apps/busybox/files/mdev/dvbdev new file mode 100644 index 0000000..f0186c1 --- /dev/null +++ b/sys-apps/busybox/files/mdev/dvbdev @@ -0,0 +1,18 @@ +#!/bin/sh + +# MDEV=dvb0.demux1 -> ADAPTER=dvb0 -> N=0 +ADAPTER=${MDEV%.*} +N=${ADAPTER#dvb} +# MDEV=dvb0.demux1 -> DEVB_DEV=demux1 +DVB_DEV=${MDEV#*.} + +case "$ACTION" in + add|"") + mkdir -p dvb/adapter${N} + mv ${MDEV} dvb/adapter${N}/${DVB_DEV} + ;; + remove) + rm -f dvb/adapter${N}/${DVB_DEV} + rmdir dvb/adapter${N} 2>/dev/null + rmdir dvb/ 2>/dev/null +esac diff --git a/sys-apps/busybox/files/mdev/ide_links b/sys-apps/busybox/files/mdev/ide_links new file mode 100644 index 0000000..be0c95a --- /dev/null +++ b/sys-apps/busybox/files/mdev/ide_links @@ -0,0 +1,23 @@ +#!/bin/sh + +[ -f /proc/ide/$MDEV/media ] || exit + +media=`cat /proc/ide/$MDEV/media` +for i in $media $media[0-9]* ; do + if [ "`readlink $i 2>/dev/null`" = $MDEV ] ; then + LINK=$i + break + fi +done + +# link exist, remove if necessary and exit +if [ "$LINK" ] ; then + [ "$ACTION" = remove ] && rm $LINK + exit +fi + +# create a link +num=`ls $media[0-9]* 2>/dev/null | wc -l` +ln -sf $MDEV "$media`echo $num`" +[ -e "$media" ] || ln -sf $MDEV "$media" + diff --git a/sys-apps/busybox/files/mdev/usbdev b/sys-apps/busybox/files/mdev/usbdev new file mode 100644 index 0000000..ea5b915 --- /dev/null +++ b/sys-apps/busybox/files/mdev/usbdev @@ -0,0 +1,62 @@ +#!/bin/sh + +# script is buggy; until patched just do exit 0 +#exit 0 + +# add zeros to device or bus +add_zeros () { + case "$(echo $1 | wc -L)" in + 1) echo "00$1" ;; + 2) echo "0$1" ;; + *) echo "$1" + esac + exit 0 +} + + +# bus and device dirs in /sys +USB_PATH=$(echo $MDEV | sed -e 's/usbdev\([0-9]\).[0-9]/usb\1/') +USB_PATH=$(find /sys/devices -type d -name "$USB_PATH") +USB_DEV_DIR=$(echo $MDEV | sed -e 's/usbdev\([0-9]\).\([0-9]\)/\1-\2/') + +# dir names in /dev +BUS=$(add_zeros $(echo $MDEV | sed -e 's/^usbdev\([0-9]\).[0-9]/\1/')) +USB_DEV=$(add_zeros $(echo $MDEV | sed -e 's/^usbdev[0-9].\([0-9]\)/\1/')) + + +# try to load the proper driver for usb devices +case "$ACTION" in + add|"") + # load usb bus driver + for i in $USB_PATH/*/modalias ; do + modprobe `cat $i` 2>/dev/null + done + # load usb device driver if existent + if [ -d $USB_PATH/$USB_DEV_DIR ]; then + for i in $USB_PATH/$USB_DEV_DIR/*/modalias ; do + modprobe `cat $i` 2>/dev/null + done + fi + # move usb device file + mkdir -p bus/usb/$BUS + mv $MDEV bus/usb/$BUS/$USB_DEV + ;; + remove) + # unload device driver, if device dir is existent + if [ -d $USB_PATH/$USB_DEV_DIR ]; then + for i in $USB_PATH/$USB_DEV_DIR/*/modalias ; do + modprobe -r `cat $i` 2>/dev/null + done + fi + # unload usb bus driver. Does this make sense? + # what happens, if two usb devices are plugged in + # and one is removed? + for i in $USB_PATH/*/modalias ; do + modprobe -r `cat $i` 2>/dev/null + done + # remove device file and possible empty dirs + rm -f bus/usb/$BUS/$USB_DEV + rmdir bus/usb/$BUS/ 2>/dev/null + rmdir bus/usb/ 2>/dev/null + rmdir bus/ 2>/dev/null +esac diff --git a/sys-apps/busybox/files/mdev/usbdisk_link b/sys-apps/busybox/files/mdev/usbdisk_link new file mode 100644 index 0000000..750242b --- /dev/null +++ b/sys-apps/busybox/files/mdev/usbdisk_link @@ -0,0 +1,34 @@ +#!/bin/sh + +# NOTE: since mdev -s only provide $MDEV, don't depend on any hotplug vars. + +current=$(readlink usbdisk) + +if [ "$current" = "$MDEV" ] && [ "$ACTION" = "remove" ]; then + rm -f usbdisk usba1 +fi +[ -n "$current" ] && exit + +if [ -e /sys/block/$MDEV ]; then + SYSDEV=$(readlink -f /sys/block/$MDEV/device) + # if /sys device path contains '/usb[0-9]' then we assume its usb + # also, if its an usb without partitions we require FAT + if [ "${SYSDEV##*/usb[0-9]}" != "$SYSDEV" ]; then + # do not create link if there is not FAT + dd if=/dev/$MDEV bs=512 count=1 2>/dev/null | strings | grep FAT >/dev/null || exit 0 + + ln -sf $MDEV usbdisk + # keep this for compat. people have it in fstab + ln -sf $MDEV usba1 + fi + +elif [ -e /sys/block/*/$MDEV ] ; then + PARENT=$(dirname /sys/block/*/$MDEV) + SYSDEV=$(readlink -f $PARENT/device) + if [ "${SYSDEV##*/usb[0-9]}" != "$SYSDEV" ]; then + ln -sf $MDEV usbdisk + # keep this for compat. people have it in fstab + ln -sf $MDEV usba1 + fi +fi + -- cgit v1.2.3-65-gdbad