Merge branch 'userns-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm...
[sfrench/cifs-2.6.git] / security / apparmor / Makefile
1 # SPDX-License-Identifier: GPL-2.0
2 # Makefile for AppArmor Linux Security Module
3 #
4 obj-$(CONFIG_SECURITY_APPARMOR) += apparmor.o
5
6 apparmor-y := apparmorfs.o audit.o capability.o context.o ipc.o lib.o match.o \
7               path.o domain.o policy.o policy_unpack.o procattr.o lsm.o \
8               resource.o secid.o file.o policy_ns.o label.o mount.o
9 apparmor-$(CONFIG_SECURITY_APPARMOR_HASH) += crypto.o
10
11 clean-files := capability_names.h rlim_names.h
12
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",
19 quiet_cmd_make-caps = GEN     $@
20 cmd_make-caps = echo "static const char *const capability_names[] = {" > $@ ;\
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';\
23         echo "};" >> $@ ;\
24         printf '%s' '\#define AA_SFS_CAPS_MASK "' >> $@ ;\
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/' >> $@
28
29
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
37 # RLIMIT defines to the order defined in asm-generic/resource.h  This is
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, 
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
50 # #define AA_SFS_RLIMIT_MASK "fsize stack"
51 quiet_cmd_make-rlim = GEN     $@
52 cmd_make-rlim = echo "static const char *const rlim_names[RLIM_NLIMITS] = {" \
53         > $@ ;\
54         sed $< >> $@ -r -n \
55             -e 's/^\# ?define[ \t]+(RLIMIT_([A-Z0-9_]+)).*/[\1] = "\L\2",/p';\
56         echo "};" >> $@ ;\
57         echo "static const int rlim_map[RLIM_NLIMITS] = {" >> $@ ;\
58         sed -r -n "s/^\# ?define[ \t]+(RLIMIT_[A-Z0-9_]+).*/\1,/p" $< >> $@ ;\
59         echo "};" >> $@ ; \
60         printf '%s' '\#define AA_SFS_RLIMIT_MASK "' >> $@ ;\
61         sed -r -n 's/^\# ?define[ \t]+RLIMIT_([A-Z0-9_]+).*/\L\1/p' $< | \
62             tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
63
64 $(obj)/capability.o : $(obj)/capability_names.h
65 $(obj)/resource.o : $(obj)/rlim_names.h
66 $(obj)/capability_names.h : $(srctree)/include/uapi/linux/capability.h \
67                             $(src)/Makefile
68         $(call cmd,make-caps)
69 $(obj)/rlim_names.h : $(srctree)/include/uapi/asm-generic/resource.h \
70                       $(src)/Makefile
71         $(call cmd,make-rlim)