Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 secid.o file.o policy_ns.o label.o mount.o net.o
  7. apparmor-$(CONFIG_SECURITY_APPARMOR_HASH) += crypto.o
  8. clean-files := capability_names.h rlim_names.h net_names.h
  9. # Build a lower case string table of address family names
  10. # Transform lines from
  11. # #define AF_LOCAL 1 /* POSIX name for AF_UNIX */
  12. # #define AF_INET 2 /* Internet IP Protocol */
  13. # to
  14. # [1] = "local",
  15. # [2] = "inet",
  16. #
  17. # and build the securityfs entries for the mapping.
  18. # Transforms lines from
  19. # #define AF_INET 2 /* Internet IP Protocol */
  20. # to
  21. # #define AA_SFS_AF_MASK "local inet"
  22. quiet_cmd_make-af = GEN $@
  23. cmd_make-af = echo "static const char *address_family_names[] = {" > $@ ;\
  24. sed $< >>$@ -r -n -e "/AF_MAX/d" -e "/AF_LOCAL/d" -e "/AF_ROUTE/d" -e \
  25. 's/^\#define[ \t]+AF_([A-Z0-9_]+)[ \t]+([0-9]+)(.*)/[\2] = "\L\1",/p';\
  26. echo "};" >> $@ ;\
  27. printf '%s' '\#define AA_SFS_AF_MASK "' >> $@ ;\
  28. sed -r -n -e "/AF_MAX/d" -e "/AF_LOCAL/d" -e "/AF_ROUTE/d" -e \
  29. 's/^\#define[ \t]+AF_([A-Z0-9_]+)[ \t]+([0-9]+)(.*)/\L\1/p'\
  30. $< | tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
  31. # Build a lower case string table of sock type names
  32. # Transform lines from
  33. # SOCK_STREAM = 1,
  34. # to
  35. # [1] = "stream",
  36. quiet_cmd_make-sock = GEN $@
  37. cmd_make-sock = echo "static const char *sock_type_names[] = {" >> $@ ;\
  38. sed $^ >>$@ -r -n \
  39. -e 's/^\tSOCK_([A-Z0-9_]+)[\t]+=[ \t]+([0-9]+)(.*)/[\2] = "\L\1",/p';\
  40. echo "};" >> $@
  41. # Build a lower case string table of capability names
  42. # Transforms lines from
  43. # #define CAP_DAC_OVERRIDE 1
  44. # to
  45. # [1] = "dac_override",
  46. quiet_cmd_make-caps = GEN $@
  47. cmd_make-caps = echo "static const char *const capability_names[] = {" > $@ ;\
  48. sed $< >>$@ -r -n -e '/CAP_FS_MASK/d' \
  49. -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/[\2] = "\L\1",/p';\
  50. echo "};" >> $@ ;\
  51. printf '%s' '\#define AA_SFS_CAPS_MASK "' >> $@ ;\
  52. sed $< -r -n -e '/CAP_FS_MASK/d' \
  53. -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/\L\1/p' | \
  54. tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
  55. # Build a lower case string table of rlimit names.
  56. # Transforms lines from
  57. # #define RLIMIT_STACK 3 /* max stack size */
  58. # to
  59. # [RLIMIT_STACK] = "stack",
  60. #
  61. # and build a second integer table (with the second sed cmd), that maps
  62. # RLIMIT defines to the order defined in asm-generic/resource.h This is
  63. # required by policy load to map policy ordering of RLIMITs to internal
  64. # ordering for architectures that redefine an RLIMIT.
  65. # Transforms lines from
  66. # #define RLIMIT_STACK 3 /* max stack size */
  67. # to
  68. # RLIMIT_STACK,
  69. #
  70. # and build the securityfs entries for the mapping.
  71. # Transforms lines from
  72. # #define RLIMIT_FSIZE 1 /* Maximum filesize */
  73. # #define RLIMIT_STACK 3 /* max stack size */
  74. # to
  75. # #define AA_SFS_RLIMIT_MASK "fsize stack"
  76. quiet_cmd_make-rlim = GEN $@
  77. cmd_make-rlim = echo "static const char *const rlim_names[RLIM_NLIMITS] = {" \
  78. > $@ ;\
  79. sed $< >> $@ -r -n \
  80. -e 's/^\# ?define[ \t]+(RLIMIT_([A-Z0-9_]+)).*/[\1] = "\L\2",/p';\
  81. echo "};" >> $@ ;\
  82. echo "static const int rlim_map[RLIM_NLIMITS] = {" >> $@ ;\
  83. sed -r -n "s/^\# ?define[ \t]+(RLIMIT_[A-Z0-9_]+).*/\1,/p" $< >> $@ ;\
  84. echo "};" >> $@ ; \
  85. printf '%s' '\#define AA_SFS_RLIMIT_MASK "' >> $@ ;\
  86. sed -r -n 's/^\# ?define[ \t]+RLIMIT_([A-Z0-9_]+).*/\L\1/p' $< | \
  87. tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
  88. $(obj)/capability.o : $(obj)/capability_names.h
  89. $(obj)/net.o : $(obj)/net_names.h
  90. $(obj)/resource.o : $(obj)/rlim_names.h
  91. $(obj)/capability_names.h : $(srctree)/include/uapi/linux/capability.h \
  92. $(src)/Makefile
  93. $(call cmd,make-caps)
  94. $(obj)/rlim_names.h : $(srctree)/include/uapi/asm-generic/resource.h \
  95. $(src)/Makefile
  96. $(call cmd,make-rlim)
  97. $(obj)/net_names.h : $(srctree)/include/linux/socket.h \
  98. $(srctree)/include/linux/net.h \
  99. $(src)/Makefile
  100. $(call cmd,make-af)
  101. $(call cmd,make-sock)