Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add a semodule load test to verify modules insert to store. #833

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 11 additions & 8 deletions .github/workflows/build-setools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,23 @@ jobs:
artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }}

steps:
- name: Download cached SETools
uses: actions/cache@v4
id: cache-setools
with:
path: "setools-*.whl"
key: setools-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}-Python${{ inputs.python-version }}

- name: Checkout setools
uses: actions/checkout@v4
if: ${{ steps.cache-setools.outputs.cache-hit != 'true' }}
with:
repository: SELinuxProject/setools
ref: "${{ inputs.version }}"

- name: Get the latest commit hash
shell: bash
run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV

- name: Download cached SETools
uses: actions/cache@v4
id: cache-setools
with:
path: "setools-*.whl"
key: setools-${{ inputs.version }}-${{ env.COMMIT_HASH }}-${{ runner.os }}-${{ runner.arch }}-Python${{ inputs.python-version }}

- name: Download userspace artifact
uses: actions/download-artifact@v4
if: ${{ steps.cache-setools.outputs.cache-hit != 'true' }}
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/build-userspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,25 @@ jobs:
binary-id: ${{ steps.upload-artifact.outputs.artifact-id }}

steps:
- name: Download cached SELinux userspace
uses: actions/cache@v4
id: cache-userspace
with:
path: ${{ github.workspace }}/selinux.tar.gz
key: selinux-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}-Python${{ inputs.python-version }}

- name: Checkout SELinux userspace tools and libs
uses: actions/checkout@v4
if: ${{ steps.cache-userspace.outputs.cache-hit != 'true' }}
with:
repository: SELinuxProject/selinux
ref: "${{ inputs.version }}"
path: "${{ env.SELINUX_SRC }}"

- name: Get the latest commit hash
shell: bash
run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
working-directory: "${{ env.SELINUX_SRC }}"

- name: Download cached SELinux userspace
uses: actions/cache@v4
id: cache-userspace
with:
path: ${{ github.workspace }}/selinux.tar.gz
key: selinux-${{ inputs.version }}-${{ env.COMMIT_HASH }}-${{ runner.os }}-${{ runner.arch }}-Python${{ inputs.python-version }}

- name: Set up Python
uses: actions/setup-python@v5
if: ${{ steps.cache-userspace.outputs.cache-hit != 'true' }}
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
Loading