Skip to content

Commit

Permalink
podman container clone env patch
Browse files Browse the repository at this point in the history
podman container clone was failing when env variables had multiple `=` in them.
Switch split to splitn

resolves containers#15836

Signed-off-by: Charlie Doern <[email protected]>
  • Loading branch information
cdoern committed Sep 16, 2022
1 parent 8f76bc2 commit 049b108
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/specgen/generate/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func ConfigToSpec(rt *libpod.Runtime, specg *specgen.SpecGenerator, contaierID s
if conf.Spec.Process != nil && conf.Spec.Process.Env != nil {
env := make(map[string]string)
for _, entry := range conf.Spec.Process.Env {
split := strings.Split(entry, "=")
split := strings.SplitN(entry, "=", 2)
if len(split) == 2 {
env[split[0]] = split[1]
}
Expand Down
13 changes: 13 additions & 0 deletions test/e2e/container_clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,5 +308,18 @@ var _ = Describe("Podman container clone", func() {
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).Should(ContainSubstring("123"))

session = podmanTest.Podman([]string{"run", "--name", "env_ctr2", "-e", "ENV_TEST=12=3", ALPINE, "printenv", "ENV_TEST"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))

session = podmanTest.Podman([]string{"container", "clone", "env_ctr2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))

session = podmanTest.Podman([]string{"start", "-a", "env_ctr2-clone"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).Should(ContainSubstring("12=3"))

})
})

0 comments on commit 049b108

Please sign in to comment.