diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2013-06-10 17:08:22 +0200 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2013-07-26 13:39:46 +0200 |
commit | 9078633feeb129d679c97d900807ef2d5b253b65 (patch) | |
tree | 153f82ae904f01bcba2edd6197b7f5995a013a05 /applets | |
parent | 7801148a816a2ab1c2f9437c8992c86722361147 (diff) | |
download | busybox-w32-9078633feeb129d679c97d900807ef2d5b253b65.tar.gz busybox-w32-9078633feeb129d679c97d900807ef2d5b253b65.tar.bz2 busybox-w32-9078633feeb129d679c97d900807ef2d5b253b65.zip |
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-x | applets/busybox.mksuid | 54 |
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 @@ | |||
1 | #!/bin/sh | ||
2 | # Make list of configuration variables regarding suid handling | ||
3 | |||
4 | # input $1: full path to autoconf.h | ||
5 | # input $2: full path to applets.h | ||
6 | # input $3: full path to .config | ||
7 | # output (stdout): list of CONFIG_ that do or may require suid | ||
8 | |||
9 | # If the environment variable SUID is not set or set to DROP, | ||
10 | # lists all config options that do not require suid permissions. | ||
11 | # Otherwise, lists all config options for applets that DO or MAY require | ||
12 | # suid permissions. | ||
13 | |||
14 | # Maintainer: Bernhard Reutner-Fischer | ||
15 | |||
16 | export LC_ALL=POSIX | ||
17 | export LC_CTYPE=POSIX | ||
18 | |||
19 | CONFIG_H=${1:-include/autoconf.h} | ||
20 | APPLETS_H=${2:-include/applets.h} | ||
21 | DOT_CONFIG=${3:-.config} | ||
22 | |||
23 | case ${SUID:-DROP} in | ||
24 | [dD][rR][oO][pP]) USE="DROP" ;; | ||
25 | *) USE="suid" ;; | ||
26 | esac | ||
27 | |||
28 | $HOSTCC -E -DMAKE_SUID -include $CONFIG_H $APPLETS_H | | ||
29 | awk -v USE=${USE} ' | ||
30 | /^SUID[ \t]/{ | ||
31 | if (USE == "DROP") { | ||
32 | if ($2 != "BB_SUID_DROP") next | ||
33 | } else { | ||
34 | if ($2 == "BB_SUID_DROP") next | ||
35 | } | ||
36 | cfg = $NF | ||
37 | gsub("\"", "", cfg) | ||
38 | cfg = substr(cfg, 8) | ||
39 | s[i++] = "CONFIG_" cfg | ||
40 | s[i++] = "CONFIG_FEATURE_" cfg "_.*" | ||
41 | } | ||
42 | END{ | ||
43 | while (getline < ARGV[2]) { | ||
44 | for (j in s) { | ||
45 | if ($0 ~ "^" s[j] "=y$") { | ||
46 | sub(/=.*/, "") | ||
47 | |||
48 | if (s[j] !~ /\*$/) delete s[j] # can drop this applet now | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | ' - $DOT_CONFIG | ||
54 | |||