mirror of https://github.com/containers/podman.git
Merge pull request #17895 from vrothberg/containers_conf_extra
add CONTAINERS_CONF_OVERRIDE
This commit is contained in:
commit
905dc6de48
2
go.mod
2
go.mod
|
@ -12,7 +12,7 @@ require (
|
|||
github.com/containernetworking/cni v1.1.2
|
||||
github.com/containernetworking/plugins v1.2.0
|
||||
github.com/containers/buildah v1.29.1-0.20230201192322-e56eb25575c7
|
||||
github.com/containers/common v0.51.1-0.20230316131336-0be880eaeb02
|
||||
github.com/containers/common v0.51.1-0.20230323135459-03a2cc01973c
|
||||
github.com/containers/conmon v2.0.20+incompatible
|
||||
github.com/containers/image/v5 v5.24.3-0.20230314083015-0c6d07e02a9a
|
||||
github.com/containers/libhvee v0.0.2
|
||||
|
|
4
go.sum
4
go.sum
|
@ -247,8 +247,8 @@ github.com/containernetworking/plugins v1.2.0 h1:SWgg3dQG1yzUo4d9iD8cwSVh1VqI+bP
|
|||
github.com/containernetworking/plugins v1.2.0/go.mod h1:/VjX4uHecW5vVimFa1wkG4s+r/s9qIfPdqlLF4TW8c4=
|
||||
github.com/containers/buildah v1.29.1-0.20230201192322-e56eb25575c7 h1:GmQhTfsGuYgGfuYWEF4Ed+rEvlSWRmxisLBL2J8rCb4=
|
||||
github.com/containers/buildah v1.29.1-0.20230201192322-e56eb25575c7/go.mod h1:sFvOi+WMtMtrkxx1Dn8EhF5/ddXNyC1f5LAj4ZGzjAs=
|
||||
github.com/containers/common v0.51.1-0.20230316131336-0be880eaeb02 h1:u8ahsfyLhCnTCbxzBuFbcQdGFx2dvz9RWMCe5yNISZ0=
|
||||
github.com/containers/common v0.51.1-0.20230316131336-0be880eaeb02/go.mod h1:RyY5B1E+PsFnZOW28xgFkjce0oCAMN7c/zskaCYmAkQ=
|
||||
github.com/containers/common v0.51.1-0.20230323135459-03a2cc01973c h1:j/52772OnuMHg3B2sgMM038S6C/uAJ8cXj9l4jNOjvo=
|
||||
github.com/containers/common v0.51.1-0.20230323135459-03a2cc01973c/go.mod h1:RyY5B1E+PsFnZOW28xgFkjce0oCAMN7c/zskaCYmAkQ=
|
||||
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
|
||||
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
|
||||
github.com/containers/image/v5 v5.24.3-0.20230314083015-0c6d07e02a9a h1:2xIif78r5x2nmdb5uhjXBZuexiDAt1c/XIXFxFhfKSk=
|
||||
|
|
|
@ -494,7 +494,7 @@ var _ = Describe("Podman run", func() {
|
|||
session := podmanTest.Podman([]string{"run", "--rm", "--user", "bin", ALPINE, "grep", "CapBnd", "/proc/self/status"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("00000000800005fb"))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("00000000800405fb"))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--rm", "--user", "bin", ALPINE, "grep", "CapEff", "/proc/self/status"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
|
@ -509,12 +509,12 @@ var _ = Describe("Podman run", func() {
|
|||
session = podmanTest.Podman([]string{"run", "--rm", "--user", "root", ALPINE, "grep", "CapBnd", "/proc/self/status"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("00000000800005fb"))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("00000000800405fb"))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--rm", "--user", "root", ALPINE, "grep", "CapEff", "/proc/self/status"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("00000000800005fb"))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("00000000800405fb"))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--rm", "--user", "root", ALPINE, "grep", "CapInh", "/proc/self/status"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
|
@ -524,12 +524,12 @@ var _ = Describe("Podman run", func() {
|
|||
session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "grep", "CapBnd", "/proc/self/status"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("00000000800005fb"))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("00000000800405fb"))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "grep", "CapEff", "/proc/self/status"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("00000000800005fb"))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("00000000800405fb"))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--user=1000:1000", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
|
@ -597,7 +597,7 @@ USER bin`, BB)
|
|||
session := podmanTest.Podman([]string{"run", "--rm", "--user", "bin", "test", "grep", "CapBnd", "/proc/self/status"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("00000000800005fb"))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("00000000800405fb"))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--rm", "--user", "bin", "test", "grep", "CapEff", "/proc/self/status"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
|
|
|
@ -182,4 +182,30 @@ host.slirp4netns.executable | $expr_path
|
|||
is "$output" "Error: unsupported database backend: \"bogus\""
|
||||
}
|
||||
|
||||
@test "CONTAINERS_CONF_OVERRIDE" {
|
||||
skip_if_remote "remote does not support CONTAINERS_CONF*"
|
||||
|
||||
containersConf=$PODMAN_TMPDIR/containers.conf
|
||||
cat >$containersConf <<EOF
|
||||
[engine]
|
||||
database_backend = "boltdb"
|
||||
EOF
|
||||
|
||||
overrideConf=$PODMAN_TMPDIR/override.conf
|
||||
cat >$overrideConf <<EOF
|
||||
[engine]
|
||||
database_backend = "sqlite"
|
||||
EOF
|
||||
|
||||
CONTAINERS_CONF="$containersConf" run_podman info --format "{{ .Host.DatabaseBackend }}"
|
||||
is "$output" "boltdb"
|
||||
|
||||
CONTAINERS_CONF_OVERRIDE=$overrideConf run_podman info --format "{{ .Host.DatabaseBackend }}"
|
||||
is "$output" "sqlite"
|
||||
|
||||
# CONTAINERS_CONF will be overriden by _OVERRIDE
|
||||
CONTAINERS_CONF=$containersConf CONTAINERS_CONF_OVERRIDE=$overrideConf run_podman info --format "{{ .Host.DatabaseBackend }}"
|
||||
is "$output" "sqlite"
|
||||
}
|
||||
|
||||
# vim: filetype=sh
|
||||
|
|
|
@ -765,11 +765,21 @@ func addConfigs(dirPath string, configs []string) ([]string, error) {
|
|||
// Returns the list of configuration files, if they exist in order of hierarchy.
|
||||
// The files are read in order and each new file can/will override previous
|
||||
// file settings.
|
||||
func systemConfigs() ([]string, error) {
|
||||
var err error
|
||||
configs := []string{}
|
||||
path := os.Getenv("CONTAINERS_CONF")
|
||||
if path != "" {
|
||||
func systemConfigs() (configs []string, finalErr error) {
|
||||
if path := os.Getenv("CONTAINERS_CONF_OVERRIDE"); path != "" {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return nil, fmt.Errorf("CONTAINERS_CONF_OVERRIDE file: %w", err)
|
||||
}
|
||||
// Add the override config last to make sure it can override any
|
||||
// previous settings.
|
||||
defer func() {
|
||||
if finalErr == nil {
|
||||
configs = append(configs, path)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if path := os.Getenv("CONTAINERS_CONF"); path != "" {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return nil, fmt.Errorf("CONTAINERS_CONF file: %w", err)
|
||||
}
|
||||
|
@ -781,12 +791,14 @@ func systemConfigs() ([]string, error) {
|
|||
if _, err := os.Stat(OverrideContainersConfig); err == nil {
|
||||
configs = append(configs, OverrideContainersConfig)
|
||||
}
|
||||
|
||||
var err error
|
||||
configs, err = addConfigs(OverrideContainersConfig+".d", configs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
path, err = ifRootlessConfigPath()
|
||||
path, err := ifRootlessConfigPath()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
# "SETGID",
|
||||
# "SETPCAP",
|
||||
# "SETUID",
|
||||
# "SYS_CHROOT",
|
||||
#]
|
||||
|
||||
# A list of sysctls to be set in containers by default,
|
||||
|
|
|
@ -60,6 +60,7 @@ var (
|
|||
"CAP_SETGID",
|
||||
"CAP_SETPCAP",
|
||||
"CAP_SETUID",
|
||||
"CAP_SYS_CHROOT",
|
||||
}
|
||||
|
||||
// Search these locations in which CNIPlugins can be installed.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package version
|
||||
|
||||
// Version is the version of the build.
|
||||
const Version = "0.51.1-dev"
|
||||
const Version = "0.52.0-dev"
|
||||
|
|
|
@ -123,7 +123,7 @@ github.com/containers/buildah/pkg/rusage
|
|||
github.com/containers/buildah/pkg/sshagent
|
||||
github.com/containers/buildah/pkg/util
|
||||
github.com/containers/buildah/util
|
||||
# github.com/containers/common v0.51.1-0.20230316131336-0be880eaeb02
|
||||
# github.com/containers/common v0.51.1-0.20230323135459-03a2cc01973c
|
||||
## explicit; go 1.18
|
||||
github.com/containers/common/libimage
|
||||
github.com/containers/common/libimage/define
|
||||
|
|
Loading…
Reference in New Issue