mirror of
https://github.com/containers/podman.git
synced 2025-10-18 03:33:32 +08:00
Reuse timezone code from containers/common
Replaces: https://github.com/containers/podman/pull/21077 [NO NEW TESTS NEEDED] Existing tests should handle this. Signed-off-by: Sohan Kunkerkar <sohank2602@gmail.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -2782,38 +2782,6 @@ func (c *Container) generatePasswdAndGroup() (string, string, error) {
|
||||
return passwdPath, groupPath, nil
|
||||
}
|
||||
|
||||
func (c *Container) copyTimezoneFile(zonePath string) (string, error) {
|
||||
localtimeCopy := filepath.Join(c.state.RunDir, "localtime")
|
||||
file, err := os.Stat(zonePath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if file.IsDir() {
|
||||
return "", errors.New("invalid timezone: is a directory")
|
||||
}
|
||||
src, err := os.Open(zonePath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer src.Close()
|
||||
dest, err := os.Create(localtimeCopy)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer dest.Close()
|
||||
_, err = io.Copy(dest, src)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := c.relabel(localtimeCopy, c.config.MountLabel, false); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := dest.Chown(c.RootUID(), c.RootGID()); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return localtimeCopy, err
|
||||
}
|
||||
|
||||
func (c *Container) cleanupOverlayMounts() error {
|
||||
return overlay.CleanupContent(c.config.StaticDir)
|
||||
}
|
||||
|
Reference in New Issue
Block a user