Skip to content

Commit

Permalink
Merge pull request #2219 from Luap99/tzdir-local
Browse files Browse the repository at this point in the history
pkg/timezone: handle TZDIR and local correctly
  • Loading branch information
openshift-merge-bot[bot] authored Oct 30, 2024
2 parents a44f1f1 + 5a27d7d commit eda742d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/timezone/timezone.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ func ConfigureContainerTimeZone(timezone, containerRunDir, mountPoint, etcPath,
switch {
case timezone == "":
return "", nil
case os.Getenv("TZDIR") != "":
// Allow using TZDIR per:
// https://sourceware.org/git/?p=glibc.git;a=blob;f=time/tzfile.c;h=8a923d0cccc927a106dc3e3c641be310893bab4e;hb=HEAD#l149

timezonePath = filepath.Join(os.Getenv("TZDIR"), timezone)
case timezone == "local":
timezonePath, err = filepath.EvalSymlinks("/etc/localtime")
if err != nil {
return "", fmt.Errorf("finding local timezone for container %s: %w", containerID, err)
}
default:
timezonePath = filepath.Join("/usr/share/zoneinfo", timezone)
// Allow using TZDIR per:
// https://sourceware.org/git/?p=glibc.git;a=blob;f=time/tzfile.c;h=8a923d0cccc927a106dc3e3c641be310893bab4e;hb=HEAD#l149
zoneinfo := os.Getenv("TZDIR")
if zoneinfo == "" {
// default zoneinfo location
zoneinfo = "/usr/share/zoneinfo"
}
timezonePath = filepath.Join(zoneinfo, timezone)
}

etcFd, err := openDirectory(etcPath)
Expand Down

0 comments on commit eda742d

Please sign in to comment.