]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/timesync/timesyncd-conf.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2014 Kay Sievers, Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 #include "alloc-util.h"
24 #include "extract-word.h"
25 #include "string-util.h"
26 #include "timesyncd-conf.h"
27 #include "timesyncd-manager.h"
28 #include "timesyncd-server.h"
30 int manager_parse_server_string(Manager
*m
, ServerType type
, const char *string
) {
37 first
= type
== SERVER_FALLBACK
? m
->fallback_servers
: m
->system_servers
;
40 _cleanup_free_
char *word
= NULL
;
44 r
= extract_first_word(&string
, &word
, NULL
, 0);
46 return log_error_errno(r
, "Failed to parse timesyncd server syntax \"%s\": %m", string
);
50 /* Filter out duplicates */
51 LIST_FOREACH(names
, n
, first
)
52 if (streq_ptr(n
->string
, word
)) {
60 r
= server_name_new(m
, NULL
, type
, word
);
68 int config_parse_servers(
73 unsigned section_line
,
80 Manager
*m
= userdata
;
88 manager_flush_server_names(m
, ltype
);
90 r
= manager_parse_server_string(m
, ltype
, rvalue
);
92 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse NTP server string '%s'. Ignoring.", rvalue
);
100 int manager_parse_config_file(Manager
*m
) {
103 return config_parse_many("/etc/systemd/timesyncd.conf",
104 CONF_DIRS_NULSTR("systemd/timesyncd.conf"),
106 config_item_perf_lookup
, timesyncd_gperf_lookup
,