summaryrefslogtreecommitdiff
path: root/pkg/util
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2018-06-01 09:29:22 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-06-15 14:53:18 +0000
commitbe66361e08d571dee36dd6034ee54aacf9e88e96 (patch)
tree95b3ec68750338a617b2f3116824f9701ecb9353 /pkg/util
parent7bdfb4f9b361aca4f4f3337907feb3ca414d36e4 (diff)
downloadpodman-be66361e08d571dee36dd6034ee54aacf9e88e96.tar.gz
podman-be66361e08d571dee36dd6034ee54aacf9e88e96.tar.bz2
podman-be66361e08d571dee36dd6034ee54aacf9e88e96.zip
podman: provide a default UID mapping when non root
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #871 Approved by: mheon
Diffstat (limited to 'pkg/util')
-rw-r--r--pkg/util/utils.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index 56a57c15a..28dd015bd 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -2,6 +2,7 @@ package util
import (
"fmt"
+ "os"
"strconv"
"strings"
@@ -142,6 +143,12 @@ func ParseIDMapping(UIDMapSlice, GIDMapSlice []string, subUIDMap, subGIDMap stri
if len(UIDMapSlice) == 0 && len(GIDMapSlice) != 0 {
UIDMapSlice = GIDMapSlice
}
+ if len(UIDMapSlice) == 0 && subUIDMap == "" && os.Getuid() != 0 {
+ UIDMapSlice = []string{fmt.Sprintf("0:%d:1", os.Getuid())}
+ }
+ if len(GIDMapSlice) == 0 && subGIDMap == "" && os.Getuid() != 0 {
+ GIDMapSlice = []string{fmt.Sprintf("0:%d:1", os.Getgid())}
+ }
parseTriple := func(spec []string) (container, host, size int, err error) {
cid, err := strconv.ParseUint(spec[0], 10, 32)