Skip to content

Commit 43924b1

Browse files
committed
CI: Add a semodule load test to verify modules insert to store.
There have been some discrepancies between semodule_link/_expand and semodule -i, see #829. Add an extra CI test of installing the modules using semodule -i. Signed-off-by: Chris PeBenito <[email protected]>
1 parent 3cf2758 commit 43924b1

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

.github/workflows/build-policy.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ jobs:
9090
echo "DIRECT_INITRC=${{ matrix.direct_initrc }}" >> $GITHUB_ENV
9191
echo "WERROR=y" >> $GITHUB_ENV
9292
echo "TEST_TOOLCHAIN=\"${{ steps.dl-userspace.outputs.download-path }}\"" >> $GITHUB_ENV
93+
echo 'multiple-decls = true' >> ${{ steps.dl-userspace.outputs.download-path }}/etc/selinux/semanage.conf
94+
sed -i -e '/^module-store/a compiler-directory = ${{ steps.dl-userspace.outputs.download-path }}/usr/libexec/selinux/hll' ${{ steps.dl-userspace.outputs.download-path }}/etc/selinux/semanage.conf
95+
echo -e '[sefcontext_compile]\npath = ${{ steps.dl-userspace.outputs.download-path }}/usr/sbin/sefcontext_compile\nargs = $@\n[end]' >> ${{ steps.dl-userspace.outputs.download-path }}/etc/selinux/semanage.conf
96+
echo -e '[setfiles]\npath = ${{ steps.dl-userspace.outputs.download-path }}/sbin/setfiles\nargs = -c $@ $<\n[end]' >> ${{ steps.dl-userspace.outputs.download-path }}/etc/selinux/semanage.conf
97+
sudo cp ${{ steps.dl-userspace.outputs.download-path }}/etc/selinux/semanage.conf /etc/selinux/semanage.conf
98+
cat /etc/selinux/semanage.conf
9399
94100
- name: Build refpolicy
95101
shell: bash
@@ -125,8 +131,13 @@ jobs:
125131
make install-docs
126132
make install-udica-templates
127133
make install-appconfig
134+
if [[ $MONOLITHIC == "n" ]]; then
135+
# test modules insertion
136+
make load
137+
fi
128138
env:
129139
DESTDIR: /tmp/refpolicy-install
140+
LD_LIBRARY_PATH: "${{ steps.dl-userspace.outputs.download-path }}/lib:${{ steps.dl-userspace.outputs.download-path }}/usr/lib"
130141

131142
# normalize to "sepolicy" and "file_contexts"
132143
- name: Normalize artifacts

Rules.modular

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
# Rules and Targets for building modular policies
44
#
55

6+
module_store_root := $(DESTDIR)/var/lib/selinux
7+
8+
ifneq ($(DESTDIR),)
9+
SEMODULE += -p $(DESTDIR) -n
10+
endif
11+
612
all_modules := $(base_mods) $(mod_mods) $(off_mods)
713
all_interfaces := $(all_modules:.te=.if)
814
enabled_mod_fc := $(addprefix $(tmpdir)/,$(notdir $(base_mods:.te=.mod.fc) $(mod_mods:.te=.mod.fc)))
@@ -57,7 +63,7 @@ load: $(instpkg) $(appfiles)
5763
# make sure two directories exist since they are not
5864
# created by semanage
5965
@echo "Loading configured modules."
60-
@$(INSTALL) -d -m 0755 $(policypath) $(dir $(fcpath))
66+
@$(INSTALL) -d -m 0755 $(policypath) $(dir $(fcpath)) $(module_store_root)
6167
$(verbose) $(SEMODULE) -s $(NAME) -i $(modpkgdir)/$(notdir $(base_pkg)) $(foreach mod,$(mod_pkgs),-i $(modpkgdir)/$(mod))
6268

6369
########################################
@@ -68,7 +74,7 @@ pure-load: $(instpkg) $(appfiles)
6874
# make sure two directories exist since they are not
6975
# created by semanage
7076
@echo "Loading configured modules."
71-
@$(INSTALL) -d -m 0755 $(policypath) $(dir $(fcpath))
77+
@$(INSTALL) -d -m 0755 $(policypath) $(dir $(fcpath)) $(module_store_root)
7278
$(verbose) $(SEMODULE) -s $(NAME) -i $(modpkgdir)/$(notdir $(base_pkg)) $(foreach mod,$(mod_pkgs),-i $(modpkgdir)/$(mod)) $(foreach omod,$(filter-out base $(notdir $(mod_mods:.te=)),$(shell $(SEMODULE) -l)),-r $(omod))
7379

7480
########################################

0 commit comments

Comments
 (0)