From 6372c977ea0e6206d137e734a981ca0bb3435e12 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 16 Jul 2018 10:10:20 +0200 Subject: rootless: require subids to be present Most images won't work without multiple ids/gids. Error out immediately if there are no multiple ids available. The error code when the user is not present in /etc/sub{g,u}id looks like: $ bin/podman run --rm -ti alpine echo hello ERRO[0000] No subuid ranges found for user "gscrivano" Closes: https://github.com/projectatomic/libpod/issues/1087 Signed-off-by: Giuseppe Scrivano Closes: #1097 Approved by: rhatdan --- pkg/rootless/rootless_linux.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pkg/rootless') diff --git a/pkg/rootless/rootless_linux.go b/pkg/rootless/rootless_linux.go index 6089ad73a..3d6402040 100644 --- a/pkg/rootless/rootless_linux.go +++ b/pkg/rootless/rootless_linux.go @@ -104,6 +104,9 @@ func BecomeRootInUserNS() (bool, int, error) { var uids, gids []idtools.IDMap username := os.Getenv("USER") mappings, err := idtools.NewIDMappings(username, username) + if err != nil && os.Getenv("PODMAN_ALLOW_SINGLE_ID_MAPPING_IN_USERNS") == "" { + return false, -1, err + } if err == nil { uids = mappings.UIDs() gids = mappings.GIDs() -- cgit v1.2.3-54-g00ecf