Skip to content

Commit 3046a8b

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 fb91772 commit 3046a8b

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
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
@@ -119,12 +125,17 @@ jobs:
119125
working-directory: ${{ inputs.path }}
120126
shell: bash
121127
run: |
128+
echo "${TEST_TOOLCHAIN}"
122129
make install
123130
make install-headers
124131
make install-src
125132
make install-docs
126133
make install-udica-templates
127134
make install-appconfig
135+
if [[ $MONOLITHIC == "n" ]]; then
136+
# test modules insertion
137+
sudo -E make load
138+
fi
128139
env:
129140
DESTDIR: /tmp/refpolicy-install
130141

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: ./.github/workflows/build-userspace.yml
2323
# depend on lint so expensive operations don't run if lint fails
2424
with:
25-
version: "3.2"
25+
version: "3.8.1"
2626
python-version: "3.10"
2727

2828
build_setools:

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)