diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-11-14 06:28:27 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-14 06:28:27 -0800 |
commit | 2b911b0c8a51877f75cafde5d2ebb54ad31df410 (patch) | |
tree | 8c8b2893a074c43ea9c8e8c9bef9527bc594c161 | |
parent | 12f3721c3459676cfc30eb01d393d96c594bede5 (diff) | |
parent | 1e3ff6950269cb7fdb1c9ac161cf1aabf4933326 (diff) | |
download | podman-2b911b0c8a51877f75cafde5d2ebb54ad31df410.tar.gz podman-2b911b0c8a51877f75cafde5d2ebb54ad31df410.tar.bz2 podman-2b911b0c8a51877f75cafde5d2ebb54ad31df410.zip |
Merge pull request #1812 from giuseppe/rootless-once
rootless: call IsRootless just once
-rw-r--r-- | pkg/rootless/rootless_linux.go | 11 |
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 ( |