blob: ad369a7aac24af6bdebac7229d8c6cb6389bafa8 [file] [log] [blame]
John Johansen016d8252010-07-30 13:46:33 +10001# Makefile for AppArmor Linux Security Module
2#
3obj-$(CONFIG_SECURITY_APPARMOR) += apparmor.o
4
5apparmor-y := apparmorfs.o audit.o capability.o context.o ipc.o lib.o match.o \
6 path.o domain.o policy.o policy_unpack.o procattr.o lsm.o \
John Johansen121d4a92017-01-16 00:42:17 -08007 resource.o secid.o file.o policy_ns.o
John Johansenf8eb8a12013-08-14 11:27:36 -07008apparmor-$(CONFIG_SECURITY_APPARMOR_HASH) += crypto.o
John Johansen016d8252010-07-30 13:46:33 +10009
Michal Hocko0f825022011-01-07 15:03:02 +010010clean-files := capability_names.h rlim_names.h
John Johansen016d8252010-07-30 13:46:33 +100011
John Johansen4fdef212011-03-05 02:18:02 -080012
13# Build a lower case string table of capability names
14# Transforms lines from
15# #define CAP_DAC_OVERRIDE 1
16# to
17# [1] = "dac_override",
John Johansen016d8252010-07-30 13:46:33 +100018quiet_cmd_make-caps = GEN $@
Tetsuo Handa7e570142012-03-14 23:41:17 -070019cmd_make-caps = echo "static const char *const capability_names[] = {" > $@ ;\
John Johansen4fdef212011-03-05 02:18:02 -080020 sed $< >>$@ -r -n -e '/CAP_FS_MASK/d' \
21 -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/[\2] = "\L\1",/p';\
John Johansen84f1f782013-08-14 11:27:32 -070022 echo "};" >> $@ ;\
23 echo -n '\#define AA_FS_CAPS_MASK "' >> $@ ;\
24 sed $< -r -n -e '/CAP_FS_MASK/d' \
25 -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/\L\1/p' | \
26 tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
John Johansen016d8252010-07-30 13:46:33 +100027
John Johansen4fdef212011-03-05 02:18:02 -080028
29# Build a lower case string table of rlimit names.
30# Transforms lines from
31# #define RLIMIT_STACK 3 /* max stack size */
32# to
33# [RLIMIT_STACK] = "stack",
34#
35# and build a second integer table (with the second sed cmd), that maps
Kees Cookd384b0a2012-01-26 16:29:23 -080036# RLIMIT defines to the order defined in asm-generic/resource.h This is
John Johansen4fdef212011-03-05 02:18:02 -080037# required by policy load to map policy ordering of RLIMITs to internal
38# ordering for architectures that redefine an RLIMIT.
39# Transforms lines from
40# #define RLIMIT_STACK 3 /* max stack size */
41# to
42# RLIMIT_STACK,
Kees Cookd384b0a2012-01-26 16:29:23 -080043#
44# and build the securityfs entries for the mapping.
45# Transforms lines from
46# #define RLIMIT_FSIZE 1 /* Maximum filesize */
47# #define RLIMIT_STACK 3 /* max stack size */
48# to
49# #define AA_FS_RLIMIT_MASK "fsize stack"
John Johansen016d8252010-07-30 13:46:33 +100050quiet_cmd_make-rlim = GEN $@
Tetsuo Handa7e570142012-03-14 23:41:17 -070051cmd_make-rlim = echo "static const char *const rlim_names[RLIM_NLIMITS] = {" \
John Johansen33e521a2012-03-14 05:53:40 -070052 > $@ ;\
John Johansen4fdef212011-03-05 02:18:02 -080053 sed $< >> $@ -r -n \
54 -e 's/^\# ?define[ \t]+(RLIMIT_([A-Z0-9_]+)).*/[\1] = "\L\2",/p';\
55 echo "};" >> $@ ;\
Kees Cookd384b0a2012-01-26 16:29:23 -080056 echo "static const int rlim_map[RLIM_NLIMITS] = {" >> $@ ;\
John Johansen4fdef212011-03-05 02:18:02 -080057 sed -r -n "s/^\# ?define[ \t]+(RLIMIT_[A-Z0-9_]+).*/\1,/p" $< >> $@ ;\
Kees Cookd384b0a2012-01-26 16:29:23 -080058 echo "};" >> $@ ; \
59 echo -n '\#define AA_FS_RLIMIT_MASK "' >> $@ ;\
60 sed -r -n 's/^\# ?define[ \t]+RLIMIT_([A-Z0-9_]+).*/\L\1/p' $< | \
61 tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
John Johansen016d8252010-07-30 13:46:33 +100062
63$(obj)/capability.o : $(obj)/capability_names.h
64$(obj)/resource.o : $(obj)/rlim_names.h
John Johansen43c422e2012-10-17 13:29:33 -070065$(obj)/capability_names.h : $(srctree)/include/uapi/linux/capability.h \
Kees Cookd384b0a2012-01-26 16:29:23 -080066 $(src)/Makefile
John Johansen016d8252010-07-30 13:46:33 +100067 $(call cmd,make-caps)
David Howells8a1ab312012-10-04 18:20:15 +010068$(obj)/rlim_names.h : $(srctree)/include/uapi/asm-generic/resource.h \
Kees Cookd384b0a2012-01-26 16:29:23 -080069 $(src)/Makefile
John Johansen016d8252010-07-30 13:46:33 +100070 $(call cmd,make-rlim)