Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Makefile for AppArmor Linux Security Module
  2. #
  3. obj-$(CONFIG_SECURITY_APPARMOR) += apparmor.o
  4. apparmor-y := apparmorfs.o audit.o capability.o context.o ipc.o lib.o match.o \
  5. path.o domain.o policy.o policy_unpack.o procattr.o lsm.o \
  6. resource.o sid.o file.o
  7. clean-files := capability_names.h rlim_names.h
  8. # Build a lower case string table of capability names
  9. # Transforms lines from
  10. # #define CAP_DAC_OVERRIDE 1
  11. # to
  12. # [1] = "dac_override",
  13. quiet_cmd_make-caps = GEN $@
  14. cmd_make-caps = echo "static const char *const capability_names[] = {" > $@ ;\
  15. sed $< >>$@ -r -n -e '/CAP_FS_MASK/d' \
  16. -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/[\2] = "\L\1",/p';\
  17. echo "};" >> $@
  18. # Build a lower case string table of rlimit names.
  19. # Transforms lines from
  20. # #define RLIMIT_STACK 3 /* max stack size */
  21. # to
  22. # [RLIMIT_STACK] = "stack",
  23. #
  24. # and build a second integer table (with the second sed cmd), that maps
  25. # RLIMIT defines to the order defined in asm-generic/resource.h This is
  26. # required by policy load to map policy ordering of RLIMITs to internal
  27. # ordering for architectures that redefine an RLIMIT.
  28. # Transforms lines from
  29. # #define RLIMIT_STACK 3 /* max stack size */
  30. # to
  31. # RLIMIT_STACK,
  32. #
  33. # and build the securityfs entries for the mapping.
  34. # Transforms lines from
  35. # #define RLIMIT_FSIZE 1 /* Maximum filesize */
  36. # #define RLIMIT_STACK 3 /* max stack size */
  37. # to
  38. # #define AA_FS_RLIMIT_MASK "fsize stack"
  39. quiet_cmd_make-rlim = GEN $@
  40. cmd_make-rlim = echo "static const char *const rlim_names[RLIM_NLIMITS] = {" \
  41. > $@ ;\
  42. sed $< >> $@ -r -n \
  43. -e 's/^\# ?define[ \t]+(RLIMIT_([A-Z0-9_]+)).*/[\1] = "\L\2",/p';\
  44. echo "};" >> $@ ;\
  45. echo "static const int rlim_map[RLIM_NLIMITS] = {" >> $@ ;\
  46. sed -r -n "s/^\# ?define[ \t]+(RLIMIT_[A-Z0-9_]+).*/\1,/p" $< >> $@ ;\
  47. echo "};" >> $@ ; \
  48. echo -n '\#define AA_FS_RLIMIT_MASK "' >> $@ ;\
  49. sed -r -n 's/^\# ?define[ \t]+RLIMIT_([A-Z0-9_]+).*/\L\1/p' $< | \
  50. tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
  51. $(obj)/capability.o : $(obj)/capability_names.h
  52. $(obj)/resource.o : $(obj)/rlim_names.h
  53. $(obj)/capability_names.h : $(srctree)/include/linux/capability.h \
  54. $(src)/Makefile
  55. $(call cmd,make-caps)
  56. $(obj)/rlim_names.h : $(srctree)/include/asm-generic/resource.h \
  57. $(src)/Makefile
  58. $(call cmd,make-rlim)