config: look user id instead of rootless

Change the check to look for the UID to decide whether to load the
default configuration files from the user directory instead of the
system path.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2022-09-16 16:46:09 +02:00
parent a333879248
commit 50eb74a4b1
2 changed files with 5 additions and 5 deletions

View File

@ -23,7 +23,7 @@ func customConfigFile() (string, error) {
if path, found := os.LookupEnv("CONTAINERS_CONF"); found { if path, found := os.LookupEnv("CONTAINERS_CONF"); found {
return path, nil return path, nil
} }
if unshare.IsRootless() { if unshare.GetRootlessUID() > 0 {
path, err := rootlessConfigPath() path, err := rootlessConfigPath()
if err != nil { if err != nil {
return "", err return "", err
@ -34,7 +34,7 @@ func customConfigFile() (string, error) {
} }
func ifRootlessConfigPath() (string, error) { func ifRootlessConfigPath() (string, error) {
if unshare.IsRootless() { if unshare.GetRootlessUID() > 0 {
path, err := rootlessConfigPath() path, err := rootlessConfigPath()
if err != nil { if err != nil {
return "", err return "", err

View File

@ -180,7 +180,7 @@ func DefaultConfig() (*Config, error) {
} }
defaultEngineConfig.SignaturePolicyPath = DefaultSignaturePolicyPath defaultEngineConfig.SignaturePolicyPath = DefaultSignaturePolicyPath
if unshare.IsRootless() { if unshare.GetRootlessUID() > 0 {
configHome, err := homedir.GetConfigHome() configHome, err := homedir.GetConfigHome()
if err != nil { if err != nil {
return nil, err return nil, err
@ -289,7 +289,7 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
return nil, err return nil, err
} }
} }
storeOpts, err := types.DefaultStoreOptions(unshare.IsRootless(), unshare.GetRootlessUID()) storeOpts, err := types.DefaultStoreOptions(unshare.GetRootlessUID() > 0, unshare.GetRootlessUID())
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -427,7 +427,7 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
} }
func defaultTmpDir() (string, error) { func defaultTmpDir() (string, error) {
if !unshare.IsRootless() { if unshare.GetRootlessUID() != 0 {
return getLibpodTmpDir(), nil return getLibpodTmpDir(), nil
} }