diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-06-26 12:08:18 +0200 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-07-02 16:41:02 +0200 |
commit | 35ab2184a368746366bae0cde664b5d6c7af8a99 (patch) | |
tree | 1ae0ded4ac53ba1d36623614733f1eaf37afb9a4 /pkg/rootless/rootless_unsupported.go | |
parent | c81a8f2b6d785e989eb091786dd473e383e2f00a (diff) | |
download | podman-35ab2184a368746366bae0cde664b5d6c7af8a99.tar.gz podman-35ab2184a368746366bae0cde664b5d6c7af8a99.tar.bz2 podman-35ab2184a368746366bae0cde664b5d6c7af8a99.zip |
rootless: allow to build without cgo
unfortunately rootless won't work without cgo, as most of the
implementation is in C, but at least allow to build libpod.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'pkg/rootless/rootless_unsupported.go')
-rw-r--r-- | pkg/rootless/rootless_unsupported.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/pkg/rootless/rootless_unsupported.go b/pkg/rootless/rootless_unsupported.go index 52863580e..a8485c083 100644 --- a/pkg/rootless/rootless_unsupported.go +++ b/pkg/rootless/rootless_unsupported.go @@ -1,14 +1,21 @@ -// +build !linux +// +build !linux !cgo package rootless import ( + "os" + "github.com/pkg/errors" ) -// IsRootless returns false on all non-linux platforms +// IsRootless returns whether the user is rootless func IsRootless() bool { - return false + uid := os.Geteuid() + // os.Geteuid() on Windows returns -1 + if uid == -1 { + return false + } + return uid != 0 } // BecomeRootInUserNS re-exec podman in a new userNS. It returns whether podman was re-executed |