summaryrefslogtreecommitdiff
path: root/pkg/specgen/namespaces.go
diff options
context:
space:
mode:
authorrvandernoort <s.r.vandernoort@student.tudelft.nl>2022-03-23 14:01:58 +0100
committerrvandernoort <s.r.vandernoort@student.tudelft.nl>2022-03-27 13:01:52 +0200
commit446c35efdf4f7141ec32a347385587d7b4fc2c75 (patch)
tree1591cfd468b9399a39c36dcb624e6b7efdd4c5bb /pkg/specgen/namespaces.go
parenta8743d3327b9a97ea812632885492d95c816d79a (diff)
downloadpodman-446c35efdf4f7141ec32a347385587d7b4fc2c75.tar.gz
podman-446c35efdf4f7141ec32a347385587d7b4fc2c75.tar.bz2
podman-446c35efdf4f7141ec32a347385587d7b4fc2c75.zip
Vendor common
Added patch provided by rhatdan to add support for shareable [NO NEW TESTS NEEDED] Signed-off-by: rvandernoort <s.r.vandernoort@student.tudelft.nl>
Diffstat (limited to 'pkg/specgen/namespaces.go')
-rw-r--r--pkg/specgen/namespaces.go37
1 files changed, 36 insertions, 1 deletions
diff --git a/pkg/specgen/namespaces.go b/pkg/specgen/namespaces.go
index e672bc65f..4412eff29 100644
--- a/pkg/specgen/namespaces.go
+++ b/pkg/specgen/namespaces.go
@@ -35,6 +35,10 @@ const (
FromPod NamespaceMode = "pod"
// Private indicates the namespace is private
Private NamespaceMode = "private"
+ // Shareable indicates the namespace is shareable
+ Shareable NamespaceMode = "shareable"
+ // None indicates the IPC namespace is created without mounting /dev/shm
+ None NamespaceMode = "none"
// NoNetwork indicates no network namespace should
// be joined. loopback should still exists.
// Only used with the network namespace, invalid otherwise.
@@ -77,6 +81,11 @@ func (n *Namespace) IsHost() bool {
return n.NSMode == Host
}
+// IsNone returns a bool if the namespace is set to none
+func (n *Namespace) IsNone() bool {
+ return n.NSMode == None
+}
+
// IsBridge returns a bool if the namespace is a Bridge
func (n *Namespace) IsBridge() bool {
return n.NSMode == Bridge
@@ -158,6 +167,17 @@ func validateNetNS(n *Namespace) error {
return nil
}
+func validateIPCNS(n *Namespace) error {
+ if n == nil {
+ return nil
+ }
+ switch n.NSMode {
+ case Shareable, None:
+ return nil
+ }
+ return n.validate()
+}
+
// Validate perform simple validation on the namespace to make sure it is not
// invalid from the get-go
func (n *Namespace) validate() error {
@@ -237,7 +257,7 @@ func ParseCgroupNamespace(ns string) (Namespace, error) {
case "private", "":
toReturn.NSMode = Private
default:
- return toReturn, errors.Errorf("unrecognized namespace mode %s passed", ns)
+ return toReturn, errors.Errorf("unrecognized cgroup namespace mode %s passed", ns)
}
} else {
toReturn.NSMode = Host
@@ -245,6 +265,21 @@ func ParseCgroupNamespace(ns string) (Namespace, error) {
return toReturn, nil
}
+// ParseIPCNamespace parses a ipc namespace specification in string
+// form.
+func ParseIPCNamespace(ns string) (Namespace, error) {
+ toReturn := Namespace{}
+ switch {
+ case ns == "shareable", ns == "":
+ toReturn.NSMode = Shareable
+ return toReturn, nil
+ case ns == "none":
+ toReturn.NSMode = None
+ return toReturn, nil
+ }
+ return ParseNamespace(ns)
+}
+
// ParseUserNamespace parses a user namespace specification in string
// form.
func ParseUserNamespace(ns string) (Namespace, error) {