Skip to content

Commit

Permalink
Use UTC timezone file in place of /etc/localtime (#2563)
Browse files Browse the repository at this point in the history
  • Loading branch information
robgjansen authored Nov 24, 2022
1 parent 662ad20 commit 58a1849
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/main/host/descriptor/regular_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ int regularfile_openat(RegularFile* file, RegularFile* dir, const char* pathname
}
} else if (!strcmp("/etc/localtime", abspath)) {
file->type = FILE_TYPE_LOCALTIME;
if (abspath) {
free(abspath);
}
// Shadow time is in UTC.
abspath = strdup("/usr/share/zoneinfo/Etc/UTC");
} else {
file->type = FILE_TYPE_REGULAR;
}
Expand All @@ -264,20 +269,11 @@ int regularfile_openat(RegularFile* file, RegularFile* dir, const char* pathname
// we should always use O_CLOEXEC for files opened in shadow
flags |= O_CLOEXEC;

int osfd = 0, errcode = 0;
if (file->type == FILE_TYPE_LOCALTIME) {
// Fail the localtime lookup so the plugin falls back to UTC.
// TODO: we could instead return a special file that contains
// timezone info in the correct format for UTC.
osfd = -1;
errcode = ENOENT;
} else {
// TODO: we should open the os-backed file in non-blocking mode even if a
// non-block is not requested, and then properly handle the io by, e.g.,
// epolling on all such files with a shadow support thread.
osfd = open(abspath, flags, mode);
errcode = errno;
}
// TODO: we should open the os-backed file in non-blocking mode even if a
// non-block is not requested, and then properly handle the io by, e.g.,
// epolling on all such files with a shadow support thread.
int osfd = open(abspath, flags, mode);
int errcode = errno;

if (osfd < 0) {
trace("RegularFile %p opening path '%s' returned %i: %s", file, abspath, osfd,
Expand Down

0 comments on commit 58a1849

Please sign in to comment.