summaryrefslogtreecommitdiff
path: root/pkg/rootless
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-11-14 06:28:27 -0800
committerGitHub <noreply@github.com>2018-11-14 06:28:27 -0800
commit2b911b0c8a51877f75cafde5d2ebb54ad31df410 (patch)
tree8c8b2893a074c43ea9c8e8c9bef9527bc594c161 /pkg/rootless
parent12f3721c3459676cfc30eb01d393d96c594bede5 (diff)
parent1e3ff6950269cb7fdb1c9ac161cf1aabf4933326 (diff)
downloadpodman-2b911b0c8a51877f75cafde5d2ebb54ad31df410.tar.gz
podman-2b911b0c8a51877f75cafde5d2ebb54ad31df410.tar.bz2
podman-2b911b0c8a51877f75cafde5d2ebb54ad31df410.zip
Merge pull request #1812 from giuseppe/rootless-once
rootless: call IsRootless just once
Diffstat (limited to 'pkg/rootless')
-rw-r--r--pkg/rootless/rootless_linux.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/pkg/rootless/rootless_linux.go b/pkg/rootless/rootless_linux.go
index ff8c8fe34..85b0ef392 100644
--- a/pkg/rootless/rootless_linux.go
+++ b/pkg/rootless/rootless_linux.go
@@ -12,6 +12,7 @@ import (
"runtime"
"strconv"
"strings"
+ "sync"
"syscall"
"unsafe"
@@ -33,9 +34,17 @@ func runInUser() error {
return nil
}
+var (
+ isRootlessOnce sync.Once
+ isRootless bool
+)
+
// IsRootless tells us if we are running in rootless mode
func IsRootless() bool {
- return os.Geteuid() != 0 || os.Getenv("_LIBPOD_USERNS_CONFIGURED") != ""
+ isRootlessOnce.Do(func() {
+ isRootless = os.Geteuid() != 0 || os.Getenv("_LIBPOD_USERNS_CONFIGURED") != ""
+ })
+ return isRootless
}
var (