summaryrefslogtreecommitdiff
path: root/pkg/domain/infra/abi/system.go
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-05-08 13:09:11 -0500
committerBrent Baude <bbaude@redhat.com>2020-05-08 13:28:11 -0500
commit1074a02ff85bb9f1d0db3e4468b067a6516b1521 (patch)
tree85335edcc852b85b35dbbe4fbcde27c486c84810 /pkg/domain/infra/abi/system.go
parentb2e8915baa22098fbde39b73ad0f18326ec2842b (diff)
downloadpodman-1074a02ff85bb9f1d0db3e4468b067a6516b1521.tar.gz
podman-1074a02ff85bb9f1d0db3e4468b067a6516b1521.tar.bz2
podman-1074a02ff85bb9f1d0db3e4468b067a6516b1521.zip
v2 podman unshare command
add unshare command add cp and init to container sub-command allow mount to run as rootless Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/domain/infra/abi/system.go')
-rw-r--r--pkg/domain/infra/abi/system.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go
index 24c62465f..fc92da1b2 100644
--- a/pkg/domain/infra/abi/system.go
+++ b/pkg/domain/infra/abi/system.go
@@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"os"
+ "os/exec"
"path/filepath"
"strconv"
"syscall"
@@ -391,3 +392,18 @@ func (s SystemEngine) Shutdown(ctx context.Context) {
logrus.Error(err)
}
}
+
+func unshareEnv(graphroot, runroot string) []string {
+ return append(os.Environ(), "_CONTAINERS_USERNS_CONFIGURED=done",
+ fmt.Sprintf("CONTAINERS_GRAPHROOT=%s", graphroot),
+ fmt.Sprintf("CONTAINERS_RUNROOT=%s", runroot))
+}
+
+func (ic *ContainerEngine) Unshare(ctx context.Context, args []string) error {
+ cmd := exec.Command(args[0], args[1:]...)
+ cmd.Env = unshareEnv(ic.Libpod.StorageConfig().GraphRoot, ic.Libpod.StorageConfig().RunRoot)
+ cmd.Stdin = os.Stdin
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ return cmd.Run()
+}