summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2014-10-29 05:02:56 -0700
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-11-26 19:11:37 -0500
commit7f0a55d4325f7df91f91b3b818f61f97d78df14a (patch)
treef88b96f4a0002b49749d78622fd174d54062e9f8 /src
parent3d82301321afdcc4f2f8786883bd15b1a64c6e83 (diff)
Introduce CONF_DIRS_NULSTR helper to define standard conf dirs
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.
Diffstat (limited to 'src')
-rw-r--r--src/binfmt/binfmt.c10
-rw-r--r--src/modules-load/modules-load.c10
-rw-r--r--src/shared/macro.h15
-rw-r--r--src/sysctl/sysctl.c10
-rw-r--r--src/sysusers/sysusers.c10
-rw-r--r--src/tmpfiles/tmpfiles.c10
6 files changed, 20 insertions, 45 deletions
diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
index c1c152239b..0a15fafc60 100644
--- a/src/binfmt/binfmt.c
+++ b/src/binfmt/binfmt.c
@@ -36,15 +36,7 @@
#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;
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index 08de5e0ce9..c676fd1c18 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -38,15 +38,7 @@
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) {
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 9ee332c8df..6d4712c30d 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -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
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index 809e59b71f..edebe501d1 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -38,15 +38,7 @@
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;
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 04e973ac17..7820e84983 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -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;
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 1e4675f87e..23fd6ca3bc 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -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