From: Lennart Poettering Date: Wed, 13 Nov 2019 09:32:26 +0000 (+0100) Subject: time-util: treat /etc/localtime missing as UTC X-Git-Tag: v244~99^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bc9ecd484f1ebfe0de8b567c90f6cd867fbd5894;p=platform%2Fupstream%2Fsystemd.git time-util: treat /etc/localtime missing as UTC --- diff --git a/src/basic/time-util.c b/src/basic/time-util.c index f5be619..9e123d8 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -1387,13 +1387,22 @@ bool clock_supported(clockid_t clock) { } } -int get_timezone(char **tz) { +int get_timezone(char **ret) { _cleanup_free_ char *t = NULL; const char *e; char *z; int r; r = readlink_malloc("/etc/localtime", &t); + if (r == -ENOENT) { + /* If the symlink does not exist, assume "UTC", like glibc does*/ + z = strdup("UTC"); + if (!z) + return -ENOMEM; + + *ret = z; + return 0; + } if (r < 0) return r; /* returns EINVAL if not a symlink */ @@ -1408,7 +1417,7 @@ int get_timezone(char **tz) { if (!z) return -ENOMEM; - *tz = z; + *ret = z; return 0; }