(path string)
| 1165 | } |
| 1166 | |
| 1167 | func extractTimeZoneFromLocalTimeSymLink(path string) (string, error) { |
| 1168 | zoneInfoRoots := []string{ |
| 1169 | "/run/host/usr/share/zoneinfo", |
| 1170 | "/usr/share/zoneinfo", |
| 1171 | } |
| 1172 | |
| 1173 | for _, root := range zoneInfoRoots { |
| 1174 | if !strings.HasPrefix(path, root) { |
| 1175 | continue |
| 1176 | } |
| 1177 | |
| 1178 | timeZone, err := filepath.Rel(root, path) |
| 1179 | if err != nil { |
| 1180 | return "", fmt.Errorf("failed to extract time zone: %w", err) |
| 1181 | } |
| 1182 | |
| 1183 | return timeZone, nil |
| 1184 | } |
| 1185 | |
| 1186 | return "", errors.New("/etc/localtime points to unknown location") |
| 1187 | } |
| 1188 | |
| 1189 | func updateTimeZoneFromLocalTime() error { |
| 1190 | localTimeEvaled, err := filepath.EvalSymlinks("/etc/localtime") |
no outgoing calls
no test coverage detected
searching dependent graphs…