summaryrefslogtreecommitdiff
path: root/src/basic/conf-files.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-02-05 14:53:11 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-02-05 15:04:52 +0100
commita6d8474f39d8d92077a4cefab2f355b2e5e00211 (patch)
treee6fddb1b83a0eb5f6e01126a74bf72e578ea3d78 /src/basic/conf-files.c
parent24c2c5689d8d9d771c8a0946e5dfa84f0f6026af (diff)
downloadsystemd-a6d8474f39d8d92077a4cefab2f355b2e5e00211.tar.gz
tmpfiles: allow admin/runtime overrides to runtime config
This is very similar to d16a1c1bb6. For tmpfiles this is much less useful compared to sysusers, but let's add this anyway for consistency.
Diffstat (limited to 'src/basic/conf-files.c')
-rw-r--r--src/basic/conf-files.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c
index 08ede2c766..8b4129e1cd 100644
--- a/src/basic/conf-files.c
+++ b/src/basic/conf-files.c
@@ -154,7 +154,7 @@ static int conf_files_list_strv_internal(char ***strv, const char *suffix, const
return 0;
}
-int conf_files_insert(char ***strv, const char *root, const char *dirs, const char *path) {
+int conf_files_insert(char ***strv, const char *root, char **dirs, const char *path) {
/* Insert a path into strv, at the place honouring the usual sorting rules:
* - we first compare by the basename
* - and then we compare by dirname, allowing just one file with the given
@@ -174,22 +174,22 @@ int conf_files_insert(char ***strv, const char *root, const char *dirs, const ch
c = base_cmp(*strv + i, &path);
if (c == 0) {
- const char *dir;
+ char **dir;
/* Oh, we found our spot and it already contains something. */
- NULSTR_FOREACH(dir, dirs) {
+ STRV_FOREACH(dir, dirs) {
char *p1, *p2;
p1 = path_startswith((*strv)[i], root);
if (p1)
- /* Skip "/" in dir, because p1 is without "/" too */
- p1 = path_startswith(p1, dir + 1);
+ /* Skip "/" in *dir, because p1 is without "/" too */
+ p1 = path_startswith(p1, *dir + 1);
if (p1)
/* Existing entry with higher priority
* or same priority, no need to do anything. */
return 0;
- p2 = path_startswith(path, dir);
+ p2 = path_startswith(path, *dir);
if (p2) {
/* Our new entry has higher priority */
t = path_join(root, path, NULL);
@@ -218,6 +218,18 @@ int conf_files_insert(char ***strv, const char *root, const char *dirs, const ch
return r;
}
+int conf_files_insert_nulstr(char ***strv, const char *root, const char *dirs, const char *path) {
+ _cleanup_strv_free_ char **d = NULL;
+
+ assert(strv);
+
+ d = strv_split_nulstr(dirs);
+ if (!d)
+ return -ENOMEM;
+
+ return conf_files_insert(strv, root, d, path);
+}
+
int conf_files_list_strv(char ***strv, const char *suffix, const char *root, unsigned flags, const char* const* dirs) {
_cleanup_strv_free_ char **copy = NULL;
@@ -246,14 +258,14 @@ int conf_files_list(char ***strv, const char *suffix, const char *root, unsigned
return conf_files_list_strv_internal(strv, suffix, root, flags, dirs);
}
-int conf_files_list_nulstr(char ***strv, const char *suffix, const char *root, unsigned flags, const char *d) {
- _cleanup_strv_free_ char **dirs = NULL;
+int conf_files_list_nulstr(char ***strv, const char *suffix, const char *root, unsigned flags, const char *dirs) {
+ _cleanup_strv_free_ char **d = NULL;
assert(strv);
- dirs = strv_split_nulstr(d);
- if (!dirs)
+ d = strv_split_nulstr(dirs);
+ if (!d)
return -ENOMEM;
- return conf_files_list_strv_internal(strv, suffix, root, flags, dirs);
+ return conf_files_list_strv_internal(strv, suffix, root, flags, d);
}