Use homedir.GetConfigHome()
Signed-off-by: David Scherer <david.scherer@antithesis.com>
This commit is contained in:
parent
3ce09ba75f
commit
7b48d849b7
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/containers/common/pkg/apparmor"
|
"github.com/containers/common/pkg/apparmor"
|
||||||
"github.com/containers/common/pkg/cgroupv2"
|
"github.com/containers/common/pkg/cgroupv2"
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
|
"github.com/containers/storage/pkg/homedir"
|
||||||
"github.com/containers/storage/pkg/unshare"
|
"github.com/containers/storage/pkg/unshare"
|
||||||
"github.com/opencontainers/selinux/go-selinux"
|
"github.com/opencontainers/selinux/go-selinux"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
@ -128,8 +129,6 @@ const (
|
||||||
SeccompOverridePath = _etcDir + "/containers/seccomp.json"
|
SeccompOverridePath = _etcDir + "/containers/seccomp.json"
|
||||||
// SeccompDefaultPath defines the default seccomp path.
|
// SeccompDefaultPath defines the default seccomp path.
|
||||||
SeccompDefaultPath = _installPrefix + "/share/containers/seccomp.json"
|
SeccompDefaultPath = _installPrefix + "/share/containers/seccomp.json"
|
||||||
// If XDG_CONFIG_HOME is not defined, we look here (relative to HOME)
|
|
||||||
DefaultRootlessConfigHomeDir = ".config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultConfig defines the default values from containers.conf
|
// DefaultConfig defines the default values from containers.conf
|
||||||
|
|
@ -146,13 +145,9 @@ func DefaultConfig() (*Config, error) {
|
||||||
|
|
||||||
defaultEngineConfig.SignaturePolicyPath = DefaultSignaturePolicyPath
|
defaultEngineConfig.SignaturePolicyPath = DefaultSignaturePolicyPath
|
||||||
if unshare.IsRootless() {
|
if unshare.IsRootless() {
|
||||||
configHome := os.Getenv("XDG_CONFIG_HOME")
|
configHome, err := homedir.GetConfigHome()
|
||||||
if configHome == "" {
|
if err != nil {
|
||||||
home, err := unshare.HomeDir()
|
return nil, err
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
configHome = filepath.Join(home, DefaultRootlessConfigHomeDir)
|
|
||||||
}
|
}
|
||||||
sigPath := filepath.Join(configHome, DefaultRootlessSignaturePolicyPath)
|
sigPath := filepath.Join(configHome, DefaultRootlessSignaturePolicyPath)
|
||||||
defaultEngineConfig.SignaturePolicyPath = sigPath
|
defaultEngineConfig.SignaturePolicyPath = sigPath
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue