Skip to content

Commit

Permalink
CI: Add a semodule load test to verify modules insert to store.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pebenito committed Nov 22, 2024
1 parent 3cf2758 commit 11f1f1a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build-policy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ jobs:
echo "DIRECT_INITRC=${{ matrix.direct_initrc }}" >> $GITHUB_ENV
echo "WERROR=y" >> $GITHUB_ENV
echo "TEST_TOOLCHAIN=\"${{ steps.dl-userspace.outputs.download-path }}\"" >> $GITHUB_ENV
echo 'multiple-decls = true' >> ${{ steps.dl-userspace.outputs.download-path }}/etc/selinux/semanage.conf
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
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
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
sudo cp ${{ steps.dl-userspace.outputs.download-path }}/etc/selinux/semanage.conf /etc/selinux/semanage.conf
cat /etc/selinux/semanage.conf
- name: Build refpolicy
shell: bash
Expand Down Expand Up @@ -125,6 +131,10 @@ jobs:
make install-docs
make install-udica-templates
make install-appconfig
if [[ $MONOLITHIC == "n" ]]; then
# test modules insertion
make load
fi
env:
DESTDIR: /tmp/refpolicy-install

Expand Down
10 changes: 8 additions & 2 deletions Rules.modular
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
# Rules and Targets for building modular policies
#

module_store_root := $(DESTDIR)/var/lib/selinux

ifneq ($(DESTDIR),)
SEMODULE += -p $(DESTDIR) -n
endif

all_modules := $(base_mods) $(mod_mods) $(off_mods)
all_interfaces := $(all_modules:.te=.if)
enabled_mod_fc := $(addprefix $(tmpdir)/,$(notdir $(base_mods:.te=.mod.fc) $(mod_mods:.te=.mod.fc)))
Expand Down Expand Up @@ -57,7 +63,7 @@ load: $(instpkg) $(appfiles)
# make sure two directories exist since they are not
# created by semanage
@echo "Loading configured modules."
@$(INSTALL) -d -m 0755 $(policypath) $(dir $(fcpath))
@$(INSTALL) -d -m 0755 $(policypath) $(dir $(fcpath)) $(module_store_root)
$(verbose) $(SEMODULE) -s $(NAME) -i $(modpkgdir)/$(notdir $(base_pkg)) $(foreach mod,$(mod_pkgs),-i $(modpkgdir)/$(mod))

########################################
Expand All @@ -68,7 +74,7 @@ pure-load: $(instpkg) $(appfiles)
# make sure two directories exist since they are not
# created by semanage
@echo "Loading configured modules."
@$(INSTALL) -d -m 0755 $(policypath) $(dir $(fcpath))
@$(INSTALL) -d -m 0755 $(policypath) $(dir $(fcpath)) $(module_store_root)
$(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))

########################################
Expand Down

0 comments on commit 11f1f1a

Please sign in to comment.