diff --git a/Makefile.custom b/Makefile.custom index 41c351f..3561e57 100644 --- a/Makefile.custom +++ b/Makefile.custom @@ -5,8 +5,10 @@ busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h include/applets.h $(Q)-$(SHELL) $^ > $@ -busybox.applets.suid: $(srctree)/applets/busybox.mksuid $(objtree)/include/autoconf.h include/applets.h - $(Q)-$(SHELL) $^ > $@ +busybox.cfg.suid: $(srctree)/applets/busybox.mksuid $(objtree)/include/autoconf.h include/applets.h + $(Q)-SUID="yes" $(SHELL) $^ > $@ +busybox.cfg.nosuid: $(srctree)/applets/busybox.mksuid $(objtree)/include/autoconf.h include/applets.h + $(Q)-SUID="DROP" $(SHELL) $^ > $@ .PHONY: install ifeq ($(CONFIG_INSTALL_APPLET_SYMLINKS),y) diff --git a/applets/busybox.mksuid b/applets/busybox.mksuid index 4235d89..6492c07 100755 --- a/applets/busybox.mksuid +++ b/applets/busybox.mksuid @@ -1,11 +1,16 @@ #!/bin/sh -# Make busybox list of applets that do NOT drop suid permissions +# Make list of configuration variables regarding suid handling # input $1: full path to autoconf.h # input $2: full path to applets.h # input $3: full path to .config # output (stdout): list of CONFIG_ that do or may require suid +# If the environment variable SUID is not set or set to DROP, +# lists all config options that do not require suid permissions. +# Otherwise, lists all config options for applets that DO or MAY require +# suid permissions. + # Maintainer: Bernhard Reutner-Fischer export LC_ALL=POSIX @@ -14,10 +19,20 @@ export LC_CTYPE=POSIX CONFIG_H=${1:-include/autoconf.h} APPLETS_H=${2:-include/applets.h} DOT_CONFIG=${3:-.config} + +case ${SUID:-DROP} in +[dD][rR][oO][pP]) USE="DROP" ;; +*) USE="suid" ;; +esac + $HOSTCC -E -DMAKE_SUID -include $CONFIG_H $APPLETS_H | - awk ' + awk -v USE=${USE} ' /^SUID[ \t]/{ - if ($2 == "BB_SUID_DROP") next + if (USE == "DROP") { + if ($2 != "BB_SUID_DROP") next + } else { + if ($2 == "BB_SUID_DROP") next + } cfg = $NF gsub("\"", "", cfg) cfg = substr(cfg, 8)