mirror of
https://github.com/containers/podman.git
synced 2025-05-20 08:36:23 +08:00
60 lines
1.3 KiB
Go
60 lines
1.3 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/containers/storage/pkg/unshare"
|
|
selinux "github.com/opencontainers/selinux/go-selinux"
|
|
)
|
|
|
|
const (
|
|
// OverrideContainersConfig holds the default config path overridden by the root user
|
|
OverrideContainersConfig = "/etc/" + _configPath
|
|
|
|
// DefaultContainersConfig holds the default containers config path
|
|
DefaultContainersConfig = "/usr/share/" + _configPath
|
|
|
|
// DefaultSignaturePolicyPath is the default value for the
|
|
// policy.json file.
|
|
DefaultSignaturePolicyPath = "/etc/containers/policy.json"
|
|
|
|
// Mount type for mounting host dir
|
|
_typeBind = "bind"
|
|
)
|
|
|
|
func selinuxEnabled() bool {
|
|
return selinux.GetEnabled()
|
|
}
|
|
|
|
func customConfigFile() (string, error) {
|
|
if path, found := os.LookupEnv("CONTAINERS_CONF"); found {
|
|
return path, nil
|
|
}
|
|
if unshare.GetRootlessUID() > 0 {
|
|
path, err := rootlessConfigPath()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return path, nil
|
|
}
|
|
return OverrideContainersConfig, nil
|
|
}
|
|
|
|
func ifRootlessConfigPath() (string, error) {
|
|
if unshare.GetRootlessUID() > 0 {
|
|
path, err := rootlessConfigPath()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return path, nil
|
|
}
|
|
return "", nil
|
|
}
|
|
|
|
var defaultHelperBinariesDir = []string{
|
|
"/usr/local/libexec/podman",
|
|
"/usr/local/lib/podman",
|
|
"/usr/libexec/podman",
|
|
"/usr/lib/podman",
|
|
}
|