All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Weber <matthew.weber@rockwellcollins.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 16/30] busybox: applets as individual binaries
Date: Mon, 15 Dec 2014 21:54:08 -0600	[thread overview]
Message-ID: <1418702062-61039-17-git-send-email-matthew.weber@rockwellcollins.com> (raw)
In-Reply-To: <1418702062-61039-1-git-send-email-matthew.weber@rockwellcollins.com>

The individual binaries option of busybox allows for the applets
that would usually be symlinks to be built as individual applications
that link against a shared library.

This feature is needed for SELinux to allow the applications to run
under the correct SELinux context.

The patch being added allows the individual applications to be
installed and will be upstreamed to the busybox developers.

The initial work for this change was done by Thomas Petazzoni
<thomas.petazzoni@free-electrons.com>.

Signed-off-by: Clayton Shotwell <clshotwe@rockwellcollins.com>
Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com>
---
 package/busybox/Config.in                          |   7 ++
 ...s-Add-installation-of-individual-binaries.patch | 103 +++++++++++++++++++++
 package/busybox/busybox.mk                         |  34 +++++++
 3 files changed, 144 insertions(+)
 create mode 100644 package/busybox/busybox-0007-applets-Add-installation-of-individual-binaries.patch

diff --git a/package/busybox/Config.in b/package/busybox/Config.in
index f2f2990..2344c4e 100644
--- a/package/busybox/Config.in
+++ b/package/busybox/Config.in
@@ -26,6 +26,13 @@ config BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 	  Show packages in menuconfig that are potentially also provided
 	  by busybox.
 
+config BR2_PACKAGE_BUSYBOX_INDIVIDUAL_BINARIES
+	bool "Individual binaries"
+	depends on !BR2_PREFER_STATIC_LIB
+
+comment "Busybox individual binaries depends on dynamic libraries"
+	depends on BR2_PREFER_STATIC_LIB
+
 config BR2_PACKAGE_BUSYBOX_WATCHDOG
 	bool "Install the watchdog daemon startup script"
 	help
