Skip to content

Commit ff2e3dd

Browse files
committed
Switch to github.com/moby/sys/capability v0.3.0
This removes the last unversioned package in runc's direct dependencies. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent c7d80c1 commit ff2e3dd

File tree

17 files changed

+327
-277
lines changed

17 files changed

+327
-277
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ require (
1515
github.com/cyphar/filepath-securejoin v0.3.2
1616
github.com/docker/go-units v0.5.0
1717
github.com/godbus/dbus/v5 v5.1.0
18+
github.com/moby/sys/capability v0.3.0
1819
github.com/moby/sys/mountinfo v0.7.1
1920
github.com/moby/sys/user v0.1.0
2021
github.com/mrunalp/fileutils v0.5.1
2122
github.com/opencontainers/runtime-spec v1.2.0
2223
github.com/opencontainers/selinux v1.11.0
2324
github.com/seccomp/libseccomp-golang v0.10.0
2425
github.com/sirupsen/logrus v1.9.3
25-
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
2626
github.com/urfave/cli v1.22.14
2727
github.com/vishvananda/netlink v1.1.0
2828
golang.org/x/net v0.24.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/
3838
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
3939
github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U=
4040
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
41+
github.com/moby/sys/capability v0.3.0 h1:kEP+y6te0gEXIaeQhIi0s7vKs/w0RPoH1qPa6jROcVg=
42+
github.com/moby/sys/capability v0.3.0/go.mod h1:4g9IK291rVkms3LKCDOoYlnV8xKwoDTpIrNEE35Wq0I=
4143
github.com/moby/sys/mountinfo v0.7.1 h1:/tTvQaSJRr2FshkhXiIpux6fQ2Zvc4j7tAhMTStAG2g=
4244
github.com/moby/sys/mountinfo v0.7.1/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI=
4345
github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg=
@@ -69,8 +71,6 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
6971
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
7072
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
7173
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
72-
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI=
73-
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
7474
github.com/urfave/cli v1.22.14 h1:ebbhrRiGK2i4naQJr+1Xj92HXZCrK7MsyTS/ob3HnAk=
7575
github.com/urfave/cli v1.22.14/go.mod h1:X0eDS6pD6Exaclxm99NJ3FiCDRED7vIHpx2mDOHLvkA=
7676
github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=

libcontainer/capabilities/capabilities.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"strings"
99
"sync"
1010

11+
"github.com/moby/sys/capability"
1112
"github.com/opencontainers/runc/libcontainer/configs"
1213
"github.com/sirupsen/logrus"
13-
"github.com/syndtr/gocapability/capability"
1414
)
1515

1616
const allCapabilityTypes = capability.CAPS | capability.BOUNDING | capability.AMBIENT
@@ -24,22 +24,23 @@ var (
2424
capability.AMBIENT,
2525
}
2626

27-
capMap = sync.OnceValue(func() map[string]capability.Cap {
28-
cm := make(map[string]capability.Cap, capability.CAP_LAST_CAP+1)
29-
for _, c := range capability.List() {
30-
if c > capability.CAP_LAST_CAP {
31-
continue
32-
}
27+
capMap = sync.OnceValues(func() (map[string]capability.Cap, error) {
28+
list, err := capability.ListSupported()
29+
if err != nil {
30+
return nil, err
31+
}
32+
cm := make(map[string]capability.Cap, len(list))
33+
for _, c := range list {
3334
cm["CAP_"+strings.ToUpper(c.String())] = c
3435
}
35-
return cm
36+
return cm, nil
3637
})
3738
)
3839

3940
// KnownCapabilities returns the list of the known capabilities.
4041
// Used by `runc features`.
4142
func KnownCapabilities() []string {
42-
list := capability.List()
43+
list := capability.ListKnown()
4344
res := make([]string, len(list))
4445
for i, c := range list {
4546
res[i] = "CAP_" + strings.ToUpper(c.String())
@@ -51,12 +52,12 @@ func KnownCapabilities() []string {
5152
// or Capabilities that are unavailable in the current environment are ignored,
5253
// printing a warning instead.
5354
func New(capConfig *configs.Capabilities) (*Caps, error) {
54-
var (
55-
err error
56-
c Caps
57-
)
55+
var c Caps
5856

59-
cm := capMap()
57+
cm, err := capMap()
58+
if err != nil {
59+
return nil, err
60+
}
6061
unknownCaps := make(map[string]struct{})
6162
ignoredCaps := make(map[string]struct{})
6263
// capSlice converts the slice of capability names in caps, to their numeric

libcontainer/capabilities/capabilities_linux_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import (
55
"os"
66
"testing"
77

8+
"github.com/moby/sys/capability"
89
"github.com/opencontainers/runc/libcontainer/configs"
910
"github.com/sirupsen/logrus"
1011
"github.com/sirupsen/logrus/hooks/test"
11-
"github.com/syndtr/gocapability/capability"
1212
)
1313

1414
func TestNew(t *testing.T) {

vendor/github.com/moby/sys/capability/.codespellrc

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/sys/capability/.golangci.yml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/sys/capability/CHANGELOG.md

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/syndtr/gocapability/LICENSE renamed to vendor/github.com/moby/sys/capability/LICENSE

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/sys/capability/README.md

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/syndtr/gocapability/capability/capability.go renamed to vendor/github.com/moby/sys/capability/capability.go

Lines changed: 47 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)