|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
From fff58beb5618e6cabdf716418de7e5976ed8d87f Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
From: Michael Biebl <biebl@debian.org>
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Date: Sun, 21 May 2017 03:22:43 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Subject: [PATCH] timesyncd: don't use compiled-in list if FallbackNTP has been
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
configured explicitly
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Parse the config files first and only apply the compiled-in list of
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
fallback servers if no NTP server was configured via FallbackNTP.
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Closes: #5091
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
(cherry picked from commit 3745770ae4dcf262707882a38f6c5ba2684329a3)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
src/timesync/timesyncd-conf.c | 10 ++++++++++
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
src/timesync/timesyncd-conf.h | 1 +
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
src/timesync/timesyncd-manager.c | 4 ----
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
src/timesync/timesyncd-manager.h | 2 ++
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
src/timesync/timesyncd.c | 2 ++
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
5 files changed, 15 insertions(+), 4 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
diff --git a/src/timesync/timesyncd-conf.c b/src/timesync/timesyncd-conf.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
index bf25b112e1..b4a4f19976 100644
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
--- a/src/timesync/timesyncd-conf.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+++ b/src/timesync/timesyncd-conf.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -34,6 +34,9 @@ int manager_parse_server_string(Manager *m, ServerType type, const char *string)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
first = type == SERVER_FALLBACK ? m->fallback_servers : m->system_servers;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ if (type == SERVER_FALLBACK)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ m->have_fallbacks = true;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
for (;;) {
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
_cleanup_free_ char *word = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
bool found = false;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -63,6 +66,13 @@ int manager_parse_server_string(Manager *m, ServerType type, const char *string)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+int manager_parse_fallback_string(Manager *m, const char *string) {
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ if (m->have_fallbacks)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ return manager_parse_server_string(m, SERVER_FALLBACK, string);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
int config_parse_servers(
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
const char *unit,
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
const char *filename,
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
diff --git a/src/timesync/timesyncd-conf.h b/src/timesync/timesyncd-conf.h
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
index 0280697e9c..0c4b44e707 100644
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
--- a/src/timesync/timesyncd-conf.h
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+++ b/src/timesync/timesyncd-conf.h
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -29,3 +29,4 @@ int manager_parse_server_string(Manager *m, ServerType type, const char *string)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
int config_parse_servers(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
int manager_parse_config_file(Manager *m);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+int manager_parse_fallback_string(Manager *m, const char *string);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
index ae8514550a..a24c821bdc 100644
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
--- a/src/timesync/timesyncd-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+++ b/src/timesync/timesyncd-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -1124,10 +1124,6 @@ int manager_new(Manager **ret) {
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
RATELIMIT_INIT(m->ratelimit, RATELIMIT_INTERVAL_USEC, RATELIMIT_BURST);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
- r = manager_parse_server_string(m, SERVER_FALLBACK, NTP_SERVERS);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
- if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
- return r;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
r = sd_event_default(&m->event);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
diff --git a/src/timesync/timesyncd-manager.h b/src/timesync/timesyncd-manager.h
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
index efe3e60d3e..cf681f6098 100644
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
--- a/src/timesync/timesyncd-manager.h
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+++ b/src/timesync/timesyncd-manager.h
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -38,6 +38,8 @@ struct Manager {
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
LIST_HEAD(ServerName, link_servers);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
LIST_HEAD(ServerName, fallback_servers);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ bool have_fallbacks:1;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
RateLimit ratelimit;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
bool exhausted_servers;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
index b67d672a6a..052329f61e 100644
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
--- a/src/timesync/timesyncd.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+++ b/src/timesync/timesyncd.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -132,6 +132,8 @@ int main(int argc, char *argv[]) {
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
log_warning_errno(r, "Failed to parse configuration file: %m");
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ assert_se(manager_parse_fallback_string(m, NTP_SERVERS) >= 0);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
log_debug("systemd-timesyncd running as pid " PID_FMT, getpid());
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
sd_notify(false,
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
"READY=1\n"
|