diff --git a/package/busybox/busybox-0007-applets-Add-installation-of-individual-binaries.patch b/package/busybox/busybox-0007-applets-Add-installation-of-individual-binaries.patch
new file mode 100644
index 0000000..e7b9178
--- /dev/null
+++ b/package/busybox/busybox-0007-applets-Add-installation-of-individual-binaries.patch
@@ -0,0 +1,103 @@
+From 3451b55054a6fe2073a21301938802a27dec835d Mon Sep 17 00:00:00 2001
+From: Clayton Shotwell <clshotwe@rockwellcollins.com>
+Date: Mon, 16 Dec 2013 14:45:33 -0600
+Subject: [PATCH 5/5] applets: Add installation of individual binaries
+
+Adding support to install individual binaries if the option is
+enabled. This also installs the shared libbusybox.so.* library.
+
+Signed-off-by: Clayton Shotwell <clshotwe@rockwellcollins.com>
+---
+ Makefile.custom    |    4 ++++
+ applets/install.sh |   26 ++++++++++++++++++++++++--
+ 2 files changed, 28 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile.custom b/Makefile.custom
+index 6da79e6..e4dc4dc 100644
+--- a/Makefile.custom
++++ b/Makefile.custom
+@@ -23,6 +23,10 @@ ifeq ($(CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER),y)
+ INSTALL_OPTS:= --scriptwrapper
+ endif
+ endif
++ifeq ($(CONFIG_FEATURE_INDIVIDUAL),y)
++INSTALL_OPTS:= --binaries
++LIBBUSYBOX_SONAME:= 0_lib/libbusybox.so.$(BB_VER)
++endif
+ install: $(srctree)/applets/install.sh busybox busybox.links
+ 	$(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
+ 		$(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
+diff --git a/applets/install.sh b/applets/install.sh
+index 95b4719..d01c98d 100755
+--- a/applets/install.sh
++++ b/applets/install.sh
+@@ -5,19 +5,26 @@ export LC_CTYPE=POSIX
+ 
+ prefix=$1
+ if [ -z "$prefix" ]; then
+-	echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--scriptwrapper]"
++	echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--binaries/--scriptwrapper]"
+ 	exit 1
+ fi
+ 
++# Source the configuration
++. ./.config
++
+ h=`sort busybox.links | uniq`
+ 
++sharedlib_dir="0_lib"
++
+ linkopts=""
+ scriptwrapper="n"
++binaries="n"
+ cleanup="0"
+ noclobber="0"
+ case "$2" in
+ 	--hardlinks)     linkopts="-f";;
+ 	--symlinks)      linkopts="-fs";;
++	--binaries)      binaries="y";;
+ 	--scriptwrapper) scriptwrapper="y";swrapall="y";;
+ 	--sw-sh-hard)    scriptwrapper="y";linkopts="-f";;
+ 	--sw-sh-sym)     scriptwrapper="y";linkopts="-fs";;
+@@ -40,8 +47,9 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
+ 	for i in $DO_INSTALL_LIBS; do
+ 		rm -f "$prefix/$libdir/$i" || exit 1
+ 		if [ -f "$i" ]; then
++			echo "   Installing $i to the target@$prefix/$libdir/"
+ 			cp -pPR "$i" "$prefix/$libdir/" || exit 1
+-			chmod 0644 "$prefix/$libdir/$i" || exit 1
++			chmod 0644 "$prefix/$libdir/`basename $i`" || exit 1
+ 		fi
+ 	done
+ fi
+@@ -68,6 +76,7 @@ install -m 755 busybox "$prefix/bin/busybox" || exit 1
+ 
+ for i in $h; do
+ 	appdir=`dirname "$i"`
++	app=`basename "$i"`
+ 	mkdir -p "$prefix/$appdir" || exit 1
+ 	if [ "$scriptwrapper" = "y" ]; then
+ 		if [ "$swrapall" != "y" ] && [ "$i" = "/bin/sh" ]; then
+@@ -78,6 +87,19 @@ for i in $h; do
+ 			chmod +x "$prefix/$i"
+ 		fi
+ 		echo "	$prefix/$i"
++	elif [ "$binaries" = "y" ]; then
++		# Copy the binary over rather
++		if [ -e $sharedlib_dir/$app ]; then
++			if [ "$noclobber" = "0" ] || [ ! -e "$prefix/$i" ]; then
++				echo "   Copying $sharedlib_dir/$app to $prefix/$i"
++				cp -a $sharedlib_dir/$app $prefix/$i || exit 1
++			else
++				echo "  $prefix/$i already exists"
++			fi
++		else
++			echo "Error: Could not find $sharedlib_dir/$app"
++			exit 1
++		fi
+ 	else
+ 		if [ "$2" = "--hardlinks" ]; then
+ 			bb_path="$prefix/bin/busybox"
+-- 
+1.7.1
+
diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
index 9fb389d..e689d2d 100644
--- a/package/busybox/busybox.mk
+++ b/package/busybox/busybox.mk
@@ -49,10 +49,31 @@ BUSYBOX_KCONFIG_FILE = $(BUSYBOX_CONFIG_FILE)
 BUSYBOX_KCONFIG_EDITORS = menuconfig xconfig gconfig
 BUSYBOX_KCONFIG_OPTS = $(BUSYBOX_MAKE_OPTS)
 
+ifeq ($(BR2_PACKAGE_BUSYBOX_INDIVIDUAL_BINARIES),y)
+define BUSYBOX_PERMISSIONS
+# Applets with BB_SUID_REQUIRE
+/usr/bin/crontab		 f 4755	0 0 - - - - -
+/bin/login			 f 4755	0 0 - - - - -
+/usr/bin/passwd		 f 4755	0 0 - - - - -
+/bin/su			 f 4755	0 0 - - - - -
+/usr/bin/vlock			 f 4755	0 0 - - - - -
+/usr/bin/wall			 f 4755	0 0 - - - - -
+# Applets with BB_SUID_MAYBE
+/bin/ping			 f 4755	0 0 - - - - -
+/bin/ping6			 f 4755	0 0 - - - - -
+/sbin/findfs			 f 4755	0 0 - - - - -
+/bin/mount			 f 4755	0 0 - - - - -
+/usr/bin/traceroute		 f 4755	0 0 - - - - -
+/usr/bin/traceroute6		 f 4755	0 0 - - - - -
+# Other files
+/usr/share/udhcpc/default.script f 755  0 0 - - - - -
+endef
+else
 define BUSYBOX_PERMISSIONS
 	/bin/busybox                     f 4755 0  0 - - - - -
 	/usr/share/udhcpc/default.script f 755  0  0 - - - - -
 endef
+endif
 
 # If mdev will be used for device creation enable it and copy S10mdev to /etc/init.d
 ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV),y)
@@ -161,6 +182,17 @@ define BUSYBOX_SET_INIT
 endef
 endif
 
