summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_exec.go5
-rw-r--r--libpod/options.go2
2 files changed, 7 insertions, 0 deletions
diff --git a/libpod/container_exec.go b/libpod/container_exec.go
index 795eb7453..912c2c226 100644
--- a/libpod/container_exec.go
+++ b/libpod/container_exec.go
@@ -231,6 +231,11 @@ func (c *Container) ExecStartAndAttach(sessionID string, streams *AttachStreams)
}
}
+ // Verify that we are in a good state to continue
+ if !c.ensureState(define.ContainerStateRunning) {
+ return errors.Wrapf(define.ErrCtrStateInvalid, "can only start exec sessions when their container is running")
+ }
+
session, ok := c.state.ExecSessions[sessionID]
if !ok {
return errors.Wrapf(define.ErrNoSuchExecSession, "container %s has no exec session with ID %s", c.ID(), sessionID)
diff --git a/libpod/options.go b/libpod/options.go
index 9b61d7947..74f9c485e 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -21,6 +21,8 @@ import (
var (
// NameRegex is a regular expression to validate container/pod names.
+ // This must NOT be changed from outside of Libpod. It should be a
+ // constant, but Go won't let us do that.
NameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$")
// RegexError is thrown in presence of an invalid container/pod name.
RegexError = errors.Wrapf(define.ErrInvalidArg, "names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*")