Browse Source

pkg/sysinfo: use containerd/sys to detect UserNamespaces

The implementation in libcontainer/system is quite complicated,
and we only use it to detect if user-namespaces are enabled.

In addition, the implementation in containerd uses a sync.Once,
so that detection (and reading/parsing `/proc/self/uid_map`) is
only performed once.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 5 years ago
parent
commit
66bb1c4644
1 changed files with 2 additions and 2 deletions
  1. 2 2
      pkg/sysinfo/cgroup2_linux.go

+ 2 - 2
pkg/sysinfo/cgroup2_linux.go

@@ -6,7 +6,7 @@ import (
 	"strings"
 	"strings"
 
 
 	cgroupsV2 "github.com/containerd/cgroups/v2"
 	cgroupsV2 "github.com/containerd/cgroups/v2"
-	rsystem "github.com/opencontainers/runc/libcontainer/system"
+	"github.com/containerd/containerd/sys"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 )
 )
 
 
@@ -146,6 +146,6 @@ func applyPIDSCgroupInfoV2(info *SysInfo, controllers map[string]struct{}, _ str
 }
 }
 
 
 func applyDevicesCgroupInfoV2(info *SysInfo, controllers map[string]struct{}, _ string) []string {
 func applyDevicesCgroupInfoV2(info *SysInfo, controllers map[string]struct{}, _ string) []string {
-	info.CgroupDevicesEnabled = !rsystem.RunningInUserNS()
+	info.CgroupDevicesEnabled = !sys.RunningInUserNS()
 	return nil
 	return nil
 }
 }