+static char** get_ntp_services(void) {
+ 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;
+
+ STRV_FOREACH(i, files) {
+ FILE *f;
+
+ f = fopen(*i, "re");
+ if (!f)
+ continue;
+
+ for (;;) {
+ char line[PATH_MAX], *l, **q;
+
+ if (!fgets(line, sizeof(line), f)) {
+
+ if (ferror(f))
+ log_error("Failed to read NTP units file: %m");
+
+ 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;
+ }
+
+ fclose(f);
+ }
+
+ strv_free(files);
+
+ return strv_uniq(r);
+}
+