Makefile 2.6 KB

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