summaryrefslogtreecommitdiff
path: root/vendor/github.com/opencontainers/runc/libcontainer/userns
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2021-05-11 06:19:24 +0000
committerGitHub <noreply@github.com>2021-05-11 06:19:24 +0000
commitd71672c57b5e9e41cb526b290b8b3704232e814a (patch)
tree04e0bbc73670649bee252a785f7844e195191699 /vendor/github.com/opencontainers/runc/libcontainer/userns
parent57b642525b674f99835b1abf510d1beef7bc0a23 (diff)
downloadpodman-d71672c57b5e9e41cb526b290b8b3704232e814a.tar.gz
podman-d71672c57b5e9e41cb526b290b8b3704232e814a.tar.bz2
podman-d71672c57b5e9e41cb526b290b8b3704232e814a.zip
Bump github.com/opencontainers/runc from 1.0.0-rc93 to 1.0.0-rc94
Bumps [github.com/opencontainers/runc](https://github.com/opencontainers/runc) from 1.0.0-rc93 to 1.0.0-rc94. - [Release notes](https://github.com/opencontainers/runc/releases) - [Commits](https://github.com/opencontainers/runc/compare/v1.0.0-rc93...v1.0.0-rc94) Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/github.com/opencontainers/runc/libcontainer/userns')
-rw-r--r--vendor/github.com/opencontainers/runc/libcontainer/userns/userns.go5
-rw-r--r--vendor/github.com/opencontainers/runc/libcontainer/userns/userns_fuzzer.go15
-rw-r--r--vendor/github.com/opencontainers/runc/libcontainer/userns/userns_linux.go37
-rw-r--r--vendor/github.com/opencontainers/runc/libcontainer/userns/userns_unsupported.go17
4 files changed, 74 insertions, 0 deletions
diff --git a/vendor/github.com/opencontainers/runc/libcontainer/userns/userns.go b/vendor/github.com/opencontainers/runc/libcontainer/userns/userns.go
new file mode 100644
index 000000000..f6cb98e5e
--- /dev/null
+++ b/vendor/github.com/opencontainers/runc/libcontainer/userns/userns.go
@@ -0,0 +1,5 @@
+package userns
+
+// RunningInUserNS detects whether we are currently running in a user namespace.
+// Originally copied from github.com/lxc/lxd/shared/util.go
+var RunningInUserNS = runningInUserNS
diff --git a/vendor/github.com/opencontainers/runc/libcontainer/userns/userns_fuzzer.go b/vendor/github.com/opencontainers/runc/libcontainer/userns/userns_fuzzer.go
new file mode 100644
index 000000000..529f8eaea
--- /dev/null
+++ b/vendor/github.com/opencontainers/runc/libcontainer/userns/userns_fuzzer.go
@@ -0,0 +1,15 @@
+// +build gofuzz
+
+package userns
+
+import (
+ "strings"
+
+ "github.com/opencontainers/runc/libcontainer/user"
+)
+
+func FuzzUIDMap(data []byte) int {
+ uidmap, _ := user.ParseIDMap(strings.NewReader(string(data)))
+ _ = uidMapInUserNS(uidmap)
+ return 1
+}
diff --git a/vendor/github.com/opencontainers/runc/libcontainer/userns/userns_linux.go b/vendor/github.com/opencontainers/runc/libcontainer/userns/userns_linux.go
new file mode 100644
index 000000000..724e6df01
--- /dev/null
+++ b/vendor/github.com/opencontainers/runc/libcontainer/userns/userns_linux.go
@@ -0,0 +1,37 @@
+package userns
+
+import (
+ "sync"
+
+ "github.com/opencontainers/runc/libcontainer/user"
+)
+
+var (
+ inUserNS bool
+ nsOnce sync.Once
+)
+
+// runningInUserNS detects whether we are currently running in a user namespace.
+// Originally copied from github.com/lxc/lxd/shared/util.go
+func runningInUserNS() bool {
+ nsOnce.Do(func() {
+ uidmap, err := user.CurrentProcessUIDMap()
+ if err != nil {
+ // This kernel-provided file only exists if user namespaces are supported
+ return
+ }
+ inUserNS = uidMapInUserNS(uidmap)
+ })
+ return inUserNS
+}
+
+func uidMapInUserNS(uidmap []user.IDMap) bool {
+ /*
+ * We assume we are in the initial user namespace if we have a full
+ * range - 4294967295 uids starting at uid 0.
+ */
+ if len(uidmap) == 1 && uidmap[0].ID == 0 && uidmap[0].ParentID == 0 && uidmap[0].Count == 4294967295 {
+ return false
+ }
+ return true
+}
diff --git a/vendor/github.com/opencontainers/runc/libcontainer/userns/userns_unsupported.go b/vendor/github.com/opencontainers/runc/libcontainer/userns/userns_unsupported.go
new file mode 100644
index 000000000..f45bb0c31
--- /dev/null
+++ b/vendor/github.com/opencontainers/runc/libcontainer/userns/userns_unsupported.go
@@ -0,0 +1,17 @@
+// +build !linux
+
+package userns
+
+import "github.com/opencontainers/runc/libcontainer/user"
+
+// runningInUserNS is a stub for non-Linux systems
+// Always returns false
+func runningInUserNS() bool {
+ return false
+}
+
+// uidMapInUserNS is a stub for non-Linux systems
+// Always returns false
+func uidMapInUserNS(uidmap []user.IDMap) bool {
+ return false
+}