diff options
Diffstat (limited to 'pkg/rootless/rootless_linux.go')
-rw-r--r-- | pkg/rootless/rootless_linux.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/rootless/rootless_linux.go b/pkg/rootless/rootless_linux.go index 5b4094bf2..70fa6b152 100644 --- a/pkg/rootless/rootless_linux.go +++ b/pkg/rootless/rootless_linux.go @@ -8,6 +8,7 @@ import ( "os" gosignal "os/signal" "runtime" + "strconv" "syscall" "github.com/containers/storage/pkg/idtools" @@ -26,6 +27,16 @@ func IsRootless() bool { return os.Getuid() != 0 || os.Getenv("_LIBPOD_USERNS_CONFIGURED") != "" } +// GetRootlessUID returns the UID of the user in the parent userNS +func GetRootlessUID() int { + uidEnv := os.Getenv("_LIBPOD_ROOTLESS_UID") + if uidEnv != "" { + u, _ := strconv.Atoi(uidEnv) + return u + } + return os.Getuid() +} + // BecomeRootInUserNS re-exec podman in a new userNS func BecomeRootInUserNS() (bool, error) { |