3
0

busybox.mksuid 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. # Make list of configuration variables regarding suid handling
  3. # input $1: full path to autoconf.h
  4. # input $2: full path to applets.h
  5. # input $3: full path to .config
  6. # output (stdout): list of CONFIG_ that do or may require suid
  7. # If the environment variable SUID is not set or set to DROP,
  8. # lists all config options that do not require suid permissions.
  9. # Otherwise, lists all config options for applets that DO or MAY require
  10. # suid permissions.
  11. # Maintainer: Bernhard Reutner-Fischer
  12. export LC_ALL=POSIX
  13. export LC_CTYPE=POSIX
  14. CONFIG_H=${1:-include/autoconf.h}
  15. APPLETS_H=${2:-include/applets.h}
  16. DOT_CONFIG=${3:-.config}
  17. case ${SUID:-DROP} in
  18. [dD][rR][oO][pP]) USE="DROP" ;;
  19. *) USE="suid" ;;
  20. esac
  21. $HOSTCC -E -DMAKE_SUID -include $CONFIG_H $APPLETS_H |
  22. awk -v USE=${USE} '
  23. /^SUID[ \t]/{
  24. if (USE == "DROP") {
  25. if ($2 != "BB_SUID_DROP") next
  26. } else {
  27. if ($2 == "BB_SUID_DROP") next
  28. }
  29. cfg = $NF
  30. gsub("\"", "", cfg)
  31. cfg = substr(cfg, 8)
  32. s[i++] = "CONFIG_" cfg
  33. s[i++] = "CONFIG_FEATURE_" cfg "_.*"
  34. }
  35. END{
  36. while (getline < ARGV[2]) {
  37. for (j in s) {
  38. if ($0 ~ "^" s[j] "=y$") {
  39. sub(/=.*/, "")
  40. print
  41. if (s[j] !~ /\*$/) delete s[j] # can drop this applet now
  42. }
  43. }
  44. }
  45. }
  46. ' - $DOT_CONFIG