dcavalca / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone
52b84b
From 65a066aae68744e889c114cee56dff5b48d872df Mon Sep 17 00:00:00 2001
52b84b
From: Jan Synacek <jsynacek@redhat.com>
52b84b
Date: Thu, 4 Jun 2020 16:55:52 +0200
52b84b
Subject: [PATCH] seccomp: fix __NR__sysctl usage
52b84b
52b84b
Loosely based on
52b84b
https://github.com/systemd/systemd/pull/14032 and
52b84b
https://github.com/systemd/systemd/pull/14268.
52b84b
52b84b
Related: #1843871
52b84b
---
52b84b
 src/test/test-seccomp.c | 4 ++--
52b84b
 1 file changed, 2 insertions(+), 2 deletions(-)
52b84b
52b84b
diff --git a/src/test/test-seccomp.c b/src/test/test-seccomp.c
52b84b
index 4021a06e0e..009a2e1922 100644
52b84b
--- a/src/test/test-seccomp.c
52b84b
+++ b/src/test/test-seccomp.c
52b84b
@@ -237,14 +237,14 @@ static void test_protect_sysctl(void) {
52b84b
         assert_se(pid >= 0);
52b84b
 
52b84b
         if (pid == 0) {
52b84b
-#if __NR__sysctl > 0
52b84b
+#if defined __NR__sysctl &&  __NR__sysctl >= 0
52b84b
                 assert_se(syscall(__NR__sysctl, NULL) < 0);
52b84b
                 assert_se(errno == EFAULT);
52b84b
 #endif
52b84b
 
52b84b
                 assert_se(seccomp_protect_sysctl() >= 0);
52b84b
 
52b84b
-#if __NR__sysctl > 0
52b84b
+#if defined __NR__sysctl && __NR__sysctl >= 0
52b84b
                 assert_se(syscall(__NR__sysctl, 0, 0, 0) < 0);
52b84b
                 assert_se(errno == EPERM);
52b84b
 #endif