]> git.ipfire.org Git - people/stevee/selinux-policy.git/blame - refpolicy/Rules.modular
more updates
[people/stevee/selinux-policy.git] / refpolicy / Rules.modular
CommitLineData
fb0a3a98
CP
1########################################
2#
3# Rules and Targets for building monolithic policies
4#
5
6ALL_MODULES := $(filter $(BASE_MODS) $(MOD_MODS),$(DETECTED_MODS))
7ALL_INTERFACES := $(ALL_MODULES:.te=.if)
8
9BASE_PKG := base.pp
10BASE_FC := base.fc
11
12BASE_SECTIONS := tmp/pre_te_files.conf tmp/generated_definitions.conf tmp/all_interfaces.conf tmp/all_attrs_types.conf $(GLOBALTUN) tmp/only_te_rules.conf tmp/all_post.conf
13
c04f2abe 14BASE_PRE_TE_FILES := $(SECCLASS) $(ISIDS) $(AVS) $(M4SUPPORT) $(POLDIR)/mls
fb0a3a98 15BASE_TE_FILES := $(BASE_MODS)
712566ee 16BASE_POST_TE_FILES := $(POLDIR)/systemuser $(POLDIR)/constraints
fb0a3a98
CP
17BASE_FC_FILES := $(BASE_MODS:.te=.fc)
18
19MOD_MODULES := $(MOD_MODS:.te=.mod)
c04f2abe
CP
20MOD_PKGS := $(notdir $(MOD_MODS:.te=.pp))
21
22# search layer dirs for source files
23vpath %.te $(ALL_LAYERS)
24vpath %.if $(ALL_LAYERS)
25vpath %.fc $(ALL_LAYERS)
fb0a3a98
CP
26
27########################################
28#
29# default action: create all module packages
30#
31default: base modules
32
33base: $(BASE_PKG)
34
35modules: $(MOD_PKGS)
36
37#policy: $(POLVER)
38#install: $(LOADPATH) $(FCPATH) $(APPFILES) $(USERPATH)/local.users
39#load: tmp/load
40
41########################################
42#
43# Create a base module package
44#
45$(BASE_PKG): tmp/base.mod $(BASE_FC)
46 @echo "Creating $(NAME) base module package"
47 $(QUIET) $(SEMOD_PKG) $@ $^
48
49########################################
50#
51# Compile a base module
52#
53tmp/base.mod: base.conf
54 @echo "Compiling $(NAME) base module"
55 $(QUIET) $(CHECKMODULE) $^ -o $@
56
57########################################
58#
59# Construct a base module policy.conf
60#
61base.conf: $(BASE_SECTIONS)
62 @echo "Creating $(NAME) base module policy.conf"
63# checkpolicy can use the #line directives provided by -s for error reporting:
64 $(QUIET) m4 -D monolithic_policy $(M4PARAM) -s $^ > tmp/$@.tmp
65 $(QUIET) sed -e /^portcon/d -e /^nodecon/d -e /^netifcon/d < tmp/$@.tmp > $@
66# the ordering of these ocontexts matters:
67 $(QUIET) grep ^portcon tmp/$@.tmp >> $@ || true
68 $(QUIET) grep ^netifcon tmp/$@.tmp >> $@ || true
69 $(QUIET) grep ^nodecon tmp/$@.tmp >> $@ || true
70
71tmp/pre_te_files.conf: $(BASE_PRE_TE_FILES)
72 @test -d tmp || mkdir -p tmp
73 $(QUIET) cat $^ > $@
74
28f0329c 75tmp/generated_definitions.conf: $(ALL_LAYERS) $(BASE_TE_FILES)
fb0a3a98 76 @test -d tmp || mkdir -p tmp
c04f2abe
CP
77# define all available object classes
78 $(QUIET) $(GENPERM) $(AVS) $(SECCLASS) > $@
71fe0fa4
CP
79# per-userdomain templates
80 $(QUIET) echo "define(\`per_userdomain_templates',\`" >> $@
81 $(QUIET) for i in $(patsubst %.te,%,$(notdir $(ALL_MODULES))); do \
82 echo "ifdef(\`""$$i""_per_userdomain_template',\`""$$i""_per_userdomain_template("'$$*'")')" \
83 >> $@ ;\
84 done
85 $(QUIET) echo "')" >> $@
fb0a3a98 86# define foo.te
28f0329c 87 $(QUIET) for i in $(notdir $(BASE_TE_FILES)); do \
fb0a3a98
CP
88 echo "define(\`$$i')" >> $@ ;\
89 done
90 $(QUIET) $(SETTUN) $(TUNABLES) >> $@
91
92tmp/all_interfaces.conf: $(M4SUPPORT) $(ALL_INTERFACES)
93ifeq ($(ALL_INTERFACES),)
94 $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
95endif
96 @test -d tmp || mkdir -p tmp
97 $(QUIET) m4 $^ | sed -e s/dollarsstar/\$$\*/g > $@
98
99tmp/all_te_files.conf: $(BASE_TE_FILES)
100ifeq ($(BASE_TE_FILES),)
101 $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
102endif
103 @test -d tmp || mkdir -p tmp
104 $(QUIET) cat $^ > $@
105
106tmp/post_te_files.conf: $(BASE_POST_TE_FILES)
107 @test -d tmp || mkdir -p tmp
108 $(QUIET) cat $^ > $@
109
110# extract attributes and put them first. extract post te stuff
111# like genfscon and put last. portcon, nodecon, and netifcon
112# is delayed since they are generated by m4
113tmp/all_attrs_types.conf tmp/only_te_rules.conf tmp/all_post.conf: tmp/all_te_files.conf tmp/post_te_files.conf
114 $(QUIET) grep ^attribute tmp/all_te_files.conf > tmp/all_attrs_types.conf || true
115 $(QUIET) grep '^type ' tmp/all_te_files.conf >> tmp/all_attrs_types.conf
116 $(QUIET) cat tmp/post_te_files.conf > tmp/all_post.conf
117 $(QUIET) grep '^sid ' tmp/all_te_files.conf >> tmp/all_post.conf || true
118 $(QUIET) egrep '^fs_use_(xattr|task|trans)' tmp/all_te_files.conf >> tmp/all_post.conf || true
119 $(QUIET) grep ^genfscon tmp/all_te_files.conf >> tmp/all_post.conf || true
120 $(QUIET) sed -r -e /^attribute/d -e '/^type /d' -e /^genfscon/d \
121 -e '/^sid /d' -e '/^fs_use_(xattr|task|trans)/d' \
122 < tmp/all_te_files.conf > tmp/only_te_rules.conf
123
124########################################
125#
126# Construct base module file contexts
127#
712566ee 128$(BASE_FC): $(M4SUPPORT) tmp/generated_definitions.conf $(BASE_FC_FILES) $(FCSORT)
fb0a3a98
CP
129ifeq ($(BASE_FC_FILES),)
130 $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
131endif
132 @echo "Creating $(NAME) base module file contexts."
133 @test -d tmp || mkdir -p tmp
134 $(QUIET) m4 $(M4PARAM) $(M4SUPPORT) tmp/generated_definitions.conf $(BASE_FC_FILES) > tmp/$@.tmp
135 $(QUIET) grep -e HOME -e ROLE tmp/$@.tmp > $(HOMEDIR_TEMPLATE)
136 $(QUIET) sed -i -e /HOME/d -e /ROLE/d tmp/$@.tmp
137 $(QUIET) $(FCSORT) tmp/$@.tmp $@
138
139########################################
140#
c04f2abe 141# Build module packages
fb0a3a98 142#
c04f2abe
CP
143tmp/%.mod: $(M4SUPPORT) tmp/generated_definitions.conf tmp/all_interfaces.conf %.te
144 @echo "Compliling $(NAME) $(@F) module"
145 $(QUIET) m4 $(M4PARAM) -s $^ > $(@:.mod=.tmp)
146 $(QUIET) $(CHECKMODULE) -m $(@:.mod=.tmp) -o $@
fb0a3a98 147
c04f2abe
CP
148%.pp: tmp/%.mod %.fc
149 @echo "Creating $(NAME) $(@F) policy package"
150 $(QUIET) $(SEMOD_PKG) $@ $^
fb0a3a98
CP
151
152########################################
153#
154# Clean the sources
155#
156clean:
157 rm -fR tmp
158 rm -f base.conf
c04f2abe 159 rm -f *.pp
712566ee 160 rm -f $(BASE_FC)
fb0a3a98
CP
161
162.PHONY: default base modules clean