-static char** get_ntp_services(void) {
- _cleanup_strv_free_ char **r = NULL, **files = NULL;
- char **i;
- int k;
-
- k = conf_files_list(&files, ".list", NULL,
- "/etc/systemd/ntp-units.d",
- "/run/systemd/ntp-units.d",
- "/usr/local/lib/systemd/ntp-units.d",
- "/usr/lib/systemd/ntp-units.d",
-#ifdef HAVE_SPLIT_USR
- "/lib/systemd/ntp-units.d",
-#endif
- NULL);
- if (k < 0)
- return NULL;
-
- STRV_FOREACH(i, files) {
- _cleanup_fclose_ FILE *f;
-
- f = fopen(*i, "re");
- if (!f)
- continue;
-
- for (;;) {
- char line[PATH_MAX], *l;
-
- 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;
-
- if (strv_extend(&r, l) < 0) {
- log_oom();
- return NULL;
- }
- }
- }
-
- i = r;
- r = NULL; /* avoid cleanup */
-
- return strv_uniq(i);
-}
-