diff options
author | TomSweeneyRedHat <tsweeney@redhat.com> | 2021-02-27 19:53:03 -0500 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2021-03-29 13:42:36 -0400 |
commit | 52cd3ce2d9e170d5c20246372cc1985d82b3533d (patch) | |
tree | 72b5de78bbc2e78b6a2f4e64284bcffe92649b4c /test/e2e/run_test.go | |
parent | 633ae014e6945670676e4118356d09418c678138 (diff) | |
download | podman-52cd3ce2d9e170d5c20246372cc1985d82b3533d.tar.gz podman-52cd3ce2d9e170d5c20246372cc1985d82b3533d.tar.bz2 podman-52cd3ce2d9e170d5c20246372cc1985d82b3533d.zip |
Validate passed in timezone from tz option
Erik Sjolund reported an issue where a badly formated file
could be passed into the `--tz` option and then the date in the container
would be badly messed up:
```
erik@laptop:~$ echo Hello > file.txt
erik@laptop:~$ podman run --tz=../../../home/erik/file.txt --rm -ti
docker.io/library/alpine cat /etc/localtime
Hello
erik@laptop:~$ podman --version
podman version 3.0.0-rc1
erik@laptop:~$
```
This fix checks to make sure the TZ passed in is a valid
value and then proceeds with the rest of the processing.
This was first reported as a potential security issue, but it
was thought not to be. However, I thought closing the hole
sooner rather than later would be good.
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Diffstat (limited to 'test/e2e/run_test.go')
-rw-r--r-- | test/e2e/run_test.go | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 53a304aec..23930b4f7 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -1412,7 +1412,28 @@ USER mail`, BB) }) It("podman run --tz", func() { - session := podmanTest.Podman([]string{"run", "--tz", "foo", "--rm", ALPINE, "date"}) + testDir := filepath.Join(podmanTest.RunRoot, "tz-test") + err := os.MkdirAll(testDir, 0755) + Expect(err).To(BeNil()) + + tzFile := filepath.Join(testDir, "tzfile.txt") + file, err := os.Create(tzFile) + Expect(err).To(BeNil()) + + _, err = file.WriteString("Hello") + Expect(err).To(BeNil()) + file.Close() + + badTZFile := fmt.Sprintf("../../../%s", tzFile) + session := podmanTest.Podman([]string{"run", "--tz", badTZFile, "--rm", ALPINE, "date"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + Expect(session.ErrorToString()).To(ContainSubstring("error finding timezone for container")) + + err = os.Remove(tzFile) + Expect(err).To(BeNil()) + + session = podmanTest.Podman([]string{"run", "--tz", "foo", "--rm", ALPINE, "date"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Not(Equal(0))) |