Commit | Line | Data |
---|---|---|
b2441318 | 1 | # SPDX-License-Identifier: GPL-2.0 |
016d825f JJ |
2 | # Makefile for AppArmor Linux Security Module |
3 | # | |
4 | obj-$(CONFIG_SECURITY_APPARMOR) += apparmor.o | |
5 | ||
de62de59 | 6 | apparmor-y := apparmorfs.o audit.o capability.o task.o ipc.o lib.o match.o \ |
016d825f | 7 | path.o domain.o policy.o policy_unpack.o procattr.o lsm.o \ |
80c094a4 | 8 | resource.o secid.o file.o policy_ns.o label.o mount.o |
f8eb8a13 | 9 | apparmor-$(CONFIG_SECURITY_APPARMOR_HASH) += crypto.o |
016d825f | 10 | |
80c094a4 | 11 | clean-files := capability_names.h rlim_names.h |
016d825f | 12 | |
4fdef218 JJ |
13 | |
14 | # Build a lower case string table of capability names | |
15 | # Transforms lines from | |
16 | # #define CAP_DAC_OVERRIDE 1 | |
17 | # to | |
18 | # [1] = "dac_override", | |
016d825f | 19 | quiet_cmd_make-caps = GEN $@ |
7e570145 | 20 | cmd_make-caps = echo "static const char *const capability_names[] = {" > $@ ;\ |
4fdef218 JJ |
21 | sed $< >>$@ -r -n -e '/CAP_FS_MASK/d' \ |
22 | -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/[\2] = "\L\1",/p';\ | |
84f1f787 | 23 | echo "};" >> $@ ;\ |
c97204ba | 24 | printf '%s' '\#define AA_SFS_CAPS_MASK "' >> $@ ;\ |
84f1f787 JJ |
25 | sed $< -r -n -e '/CAP_FS_MASK/d' \ |
26 | -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/\L\1/p' | \ | |
27 | tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@ | |
4fdef218 | 28 | |
016d825f | 29 | |
4fdef218 JJ |
30 | # Build a lower case string table of rlimit names. |
31 | # Transforms lines from | |
32 | # #define RLIMIT_STACK 3 /* max stack size */ | |
33 | # to | |
34 | # [RLIMIT_STACK] = "stack", | |
35 | # | |
36 | # and build a second integer table (with the second sed cmd), that maps | |
d384b0a1 | 37 | # RLIMIT defines to the order defined in asm-generic/resource.h This is |
4fdef218 JJ |
38 | # required by policy load to map policy ordering of RLIMITs to internal |
39 | # ordering for architectures that redefine an RLIMIT. | |
40 | # Transforms lines from | |
41 | # #define RLIMIT_STACK 3 /* max stack size */ | |
42 | # to | |
43 | # RLIMIT_STACK, | |
d384b0a1 KC |
44 | # |
45 | # and build the securityfs entries for the mapping. | |
46 | # Transforms lines from | |
47 | # #define RLIMIT_FSIZE 1 /* Maximum filesize */ | |
48 | # #define RLIMIT_STACK 3 /* max stack size */ | |
49 | # to | |
c97204ba | 50 | # #define AA_SFS_RLIMIT_MASK "fsize stack" |
016d825f | 51 | quiet_cmd_make-rlim = GEN $@ |
7e570145 | 52 | cmd_make-rlim = echo "static const char *const rlim_names[RLIM_NLIMITS] = {" \ |
33e521ac | 53 | > $@ ;\ |
4fdef218 JJ |
54 | sed $< >> $@ -r -n \ |
55 | -e 's/^\# ?define[ \t]+(RLIMIT_([A-Z0-9_]+)).*/[\1] = "\L\2",/p';\ | |
56 | echo "};" >> $@ ;\ | |
d384b0a1 | 57 | echo "static const int rlim_map[RLIM_NLIMITS] = {" >> $@ ;\ |
4fdef218 | 58 | sed -r -n "s/^\# ?define[ \t]+(RLIMIT_[A-Z0-9_]+).*/\1,/p" $< >> $@ ;\ |
d384b0a1 | 59 | echo "};" >> $@ ; \ |
c97204ba | 60 | printf '%s' '\#define AA_SFS_RLIMIT_MASK "' >> $@ ;\ |
d384b0a1 KC |
61 | sed -r -n 's/^\# ?define[ \t]+RLIMIT_([A-Z0-9_]+).*/\L\1/p' $< | \ |
62 | tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@ | |
016d825f JJ |
63 | |
64 | $(obj)/capability.o : $(obj)/capability_names.h | |
65 | $(obj)/resource.o : $(obj)/rlim_names.h | |
43c422ed | 66 | $(obj)/capability_names.h : $(srctree)/include/uapi/linux/capability.h \ |
d384b0a1 | 67 | $(src)/Makefile |
016d825f | 68 | $(call cmd,make-caps) |
8a1ab315 | 69 | $(obj)/rlim_names.h : $(srctree)/include/uapi/asm-generic/resource.h \ |
d384b0a1 | 70 | $(src)/Makefile |
016d825f | 71 | $(call cmd,make-rlim) |