Skip to content

Commit 30b530c

Browse files
committed
libct/userns: split userns detection from internal userns code
Commit 4316df8 isolated RunningInUserNS to a separate package to make it easier to consume without bringing in additional dependencies, and with the potential to move it separate in a similar fashion as libcontainer/user was moved to a separate module in commit ca32014. While RunningInUserNS is fairly trivial to implement, it (or variants of this utility) is used in many codebases, and moving to a separate module could consolidate those implementations, as well as making it easier to consume without large dependency trees (when being a package as part of a larger code base). Commit 1912d59 and follow-ups introduced cgo code into the userns package, and code introduced in those commits are not intended for external use, therefore complicating the potential of moving the userns package separate. This commit moves the new code to a separate package; some of this code was included in v1.1.11 and up, but I could not find external consumers of `GetUserNamespaceMappings` and `IsSameMapping`. The `Mapping` and `Handles` types (added in ba0b5e2) only exist in main and in non-stable releases (v1.2.0-rc.x), so don't need an alias / deprecation. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent ab010ae commit 30b530c

File tree

8 files changed

+5
-5
lines changed

8 files changed

+5
-5
lines changed

libcontainer/integration/exec_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/opencontainers/runc/libcontainer/cgroups"
1919
"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
2020
"github.com/opencontainers/runc/libcontainer/configs"
21-
"github.com/opencontainers/runc/libcontainer/userns"
21+
"github.com/opencontainers/runc/libcontainer/internal/userns"
2222
"github.com/opencontainers/runc/libcontainer/utils"
2323
"github.com/opencontainers/runtime-spec/specs-go"
2424

@@ -724,7 +724,7 @@ func TestContainerState(t *testing.T) {
724724
{Type: configs.NEWNS},
725725
{Type: configs.NEWUTS},
726726
// host for IPC
727-
//{Type: configs.NEWIPC},
727+
// {Type: configs.NEWIPC},
728728
{Type: configs.NEWPID},
729729
{Type: configs.NEWNET},
730730
})
File renamed without changes.

libcontainer/mount_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"golang.org/x/sys/unix"
1212

1313
"github.com/opencontainers/runc/libcontainer/configs"
14-
"github.com/opencontainers/runc/libcontainer/userns"
14+
"github.com/opencontainers/runc/libcontainer/internal/userns"
1515
"github.com/opencontainers/runc/libcontainer/utils"
1616
)
1717

libcontainer/process_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import (
2323
"github.com/opencontainers/runc/libcontainer/cgroups/fs2"
2424
"github.com/opencontainers/runc/libcontainer/configs"
2525
"github.com/opencontainers/runc/libcontainer/intelrdt"
26+
"github.com/opencontainers/runc/libcontainer/internal/userns"
2627
"github.com/opencontainers/runc/libcontainer/logs"
2728
"github.com/opencontainers/runc/libcontainer/system"
28-
"github.com/opencontainers/runc/libcontainer/userns"
2929
"github.com/opencontainers/runc/libcontainer/utils"
3030
)
3131

libcontainer/specconv/spec_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import (
1717
"github.com/opencontainers/runc/libcontainer/cgroups"
1818
"github.com/opencontainers/runc/libcontainer/configs"
1919
"github.com/opencontainers/runc/libcontainer/devices"
20+
"github.com/opencontainers/runc/libcontainer/internal/userns"
2021
"github.com/opencontainers/runc/libcontainer/seccomp"
21-
"github.com/opencontainers/runc/libcontainer/userns"
2222
libcontainerUtils "github.com/opencontainers/runc/libcontainer/utils"
2323
"github.com/opencontainers/runtime-spec/specs-go"
2424
"github.com/sirupsen/logrus"

0 commit comments

Comments
 (0)