diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-07-13 11:32:39 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-07-20 23:53:22 +0200 |
commit | 1d77721f30a821464cd715a63b89ef18419de7b0 (patch) | |
tree | 3c20d7dc1ddbcc38fb35bfd007cb2f02da9a6702 /src/tmpfiles/tmpfiles.c | |
parent | Merge pull request #23640 from cerebro1/week1 (diff) | |
download | systemd-1d77721f30a821464cd715a63b89ef18419de7b0.tar.xz systemd-1d77721f30a821464cd715a63b89ef18419de7b0.zip |
tmpfiles: accept additional tmpfiles lines via credential
Diffstat (limited to 'src/tmpfiles/tmpfiles.c')
-rw-r--r-- | src/tmpfiles/tmpfiles.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 0c50c8e1ee..e2451f1b95 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -25,6 +25,7 @@ #include "chattr-util.h" #include "conf-files.h" #include "copy.h" +#include "creds-util.h" #include "def.h" #include "devnum-util.h" #include "dirent-util.h" @@ -3594,7 +3595,12 @@ static int parse_argv(int argc, char *argv[]) { return 1; } -static int read_config_file(char **config_dirs, const char *fn, bool ignore_enoent, bool *invalid_config) { +static int read_config_file( + char **config_dirs, + const char *fn, + bool ignore_enoent, + bool *invalid_config) { + _cleanup_(hashmap_freep) Hashmap *uid_cache = NULL, *gid_cache = NULL; _cleanup_fclose_ FILE *_f = NULL; _cleanup_free_ char *pp = NULL; @@ -3736,6 +3742,25 @@ static int read_config_files(char **config_dirs, char **args, bool *invalid_conf return 0; } +static int read_credential_lines(bool *invalid_config) { + _cleanup_free_ char *j = NULL; + const char *d; + int r; + + r = get_credentials_dir(&d); + if (r == -ENXIO) + return 0; + if (r < 0) + return log_error_errno(r, "Failed to get credentials directory: %m"); + + j = path_join(d, "tmpfiles.extra"); + if (!j) + return log_oom(); + + (void) read_config_file(/* config_dirs= */ NULL, j, /* ignore_enoent= */ true, invalid_config); + return 0; +} + static int link_parent(ItemArray *a) { const char *path; char *prefix; @@ -3892,6 +3917,10 @@ static int run(int argc, char *argv[]) { if (r < 0) return r; + r = read_credential_lines(&invalid_config); + if (r < 0) + return r; + /* Let's now link up all child/parent relationships */ ORDERED_HASHMAP_FOREACH(a, items) { r = link_parent(a); |