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 | |
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')
-rw-r--r-- | pkg/rootless/rootless_linux.go | 2 | ||||
-rw-r--r-- | pkg/rootless/rootless_unsupported.go | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/pkg/rootless/rootless_linux.go b/pkg/rootless/rootless_linux.go index d51f32d68..f3b9a8fd5 100644 --- a/pkg/rootless/rootless_linux.go +++ b/pkg/rootless/rootless_linux.go @@ -1,4 +1,4 @@ -// +build linux +// +build linux,cgo package rootless 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 |