]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
defs: rework CONF_DIRS_NULSTR() macro
authorLennart Poettering <lennart@poettering.net>
Tue, 10 Nov 2015 14:57:21 +0000 (15:57 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 10 Nov 2015 16:31:31 +0000 (17:31 +0100)
The macro is generically useful for putting together search paths, hence
let's make it truly generic, by dropping the implicit ".d" appending it
does, and leave that to the caller. Also rename it from
CONF_DIRS_NULSTR() to CONF_PATHS_NULSTR(), since it's not strictly about
dirs that way, but any kind of file system path.

Also, mark CONF_DIR_SPLIT_USR() as internal macro by renaming it to
_CONF_PATHS_SPLIT_USR() so that the leading underscore indicates that
it's internal.

16 files changed:
src/basic/def.h
src/binfmt/binfmt.c
src/bootchart/bootchart.c
src/core/main.c
src/journal-remote/journal-remote.c
src/journal-remote/journal-upload.c
src/journal/coredump.c
src/journal/journald-server.c
src/login/logind.c
src/modules-load/modules-load.c
src/resolve/resolved-conf.c
src/shared/sleep-config.c
src/sysctl/sysctl.c
src/sysusers/sysusers.c
src/timesync/timesyncd-conf.c
src/tmpfiles/tmpfiles.c

index 950f693899fd2f2332c419ca38fda49216fde833..0657ac736724930a2267c2fd65d39dababca1c1e 100644 (file)
 #define NOTIFY_FD_MAX 768
 #define NOTIFY_BUFFER_MAX PIPE_BUF
 
-/* Return a nulstr for a standard cascade of configuration directories,
- * suitable to pass to conf_files_list_nulstr or config_parse_many. */
-#define CONF_DIRS_NULSTR(n) \
-        "/etc/" n ".d\0" \
-        "/run/" n ".d\0" \
-        "/usr/local/lib/" n ".d\0" \
-        "/usr/lib/" n ".d\0" \
-        CONF_DIR_SPLIT_USR(n)
-
 #ifdef HAVE_SPLIT_USR
-#define CONF_DIR_SPLIT_USR(n) "/lib/" n ".d\0"
+#define _CONF_PATHS_SPLIT_USR(n) "/lib/" n "\0"
 #else
-#define CONF_DIR_SPLIT_USR(n)
+#define _CONF_PATHS_SPLIT_USR(n)
 #endif
+
+/* Return a nulstr for a standard cascade of configuration paths,
+ * suitable to pass to conf_files_list_nulstr() or config_parse_many()
+ * to implement drop-in directories for extending configuration
+ * files. */
+#define CONF_PATHS_NULSTR(n) \
+        "/etc/" n "\0" \
+        "/run/" n "\0" \
+        "/usr/local/lib/" n "\0" \
+        "/usr/lib/" n "\0" \
+        _CONF_PATHS_SPLIT_USR(n)
index 42ad0adb02a09d73a929c311e274a0ab35e72337..03fb413fe5e40ddfcbe8e25f6e703ada91cba503 100644 (file)
@@ -37,7 +37,7 @@
 #include "strv.h"
 #include "util.h"
 
-static const char conf_file_dirs[] = CONF_DIRS_NULSTR("binfmt");
+static const char conf_file_dirs[] = CONF_PATHS_NULSTR("binfmt.d");
 
 static int delete_rule(const char *rule) {
         _cleanup_free_ char *x = NULL, *fn = NULL;
index 852febb22570b327719ed1fa4031018507ec17e0..6a0e1d6b141b726f6413543d6901cba3084f7d67 100644 (file)
@@ -95,8 +95,6 @@ static void signal_handler(int sig) {
         exiting = 1;
 }
 
-#define BOOTCHART_CONF "/etc/systemd/bootchart.conf"
-
 #define BOOTCHART_MAX (16*1024*1024)
 
 static void parse_conf(void) {
@@ -117,8 +115,8 @@ static void parse_conf(void) {
                 { NULL, NULL, NULL, 0, NULL }
         };
 
-        config_parse_many(BOOTCHART_CONF,
-                          CONF_DIRS_NULSTR("systemd/bootchart.conf"),
+        config_parse_many(PKGSYSCONFDIR "/bootchart.conf",
+                          CONF_PATHS_NULSTR("systemd/bootchart.conf.d"),
                           NULL, config_item_table_lookup, items, true, NULL);
 
         if (init != NULL)
index 950315e857a8410af347d0818902c98740410158..a86080642de20925f3e4352a30f38d61619c378a 100644 (file)
@@ -682,8 +682,14 @@ static int parse_config_file(void) {
 
         const char *fn, *conf_dirs_nulstr;
 
-        fn = arg_running_as == MANAGER_SYSTEM ? PKGSYSCONFDIR "/system.conf" : PKGSYSCONFDIR "/user.conf";
-        conf_dirs_nulstr = arg_running_as == MANAGER_SYSTEM ? CONF_DIRS_NULSTR("systemd/system.conf") : CONF_DIRS_NULSTR("systemd/user.conf");
+        fn = arg_running_as == MANAGER_SYSTEM ?
+                PKGSYSCONFDIR "/system.conf" :
+                PKGSYSCONFDIR "/user.conf";
+
+        conf_dirs_nulstr = arg_running_as == MANAGER_SYSTEM ?
+                CONF_PATHS_NULSTR("systemd/system.conf.d") :
+                CONF_PATHS_NULSTR("systemd/user.conf.d");
+
         config_parse_many(fn, conf_dirs_nulstr, "Manager\0",
                           config_item_table_lookup, items, false, NULL);
 
index 6eb0ee9d9ef5c4bb2719680aedcda60a2cb477e4..b2f5fbf6b4caddaad2e0182893807ff563bf4594 100644 (file)
@@ -1188,7 +1188,7 @@ static int parse_config(void) {
                 {}};
 
         return config_parse_many(PKGSYSCONFDIR "/journal-remote.conf",
-                                 CONF_DIRS_NULSTR("systemd/journal-remote.conf"),
+                                 CONF_PATHS_NULSTR("systemd/journal-remote.conf.d"),
                                  "Remote\0", config_item_table_lookup, items,
                                  false, NULL);
 }
index 42d14dc7c4eab561657c8abdf0b77aaf775c144d..6302266ccbf5c3faaa57043fc96e1e802c8e6971 100644 (file)
@@ -542,7 +542,7 @@ static int parse_config(void) {
                 {}};
 
         return config_parse_many(PKGSYSCONFDIR "/journal-upload.conf",
-                                 CONF_DIRS_NULSTR("systemd/journal-upload.conf"),
+                                 CONF_PATHS_NULSTR("systemd/journal-upload.conf.d"),
                                  "Upload\0", config_item_table_lookup, items,
                                  false, NULL);
 }
index 4c83e311db937ff2e5770430ea758883ed507647..f750ddfcbd625eb54a94d81bbfb39e8c1637db21 100644 (file)
@@ -126,8 +126,8 @@ static int parse_config(void) {
                 {}
         };
 
-        return config_parse_many("/etc/systemd/coredump.conf",
-                                 CONF_DIRS_NULSTR("systemd/coredump.conf"),
+        return config_parse_many(PKGSYSCONFDIR "/coredump.conf",
+                                 CONF_PATHS_NULSTR("systemd/coredump.conf.d"),
                                  "Coredump\0",
                                  config_item_table_lookup, items,
                                  false, NULL);
index 7a70dcbc57c071b36048464f5bd3c4a7c8b76f2b..f0d3a26372dff0307753f9b64150fc296ced8b4a 100644 (file)
@@ -1360,8 +1360,8 @@ static int server_parse_proc_cmdline(Server *s) {
 static int server_parse_config_file(Server *s) {
         assert(s);
 
-        return config_parse_many("/etc/systemd/journald.conf",
-                                 CONF_DIRS_NULSTR("systemd/journald.conf"),
+        return config_parse_many(PKGSYSCONFDIR "/journald.conf",
+                                 CONF_PATHS_NULSTR("systemd/journald.conf.d"),
                                  "Journal\0",
                                  config_item_perf_lookup, journald_gperf_lookup,
                                  false, s);
index 83896ea6275c4d783050cdaa3b5c3d022fed4a32..be6bbe5b5cdba987d0218f37ba1add4e90e8d5cb 100644 (file)
@@ -1102,8 +1102,8 @@ static int manager_run(Manager *m) {
 static int manager_parse_config_file(Manager *m) {
         assert(m);
 
-        return config_parse_many("/etc/systemd/logind.conf",
-                                 CONF_DIRS_NULSTR("systemd/logind.conf"),
+        return config_parse_many(PKGSYSCONFDIR "/logind.conf",
+                                 CONF_PATHS_NULSTR("systemd/logind.conf.d"),
                                  "Login\0",
                                  config_item_perf_lookup, logind_gperf_lookup,
                                  false, m);
index 13784763f1ae8c23f93cb4aff1f922189a77405e..a7fdcb09cf4a0c2435d7d0e269f9a78575ba4e19 100644 (file)
@@ -38,7 +38,7 @@
 
 static char **arg_proc_cmdline_modules = NULL;
 
-static const char conf_file_dirs[] = CONF_DIRS_NULSTR("modules-load");
+static const char conf_file_dirs[] = CONF_PATHS_NULSTR("modules-load.d");
 
 static void systemd_kmod_log(void *data, int priority, const char *file, int line,
                              const char *fn, const char *format, va_list args) {
index de1bd26174c68192fe59004122260916f0aa7bb4..920771955136d3ab56658578271b158520003b4c 100644 (file)
@@ -150,8 +150,8 @@ int config_parse_support(
 int manager_parse_config_file(Manager *m) {
         assert(m);
 
-        return config_parse_many("/etc/systemd/resolved.conf",
-                                 CONF_DIRS_NULSTR("systemd/resolved.conf"),
+        return config_parse_many(PKGSYSCONFDIR "/resolved.conf",
+                                 CONF_PATHS_NULSTR("systemd/resolved.conf.d"),
                                  "Resolve\0",
                                  config_item_perf_lookup, resolved_gperf_lookup,
                                  false, m);
index 102c5cc9925aafeea50ab166692abc6c51dcc410..39b836d0535403c0c598ee8998dd6ecf5627d1c5 100644 (file)
@@ -54,7 +54,7 @@ int parse_sleep_config(const char *verb, char ***_modes, char ***_states) {
         };
 
         config_parse_many(PKGSYSCONFDIR "/sleep.conf",
-                          CONF_DIRS_NULSTR("systemd/sleep.conf"),
+                          CONF_PATHS_NULSTR("systemd/sleep.conf.d"),
                           "Sleep\0", config_item_table_lookup, items,
                           false, NULL);
 
index 152c98b3482fd6b39c9752c06c83a3b39ce6b04a..25b5ff52eab6a3adff91a52db656c874761edc0a 100644 (file)
@@ -41,7 +41,7 @@
 
 static char **arg_prefixes = NULL;
 
-static const char conf_file_dirs[] = CONF_DIRS_NULSTR("sysctl");
+static const char conf_file_dirs[] = CONF_PATHS_NULSTR("sysctl.d");
 
 static int apply_all(Hashmap *sysctl_options) {
         char *property, *value;
index 008b1bde24396e89a183053ca2bfc0930d28ee9b..675f94906b2dd89eae7e22ae82ada54ff972fe00 100644 (file)
@@ -72,7 +72,7 @@ typedef struct Item {
 
 static char *arg_root = NULL;
 
-static const char conf_file_dirs[] = CONF_DIRS_NULSTR("sysusers");
+static const char conf_file_dirs[] = CONF_PATHS_NULSTR("sysusers.d");
 
 static Hashmap *users = NULL, *groups = NULL;
 static Hashmap *todo_uids = NULL, *todo_gids = NULL;
index 001a0f4d4117734b3c62a79327db3974ab469feb..5881bc0c452c2437c4910471b9747208037f5e48 100644 (file)
@@ -100,8 +100,8 @@ int config_parse_servers(
 int manager_parse_config_file(Manager *m) {
         assert(m);
 
-        return config_parse_many("/etc/systemd/timesyncd.conf",
-                                 CONF_DIRS_NULSTR("systemd/timesyncd.conf"),
+        return config_parse_many(PKGSYSCONFDIR "/timesyncd.conf",
+                                 CONF_PATHS_NULSTR("systemd/timesyncd.conf.d"),
                                  "Time\0",
                                  config_item_perf_lookup, timesyncd_gperf_lookup,
                                  false, m);
index ffae91a3caf1998c8eb4b020a6d7be0cc61730e1..64f0c9396c6268f2e9463c934376069382500a75 100644 (file)
@@ -159,7 +159,7 @@ static char **arg_include_prefixes = NULL;
 static char **arg_exclude_prefixes = NULL;
 static char *arg_root = NULL;
 
-static const char conf_file_dirs[] = CONF_DIRS_NULSTR("tmpfiles");
+static const char conf_file_dirs[] = CONF_PATHS_NULSTR("tmpfiles.d");
 
 #define MAX_DEPTH 256