Various CI-related testsuite fixes
cover Various CI-related testsuite fixes
There are some warnings and non-fatal errors reported during CI runs. Additionally, the CI gets stuck when there is a force-push on some upstream repo that is cached. This series fixes these issues.
Testing Travis run:
https://travis-ci.org/github/WOnder93/selinux-testsuite/builds/698848141
Ondrej Mosnacek (4):
Makefiles: remove bashisms
travis: add missing node to fake selinuxfs
travis: fix git/cache handling
tests: stop using deprecated security_context_t
.travis.yml | 2 ++ policy/Makefile | 4 +++- tests/Makefile | 8 ++++++-- tests/bounds/thread.c | 4 ++-- tests/dyntrace/parent.c | 2 +- tests/dyntrans/parent.c | 2 +- tests/execshare/parent.c | 2 +- tests/exectrace/parent.c | 2 +- tests/inherit/parent.c | 2 +- tests/prlimit/parent.c | 2 +- tests/setnice/parent.c | 2 +- travis-ci/setup-policy-fedora.sh | 10 ++++++---- travis-ci/setup-policy-refpolicy.sh | 4 +++- 13 files changed, 29 insertions(+), 17 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/4 Makefiles: remove bashisms
In Travis CI (Ubuntu), the shell used by Make doesn't understand bashisms like [[ ... ]]. Replace them with plain [ ... ] and also break up the conditionals for better readabilty.
--- policy/Makefile | 4 +++- tests/Makefile | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-)
policy/Makefile +3 -1
@@ -37,13 +37,15 @@ endif ifeq ($(SUPPORTS_CIL),y) CIL_TARGETS = test_mlsconstrain.cil test_overlay_defaultrange.cil -ifeq ($(shell [[ $(MAX_KERNEL_POLICY) -ge 32 && $(POL_VERS) -ge 32 ]] && echo true),true) +ifeq ($(shell [ $(MAX_KERNEL_POLICY) -ge 32 ] && echo true),true) +ifeq ($(shell [ $(POL_VERS) -ge 32 ] && echo true),true) # If other MLS tests get written this can be moved outside of the glblub test ifeq ($(POL_TYPE), MLS) CIL_TARGETS += test_glblub.cil else ifeq ($(POL_TYPE), MCS) CIL_TARGETS += test_add_levels.cil test_glblub.cil endif # POL_TYPE +endif # POL_VERS endif # MAX_KERNEL_POLICY endif # SUPPORTS_CIL
tests/Makefile +6 -2
@@ -68,9 +68,13 @@ ifeq ($(shell grep -q key_socket $(POLDEV)/include/support/all_perms.spt && test SUBDIRS += key_socket endif -ifeq ($(shell [[ $(MAX_KERNEL_POLICY) -ge 32 && ( $(POL_TYPE) == 'MLS' || $(POL_TYPE) == 'MCS' ) && $(POL_VERS) -ge 32 ]] && echo true),true) +ifeq ($(shell [ $(MAX_KERNEL_POLICY) -ge 32 ] && echo true),true) +ifeq ($(shell [ $(POL_TYPE) = 'MLS' ] || [ $(POL_TYPE) = 'MCS' ] && echo true),true) +ifeq ($(shell [ $(POL_VERS) -ge 32 ] && echo true),true) SUBDIRS += glblub -endif +endif # POL_VERS +endif # POL_TYPE +endif # MAX_KERNEL_POLICY ifeq ($(shell grep "^SELINUX_INFINIBAND_ENDPORT_TEST=" infiniband_endport/ibendport_test.conf | cut -d'=' -f 2),1) SUBDIRS += infiniband_endport
Signature · 1 line
2.26.2
Re: [PATCH testsuite 1/4] Makefiles: remove bashisms
Quoted 6 lines · Ondrej Mosnacek
In Travis CI (Ubuntu), the shell used by Make doesn't understand bashisms like [[ ... ]]. Replace them with plain [ ... ] and also break up the conditionals for better readabilty.
Signed-off-by Ondrej Mosnacek <[email protected]>
When I ran into these issues (along with some similar problems with bashisms in some of the test scripts) in getting the testsuite to pass on Debian and Ubuntu, I addressed it by running dkpg-reconfigure dash and switching the default shell to bash (as noted in the README.md). Not objecting to changing it but just noting that there are further bashisms in the testsuite beyond the Makefiles.
In any event,
Paul Moore
maintainerRe: [PATCH testsuite 1/4] Makefiles: remove bashisms
Quoted 6 lines · Stephen Smalley
Quoted 5 lines · Ondrej Mosnacek
In Travis CI (Ubuntu), the shell used by Make doesn't understand bashisms like [[ ... ]]. Replace them with plain [ ... ] and also break up the conditionals for better readabilty.
Quoted 8 lines
Quoted 1 line
Signed-off-by Ondrej Mosnacek <[email protected]>When I ran into these issues (along with some similar problems with bashisms in some of the test scripts) in getting the testsuite to pass on Debian and Ubuntu, I addressed it by running dkpg-reconfigure dash and switching the default shell to bash (as noted in the README.md). Not objecting to changing it but just noting that there are further bashisms in the testsuite beyond the Makefiles.
Agreed.
I don't think requiring bash is the same problem that it may have been ~20 years ago; it would be even easier if Ubuntu hadn't decided to go with dash (/me shakes fist). Regardless of this patch, I think it might be good to add a check to the test suite to warn (fail?) if the current shell is not bash.
Signature · 2 lines
paul moore www.paul-moore.com
PATCH 2/4 travis: add missing node to fake selinuxfs
In reply to Ondrej MosnacekSince commit e95fe9503816 ("Add tests for default_range glblub") we look at $(SELINUXFS)/initial_contexts/kernel to determine the type of the policy. However, this node is not provided by the fake selinuxfs created by our CI scripts, leading to non-fatal errors like this:
[...]
make[1]: Entering directory '/home/travis/build/WOnder93/selinux-testsuite/policy'
cat: /tmp/fake-selinuxfs/initial_contexts/kernel: No such file or directory [...]
Create that node and fill it with the ussual kernel context to silence the errors.
--- .travis.yml | 2 ++ 1 file changed, 2 insertions(+)
.travis.yml +2 -0
@@ -55,6 +55,8 @@ before_install: # establish a fake "selinuxfs" mount (policy/Makefile just greps for selinuxfs) - mkdir -p /tmp/fake-selinuxfs/policy_capabilities - echo 1 > /tmp/fake-selinuxfs/policy_capabilities/extended_socket_class + - mkdir -p /tmp/fake-selinuxfs/initial_contexts + - echo system_u:system_r:kernel_t:s0 > /tmp/fake-selinuxfs/initial_contexts/kernel - echo 999 >/tmp/fake-selinuxfs/policyvers script:
Signature · 1 line
2.26.2
Re: [PATCH testsuite 2/4] travis: add missing node to fake selinuxfs
Quoted 11 lines · Ondrej Mosnacek
Since commit
e95fe9503816("Add tests fordefault_rangeglblub") we look at $(SELINUXFS)/initial_contexts/kernel to determine the type of the policy. However, this node is not provided by the fake selinuxfs created by our CI scripts, leading to non-fatal errors like this:[...]
make[1]: Entering directory '/home/travis/build/WOnder93/selinux-testsuite/policy'
cat:/tmp/fake-selinuxfs/initial_contexts/kernel: No such file or directory [...]
Quoted 4 lines
Create that node and fill it with the ussual kernel context to silence the errors.
Signed-off-by Ondrej Mosnacek <[email protected]>
Not objecting to fixing this but wondered if you had considered extending the .travis.yml to actually run the testsuite in a SELinux-enabled VM as per the selinux .travis.yml.
Re: [PATCH testsuite 2/4] travis: add missing node to fake selinuxfs
Quoted 12 lines · Stephen Smalley
Quoted 11 lines · Ondrej Mosnacek
Since commit
e95fe9503816("Add tests fordefault_rangeglblub") we look at $(SELINUXFS)/initial_contexts/kernel to determine the type of the policy. However, this node is not provided by the fake selinuxfs created by our CI scripts, leading to non-fatal errors like this:[...]
make[1]: Entering directory '/home/travis/build/WOnder93/selinux-testsuite/policy'
cat:/tmp/fake-selinuxfs/initial_contexts/kernel: No such file or directory [...]
Quoted 8 lines
Quoted 4 lines
Create that node and fill it with the ussual kernel context to silence the errors.
Signed-off-by Ondrej Mosnacek <[email protected]>Not objecting to fixing this but wondered if you had considered extending the .travis.yml to actually run the testsuite in a SELinux-enabled VM as per the selinux .travis.yml.
Maybe eventually, but for now I wanted to at least fix what we have now,
Signature · 3 lines
Ondrej Mosnacek Software Engineer, Platform Security - SELinux kernel Red Hat, Inc.
Stephen Smalley
maintainerRe: [PATCH testsuite 2/4] travis: add missing node to fake selinuxfs
Quoted 18 lines · Ondrej Mosnacek
Quoted 15 lines · Stephen Smalley
Quoted 14 lines · Ondrej Mosnacek
Since commit
e95fe9503816("Add tests fordefault_rangeglblub") we look at $(SELINUXFS)/initial_contexts/kernel to determine the type of the policy. However, this node is not provided by the fake selinuxfs created by our CI scripts, leading to non-fatal errors like this:[...]
make[1]: Entering directory '/home/travis/build/WOnder93/selinux-testsuite/policy'
cat:/tmp/fake-selinuxfs/initial_contexts/kernel: No such file or directory [...]Create that node and fill it with the ussual kernel context to silence the errors.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Ondrej Mosnacek <[email protected]>Not objecting to fixing this but wondered if you had considered extending the .travis.yml to actually run the testsuite in a SELinux-enabled VM as per the selinux .travis.yml.
Maybe eventually, but for now I wanted to at least fix what we have now,
Sure, no problem. In an ideal world, we'd even run it on a Debian and/or Ubuntu SELinux-enabled VM too as part of travis-ci (following the README.md instructions and if on Ubuntu ignoring the two kernel-config-induced failures) but that would require an extra relabeling and reboot step to get the VM into a SELinux enabled state.
PATCH 3/4 travis: fix git/cache handling
In reply to Ondrej MosnacekThe current way of fetching new changes from git blows up when there has been a force-push. Switch to just fetching and then checking out the remote branch directly rather than using git pull.
--- travis-ci/setup-policy-fedora.sh | 10 ++++++---- travis-ci/setup-policy-refpolicy.sh | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-)
travis-ci/setup-policy-fedora.sh +6 -4
@@ -4,11 +4,12 @@ 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) + git -C selinux-policy fetch origin + git -C selinux-policy/policy/modules/contrib fetch origin fi +git -C selinux-policy checkout origin/rawhide +git -C selinux-policy/policy/modules/contrib checkout origin/rawhide if ! [ -d container-selinux/.git ]; then git clone https://github.com/containers/container-selinux.git
@@ -17,8 +18,9 @@ if ! [ -d container-selinux/.git ]; then selinux-policy/policy/modules/contrib/$f done else - (cd container-selinux && git pull) + git -C container-selinux fetch origin fi +git -C container-selinux checkout origin/master cd selinux-policy
travis-ci/setup-policy-refpolicy.sh +3 -1
@@ -5,11 +5,13 @@ set -ex if ! [ -d refpolicy/.git ]; then git clone https://github.com/SELinuxProject/refpolicy else - git pull || { git checkout '*' && git pull; } + git -C refpolicy fetch origin fi cd refpolicy +git checkout origin/master + [ -f policy/modules.conf ] || make conf make -j`nproc --all` BINDIR=/usr/local/bin SBINDIR=/usr/local/sbin
Signature · 1 line
2.26.2
Re: [PATCH testsuite 3/4] travis: fix git/cache handling
Quoted 6 lines · Ondrej Mosnacek
The current way of fetching new changes from git blows up when there has been a force-push. Switch to just fetching and then checking out the remote branch directly rather than using git pull.
Signed-off-by Ondrej Mosnacek <[email protected]>
PATCH 4/4 tests: stop using deprecated security_context_t
In reply to Ondrej MosnacekIn Travis CI, GCC reports in several places:
gcc -g -O0 -Wall -D_GNU_SOURCE -DHAVE_BPF parent.c -lselinux -o parentparent.c: In function ‘main’:
parent.c:25:2: warning: ‘security_context_t’ is deprecated [-Wdeprecated-declarations]
security_context_t context_s;
^~~~~~~~~~~~~~~~~~
Fix this by using plain char * instead of security_context_t.
--- tests/bounds/thread.c | 4 ++-- tests/dyntrace/parent.c | 2 +- tests/dyntrans/parent.c | 2 +- tests/execshare/parent.c | 2 +- tests/exectrace/parent.c | 2 +- tests/inherit/parent.c | 2 +- tests/prlimit/parent.c | 2 +- tests/setnice/parent.c | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-)
tests/bounds/thread.c +2 -2
@@ -19,7 +19,7 @@ static int thread_status = 0;static void *worker (void *datap) { -security_context_t security_context = datap; +char *security_context = datap;int rc; rc =setcon (security_context);
@@ -31,7 +31,7 @@ static void *worker(void *datap)int main (int argc,char *argv[]) { -security_context_t security_context; +char *security_context;context_t context;pthread_t thread;int rc;
tests/dyntrace/parent.c +1 -1
@@ -12,7 +12,7 @@int main (int argc,char **argv) {int pid, rc, status; -security_context_t context_s; +char *context_s;context_t context;char *child_argv[3 ];
tests/dyntrans/parent.c +1 -1
@@ -11,7 +11,7 @@int main (int argc,char **argv) {int rc; -security_context_t context_s; +char *context_s;context_t context;if (argc !=2 ) {
tests/execshare/parent.c +1 -1
@@ -22,7 +22,7 @@ int main(int argc, char **argv)int pagesize;void *clone_stack, *page;int pid, rc, status, cloneflags; -security_context_t context_s; +char *context_s;context_t context;if (argc !=4 ) {
tests/exectrace/parent.c +1 -1
@@ -11,7 +11,7 @@int main (int argc,char **argv) {int pid, rc, status; -security_context_t context_s; +char *context_s;context_t context;if (argc !=3 ) {
tests/inherit/parent.c +1 -1
@@ -9,7 +9,7 @@int main (int argc,char **argv) {char **childargv; -security_context_t context_s; +char *context_s;context_t context;int rc, fd;
tests/prlimit/parent.c +1 -1
@@ -26,7 +26,7 @@ int main(int argc, char **argv) {char buf[1 ];int pid, rc, fd[2 ], fd2[2 ], opt; -security_context_t context_s; +char *context_s;context_t context;struct rlimit newrlim, oldrlim, *newrlimp =NULL , *oldrlimp =NULL ;bool get = false, set = false, soft = false;
tests/setnice/parent.c +1 -1
@@ -14,7 +14,7 @@ int main(int argc, char **argv) {char buf[1 ];int pid, rc, rc2, fd[2 ], fd2[2 ]; -security_context_t context_s; +char *context_s;context_t context;if (argc !=3 ) {
Signature · 1 line
2.26.2
Re: [PATCH testsuite 4/4] tests: stop using deprecated security_context_t
Quoted 9 lines · Ondrej Mosnacek
In Travis CI, GCC reports in several places:
gcc -g -O0 -Wall -D_GNU_SOURCE -DHAVE_BPF
parent.c-lselinux -o parentparent.c: In function ‘main’:
parent.c:25:2: warning: ‘security_context_t’ is deprecated [-Wdeprecated-declarations]
security_context_tcontext_s;
^~~~~~~~~~~~~~~~~~
Quoted 3 lines
Fix this by using plain char * instead of
security_context_t.Signed-off-by Ondrej Mosnacek <[email protected]>
Quoted 5 lines · Ondrej Mosnacek
There are some warnings and non-fatal errors reported during CI runs. Additionally, the CI gets stuck when there is a force-push on some upstream repo that is cached. This series fixes these issues.
Quoted 8 lines
Testing Travis run:
https://travis-ci.org/github/WOnder93/selinux-testsuite/builds/698848141Ondrej Mosnacek (4):
Makefiles: remove bashisms
travis: add missing node to fake selinuxfs
travis: fix git/cache handling
tests: stop using deprecatedsecurity_context_t
Applied.