chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
timedated: replace ntp-units file with an ntp-units.d drop-in dir
[elogind.git]
/
src
/
timedate
/
timedated.c
diff --git
a/src/timedate/timedated.c
b/src/timedate/timedated.c
index 4be7c3a9973d4b671846cf27f1a7c8cca5ca4fbc..5387699bf316b1d1830fe1f7989b281f40cb6df1 100644
(file)
--- a/
src/timedate/timedated.c
+++ b/
src/timedate/timedated.c
@@
-31,6
+31,7
@@
#include "polkit.h"
#include "def.h"
#include "hwclock.h"
#include "polkit.h"
#include "def.h"
#include "hwclock.h"
+#include "conf-files.h"
#define NULL_ADJTIME_UTC "0.0 0 0\n0\nUTC\n"
#define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n"
#define NULL_ADJTIME_UTC "0.0 0 0\n0\nUTC\n"
#define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n"
@@
-304,40
+305,54
@@
static int write_data_local_rtc(void) {
}
static char** get_ntp_services(void) {
}
static char** get_ntp_services(void) {
- char **r = NULL;
- FILE *f;
-
- f = fopen(SYSTEMD_NTP_UNITS, "re");
- if (!f)
+ char **r = NULL, **files, **i;
+ int k;
+
+ k = conf_files_list(&files, ".list",
+ "/etc/systemd/ntp-units.d",
+ "/run/systemd/ntp-units.d",
+ "/usr/local/lib/systemd/ntp-units.d",
+ "/usr/lib/systemd/ntp-units.d",
+ NULL);
+ if (k < 0)
return NULL;
return NULL;
-
for (;;
) {
-
char line[PATH_MAX], *l, **q
;
+
STRV_FOREACH(i, files
) {
+
FILE *f
;
- if (!fgets(line, sizeof(line), f)) {
+ f = fopen(*i, "re");
+ if (!f)
+ continue;
- if (ferror(f))
-
log_error("Failed to read NTP units file: %m")
;
+ for (;;) {
+
char line[PATH_MAX], *l, **q
;
- break;
- }
+ if (!fgets(line, sizeof(line), f)) {
- l = strstrip(line);
- if (l[0] == 0 || l[0] == '#')
- continue;
+ if (ferror(f))
+ log_error("Failed to read NTP units file: %m");
+ break;
+ }
- q = strv_append(r, l);
- if (!q) {
- log_error("Out of memory");
- break;
+ l = strstrip(line);
+ if (l[0] == 0 || l[0] == '#')
+ continue;
+
+ q = strv_append(r, l);
+ if (!q) {
+ log_error("Out of memory");
+ break;
+ }
+
+ strv_free(r);
+ r = q;
}
}
- strv_free(r);
- r = q;
+ fclose(f);
}
}
-
fclose(f
);
+
strv_free(files
);
return r;
}
return r;
}