+ifeq ($(BR2_PACKAGE_BUSYBOX_INDIVIDUAL_BINARIES),y)
+define BUSYBOX_CONFIGURE_INDIVIDUAL_BINARIES
+	$(call KCONFIG_ENABLE_OPT,CONFIG_BUILD_LIBBUSYBOX,$(BUSYBOX_BUILD_CONFIG))
+	$(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_INDIVIDUAL,$(BUSYBOX_BUILD_CONFIG))
+endef
+
+define BUSYBOX_INSTALL_INDIVIDUAL_BINARIES
+	rm -f $(TARGET_DIR)/bin/busybox
+endef
+endif
+
 define BUSYBOX_INSTALL_LOGGING_SCRIPT
 	if grep -q CONFIG_SYSLOGD=y $(@D)/.config; then \
 		$(INSTALL) -m 0755 -D package/busybox/S01logging \
@@ -198,6 +230,7 @@ define BUSYBOX_KCONFIG_FIXUP_CMDS
 	$(BUSYBOX_INTERNAL_SHADOW_PASSWORDS)
 	$(BUSYBOX_SET_INIT)
 	$(BUSYBOX_SET_WATCHDOG)
+	$(BUSYBOX_CONFIGURE_INDIVIDUAL_BINARIES)
 endef
 
 define BUSYBOX_CONFIGURE_CMDS
@@ -219,6 +252,7 @@ define BUSYBOX_INSTALL_INIT_SYSV
 	$(BUSYBOX_INSTALL_MDEV_SCRIPT)
 	$(BUSYBOX_INSTALL_LOGGING_SCRIPT)
 	$(BUSYBOX_INSTALL_WATCHDOG_SCRIPT)
+	$(BUSYBOX_INSTALL_INDIVIDUAL_BINARIES)
 endef
 
 $(eval $(kconfig-package))
-- 
1.9.1

  parent reply	other threads:[~2014-12-16  3:54 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-16  3:53 [Buildroot] [PATCH 00/29] SELinux Buildroot Additions Matt Weber
2014-12-16  3:53 ` [Buildroot] [PATCH 01/30] libselinux: new package Matt Weber
2015-01-01 19:45   ` Thomas Petazzoni
2014-12-16  3:53 ` [Buildroot] [PATCH 02/30] ustr: " Matt Weber
2015-01-01 20:10   ` Thomas Petazzoni
2014-12-16  3:53 ` [Buildroot] [PATCH 03/30] libsemanage: " Matt Weber
2015-01-01 21:43   ` Thomas Petazzoni
2014-12-16  3:53 ` [Buildroot] [PATCH 04/30] checkpolicy: " Matt Weber
2014-12-16  3:53 ` [Buildroot] [PATCH 05/30] sepolgen: " Matt Weber
2014-12-16  3:53 ` [Buildroot] [PATCH 06/30] sqlite: Add host build support Matt Weber
2014-12-16  3:53 ` [Buildroot] [PATCH 07/30] setools: new package Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 08/30] python-pyparsing: Add host build option Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 09/30] audit: new package Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 10/30] policycoreutils: " Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 11/30] python-pyxml: " Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 12/30] refpolicy: " Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 13/30] repolicy: base policy modifications for embedded target Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 14/30] refpolicy: custom git repo Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 15/30] shadow: new package Matt Weber
2014-12-16  3:54 ` Matt Weber [this message]
2014-12-16  3:54 ` [Buildroot] [PATCH 17/30] busybox: selinux support Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 18/30] busybox: added linux-pam support Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 19/30] busybox: default selinux config which disables init and uses sysvinit Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 20/30] qemu_x86_selinux_defconfig: base SELinux QEMU image for x86 Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 21/30] linux-pam: selinux support Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 22/30] sysvinit: added libselinux dependency Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 23/30] dbus: selinux file context support Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 24/30] logrotate: selinux support Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 25/30] openssh: selinux and pam support Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 26/30] util-linux: selinux, audit, " Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 27/30] vim: selinux support Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 28/30] rsyslog: fix config file comment style Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 29/30] qemu x86 readme: documented selinux target Matt Weber
2014-12-16  3:54 ` [Buildroot] [PATCH 30/30] readline: host support for host-sqlite Matt Weber
2015-01-01 21:47 ` [Buildroot] [PATCH 00/29] SELinux Buildroot Additions Thomas Petazzoni
2015-01-02 20:59   ` Matthew Weber
2015-01-06  3:15     ` Matthew Weber
2015-01-06  3:37       ` Matthew Weber
2015-01-06  8:34         ` Thomas Petazzoni
2015-01-06 13:53           ` Matthew Weber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418702062-61039-17-git-send-email-matthew.weber@rockwellcollins.com \
    --to=matthew.weber@rockwellcollins.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.