Skip to content

Commit

Permalink
libcontainer/userns: migrate to github.com/moby/sys/user/userns
Browse files Browse the repository at this point in the history
The userns package was integrated into the moby/sys/user module
at commit 3778ae6.

This patch deprecates the old location, and adds it as an alias
for the moby/sys/user/userns package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Jul 16, 2024
1 parent 3778ae6 commit cfb8cb4
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 51 deletions.
5 changes: 3 additions & 2 deletions checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
"strconv"

criu "github.com/checkpoint-restore/go-criu/v6/rpc"
"github.com/opencontainers/runc/libcontainer"
"github.com/opencontainers/runc/libcontainer/userns"
"github.com/moby/sys/user/userns"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"golang.org/x/sys/unix"

"github.com/opencontainers/runc/libcontainer"
)

var checkpointCommand = cli.Command{
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module github.com/opencontainers/runc

go 1.21

// FIXME(thaJeztah): testing https://github.com/moby/sys/pull/140
replace github.com/moby/sys/user => github.com/thaJeztah/sys/user v0.0.0-20240716182136-7cfea2ca93af

require (
github.com/checkpoint-restore/go-criu/v6 v6.3.0
github.com/cilium/ebpf v0.12.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/moby/sys/mountinfo v0.7.1 h1:/tTvQaSJRr2FshkhXiIpux6fQ2Zvc4j7tAhMTStAG2g=
github.com/moby/sys/mountinfo v0.7.1/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI=
github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg=
github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU=
github.com/mrunalp/fileutils v0.5.1 h1:F+S7ZlNKnrwHfSwdlgNSkKo67ReVf8o9fel6C3dkm/Q=
github.com/mrunalp/fileutils v0.5.1/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk=
Expand Down Expand Up @@ -62,6 +60,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/thaJeztah/sys/user v0.0.0-20240716182136-7cfea2ca93af h1:5VrEoF9+k36FwMBMQ09SUO8isUEjxbd2yZCBMkWuu04=
github.com/thaJeztah/sys/user v0.0.0-20240716182136-7cfea2ca93af/go.mod h1:RYstrcWOJpVh+6qzUqp2bU3eaRpdiQeKGlKitaH0PM8=
github.com/urfave/cli v1.22.14 h1:ebbhrRiGK2i4naQJr+1Xj92HXZCrK7MsyTS/ob3HnAk=
github.com/urfave/cli v1.22.14/go.mod h1:X0eDS6pD6Exaclxm99NJ3FiCDRED7vIHpx2mDOHLvkA=
github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/cgroups/devices/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"errors"
"reflect"

"github.com/moby/sys/user/userns"
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/devices"
"github.com/opencontainers/runc/libcontainer/userns"
)

var testingSkipFinalCheck bool
Expand Down
3 changes: 2 additions & 1 deletion libcontainer/cgroups/devices/v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"path"
"testing"

"github.com/moby/sys/user/userns"

"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/cgroups/fscommon"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/devices"
"github.com/opencontainers/runc/libcontainer/userns"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/cgroups/devices/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package devices
import (
"fmt"

"github.com/moby/sys/user/userns"
"golang.org/x/sys/unix"

"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/devices"
"github.com/opencontainers/runc/libcontainer/userns"
)

func isRWM(perms devices.Permissions) bool {
Expand Down
3 changes: 1 addition & 2 deletions libcontainer/cgroups/systemd/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (

systemdDbus "github.com/coreos/go-systemd/v22/dbus"
dbus "github.com/godbus/dbus/v5"

"github.com/opencontainers/runc/libcontainer/userns"
"github.com/moby/sys/user/userns"
)

// newUserSystemdDbus creates a connection for systemd user-instance.
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/cgroups/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"sync"
"time"

"github.com/opencontainers/runc/libcontainer/userns"
"github.com/moby/sys/user/userns"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
)
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/rootfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

securejoin "github.com/cyphar/filepath-securejoin"
"github.com/moby/sys/mountinfo"
"github.com/moby/sys/user/userns"
"github.com/mrunalp/fileutils"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/selinux/go-selinux/label"
Expand All @@ -24,7 +25,6 @@ import (
"github.com/opencontainers/runc/libcontainer/cgroups/fs2"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/devices"
"github.com/opencontainers/runc/libcontainer/userns"
"github.com/opencontainers/runc/libcontainer/utils"
)

Expand Down
13 changes: 13 additions & 0 deletions libcontainer/userns/userns_deprecated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Deprecated: use github.com/moby/sys/user/userns
package userns

import "github.com/moby/sys/user/userns"

// RunningInUserNS detects whether we are currently running in a Linux
// user namespace and memoizes the result. It returns false on non-Linux
// platforms.
//
// Deprecated: use [userns.RunningInUserNS].
func RunningInUserNS() bool {
return userns.RunningInUserNS()
}
34 changes: 0 additions & 34 deletions libcontainer/userns/userns_linux_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"os"

"github.com/opencontainers/runc/libcontainer/userns"
"github.com/moby/sys/user/userns"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
Expand Down
5 changes: 3 additions & 2 deletions rootless_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package main
import (
"os"

"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
"github.com/opencontainers/runc/libcontainer/userns"
"github.com/moby/sys/user/userns"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"

"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
)

func shouldUseRootlessCgroupManager(context *cli.Context) (bool, error) {
Expand Down
1 change: 0 additions & 1 deletion vendor/github.com/moby/sys/user/user.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ github.com/godbus/dbus/v5
# github.com/moby/sys/mountinfo v0.7.1
## explicit; go 1.16
github.com/moby/sys/mountinfo
# github.com/moby/sys/user v0.1.0
## explicit; go 1.17
# github.com/moby/sys/user v0.1.0 => github.com/thaJeztah/sys/user v0.0.0-20240716182136-7cfea2ca93af
## explicit; go 1.21
github.com/moby/sys/user
github.com/moby/sys/user/userns
# github.com/mrunalp/fileutils v0.5.1
## explicit; go 1.13
github.com/mrunalp/fileutils
Expand Down Expand Up @@ -115,3 +116,4 @@ google.golang.org/protobuf/reflect/protoreflect
google.golang.org/protobuf/reflect/protoregistry
google.golang.org/protobuf/runtime/protoiface
google.golang.org/protobuf/runtime/protoimpl
# github.com/moby/sys/user => github.com/thaJeztah/sys/user v0.0.0-20240716182136-7cfea2ca93af

0 comments on commit cfb8cb4

Please sign in to comment.