]> git.ipfire.org Git - people/stevee/selinux-policy.git/blame - refpolicy/Rules.modular
fixes to make base module compilable
[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) > $@
fb0a3a98 79# define foo.te
28f0329c 80 $(QUIET) for i in $(notdir $(BASE_TE_FILES)); do \
fb0a3a98
CP
81 echo "define(\`$$i')" >> $@ ;\
82 done
83 $(QUIET) $(SETTUN) $(TUNABLES) >> $@
84
85tmp/all_interfaces.conf: $(M4SUPPORT) $(ALL_INTERFACES)
86ifeq ($(ALL_INTERFACES),)
87 $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
88endif
89 @test -d tmp || mkdir -p tmp
90 $(QUIET) m4 $^ | sed -e s/dollarsstar/\$$\*/g > $@
91
92tmp/all_te_files.conf: $(BASE_TE_FILES)
93ifeq ($(BASE_TE_FILES),)
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) cat $^ > $@
98
99tmp/post_te_files.conf: $(BASE_POST_TE_FILES)
100 @test -d tmp || mkdir -p tmp
101 $(QUIET) cat $^ > $@
102
103# extract attributes and put them first. extract post te stuff
104# like genfscon and put last. portcon, nodecon, and netifcon
105# is delayed since they are generated by m4
106tmp/all_attrs_types.conf tmp/only_te_rules.conf tmp/all_post.conf: tmp/all_te_files.conf tmp/post_te_files.conf
107 $(QUIET) grep ^attribute tmp/all_te_files.conf > tmp/all_attrs_types.conf || true
108 $(QUIET) grep '^type ' tmp/all_te_files.conf >> tmp/all_attrs_types.conf
109 $(QUIET) cat tmp/post_te_files.conf > tmp/all_post.conf
110 $(QUIET) grep '^sid ' tmp/all_te_files.conf >> tmp/all_post.conf || true
111 $(QUIET) egrep '^fs_use_(xattr|task|trans)' tmp/all_te_files.conf >> tmp/all_post.conf || true
112 $(QUIET) grep ^genfscon tmp/all_te_files.conf >> tmp/all_post.conf || true
113 $(QUIET) sed -r -e /^attribute/d -e '/^type /d' -e /^genfscon/d \
114 -e '/^sid /d' -e '/^fs_use_(xattr|task|trans)/d' \
115 < tmp/all_te_files.conf > tmp/only_te_rules.conf
116
117########################################
118#
119# Construct base module file contexts
120#
712566ee 121$(BASE_FC): $(M4SUPPORT) tmp/generated_definitions.conf $(BASE_FC_FILES) $(FCSORT)
fb0a3a98
CP
122ifeq ($(BASE_FC_FILES),)
123 $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
124endif
125 @echo "Creating $(NAME) base module file contexts."
126 @test -d tmp || mkdir -p tmp
127 $(QUIET) m4 $(M4PARAM) $(M4SUPPORT) tmp/generated_definitions.conf $(BASE_FC_FILES) > tmp/$@.tmp
128 $(QUIET) grep -e HOME -e ROLE tmp/$@.tmp > $(HOMEDIR_TEMPLATE)
129 $(QUIET) sed -i -e /HOME/d -e /ROLE/d tmp/$@.tmp
130 $(QUIET) $(FCSORT) tmp/$@.tmp $@
131
132########################################
133#
c04f2abe 134# Build module packages
fb0a3a98 135#
c04f2abe
CP
136tmp/%.mod: $(M4SUPPORT) tmp/generated_definitions.conf tmp/all_interfaces.conf %.te
137 @echo "Compliling $(NAME) $(@F) module"
138 $(QUIET) m4 $(M4PARAM) -s $^ > $(@:.mod=.tmp)
139 $(QUIET) $(CHECKMODULE) -m $(@:.mod=.tmp) -o $@
fb0a3a98 140
c04f2abe
CP
141%.pp: tmp/%.mod %.fc
142 @echo "Creating $(NAME) $(@F) policy package"
143 $(QUIET) $(SEMOD_PKG) $@ $^
fb0a3a98
CP
144
145########################################
146#
147# Clean the sources
148#
149clean:
150 rm -fR tmp
151 rm -f base.conf
c04f2abe 152 rm -f *.pp
712566ee 153 rm -f $(BASE_FC)
fb0a3a98
CP
154
155.PHONY: default base modules clean