summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-03-23 12:52:22 -0700
committerGitHub <noreply@github.com>2021-03-23 12:52:22 -0700
commit9982923276f35fa05f259c934c6406fbce3e1dd4 (patch)
treeddec16a1db2a7f2c57f636bc2957430b9faaf70b /libpod
parentae1529ca191d4ab4d010703729c0ff656cc44276 (diff)
parent5b2e71dc5b939378303daecab708c4042ee3677d (diff)
downloadpodman-9982923276f35fa05f259c934c6406fbce3e1dd4.tar.gz
podman-9982923276f35fa05f259c934c6406fbce3e1dd4.tar.bz2
podman-9982923276f35fa05f259c934c6406fbce3e1dd4.zip
Merge pull request #9537 from TomSweeneyRedHat/dev/tsweeney/tz_check
Validate passed in timezone from tz option
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal_linux.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 24319f4b5..94c6c3840 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -1503,16 +1503,24 @@ func (c *Container) makeBindMounts() error {
}
// Make /etc/localtime
- if c.Timezone() != "" {
+ ctrTimezone := c.Timezone()
+ if ctrTimezone != "" {
+ // validate the format of the timezone specified if it's not "local"
+ if ctrTimezone != "local" {
+ _, err = time.LoadLocation(ctrTimezone)
+ if err != nil {
+ return errors.Wrapf(err, "error finding timezone for container %s", c.ID())
+ }
+ }
if _, ok := c.state.BindMounts["/etc/localtime"]; !ok {
var zonePath string
- if c.Timezone() == "local" {
+ if ctrTimezone == "local" {
zonePath, err = filepath.EvalSymlinks("/etc/localtime")
if err != nil {
return errors.Wrapf(err, "error finding local timezone for container %s", c.ID())
}
} else {
- zone := filepath.Join("/usr/share/zoneinfo", c.Timezone())
+ zone := filepath.Join("/usr/share/zoneinfo", ctrTimezone)
zonePath, err = filepath.EvalSymlinks(zone)
if err != nil {
return errors.Wrapf(err, "error setting timezone for container %s", c.ID())