Merge "Do not look for tzdata file in /data." am: 7ed88b6276

Original change: https://android-review.googlesource.com/c/platform/bionic/+/2127412

Change-Id: I865b36adbcd937a1439ea50e80f7fcdbc08162a1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2022-06-23 12:35:14 +00:00 committed by Automerger Merge Worker
commit 644ad58099

View file

@ -206,24 +206,14 @@ static int __bionic_open_tzdata_path(const char* path,
int __bionic_open_tzdata(const char* olson_id, int32_t* entry_length) {
int fd;
// Try the three locations for the tzdata file in a strict order:
// 1: The O-MR1 time zone updates via APK update mechanism. This is
// tried first because it allows us to test that the time zone updates
// via APK mechanism still works even on devices with the time zone
// module.
// TODO: remove this when those devices are no longer supported.
// 2: The time zone data module which contains the main copy. This is the
// Try the two locations for the tzdata file in a strict order:
// 1: The time zone data module which contains the main copy. This is the
// common case for current devices.
// 3: The ultimate fallback: the non-updatable copy in /system.
// 2: The ultimate fallback: the non-updatable copy in /system.
#if defined(__ANDROID__)
// On Android devices, bionic has to work even if exec takes place without
// environment variables set. So, all paths are hardcoded here.
fd = __bionic_open_tzdata_path("/data/misc/zoneinfo/current/tzdata",
olson_id, entry_length);
if (fd >= -1) return fd;
fd = __bionic_open_tzdata_path("/apex/com.android.tzdata/etc/tz/tzdata",
olson_id, entry_length);
if (fd >= -1) return fd;
@ -233,16 +223,10 @@ int __bionic_open_tzdata(const char* olson_id, int32_t* entry_length) {
if (fd >= -1) return fd;
#else
// On the host, we don't expect the hard-coded locations above to exist, and
// we're not worried about security so we trust $ANDROID_DATA,
// $ANDROID_TZDATA_ROOT, and $ANDROID_ROOT to point us in the right direction
// instead.
// we're not worried about security so we trust $ANDROID_TZDATA_ROOT, and
// $ANDROID_ROOT to point us in the right direction instead.
char* path = make_path("ANDROID_DATA", "/misc/zoneinfo/current/tzdata");
fd = __bionic_open_tzdata_path(path, olson_id, entry_length);
free(path);
if (fd >= -1) return fd;
path = make_path("ANDROID_TZDATA_ROOT", "/etc/tz/tzdata");
char* path = make_path("ANDROID_TZDATA_ROOT", "/etc/tz/tzdata");
fd = __bionic_open_tzdata_path(path, olson_id, entry_length);
free(path);
if (fd >= -1) return fd;