summaryrefslogtreecommitdiff
path: root/libpod/container.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2017-12-11 10:41:58 -0600
committerGitHub <noreply@github.com>2017-12-11 10:41:58 -0600
commit0e328de08dc6e17b4cc45b1bf47f2deddb3fef6d (patch)
tree8b88407b645e9403f4fc7ebf2e4d62bc34785a20 /libpod/container.go
parent8d31ec2ad775c97c4b860eb24a3481092b6e88e3 (diff)
parente8a32e3722e0b814c654cdb8809565a21fc120d3 (diff)
downloadpodman-0e328de08dc6e17b4cc45b1bf47f2deddb3fef6d.tar.gz
podman-0e328de08dc6e17b4cc45b1bf47f2deddb3fef6d.tar.bz2
podman-0e328de08dc6e17b4cc45b1bf47f2deddb3fef6d.zip
Merge pull request #93 from baude/kpod_exec
kpod exec
Diffstat (limited to 'libpod/container.go')
-rw-r--r--libpod/container.go34
1 files changed, 31 insertions, 3 deletions
diff --git a/libpod/container.go b/libpod/container.go
index 40aa689ff..474d4be95 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -14,6 +14,7 @@ import (
"github.com/containers/storage"
"github.com/containers/storage/pkg/archive"
+ "github.com/docker/docker/daemon/caps"
"github.com/docker/docker/pkg/mount"
"github.com/docker/docker/pkg/namesgenerator"
"github.com/docker/docker/pkg/stringid"
@@ -552,9 +553,36 @@ func (c *Container) Kill(signal uint) error {
}
// Exec starts a new process inside the container
-// Returns fully qualified URL of streaming server for executed process
-func (c *Container) Exec(cmd []string, tty bool, stdin bool) (string, error) {
- return "", ErrNotImplemented
+func (c *Container) Exec(tty, privileged bool, env, cmd []string, user string) error {
+ var capList []string
+ c.lock.Lock()
+ defer c.lock.Unlock()
+
+ if err := c.syncContainer(); err != nil {
+ return err
+ }
+
+ conState := c.state.State
+
+ if conState != ContainerStateRunning {
+ return errors.Errorf("cannot attach to container that is not running")
+ }
+ if privileged {
+ capList = caps.GetAllCapabilities()
+ }
+ globalOpts := runcGlobalOptions{
+ log: c.LogPath(),
+ }
+ execOpts := runcExecOptions{
+ capAdd: capList,
+ pidFile: filepath.Join(c.state.RunDir, fmt.Sprintf("%s-execpid", stringid.GenerateNonCryptoID()[:12])),
+ env: env,
+ user: user,
+ cwd: c.config.Spec.Process.Cwd,
+ tty: tty,
+ }
+
+ return c.runtime.ociRuntime.execContainer(c, cmd, globalOpts, execOpts)
}
// Attach attaches to a container