Skip to content

Commit

Permalink
Fix unit test failures on 32-bit systems
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mheon committed May 5, 2017
1 parent 84e90a9 commit b03f1ef
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion seccomp_test.go
Expand Up @@ -465,6 +465,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()

Expand All @@ -490,6 +495,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)
Expand All @@ -503,7 +513,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!")
}
}

0 comments on commit b03f1ef

Please sign in to comment.