summaryrefslogtreecommitdiff
path: root/src/timedate
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-08-26 19:14:51 +0200
committerLennart Poettering <lennart@poettering.net>2015-08-26 20:36:42 +0200
commit5c904ba5a5f0953b568ae257b9667222d1d21808 (patch)
treedaf825083b3a98d781e916e1e1322926059e6487 /src/timedate
parenta00458421dd4b6fcb9b4cdc433ba0c13970907f1 (diff)
time-util: add new get_timezone() call to get local timezone
Let's move the timedated-specific code to time-util.h and make it generic.
Diffstat (limited to 'src/timedate')
-rw-r--r--src/timedate/timedated.c33
1 files changed, 8 insertions, 25 deletions
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 21d6ee4c0c..42ae70fd1d 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -68,32 +68,15 @@ static int context_read_data(Context *c) {
assert(c);
- r = readlink_malloc("/etc/localtime", &t);
- if (r < 0) {
- if (r == -EINVAL)
- log_warning("/etc/localtime should be a symbolic link to a time zone data file in /usr/share/zoneinfo/.");
- else
- log_warning_errno(r, "Failed to get target of /etc/localtime: %m");
- } else {
- const char *e;
+ r = get_timezone(&t);
+ if (r == -EINVAL)
+ log_warning_errno(r, "/etc/localtime should be a symbolic link to a time zone data file in /usr/share/zoneinfo/.");
+ else if (r < 0)
+ log_warning_errno(r, "Failed to get target of /etc/localtime: %m");
- e = path_startswith(t, "/usr/share/zoneinfo/");
- if (!e)
- e = path_startswith(t, "../usr/share/zoneinfo/");
-
- if (!e)
- log_warning("/etc/localtime should be a symbolic link to a time zone data file in /usr/share/zoneinfo/.");
- else {
- c->zone = strdup(e);
- if (!c->zone)
- return log_oom();
- }
- }
-
- if (isempty(c->zone)) {
- free(c->zone);
- c->zone = NULL;
- }
+ free(c->zone);
+ c->zone = t;
+ t = NULL;
c->local_rtc = clock_is_localtime() > 0;