From ff66f31ddd85deccbbd7c579e62a986c2ce148c2 Mon Sep 17 00:00:00 2001 From: Peter Hunt Date: Mon, 12 Jun 2023 15:05:46 -0400 Subject: [PATCH] libpod: correctly pass env so alternative locales work in addition to https://github.com/containers/podman/commit/b6167cedb2ba69a66646a94eb27c49bbbea88e15 we also need to pass LANG. Do so, and add a test to verify Signed-off-by: Peter Hunt --- libpod/oci_conmon_common.go | 3 +++ test/e2e/logs_test.go | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libpod/oci_conmon_common.go b/libpod/oci_conmon_common.go index 32877c5ad2..10842a011b 100644 --- a/libpod/oci_conmon_common.go +++ b/libpod/oci_conmon_common.go @@ -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)) diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index 953f4c226e..0ae1b79af3 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -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()) }) - })