main: improve XDG_RUNTIME_DIR handling

1. Variable xdgRuntimeDir is only checked to be non-empty. Change it to
   a boolean.

2. Refactor so that os.Getenv is not called twice.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2022-02-11 13:14:01 -08:00
parent eb2f08dc4e
commit 899342b5d4
2 changed files with 6 additions and 10 deletions
-3
View File
@@ -52,9 +52,6 @@ func shouldUseRootlessCgroupManager(context *cli.Context) (bool, error) {
}
func shouldHonorXDGRuntimeDir() bool {
if os.Getenv("XDG_RUNTIME_DIR") == "" {
return false
}
if os.Geteuid() != 0 {
return true
}