Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0
0002 # Makefile for AppArmor Linux Security Module
0003 #
0004 obj-$(CONFIG_SECURITY_APPARMOR) += apparmor.o
0005 
0006 apparmor-y := apparmorfs.o audit.o capability.o task.o ipc.o lib.o match.o \
0007               path.o domain.o policy.o policy_unpack.o procattr.o lsm.o \
0008               resource.o secid.o file.o policy_ns.o label.o mount.o net.o
0009 apparmor-$(CONFIG_SECURITY_APPARMOR_HASH) += crypto.o
0010 
0011 clean-files := capability_names.h rlim_names.h net_names.h
0012 
0013 # Build a lower case string table of address family names
0014 # Transform lines from
0015 #    #define AF_LOCAL           1       /* POSIX name for AF_UNIX       */
0016 #    #define AF_INET            2       /* Internet IP Protocol         */
0017 # to
0018 #    [1] = "local",
0019 #    [2] = "inet",
0020 #
0021 # and build the securityfs entries for the mapping.
0022 # Transforms lines from
0023 #    #define AF_INET            2       /* Internet IP Protocol         */
0024 # to
0025 #    #define AA_SFS_AF_MASK "local inet"
0026 quiet_cmd_make-af = GEN     $@
0027 cmd_make-af = echo "static const char *address_family_names[] = {" > $@ ;\
0028         sed $< >>$@ -r -n -e "/AF_MAX/d" -e "/AF_LOCAL/d" -e "/AF_ROUTE/d" -e \
0029          's/^\#define[ \t]+AF_([A-Z0-9_]+)[ \t]+([0-9]+)(.*)/[\2] = "\L\1",/p';\
0030         echo "};" >> $@ ;\
0031         printf '%s' '\#define AA_SFS_AF_MASK "' >> $@ ;\
0032         sed -r -n -e "/AF_MAX/d" -e "/AF_LOCAL/d" -e "/AF_ROUTE/d" -e \
0033          's/^\#define[ \t]+AF_([A-Z0-9_]+)[ \t]+([0-9]+)(.*)/\L\1/p'\
0034          $< | tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
0035 
0036 # Build a lower case string table of sock type names
0037 # Transform lines from
0038 #    SOCK_STREAM        = 1,
0039 # to
0040 #    [1] = "stream",
0041 quiet_cmd_make-sock = GEN     $@
0042 cmd_make-sock = echo "static const char *sock_type_names[] = {" >> $@ ;\
0043         sed $^ >>$@ -r -n \
0044         -e 's/^\tSOCK_([A-Z0-9_]+)[\t]+=[ \t]+([0-9]+)(.*)/[\2] = "\L\1",/p';\
0045         echo "};" >> $@
0046 
0047 # Build a lower case string table of capability names
0048 # Transforms lines from
0049 #    #define CAP_DAC_OVERRIDE     1
0050 # to
0051 #    [1] = "dac_override",
0052 quiet_cmd_make-caps = GEN     $@
0053 cmd_make-caps = echo "static const char *const capability_names[] = {" > $@ ;\
0054         sed $< >>$@ -r -n -e '/CAP_FS_MASK/d' \
0055         -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/[\2] = "\L\1",/p';\
0056         echo "};" >> $@ ;\
0057         printf '%s' '\#define AA_SFS_CAPS_MASK "' >> $@ ;\
0058         sed $< -r -n -e '/CAP_FS_MASK/d' \
0059             -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/\L\1/p' | \
0060              tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
0061 
0062 
0063 # Build a lower case string table of rlimit names.
0064 # Transforms lines from
0065 #    #define RLIMIT_STACK               3       /* max stack size */
0066 # to
0067 #    [RLIMIT_STACK] = "stack",
0068 #
0069 # and build a second integer table (with the second sed cmd), that maps
0070 # RLIMIT defines to the order defined in asm-generic/resource.h  This is
0071 # required by policy load to map policy ordering of RLIMITs to internal
0072 # ordering for architectures that redefine an RLIMIT.
0073 # Transforms lines from
0074 #    #define RLIMIT_STACK               3       /* max stack size */
0075 # to
0076 # RLIMIT_STACK, 
0077 #
0078 # and build the securityfs entries for the mapping.
0079 # Transforms lines from
0080 #    #define RLIMIT_FSIZE        1   /* Maximum filesize */
0081 #    #define RLIMIT_STACK               3       /* max stack size */
0082 # to
0083 # #define AA_SFS_RLIMIT_MASK "fsize stack"
0084 quiet_cmd_make-rlim = GEN     $@
0085 cmd_make-rlim = echo "static const char *const rlim_names[RLIM_NLIMITS] = {" \
0086         > $@ ;\
0087         sed $< >> $@ -r -n \
0088             -e 's/^\# ?define[ \t]+(RLIMIT_([A-Z0-9_]+)).*/[\1] = "\L\2",/p';\
0089         echo "};" >> $@ ;\
0090         echo "static const int rlim_map[RLIM_NLIMITS] = {" >> $@ ;\
0091         sed -r -n "s/^\# ?define[ \t]+(RLIMIT_[A-Z0-9_]+).*/\1,/p" $< >> $@ ;\
0092         echo "};" >> $@ ; \
0093         printf '%s' '\#define AA_SFS_RLIMIT_MASK "' >> $@ ;\
0094         sed -r -n 's/^\# ?define[ \t]+RLIMIT_([A-Z0-9_]+).*/\L\1/p' $< | \
0095             tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
0096 
0097 $(obj)/capability.o : $(obj)/capability_names.h
0098 $(obj)/net.o : $(obj)/net_names.h
0099 $(obj)/resource.o : $(obj)/rlim_names.h
0100 $(obj)/capability_names.h : $(srctree)/include/uapi/linux/capability.h \
0101                             $(src)/Makefile
0102         $(call cmd,make-caps)
0103 $(obj)/rlim_names.h : $(srctree)/include/uapi/asm-generic/resource.h \
0104                       $(src)/Makefile
0105         $(call cmd,make-rlim)
0106 $(obj)/net_names.h : $(srctree)/include/linux/socket.h \
0107                      $(srctree)/include/linux/net.h \
0108                      $(src)/Makefile
0109         $(call cmd,make-af)
0110         $(call cmd,make-sock)