summaryrefslogtreecommitdiff
path: root/pkg/specgen/specgen.go
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-07-14 12:39:24 -0500
committerMatthew Heon <matthew.heon@pm.me>2020-07-22 14:13:43 -0400
commitc6852ee516abe3e1c4e5e31168d85d7cd446ce36 (patch)
treec99dba6af62b3c767b9a0f9a8d18201fad3e5445 /pkg/specgen/specgen.go
parentc31dc9b26054104c749cf7551f92b888a24c2586 (diff)
downloadpodman-c6852ee516abe3e1c4e5e31168d85d7cd446ce36.tar.gz
podman-c6852ee516abe3e1c4e5e31168d85d7cd446ce36.tar.bz2
podman-c6852ee516abe3e1c4e5e31168d85d7cd446ce36.zip
Error on rootless mac and ip addresses
When creating a pod or container where a static MAC or IP address is provided, we should return a proper error and exit as 125. Fixes: #6972 Signed-off-by: Brent Baude <bbaude@redhat.com> <MH: Fixed build after cherry-pick> Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'pkg/specgen/specgen.go')
-rw-r--r--pkg/specgen/specgen.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/pkg/specgen/specgen.go b/pkg/specgen/specgen.go
index 327c15c5a..91bc36709 100644
--- a/pkg/specgen/specgen.go
+++ b/pkg/specgen/specgen.go
@@ -1,6 +1,7 @@
package specgen
import (
+ "errors"
"net"
"syscall"
@@ -449,6 +450,15 @@ type PortMapping struct {
Protocol string `json:"protocol,omitempty"`
}
+var (
+ // ErrNoStaticIPRootless is used when a rootless user requests to assign a static IP address
+ // to a pod or container
+ ErrNoStaticIPRootless error = errors.New("rootless containers and pods cannot be assigned static IP addresses")
+ // ErrNoStaticMACRootless is used when a rootless user requests to assign a static MAC address
+ // to a pod or container
+ ErrNoStaticMACRootless error = errors.New("rootless containers and pods cannot be assigned static MAC addresses")
+)
+
// NewSpecGenerator returns a SpecGenerator struct given one of two mandatory inputs
func NewSpecGenerator(arg string, rootfs bool) *SpecGenerator {
csc := ContainerStorageConfig{}