Fix refpolicy build & build test_policy.pp in Travis
v2 cover Fix refpolicy build & build test_policy.pp in Travis
This series fixes the remaining test_policy.pp build errors under refpolicy and enables building the test policy under both Fedora policy and refpolicy in Travis CI.
Changes in v2:
- report policy version 999 in the fake selinuxfs to force building latest version
- install userspace tools and libraries straight from source instead of working around maissing features in the Ubuntu builds
- install also latest keyutils from source to allow the new 'keys' subtest helpers to build
Ondrej Mosnacek (3):
policy: consolidate macros for home dirs access
policy: add fallbacks for Fedora-specific macros
travis: test building the test policy package
.travis.yml | 48 ++++++++++++++++++++++++++--- policy/Makefile | 11 ++++--- policy/test_overlayfs.te | 6 ++-- policy/test_policy.if | 23 ++++++++++++-- travis-ci/enable-policy.sh | 10 ++++++ travis-ci/setup-policy-fedora.sh | 33 ++++++++++++++++++++ travis-ci/setup-policy-refpolicy.sh | 19 ++++++++++++ 7 files changed, 136 insertions(+), 14 deletions(-) create mode 100644 travis-ci/enable-policy.sh create mode 100644 travis-ci/setup-policy-fedora.sh create mode 100644 travis-ci/setup-policy-refpolicy.sh
Signature · 1 line
2.23.0
PATCH v2 1/3 policy: consolidate macros for home dirs access
Use userdom_search_generic_user_home_dirs(), which is always defined, and redefine it to match what overlayfs was doing (just in case),
--- policy/test_overlayfs.te | 6 ++---- policy/test_policy.if | 9 +++++++-- 2 files changed, 9 insertions(+), 6 deletions(-)
policy/test_overlayfs.te +2 -4
@@ -50,8 +50,7 @@ fs_mount_xattr_fs(test_overlay_mounter_t) corecmd_shell_entry_type(test_overlay_mounter_t) corecmd_exec_bin(test_overlay_mounter_t) -userdom_search_admin_dir(test_overlay_mounter_t) -userdom_search_user_home_content(test_overlay_mounter_t) +userdom_search_generic_user_home_dirs(test_overlay_mounter_t) mount_exec(test_overlay_mounter_t) mount_rw_pid_files(test_overlay_mounter_t)
@@ -122,8 +121,7 @@ corecmd_exec_bin(test_overlay_client_t) kernel_read_system_state(test_overlay_client_t) kernel_read_proc_symlinks(test_overlay_client_t) -userdom_search_admin_dir(test_overlay_client_t) -userdom_search_user_home_content(test_overlay_client_t) +userdom_search_generic_user_home_dirs(test_overlay_client_t) fs_getattr_xattr_fs(test_overlay_client_t)
policy/test_policy.if +7 -2
@@ -61,8 +61,13 @@ interface(`userdom_sysadm_entry_spec_domtrans_to',` ') ') -ifdef(`userdom_search_generic_user_home_dirs', `', ` dnl +ifdef(`userdom_search_admin_dir', ` dnl interface(`userdom_search_generic_user_home_dirs', ` - userdom_search_user_home_dirs($1) + userdom_search_user_home_content($1) + userdom_search_admin_dir($1) +') +', ` dnl +interface(`userdom_search_generic_user_home_dirs', ` + userdom_search_user_home_content($1) ') ')
Signature · 1 line
2.23.0
PATCH v2 2/3 policy: add fallbacks for Fedora-specific macros
In reply to Ondrej Mosnacekdev_rw_infiniband_dev() and mount_rw_pid_files() are not defined in refpolicy. Fall back to dev_rw_generic_files() and mount_rw_runtime_files() if they are not defined.
--- policy/test_policy.if | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
policy/test_policy.if +14 -0
@@ -71,3 +71,17 @@ interface(`userdom_search_generic_user_home_dirs', ` userdom_search_user_home_content($1) ') ') + +# Workarounds for refpolicy: + +ifdef(`dev_rw_infiniband_dev', `', ` dnl +interface(`dev_rw_infiniband_dev', ` + dev_rw_generic_files($1) +') +') + +ifdef(`mount_rw_pid_files', `', ` dnl +interface(`mount_rw_pid_files', ` + mount_rw_runtime_files($1) +') +')
Signature · 1 line
2.23.0
PATCH v2 3/3 travis: test building the test policy package
In reply to Ondrej MosnacekDownload, build, and install Fedora policy & refpolicy and try building the test policy package against both of them.
--- .travis.yml | 48 ++++++++++++++++++++++++++--- policy/Makefile | 11 ++++--- travis-ci/enable-policy.sh | 10 ++++++ travis-ci/setup-policy-fedora.sh | 33 ++++++++++++++++++++ travis-ci/setup-policy-refpolicy.sh | 19 ++++++++++++ 5 files changed, 113 insertions(+), 8 deletions(-) create mode 100644 travis-ci/enable-policy.sh create mode 100644 travis-ci/setup-policy-fedora.sh create mode 100644 travis-ci/setup-policy-refpolicy.sh
.travis.yml +44 -4
@@ -1,6 +1,6 @@ language: c -dist: xenial +dist: bionic addons: apt:
@@ -8,16 +8,56 @@ addons: - astyle - libselinux1-dev - libsctp-dev + - libaudit-dev + - libcap-dev + - libdbus-glib-1-dev + - xmlto + +cache: + directories: + - selinux-policy + - container-selinux + - refpolicy before_install: + - export LIBRARY_PATH=/usr/local/lib + - export LD_LIBRARY_PATH=/usr/local/lib # FYI: known good with HEAD at 8551fc60fc515cd290ba38ee8c758c1f4df52b56 - git clone https://github.com/perltidy/perltidy.git perltidy - | (cd perltidy && perl Makefile.PL && - make && - sudo make install) + make PREFIX=/usr/local && + sudo make install PREFIX=/usr/local) + # install libbpf from sources + - git clone https://github.com/libbpf/libbpf + - (cd libbpf/src && make PREFIX=/usr/local) + - (cd libbpf/src && sudo make install PREFIX=/usr/local) + # install keyutils from sources + - git clone https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git + - KEYUTILS_OPTS="" + - KEYUTILS_OPTS+="BINDIR=/usr/local/bin SBINDIR=/usr/local/sbin " + - KEYUTILS_OPTS+="LIBDIR=/usr/local/lib USRLIBDIR=/usr/local/lib " + - KEYUTILS_OPTS+="INCLUDEDIR=/usr/local/include " + - KEYUTILS_OPTS+="SHAREDIR=/usr/local/share/keyutils MANDIR=/usr/local/share/man" + - (cd keyutils && make $KEYUTILS_OPTS) + - (cd keyutils && sudo make install $KEYUTILS_OPTS) + # install SELinux userspace from source + - git clone https://github.com/SELinuxProject/selinux + - (cd selinux && sudo make install PREFIX=/usr/local SHLIBDIR=/usr/local/lib) + # install Fedora policy and refpolicy + - bash travis-ci/setup-policy-fedora.sh + - bash travis-ci/setup-policy-refpolicy.sh + # establish a fake "selinuxfs" mount (policy/Makefile just greps for selinuxfs) + - sudo mkdir -p /tmp/fake-selinuxfs + - sudo mount -t tmpfs tmpfs /tmp/fake-selinuxfs + - echo 999 >/tmp/fake-selinuxfs/policyvers script: - tools/check-syntax -f && git diff --exit-code - - make + - | + bash travis-ci/enable-policy.sh targeted && + make PREFIX=/usr/local POLDEV=/usr/share/selinux/targeted + - | + bash travis-ci/enable-policy.sh refpolicy && + make PREFIX=/usr/local POLDEV=/usr/share/selinux/refpolicy
policy/Makefile +7 -4
@@ -1,8 +1,11 @@ -POLDEV ?= /usr/share/selinux/devel -SEMODULE = /usr/sbin/semodule -CHECKPOLICY = /usr/bin/checkpolicy -CHECKMODULE = /usr/bin/checkmodule +PREFIX ?= /usr +BINDIR ?= $(PREFIX)/bin +SBINDIR ?= $(PREFIX)/sbin +POLDEV ?= $(PREFIX)/share/selinux/devel +SEMODULE = $(SBINDIR)/semodule +CHECKPOLICY = $(BINDIR)/checkpolicy +CHECKMODULE = $(BINDIR)/checkmodule DISTRO=$(shell ../tests/os_detect)
travis-ci/enable-policy.sh new file +10 -0
@@ -0,0 +1,10 @@ +#!/bin/bash + +set -e + +# create a dummy /etc/selinux/config +sudo mkdir -p /etc/selinux +sudo tee /etc/selinux/config >/dev/null <<EOF +SELINUX=disabled +SELINUXTYPE=$1 +EOF
travis-ci/setup-policy-fedora.sh new file +33 -0
@@ -0,0 +1,33 @@ +#!/bin/bash + +set -ex + +if ! [ -d selinux-policy/.git ]; then + git clone --recursive https://github.com/fedora-selinux/selinux-policy + (cd selinux-policy/policy/modules/contrib && git checkout rawhide) +else + (cd selinux-policy && git pull || { git checkout '*' && git pull; }) + (cd selinux-policy/policy/modules/contrib && git pull) +fi + +if ! [ -d container-selinux/.git ]; then + git clone https://github.com/containers/container-selinux.git + for f in container.if container.te; do + ln -s ../../../../container-selinux/$f \ + selinux-policy/policy/modules/contrib/$f + done +else + (cd container-selinux && git pull) +fi + +cd selinux-policy + +grep -q refpolicy build.conf && sed -i 's/refpolicy/targeted/' build.conf + +[ -f policy/modules.conf ] || make conf + +make -j`nproc --all` BINDIR=/usr/local/bin SBINDIR=/usr/local/sbin +sudo make install install-headers + +# workaround for different Makefile location in Fedora RPMs +sudo ln -s include/Makefile /usr/share/selinux/targeted/Makefile
travis-ci/setup-policy-refpolicy.sh new file +19 -0
@@ -0,0 +1,19 @@ +#!/bin/bash + +set -ex + +if ! [ -d refpolicy/.git ]; then + git clone https://github.com/SELinuxProject/refpolicy +else + git pull || { git checkout '*' && git pull; } +fi + +cd refpolicy + +[ -f policy/modules.conf ] || make conf + +make -j`nproc --all` BINDIR=/usr/local/bin SBINDIR=/usr/local/sbin +sudo make install install-headers + +# workaround for different Makefile location in Fedora RPMs +sudo ln -s include/Makefile /usr/share/selinux/refpolicy/Makefile
Signature · 1 line
2.23.0
Quoted 11 lines · Ondrej Mosnacek
This series fixes the remaining test_policy.pp build errors under refpolicy and enables building the test policy under both Fedora policy and refpolicy in Travis CI.
Changes in v2:
- report policy version 999 in the fake selinuxfs to force building latest version
- install userspace tools and libraries straight from source instead of working around maissing features in the Ubuntu builds
- install also latest keyutils from source to allow the new 'keys' subtest helpers to build
Demo Travis run:
https://travis-ci.org/WOnder93/selinux-testsuite/builds/612431495
Quoted 20 lines
Ondrej Mosnacek (3):
policy: consolidate macros for home dirs access
policy: add fallbacks for Fedora-specific macros
travis: test building the test policy package.travis.yml | 48 ++++++++++++++++++++++++++--- policy/Makefile | 11 ++++--- policy/test_overlayfs.te | 6 ++-- policy/test_policy.if | 23 ++++++++++++-- travis-ci/enable-policy.sh | 10 ++++++ travis-ci/setup-policy-fedora.sh | 33 ++++++++++++++++++++ travis-ci/setup-policy-refpolicy.sh | 19 ++++++++++++ 7 files changed, 136 insertions(+), 14 deletions(-) create mode 100644 travis-ci/enable-policy.sh create mode 100644 travis-ci/setup-policy-fedora.sh create mode 100644 travis-ci/setup-policy-refpolicy.sh--
2.23.0
Signature · 3 lines
Ondrej Mosnacek <omosnace at redhat dot com> Software Engineer, Security Technologies Red Hat, Inc.
Quoted 11 lines · Ondrej Mosnacek
This series fixes the remaining test_policy.pp build errors under refpolicy and enables building the test policy under both Fedora policy and refpolicy in Travis CI.
Changes in v2:
- report policy version 999 in the fake selinuxfs to force building latest version
- install userspace tools and libraries straight from source instead of working around maissing features in the Ubuntu builds
- install also latest keyutils from source to allow the new 'keys' subtest helpers to build
Doesn't appear to have addressed any of my comments on the first version of the first two patches:
https://lore.kernel.org/selinux/[email protected]/
https://lore.kernel.org/selinux/[email protected]/
Quoted 18 lines
Ondrej Mosnacek (3):
policy: consolidate macros for home dirs access
policy: add fallbacks for Fedora-specific macros
travis: test building the test policy package.travis.yml | 48 ++++++++++++++++++++++++++--- policy/Makefile | 11 ++++--- policy/test_overlayfs.te | 6 ++-- policy/test_policy.if | 23 ++++++++++++-- travis-ci/enable-policy.sh | 10 ++++++ travis-ci/setup-policy-fedora.sh | 33 ++++++++++++++++++++ travis-ci/setup-policy-refpolicy.sh | 19 ++++++++++++ 7 files changed, 136 insertions(+), 14 deletions(-)create mode 100644
travis-ci/enable-policy.shcreate mode 100644travis-ci/setup-policy-fedora.shcreate mode 100644travis-ci/setup-policy-refpolicy.sh
Quoted 13 lines · Stephen Smalley
Quoted 11 lines · Ondrej Mosnacek
This series fixes the remaining test_policy.pp build errors under refpolicy and enables building the test policy under both Fedora policy and refpolicy in Travis CI.
Changes in v2:
- report policy version 999 in the fake selinuxfs to force building latest version
- install userspace tools and libraries straight from source instead of working around maissing features in the Ubuntu builds
- install also latest keyutils from source to allow the new 'keys' subtest helpers to build
Quoted 6 lines
Doesn't appear to have addressed any of my comments on the first version of the first two patches:
Ah, sorry, I got back to this after a long delay and forgot about those... I'll address them in v3 then.
Quoted 20 lines
Quoted 19 lines
Ondrej Mosnacek (3):
policy: consolidate macros for home dirs access
policy: add fallbacks for Fedora-specific macros
travis: test building the test policy package.travis.yml | 48 ++++++++++++++++++++++++++--- policy/Makefile | 11 ++++--- policy/test_overlayfs.te | 6 ++-- policy/test_policy.if | 23 ++++++++++++-- travis-ci/enable-policy.sh | 10 ++++++ travis-ci/setup-policy-fedora.sh | 33 ++++++++++++++++++++ travis-ci/setup-policy-refpolicy.sh | 19 ++++++++++++ 7 files changed, 136 insertions(+), 14 deletions(-)create mode 100644
travis-ci/enable-policy.shcreate mode 100644travis-ci/setup-policy-fedora.shcreate mode 100644travis-ci/setup-policy-refpolicy.sh
Signature · 3 lines
Ondrej Mosnacek <omosnace at redhat dot com> Software Engineer, Security Technologies Red Hat, Inc.