xref: /linux/security/apparmor/Makefile (revision d384b0a1a35f87f0ad70c29518f98f922b1c15cb)
1016d825fSJohn Johansen# Makefile for AppArmor Linux Security Module
2016d825fSJohn Johansen#
3016d825fSJohn Johansenobj-$(CONFIG_SECURITY_APPARMOR) += apparmor.o
4016d825fSJohn Johansen
5016d825fSJohn Johansenapparmor-y := apparmorfs.o audit.o capability.o context.o ipc.o lib.o match.o \
6016d825fSJohn Johansen              path.o domain.o policy.o policy_unpack.o procattr.o lsm.o \
7016d825fSJohn Johansen              resource.o sid.o file.o
8016d825fSJohn Johansen
90f825026SMichal Hockoclean-files := capability_names.h rlim_names.h
10016d825fSJohn Johansen
114fdef218SJohn Johansen
124fdef218SJohn Johansen# Build a lower case string table of capability names
134fdef218SJohn Johansen# Transforms lines from
144fdef218SJohn Johansen#    #define CAP_DAC_OVERRIDE     1
154fdef218SJohn Johansen# to
164fdef218SJohn Johansen#    [1] = "dac_override",
17016d825fSJohn Johansenquiet_cmd_make-caps = GEN     $@
184fdef218SJohn Johansencmd_make-caps = echo "static const char *capability_names[] = {" > $@ ;\
194fdef218SJohn Johansen	sed $< >>$@ -r -n -e '/CAP_FS_MASK/d' \
204fdef218SJohn Johansen	-e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/[\2] = "\L\1",/p';\
214fdef218SJohn Johansen	echo "};" >> $@
22016d825fSJohn Johansen
234fdef218SJohn Johansen
244fdef218SJohn Johansen# Build a lower case string table of rlimit names.
254fdef218SJohn Johansen# Transforms lines from
264fdef218SJohn Johansen#    #define RLIMIT_STACK		3	/* max stack size */
274fdef218SJohn Johansen# to
284fdef218SJohn Johansen#    [RLIMIT_STACK] = "stack",
294fdef218SJohn Johansen#
304fdef218SJohn Johansen# and build a second integer table (with the second sed cmd), that maps
31*d384b0a1SKees Cook# RLIMIT defines to the order defined in asm-generic/resource.h  This is
324fdef218SJohn Johansen# required by policy load to map policy ordering of RLIMITs to internal
334fdef218SJohn Johansen# ordering for architectures that redefine an RLIMIT.
344fdef218SJohn Johansen# Transforms lines from
354fdef218SJohn Johansen#    #define RLIMIT_STACK		3	/* max stack size */
364fdef218SJohn Johansen# to
374fdef218SJohn Johansen# RLIMIT_STACK,
38*d384b0a1SKees Cook#
39*d384b0a1SKees Cook# and build the securityfs entries for the mapping.
40*d384b0a1SKees Cook# Transforms lines from
41*d384b0a1SKees Cook#    #define RLIMIT_FSIZE        1   /* Maximum filesize */
42*d384b0a1SKees Cook#    #define RLIMIT_STACK		3	/* max stack size */
43*d384b0a1SKees Cook# to
44*d384b0a1SKees Cook# #define AA_FS_RLIMIT_MASK "fsize stack"
45016d825fSJohn Johansenquiet_cmd_make-rlim = GEN     $@
46*d384b0a1SKees Cookcmd_make-rlim = echo "static const char *rlim_names[RLIM_NLIMITS] = {" > $@ ;\
474fdef218SJohn Johansen	sed $< >> $@ -r -n \
484fdef218SJohn Johansen	    -e 's/^\# ?define[ \t]+(RLIMIT_([A-Z0-9_]+)).*/[\1] = "\L\2",/p';\
494fdef218SJohn Johansen	echo "};" >> $@ ;\
50*d384b0a1SKees Cook	echo "static const int rlim_map[RLIM_NLIMITS] = {" >> $@ ;\
514fdef218SJohn Johansen	sed -r -n "s/^\# ?define[ \t]+(RLIMIT_[A-Z0-9_]+).*/\1,/p" $< >> $@ ;\
52*d384b0a1SKees Cook	echo "};" >> $@ ; \
53*d384b0a1SKees Cook	echo -n '\#define AA_FS_RLIMIT_MASK "' >> $@ ;\
54*d384b0a1SKees Cook	sed -r -n 's/^\# ?define[ \t]+RLIMIT_([A-Z0-9_]+).*/\L\1/p' $< | \
55*d384b0a1SKees Cook	    tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
56016d825fSJohn Johansen
57016d825fSJohn Johansen$(obj)/capability.o : $(obj)/capability_names.h
58016d825fSJohn Johansen$(obj)/resource.o : $(obj)/rlim_names.h
59*d384b0a1SKees Cook$(obj)/capability_names.h : $(srctree)/include/linux/capability.h \
60*d384b0a1SKees Cook			    $(src)/Makefile
61016d825fSJohn Johansen	$(call cmd,make-caps)
62*d384b0a1SKees Cook$(obj)/rlim_names.h : $(srctree)/include/asm-generic/resource.h \
63*d384b0a1SKees Cook		      $(src)/Makefile
64016d825fSJohn Johansen	$(call cmd,make-rlim)
65