ia64/xen-unstable

view tools/flask/policy/Rules.monolithic @ 19648:f0e2df69a8eb

x86 hvm: Allow cross-vendor migration

Intercept #UD and emulate SYSCALL/SYSENTER/SYSEXIT as necessary.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 26 15:01:36 2009 +0100 (2009-05-26)
parents 294fc8fc4ba0
children
line source
1 ########################################
2 #
3 # Rules and Targets for building monolithic policies
4 #
6 # install paths
7 POLICYPATH = $(INSTALLDIR)/policy
8 LOADPATH = $(POLICYPATH)/$(POLVER)
9 FCPATH = $(CONTEXTPATH)/files/file_contexts
10 HOMEDIRPATH = $(CONTEXTPATH)/files/homedir_template
12 # for monolithic policy use all base and module to create policy
13 ENABLEMOD := $(BASE_MODS) $(MOD_MODS)
15 ALL_MODULES := $(filter $(ENABLEMOD),$(DETECTED_MODS))
17 ALL_INTERFACES := $(ALL_MODULES:.te=.if)
18 ALL_TE_FILES := $(ALL_MODULES)
19 ALL_FC_FILES := $(ALL_MODULES:.te=.fc)
21 PRE_TE_FILES := $(SECCLASS) $(ISIDS) $(AVS) $(M4SUPPORT) $(POLDIR)/mls $(POLDIR)/mcs
22 POST_TE_FILES := $(POLDIR)/systemuser $(POLDIR)/users $(POLDIR)/constraints
24 POLICY_SECTIONS := tmp/pre_te_files.conf tmp/generated_definitions.conf tmp/all_interfaces.conf tmp/all_attrs_types.conf $(GLOBALBOOL) $(GLOBALTUN) tmp/only_te_rules.conf tmp/all_post.conf
26 ########################################
27 #
28 # default action: build policy locally
29 #
30 default: policy
32 policy: $(POLVER)
34 install: $(LOADPATH) $(FCPATH) $(APPFILES) $(USERPATH)/local.users
36 load: tmp/load
38 ########################################
39 #
40 # Build a binary policy locally
41 #
42 $(POLVER): policy.conf
43 @echo "Compiling $(NAME) $(POLVER)"
44 ifneq ($(PV),$(KV))
45 @echo
46 @echo "WARNING: Policy version mismatch! Is your OUTPUT_POLICY set correctly?"
47 @echo
48 endif
49 $(QUIET) $(CHECKPOLICY) $^ -o $@
51 ########################################
52 #
53 # Install a binary policy
54 #
55 $(LOADPATH): policy.conf
56 @mkdir -p $(POLICYPATH)
57 @echo "Compiling and installing $(NAME) $(LOADPATH)"
58 ifneq ($(PV),$(KV))
59 @echo
60 @echo "WARNING: Policy version mismatch! Is your OUTPUT_POLICY set correctly?"
61 @echo
62 endif
63 $(QUIET) $(CHECKPOLICY) $^ -o $@
65 ########################################
66 #
67 # Load the binary policy
68 #
69 reload tmp/load: $(LOADPATH) $(FCPATH)
70 @echo "Loading $(NAME) $(LOADPATH)"
71 $(QUIET) $(LOADPOLICY) -q $(LOADPATH)
72 @touch tmp/load
74 ########################################
75 #
76 # Construct a monolithic policy.conf
77 #
78 policy.conf: $(POLICY_SECTIONS)
79 @echo "Creating $(NAME) policy.conf"
80 # checkpolicy can use the #line directives provided by -s for error reporting:
81 $(QUIET) m4 -D self_contained_policy $(M4PARAM) -s $^ > tmp/$@.tmp
82 $(QUIET) sed -e /^portcon/d -e /^nodecon/d -e /^netifcon/d < tmp/$@.tmp > $@
84 tmp/pre_te_files.conf: $(PRE_TE_FILES)
85 @test -d tmp || mkdir -p tmp
86 $(QUIET) cat $^ > $@
88 tmp/generated_definitions.conf: $(ALL_LAYERS) $(ALL_TE_FILES)
89 # per-userdomain templates:
90 @test -d tmp || mkdir -p tmp
91 $(QUIET) echo "define(\`per_userdomain_templates',\`" > $@
92 $(QUIET) for i in $(patsubst %.te,%,$(notdir $(ALL_MODULES))); do \
93 echo "ifdef(\`""$$i""_per_userdomain_template',\`""$$i""_per_userdomain_template("'$$*'")')" \
94 >> $@ ;\
95 done
96 $(QUIET) echo "')" >> $@
97 # define foo.te
98 $(QUIET) for i in $(notdir $(ALL_MODULES)); do \
99 echo "define(\`$$i')" >> $@ ;\
100 done
101 # $(QUIET) $(SETTUN) $(BOOLEANS) >> $@
103 tmp/all_interfaces.conf: $(M4SUPPORT) $(ALL_INTERFACES)
104 ifeq ($(ALL_INTERFACES),)
105 $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
106 endif
107 @test -d tmp || mkdir -p tmp
108 $(QUIET) m4 $^ | sed -e s/dollarsstar/\$$\*/g > $@
110 tmp/all_te_files.conf: $(ALL_TE_FILES)
111 ifeq ($(ALL_TE_FILES),)
112 $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
113 endif
114 @test -d tmp || mkdir -p tmp
115 $(QUIET) cat $^ > $@
117 tmp/post_te_files.conf: $(POST_TE_FILES)
118 @test -d tmp || mkdir -p tmp
119 $(QUIET) cat $^ > $@
121 # extract attributes and put them first. extract post te stuff
122 # like genfscon and put last. portcon, nodecon, and netifcon
123 # is delayed since they are generated by m4
124 tmp/all_attrs_types.conf tmp/only_te_rules.conf tmp/all_post.conf: tmp/all_te_files.conf tmp/post_te_files.conf
125 $(QUIET) grep ^attribute tmp/all_te_files.conf > tmp/all_attrs_types.conf || true
126 $(QUIET) grep '^type ' tmp/all_te_files.conf >> tmp/all_attrs_types.conf
127 $(QUIET) cat tmp/post_te_files.conf > tmp/all_post.conf
128 $(QUIET) grep '^sid ' tmp/all_te_files.conf >> tmp/all_post.conf || true
129 $(QUIET) egrep '^fs_use_(xattr|task|trans)' tmp/all_te_files.conf >> tmp/all_post.conf || true
130 $(QUIET) grep ^genfscon tmp/all_te_files.conf >> tmp/all_post.conf || true
131 $(QUIET) sed -r -e /^attribute/d -e '/^type /d' -e /^genfscon/d \
132 -e '/^sid /d' -e '/^fs_use_(xattr|task|trans)/d' \
133 < tmp/all_te_files.conf > tmp/only_te_rules.conf
135 ########################################
136 #
137 # Remove the dontaudit rules from the policy.conf
138 #
139 enableaudit: policy.conf
140 @test -d tmp || mkdir -p tmp
141 @echo "Removing dontaudit rules from policy.conf"
142 $(QUIET) grep -v dontaudit policy.conf > tmp/policy.audit
143 $(QUIET) mv tmp/policy.audit policy.conf
145 ########################################
146 #
147 # Construct file_contexts
148 #
149 $(FC): $(M4SUPPORT) tmp/generated_definitions.conf $(ALL_FC_FILES)
150 ifeq ($(ALL_FC_FILES),)
151 $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
152 endif
153 @echo "Creating $(NAME) file_contexts."
154 @test -d tmp || mkdir -p tmp
155 $(QUIET) m4 $(M4PARAM) $(M4SUPPORT) tmp/generated_definitions.conf $(ALL_FC_FILES) > tmp/$@.tmp
156 # $(QUIET) grep -e HOME -e ROLE tmp/$@.tmp > $(HOMEDIR_TEMPLATE)
157 # $(QUIET) sed -i -e /HOME/d -e /ROLE/d tmp/$@.tmp
158 # $(QUIET) $(FCSORT) tmp/$@.tmp $@
159 $(QUIET) touch $(HOMEDIR_TEMPLATE)
160 $(QUIET) touch $@
162 ########################################
163 #
164 # Install file_contexts
165 #
166 $(FCPATH): $(FC) $(LOADPATH) $(USERPATH)/system.users
167 @echo "Validating $(NAME) file_contexts."
168 # $(QUIET) $(SETFILES) -q -c $(LOADPATH) $(FC)
169 @echo "Installing file_contexts."
170 @mkdir -p $(CONTEXTPATH)/files
171 $(QUIET) install -m 644 $(FC) $(FCPATH)
172 $(QUIET) install -m 644 $(HOMEDIR_TEMPLATE) $(HOMEDIRPATH)
173 # $(QUIET) $(GENHOMEDIRCON) -d $(TOPDIR) -t $(NAME) $(USEPWD)
175 ########################################
176 #
177 # Run policy source checks
178 #
179 check: policy.conf $(FC)
180 $(SECHECK) -s --profile=development --policy=policy.conf --fcfile=$(FC) > $@.res
182 longcheck: policy.conf $(FC)
183 $(SECHECK) -s --profile=all --policy=policy.conf --fcfile=$(FC) > $@.res
185 ########################################
186 #
187 # Clean the sources
188 #
189 clean:
190 rm -fR tmp
191 rm -f policy.conf
192 rm -f policy.$(PV)
193 rm -f $(FC)
194 rm -f *.res
196 .PHONY: default policy install load reload enableaudit checklabels restorelabels relabel check longcheck clean