seccomp: fix __NR__sysctl usage v239-32
authorJan Synacek <jsynacek@redhat.com>
Thu, 4 Jun 2020 14:55:52 +0000 (16:55 +0200)
committerJan Synacek <jsynacek@redhat.com>
Thu, 4 Jun 2020 14:56:49 +0000 (16:56 +0200)
Loosely based on
https://github.com/systemd/systemd/pull/14032 and
https://github.com/systemd/systemd/pull/14268.

Related: #1843871

src/test/test-seccomp.c

index 4021a06e0e2a6f3fcf1c96a2e33e20dd2175bd20..009a2e192229f1725d4e370cfdf54c4734855589 100644 (file)
@@ -237,14 +237,14 @@ static void test_protect_sysctl(void) {
         assert_se(pid >= 0);
 
         if (pid == 0) {
-#if __NR__sysctl > 0
+#if defined __NR__sysctl &&  __NR__sysctl >= 0
                 assert_se(syscall(__NR__sysctl, NULL) < 0);
                 assert_se(errno == EFAULT);
 #endif
 
                 assert_se(seccomp_protect_sysctl() >= 0);
 
-#if __NR__sysctl > 0
+#if defined __NR__sysctl && __NR__sysctl >= 0
                 assert_se(syscall(__NR__sysctl, 0, 0, 0) < 0);
                 assert_se(errno == EPERM);
 #endif