libpod: correctly pass env so alternative locales work

in addition to b6167cedb2
we also need to pass LANG. Do so, and add a test to verify

Signed-off-by: Peter Hunt <pehunt@redhat.com>
This commit is contained in:
Peter Hunt
2023-06-12 15:05:46 -04:00
committed by Paul Holzinger
parent e0b8178ad0
commit ff66f31ddd
2 changed files with 17 additions and 1 deletions

View File

@ -1311,6 +1311,9 @@ func (r *ConmonOCIRuntime) configureConmonEnv(runtimeDir string) []string {
if strings.HasPrefix(e, "LC_") {
env = append(env, e)
}
if strings.HasPrefix(e, "LANG=") {
env = append(env, e)
}
}
if path, ok := os.LookupEnv("PATH"); ok {
env = append(env, fmt.Sprintf("PATH=%s", path))

View File

@ -2,6 +2,7 @@ package integration
import (
"fmt"
"os"
"os/exec"
"time"
@ -584,6 +585,19 @@ var _ = Describe("Podman logs", func() {
Expect(logs.ErrorToString()).To(ContainSubstring("this container is using the 'none' log driver, cannot read logs: this container is not logging output"))
})
It("podman logs with non ASCII log tag fails without env", func() {
// Env won't be passed to the podman command by default, so it will be empty
logc := podmanTest.Podman([]string{"run", "--log-opt", "tag=\"äöüß\"", ALPINE, "echo", "podman"})
logc.WaitWithDefaultTimeout()
Expect(logc).To(Not(Exit(0)))
})
It("podman logs with non ASCII log tag succeeds with env", func() {
env := append(os.Environ(), "LANG=en_US.UTF-8", "LC_ALL=")
logc := podmanTest.PodmanAsUser([]string{"run", "--log-opt", "tag=äöüß", ALPINE, "echo", "podman"}, 0, 0, "", env)
logc.WaitWithDefaultTimeout()
Expect(logc).To(Exit(0))
})
It("podman pod logs with container names", func() {
SkipIfRemote("Remote can only process one container at a time")
podName := "testPod"
@ -638,5 +652,4 @@ var _ = Describe("Podman logs", func() {
g.Expect(output[1]).To(MatchRegexp(`\x1b\[3[0-9a-z ]+\x1b\[0m`))
}).Should(Succeed())
})
})