summaryrefslogtreecommitdiff
path: root/libpod/oci.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-02-27 09:50:22 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-03-01 21:17:50 +0000
commit345bfafee27870cdcb21bcd2ee7e7825b99818a0 (patch)
treee7ecbf11861284e555da984d1232ca2bb9acf25f /libpod/oci.go
parent2a0c949b9bab88f4e05d39b5e6d7db62bb39df11 (diff)
downloadpodman-345bfafee27870cdcb21bcd2ee7e7825b99818a0.tar.gz
podman-345bfafee27870cdcb21bcd2ee7e7825b99818a0.tar.bz2
podman-345bfafee27870cdcb21bcd2ee7e7825b99818a0.zip
Rework exec to enable splitting to retrieve exec PID
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #412 Approved by: baude
Diffstat (limited to 'libpod/oci.go')
-rw-r--r--libpod/oci.go54
1 files changed, 50 insertions, 4 deletions
diff --git a/libpod/oci.go b/libpod/oci.go
index 4847eceb6..225643f39 100644
--- a/libpod/oci.go
+++ b/libpod/oci.go
@@ -467,8 +467,54 @@ func (r *OCIRuntime) unpauseContainer(ctr *Container) error {
return utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, r.path, "resume", ctr.ID())
}
-//execContiner executes a command in a running container
-func (r *OCIRuntime) execContainer(c *Container, cmd []string, globalOpts runcGlobalOptions, commandOpts runcExecOptions) error {
- r.RuncExec(c, cmd, globalOpts, commandOpts)
- return nil
+// execContainer executes a command in a running container
+// TODO: Add --detach support
+// TODO: Convert to use conmon
+// TODO: add --pid-file and use that to generate exec session tracking
+func (r *OCIRuntime) execContainer(c *Container, cmd []string, tty bool, user string, capAdd, env []string) error {
+ args := []string{}
+
+ // TODO - should we maintain separate logpaths for exec sessions?
+ args = append(args, "--log", c.LogPath())
+
+ args = append(args, "exec")
+
+ args = append(args, "--cwd", c.config.Spec.Process.Cwd)
+
+ if tty {
+ args = append(args, "--tty")
+ }
+
+ if user != "" {
+ args = append(args, "--user", user)
+ }
+
+ if c.config.Spec.Process.NoNewPrivileges {
+ args = append(args, "--no-new-privs")
+ }
+
+ for _, cap := range capAdd {
+ args = append(args, "--cap", cap)
+ }
+
+ for _, envVar := range env {
+ args = append(args, "--env", envVar)
+ }
+
+ // Append container ID and command
+ args = append(args, c.ID())
+ args = append(args, cmd...)
+
+ logrus.Debugf("Starting runtime %s with following arguments: %v", r.path, args)
+
+ execCmd := exec.Command(r.path, args...)
+ execCmd.Stdout = os.Stdout
+ execCmd.Stderr = os.Stderr
+ execCmd.Stdin = os.Stdin
+
+ if err := execCmd.Start(); err != nil {
+ return errors.Wrapf(err, "error starting exec command for container %s", c.ID())
+ }
+
+ return execCmd.Wait()
}