]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Introduce CONF_DIRS_NULSTR helper to define standard conf dirs
authorJosh Triplett <josh@joshtriplett.org>
Wed, 29 Oct 2014 12:02:56 +0000 (05:02 -0700)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 27 Nov 2014 00:11:37 +0000 (19:11 -0500)
Several different systemd tools define a nulstr containing a standard
series of configuration file directories, in /etc, /run, /usr/local/lib,
/usr/lib, and (#ifdef HAVE_SPLIT_USR) /lib.  Factor that logic out into
a new helper macro, CONF_DIRS_NULSTR.

src/binfmt/binfmt.c
src/modules-load/modules-load.c
src/shared/macro.h
src/sysctl/sysctl.c
src/sysusers/sysusers.c
src/tmpfiles/tmpfiles.c

index c1c152239bed496e8c37d353e8bc7d3b2c1182b1..0a15fafc6092d3ab0577e4c3aa6a4174857be678 100644 (file)
 #include "fileio.h"
 #include "build.h"
 
-static const char conf_file_dirs[] =
-        "/etc/binfmt.d\0"
-        "/run/binfmt.d\0"
-        "/usr/local/lib/binfmt.d\0"
-        "/usr/lib/binfmt.d\0"
-#ifdef HAVE_SPLIT_USR
-        "/lib/binfmt.d\0"
-#endif
-        ;
+static const char conf_file_dirs[] = CONF_DIRS_NULSTR("binfmt");
 
 static int delete_rule(const char *rule) {
         _cleanup_free_ char *x = NULL, *fn = NULL;
index 08de5e0ce9e506121b87ad86a72d541ca80c017e..c676fd1c1890cd89903dfebb2b470f7c290659f7 100644 (file)
 
 static char **arg_proc_cmdline_modules = NULL;
 
-static const char conf_file_dirs[] =
-        "/etc/modules-load.d\0"
-        "/run/modules-load.d\0"
-        "/usr/local/lib/modules-load.d\0"
-        "/usr/lib/modules-load.d\0"
-#ifdef HAVE_SPLIT_USR
-        "/lib/modules-load.d\0"
-#endif
-        ;
+static const char conf_file_dirs[] = CONF_DIRS_NULSTR("modules-load");
 
 static void systemd_kmod_log(void *data, int priority, const char *file, int line,
                              const char *fn, const char *format, va_list args) {
index 9ee332c8dfaf74c4e0a0b8b2b0350d8db7446a98..6d4712c30d779ac9889a605b1201f9ad18a5c0ec 100644 (file)
@@ -384,6 +384,21 @@ do {                                                                    \
                 _found;                                                 \
         })
 
+/* 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"
+#else
+#define CONF_DIR_SPLIT_USR(n)
+#endif
+
 /* Define C11 thread_local attribute even on older gcc compiler
  * version */
 #ifndef thread_local
index 809e59b71fdb6acd8a184e2f52a5fca7d2c092ce..edebe501d198bb2f051983d66c3f92d3f5b98764 100644 (file)
 
 static char **arg_prefixes = NULL;
 
-static const char conf_file_dirs[] =
-        "/etc/sysctl.d\0"
-        "/run/sysctl.d\0"
-        "/usr/local/lib/sysctl.d\0"
-        "/usr/lib/sysctl.d\0"
-#ifdef HAVE_SPLIT_USR
-        "/lib/sysctl.d\0"
-#endif
-        ;
+static const char conf_file_dirs[] = CONF_DIRS_NULSTR("sysctl");
 
 static char* normalize_sysctl(char *s) {
         char *n;
index 04e973ac17bf784520257ec7b51c3bc0304fc9c4..7820e849839079488e886cef61a2bd9f7b87478c 100644 (file)
@@ -67,15 +67,7 @@ typedef struct Item {
 
 static char *arg_root = NULL;
 
-static const char conf_file_dirs[] =
-        "/etc/sysusers.d\0"
-        "/run/sysusers.d\0"
-        "/usr/local/lib/sysusers.d\0"
-        "/usr/lib/sysusers.d\0"
-#ifdef HAVE_SPLIT_USR
-        "/lib/sysusers.d\0"
-#endif
-        ;
+static const char conf_file_dirs[] = CONF_DIRS_NULSTR("sysusers");
 
 static Hashmap *users = NULL, *groups = NULL;
 static Hashmap *todo_uids = NULL, *todo_gids = NULL;
index 1e4675f87eb9ecf304e46290613c8e72e58810b9..23fd6ca3bcec75b3cf28fb7f6696568197ac02f6 100644 (file)
@@ -117,15 +117,7 @@ static char **arg_include_prefixes = NULL;
 static char **arg_exclude_prefixes = NULL;
 static char *arg_root = NULL;
 
-static const char conf_file_dirs[] =
-        "/etc/tmpfiles.d\0"
-        "/run/tmpfiles.d\0"
-        "/usr/local/lib/tmpfiles.d\0"
-        "/usr/lib/tmpfiles.d\0"
-#ifdef HAVE_SPLIT_USR
-        "/lib/tmpfiles.d\0"
-#endif
-        ;
+static const char conf_file_dirs[] = CONF_DIRS_NULSTR("tmpfiles");
 
 #define MAX_DEPTH 256