1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
From: Matthew Heon <matthew.heon@gmail.com>
Date: Fri, 5 May 2017 08:44:47 -0400
Subject: Fix unit test failures on 32-bit systems
Add the setreuid32 syscall to the test filter as well as setreuid.
On most 64-bit systems the syscall does not exist, but this should
be handled by libseccomp, and actually slightly increases test
coverage.
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
---
seccomp_test.go | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/seccomp_test.go b/seccomp_test.go
index b3a49d2..a068507 100644
--- a/seccomp_test.go
+++ b/seccomp_test.go
@@ -413,6 +413,11 @@ func TestRuleAddAndLoad(t *testing.T) {
t.Errorf("Error getting syscall number of setreuid: %s", err)
}
+ call3, err := GetSyscallFromName("setreuid32")
+ if err != nil {
+ t.Errorf("Error getting syscall number of setreuid32: %s", err)
+ }
+
uid := syscall.Getuid()
euid := syscall.Geteuid()
@@ -438,6 +443,11 @@ func TestRuleAddAndLoad(t *testing.T) {
t.Errorf("Error adding conditional rule: %s", err)
}
+ err = filter1.AddRuleConditional(call3, ActErrno.SetReturnCode(0x3), conditions)
+ if err != nil {
+ t.Errorf("Error adding second conditional rule: %s", err)
+ }
+
err = filter1.Load()
if err != nil {
t.Errorf("Error loading filter: %s", err)
@@ -451,7 +461,9 @@ func TestRuleAddAndLoad(t *testing.T) {
// Try making a Geteuid syscall that should normally succeed
err = syscall.Setreuid(uid, euid)
- if err != syscall.Errno(2) {
+ if err == nil {
t.Errorf("Syscall should have returned error code!")
+ } else if err != syscall.Errno(2) && err != syscall.Errno(3) {
+ t.Errorf("Syscall returned incorrect error code - likely not blocked by Seccomp!")
}
}
|