summaryrefslogtreecommitdiffhomepage
path: root/applets
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2013-06-10 17:08:22 +0200
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2013-07-26 13:39:46 +0200
commit9078633feeb129d679c97d900807ef2d5b253b65 (patch)
tree153f82ae904f01bcba2edd6197b7f5995a013a05 /applets
parent7801148a816a2ab1c2f9437c8992c86722361147 (diff)
buildsys: Add helper to list suid applets
Add a helper script that lists all applets that - do or may require SUID provileges (busybox.cfg.suid) - do not require SUID provileges (busybox.cfg.nosuid) Some setups prefer to build two busybox binaries, one that is suid which contains all applets that do or may require suid privileges, and a second one for all the rest (which drops suid). To ease splitting these two binaries, generate a list of CONFIG_ items for the suid binary. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'applets')
-rwxr-xr-xapplets/busybox.mksuid54
1 files changed, 54 insertions, 0 deletions
diff --git a/applets/busybox.mksuid b/applets/busybox.mksuid
new file mode 100755
index 000000000..6492c079a
--- /dev/null
+++ b/applets/busybox.mksuid
@@ -0,0 +1,54 @@
+#!/bin/sh
+# 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
+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 -v USE=${USE} '
+ /^SUID[ \t]/{
+ if (USE == "DROP") {
+ if ($2 != "BB_SUID_DROP") next
+ } else {
+ if ($2 == "BB_SUID_DROP") next
+ }
+ cfg = $NF
+ gsub("\"", "", cfg)
+ cfg = substr(cfg, 8)
+ s[i++] = "CONFIG_" cfg
+ s[i++] = "CONFIG_FEATURE_" cfg "_.*"
+ }
+ END{
+ while (getline < ARGV[2]) {
+ for (j in s) {
+ if ($0 ~ "^" s[j] "=y$") {
+ sub(/=.*/, "")
+ print
+ if (s[j] !~ /\*$/) delete s[j] # can drop this applet now
+ }
+ }
+ }
+ }
+' - $DOT_CONFIG
+