From 29f74559d4dc6ea41232233d32f1a92bcee43626 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 23 Mar 2018 09:47:04 +0100 Subject: [PATCH 1/6] stat-util: fix fd_is_network_ns() This was broken in 77f9fa3b8ea46c27e5a5e9270f71bf1b4000c3e0. My fault. Fixes: #8543 --- src/basic/stat-util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c index 3689f6e983..67705947aa 100644 --- a/src/basic/stat-util.c +++ b/src/basic/stat-util.c @@ -254,7 +254,8 @@ int fd_is_network_ns(int fd) { if (r <= 0) return r; - if (ioctl(fd, NS_GET_NSTYPE) < 0) + r = ioctl(fd, NS_GET_NSTYPE); + if (r < 0) return -errno; return r == CLONE_NEWNET; From 67321fdf3ea60566a718a2e60ddc2628609a2895 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 23 Mar 2018 09:48:15 +0100 Subject: [PATCH 2/6] test: bypass selinux integration test if selinux policy devel package is not installed With this "sudo ./run-integration-tests.sh" should work fully without exception, even on systems lacking SELinux (in which case that test will just be skipped) --- test/TEST-06-SELINUX/test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/TEST-06-SELINUX/test.sh b/test/TEST-06-SELINUX/test.sh index e0c4c10e1c..18856c2459 100755 --- a/test/TEST-06-SELINUX/test.sh +++ b/test/TEST-06-SELINUX/test.sh @@ -10,6 +10,9 @@ TEST_NO_NSPAWN=1 # selinux-policy-targeted # selinux-policy-devel +# Check if selinux-policy-devel is installed, and if it isn't bail out early instead of failing +test -d /usr/share/selinux/devel || exit 0 + . $TEST_BASE_DIR/test-functions SETUP_SELINUX=yes KERNEL_APPEND="$KERNEL_APPEND selinux=1 security=selinux" From ce6b7858cad8a8c692c35feb581e0efa98303bb5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 23 Mar 2018 09:51:02 +0100 Subject: [PATCH 3/6] run-integration-tests: show make command line executed That makes it much easier to figure out what to type to just run one specific test for debugging. --- test/run-integration-tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/run-integration-tests.sh b/test/run-integration-tests.sh index 7d70be3fea..4afaa0909e 100755 --- a/test/run-integration-tests.sh +++ b/test/run-integration-tests.sh @@ -16,9 +16,9 @@ FAILURES=0 cd "$(dirname "$0")" for TEST in TEST-??-* ; do - echo -e "\n--x-- Starting $TEST --x--" + echo -e "\n--x-- Running $TEST --x--" set +e - make -C "$TEST" "BUILD_DIR=$BUILD_DIR" $args + ( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" $args ) RESULT=$? set -e echo "--x-- Result of $TEST: $RESULT --x--" From 967bae687c191842d38b738f08523e868a081dc4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 23 Mar 2018 10:02:22 +0100 Subject: [PATCH 4/6] run-integration-tests: show number of tests run --- test/run-integration-tests.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/run-integration-tests.sh b/test/run-integration-tests.sh index 4afaa0909e..94df346c28 100755 --- a/test/run-integration-tests.sh +++ b/test/run-integration-tests.sh @@ -11,11 +11,13 @@ ninja -C "$BUILD_DIR" declare -A results -RESULT=0 +COUNT=0 FAILURES=0 cd "$(dirname "$0")" for TEST in TEST-??-* ; do + COUNT=$(($COUNT+1)) + echo -e "\n--x-- Running $TEST --x--" set +e ( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" $args ) @@ -40,9 +42,9 @@ for TEST in ${!results[@]}; do done | sort if [ "$FAILURES" -eq 0 ] ; then - echo -e "\nALL PASSED" + echo -e "\nALL $COUNT TESTS PASSED" else - echo -e "\nTOTAL FAILURES: $FAILURES" + echo -e "\nTOTAL FAILURES: $FAILURES OF $COUNT" fi exit "$FAILURES" From 34d267776acf55ac1b4009f04f21a67547545aba Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 23 Mar 2018 15:41:33 +0100 Subject: [PATCH 5/6] coccinelle: run const-strlen.cocci again --- src/tmpfiles/tmpfiles.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 1794290ebe..b56b7ac963 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -821,7 +821,7 @@ static int fd_set_perms(Item *i, int fd, const struct stat *st) { if (m == (st->st_mode & 07777)) log_debug("\"%s\" has correct mode %o already.", path, st->st_mode); else { - char procfs_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; + char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; log_debug("Changing \"%s\" to mode %o.", path, m); @@ -920,7 +920,7 @@ static int parse_xattrs_from_arg(Item *i) { } static int fd_set_xattrs(Item *i, int fd, const struct stat *st) { - char procfs_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; + char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; _cleanup_free_ char *path = NULL; char **name, **value; int r; @@ -1024,7 +1024,7 @@ static int path_set_acl(const char *path, const char *pretty, acl_type_t type, a static int fd_set_acls(Item *item, int fd, const struct stat *st) { int r = 0; #if HAVE_ACL - char procfs_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; + char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; _cleanup_free_ char *path = NULL; assert(item); @@ -1186,7 +1186,7 @@ static int parse_attribute_from_arg(Item *item) { } static int fd_set_attribute(Item *item, int fd, const struct stat *st) { - char procfs_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; + char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; _cleanup_close_ int procfs_fd = -1; _cleanup_free_ char *path = NULL; unsigned f; From 849b610489a125799a7395f3d8223e63e5c21b40 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 23 Mar 2018 15:44:10 +0100 Subject: [PATCH 6/6] run-coccinelle.sh: use set -x for showing command line of "spatch" Let's make sure run-coccinelle.sh generates similar output as run-integration-tests.sh, hence use the same "set -x" logic. --- coccinelle/run-coccinelle.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/coccinelle/run-coccinelle.sh b/coccinelle/run-coccinelle.sh index de23546f19..f463f5eed5 100755 --- a/coccinelle/run-coccinelle.sh +++ b/coccinelle/run-coccinelle.sh @@ -1,10 +1,9 @@ #!/bin/bash -e for SCRIPT in ${@-*.cocci} ; do - echo "--x-- Processing: spatch --sp-file $SCRIPT --dir $(pwd)/.. --x--" + echo "--x-- Processing $SCRIPT --x--" TMPFILE=`mktemp` - spatch --sp-file $SCRIPT --dir $(pwd)/.. 2> "$TMPFILE" || cat "$TMPFILE" + ( set -x ; spatch --sp-file $SCRIPT --dir $PWD/.. 2> "$TMPFILE" || cat "$TMPFILE" ) rm "$TMPFILE" - echo "--x-- Processed: spatch --sp-file $SCRIPT --dir $(pwd)/.. --x--" - echo "" + echo -e "--x-- Processed $SCRIPT --x--\n" done