Skip to content

Commit ef6d1b6

Browse files
committed
all: require libseccomp >= 2.3.1
Currently this package requires libseccomp < 2.2.0, refusing to build otherwise, and contains a few kludges specifically targeting libseccomp 2.2.0. Let's require version 2.3.1 or greater, and remove the kludges for older versions. While at it, reword the error message to remove the word "supported". Checking for libseccomp versions shipped with various old (but still supported) releases, here is what I found out: * Ubuntu 14.04 "Trusty Tahr": 2.1.1 (unsupported by this pkg), with 2.2.3 available in backports repo [1] * Debian "Stretch" (aka oldoldstable): 2.3.1 [2] * RHEL/CentOS 7: 2.3.1 [3] * SLES 15 SP1: 2.4.3 [4] * openSUSE Leap 15.2: 2.4.1 [4] * Alpine 3.11: 2.4.2 [5] * Arch, Gentoo: 2.5.x [1] https://launchpad.net/ubuntu/+source/libseccomp [2] https://packages.debian.org/search?keywords=libseccomp [3] https://rpmfind.net/linux/rpm2html/search.php?query=libseccomp [4] https://software.opensuse.org/package/libseccomp [5] https://pkgs.alpinelinux.org/packages?name=libseccomp&branch=v3.11 Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 4a0a385 commit ef6d1b6

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

seccomp.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,9 +1023,6 @@ func (f *ScmpFilter) AddRuleExact(call ScmpSyscall, action ScmpAction) error {
10231023
// AddRuleConditional adds a single rule for a conditional action on a syscall.
10241024
// Returns an error if an issue was encountered adding the rule.
10251025
// All conditions must match for the rule to match.
1026-
// There is a bug in library versions below v2.2.1 which can, in some cases,
1027-
// cause conditions to be lost when more than one are used. Consequently,
1028-
// AddRuleConditional is disabled on library versions lower than v2.2.1
10291026
func (f *ScmpFilter) AddRuleConditional(call ScmpSyscall, action ScmpAction, conds []ScmpCondition) error {
10301027
return f.addRuleGeneric(call, action, false, conds)
10311028
}
@@ -1037,9 +1034,6 @@ func (f *ScmpFilter) AddRuleConditional(call ScmpSyscall, action ScmpAction, con
10371034
// The rule will function exactly as described, but it may not function identically
10381035
// (or be able to be applied to) all architectures.
10391036
// Returns an error if an issue was encountered adding the rule.
1040-
// There is a bug in library versions below v2.2.1 which can, in some cases,
1041-
// cause conditions to be lost when more than one are used. Consequently,
1042-
// AddRuleConditionalExact is disabled on library versions lower than v2.2.1
10431037
func (f *ScmpFilter) AddRuleConditionalExact(call ScmpSyscall, action ScmpAction, conds []ScmpCondition) error {
10441038
return f.addRuleGeneric(call, action, true, conds)
10451039
}

seccomp_internal.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import (
2525
#include <stdlib.h>
2626
#include <seccomp.h>
2727
28-
#if SCMP_VER_MAJOR < 2
29-
#error Minimum supported version of Libseccomp is v2.2.0
30-
#elif SCMP_VER_MAJOR == 2 && SCMP_VER_MINOR < 2
31-
#error Minimum supported version of Libseccomp is v2.2.0
28+
#if (SCMP_VER_MAJOR < 2) || \
29+
(SCMP_VER_MAJOR == 2 && SCMP_VER_MINOR < 3) || \
30+
(SCMP_VER_MAJOR == 2 && SCMP_VER_MINOR == 3 && SCMP_VER_MICRO < 1)
31+
#error This package requires libseccomp >= v2.3.1
3232
#endif
3333
3434
#define ARCH_BAD ~0
@@ -322,7 +322,7 @@ func checkVersion(op string, major, minor, micro uint) error {
322322
}
323323

324324
func ensureSupportedVersion() error {
325-
return checkVersion("seccomp", 2, 2, 0)
325+
return checkVersion("seccomp", 2, 3, 1)
326326
}
327327

328328
// Get the API level
@@ -440,11 +440,6 @@ func (f *ScmpFilter) addRuleGeneric(call ScmpSyscall, action ScmpAction, exact b
440440
return err
441441
}
442442
} else {
443-
// We don't support conditional filtering in library version v2.1
444-
if err := checkVersion("conditional filtering", 2, 2, 1); err != nil {
445-
return err
446-
}
447-
448443
argsArr := C.make_arg_cmp_array(C.uint(len(conds)))
449444
if argsArr == nil {
450445
return fmt.Errorf("error allocating memory for conditions")

0 commit comments

Comments
 (0)