blob: 0831e049072d01f6815225c74d2554c66db71129 [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 \
7 resource.o sid.o file.o
8
Michal Hocko0f825022011-01-07 15:03:02 +01009clean-files := capability_names.h rlim_names.h
John Johansen016d8252010-07-30 13:46:33 +100010
John Johansen4fdef212011-03-05 02:18:02 -080011
12# Build a lower case string table of capability names
13# Transforms lines from
14# #define CAP_DAC_OVERRIDE 1
15# to
16# [1] = "dac_override",
John Johansen016d8252010-07-30 13:46:33 +100017quiet_cmd_make-caps = GEN $@
Tetsuo Handa7e570142012-03-14 23:41:17 -070018cmd_make-caps = echo "static const char *const capability_names[] = {" > $@ ;\
John Johansen4fdef212011-03-05 02:18:02 -080019 sed $< >>$@ -r -n -e '/CAP_FS_MASK/d' \
20 -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/[\2] = "\L\1",/p';\
John Johansen84f1f782013-08-14 11:27:32 -070021 echo "};" >> $@ ;\
22 echo -n '\#define AA_FS_CAPS_MASK "' >> $@ ;\
23 sed $< -r -n -e '/CAP_FS_MASK/d' \
24 -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/\L\1/p' | \
25 tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
John Johansen016d8252010-07-30 13:46:33 +100026
John Johansen4fdef212011-03-05 02:18:02 -080027
28# Build a lower case string table of rlimit names.
29# Transforms lines from
30# #define RLIMIT_STACK 3 /* max stack size */
31# to
32# [RLIMIT_STACK] = "stack",
33#
34# and build a second integer table (with the second sed cmd), that maps
Kees Cookd384b0a2012-01-26 16:29:23 -080035# RLIMIT defines to the order defined in asm-generic/resource.h This is
John Johansen4fdef212011-03-05 02:18:02 -080036# required by policy load to map policy ordering of RLIMITs to internal
37# ordering for architectures that redefine an RLIMIT.
38# Transforms lines from
39# #define RLIMIT_STACK 3 /* max stack size */
40# to
41# RLIMIT_STACK,
Kees Cookd384b0a2012-01-26 16:29:23 -080042#
43# and build the securityfs entries for the mapping.
44# Transforms lines from
45# #define RLIMIT_FSIZE 1 /* Maximum filesize */
46# #define RLIMIT_STACK 3 /* max stack size */
47# to
48# #define AA_FS_RLIMIT_MASK "fsize stack"
John Johansen016d8252010-07-30 13:46:33 +100049quiet_cmd_make-rlim = GEN $@
Tetsuo Handa7e570142012-03-14 23:41:17 -070050cmd_make-rlim = echo "static const char *const rlim_names[RLIM_NLIMITS] = {" \
John Johansen33e521a2012-03-14 05:53:40 -070051 > $@ ;\
John Johansen4fdef212011-03-05 02:18:02 -080052 sed $< >> $@ -r -n \
53 -e 's/^\# ?define[ \t]+(RLIMIT_([A-Z0-9_]+)).*/[\1] = "\L\2",/p';\
54 echo "};" >> $@ ;\
Kees Cookd384b0a2012-01-26 16:29:23 -080055 echo "static const int rlim_map[RLIM_NLIMITS] = {" >> $@ ;\
John Johansen4fdef212011-03-05 02:18:02 -080056 sed -r -n "s/^\# ?define[ \t]+(RLIMIT_[A-Z0-9_]+).*/\1,/p" $< >> $@ ;\
Kees Cookd384b0a2012-01-26 16:29:23 -080057 echo "};" >> $@ ; \
58 echo -n '\#define AA_FS_RLIMIT_MASK "' >> $@ ;\
59 sed -r -n 's/^\# ?define[ \t]+RLIMIT_([A-Z0-9_]+).*/\L\1/p' $< | \
60 tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
John Johansen016d8252010-07-30 13:46:33 +100061
62$(obj)/capability.o : $(obj)/capability_names.h
63$(obj)/resource.o : $(obj)/rlim_names.h
John Johansen43c422e2012-10-17 13:29:33 -070064$(obj)/capability_names.h : $(srctree)/include/uapi/linux/capability.h \
Kees Cookd384b0a2012-01-26 16:29:23 -080065 $(src)/Makefile
John Johansen016d8252010-07-30 13:46:33 +100066 $(call cmd,make-caps)
David Howells8a1ab312012-10-04 18:20:15 +010067$(obj)/rlim_names.h : $(srctree)/include/uapi/asm-generic/resource.h \
Kees Cookd384b0a2012-01-26 16:29:23 -080068 $(src)/Makefile
John Johansen016d8252010-07-30 13:46:33 +100069 $(call cmd,make-rlim)