blob: 380c8e08174ac9e545729650db4cc57b6a663e0e [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
John Johansen016d8252010-07-30 13:46:33 +10002# Makefile for AppArmor Linux Security Module
3#
4obj-$(CONFIG_SECURITY_APPARMOR) += apparmor.o
5
John Johansende62de52017-10-08 00:43:02 -07006apparmor-y := apparmorfs.o audit.o capability.o task.o ipc.o lib.o match.o \
John Johansen016d8252010-07-30 13:46:33 +10007 path.o domain.o policy.o policy_unpack.o procattr.o lsm.o \
Linus Torvalds80c094a2017-10-26 19:35:35 +02008 resource.o secid.o file.o policy_ns.o label.o mount.o
John Johansenf8eb8a12013-08-14 11:27:36 -07009apparmor-$(CONFIG_SECURITY_APPARMOR_HASH) += crypto.o
John Johansen016d8252010-07-30 13:46:33 +100010
Linus Torvalds80c094a2017-10-26 19:35:35 +020011clean-files := capability_names.h rlim_names.h
John Johansen016d8252010-07-30 13:46:33 +100012
John Johansen4fdef212011-03-05 02:18:02 -080013
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",
John Johansen016d8252010-07-30 13:46:33 +100019quiet_cmd_make-caps = GEN $@
Tetsuo Handa7e570142012-03-14 23:41:17 -070020cmd_make-caps = echo "static const char *const capability_names[] = {" > $@ ;\
John Johansen4fdef212011-03-05 02:18:02 -080021 sed $< >>$@ -r -n -e '/CAP_FS_MASK/d' \
22 -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/[\2] = "\L\1",/p';\
John Johansen84f1f782013-08-14 11:27:32 -070023 echo "};" >> $@ ;\
John Johansenc97204b2017-05-25 06:23:42 -070024 printf '%s' '\#define AA_SFS_CAPS_MASK "' >> $@ ;\
John Johansen84f1f782013-08-14 11:27:32 -070025 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/' >> $@
John Johansen016d8252010-07-30 13:46:33 +100028
John Johansen4fdef212011-03-05 02:18:02 -080029
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
Kees Cookd384b0a2012-01-26 16:29:23 -080037# RLIMIT defines to the order defined in asm-generic/resource.h This is
John Johansen4fdef212011-03-05 02:18:02 -080038# 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,
Kees Cookd384b0a2012-01-26 16:29:23 -080044#
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
John Johansenc97204b2017-05-25 06:23:42 -070050# #define AA_SFS_RLIMIT_MASK "fsize stack"
John Johansen016d8252010-07-30 13:46:33 +100051quiet_cmd_make-rlim = GEN $@
Tetsuo Handa7e570142012-03-14 23:41:17 -070052cmd_make-rlim = echo "static const char *const rlim_names[RLIM_NLIMITS] = {" \
John Johansen33e521a2012-03-14 05:53:40 -070053 > $@ ;\
John Johansen4fdef212011-03-05 02:18:02 -080054 sed $< >> $@ -r -n \
55 -e 's/^\# ?define[ \t]+(RLIMIT_([A-Z0-9_]+)).*/[\1] = "\L\2",/p';\
56 echo "};" >> $@ ;\
Kees Cookd384b0a2012-01-26 16:29:23 -080057 echo "static const int rlim_map[RLIM_NLIMITS] = {" >> $@ ;\
John Johansen4fdef212011-03-05 02:18:02 -080058 sed -r -n "s/^\# ?define[ \t]+(RLIMIT_[A-Z0-9_]+).*/\1,/p" $< >> $@ ;\
Kees Cookd384b0a2012-01-26 16:29:23 -080059 echo "};" >> $@ ; \
John Johansenc97204b2017-05-25 06:23:42 -070060 printf '%s' '\#define AA_SFS_RLIMIT_MASK "' >> $@ ;\
Kees Cookd384b0a2012-01-26 16:29:23 -080061 sed -r -n 's/^\# ?define[ \t]+RLIMIT_([A-Z0-9_]+).*/\L\1/p' $< | \
62 tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
John Johansen016d8252010-07-30 13:46:33 +100063
64$(obj)/capability.o : $(obj)/capability_names.h
65$(obj)/resource.o : $(obj)/rlim_names.h
John Johansen43c422e2012-10-17 13:29:33 -070066$(obj)/capability_names.h : $(srctree)/include/uapi/linux/capability.h \
Kees Cookd384b0a2012-01-26 16:29:23 -080067 $(src)/Makefile
John Johansen016d8252010-07-30 13:46:33 +100068 $(call cmd,make-caps)
David Howells8a1ab312012-10-04 18:20:15 +010069$(obj)/rlim_names.h : $(srctree)/include/uapi/asm-generic/resource.h \
Kees Cookd384b0a2012-01-26 16:29:23 -080070 $(src)/Makefile
John Johansen016d8252010-07-30 13:46:33 +100071 $(call cmd,make-rlim)