From 626f8d1672c57e0ebbe9331d98bd0cf841754bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 5 Jun 2019 14:46:04 +0200 Subject: [PATCH 1/2] tmpfiles: also prefix C source paths with --root This makes the code match the docs for --root ("all paths will be prefixed"). I think this is reasonable, because --root also works for config paths, and any configuration inside --root must refer to paths under --root. If we allowed C to go "outside of root" in this way, the effect of calling systemd-tmpfiles --root=... and chrooting first and then calling systemd-tmpfiles second would be quite different. I think it's better to keep things simple and consistent. Fixes #12467. --- src/tmpfiles/tmpfiles.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index eabc51101d..36ffd072b4 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -2638,13 +2638,22 @@ static int parse_line(const char *fname, unsigned line, const char *buffer, bool case COPY_FILES: if (!i.argument) { - i.argument = strappend("/usr/share/factory/", i.path); + i.argument = path_join(arg_root, "/usr/share/factory/", i.path); if (!i.argument) return log_oom(); + } else if (!path_is_absolute(i.argument)) { *invalid_config = true; log_error("[%s:%u] Source path is not absolute.", fname, line); return -EBADMSG; + + } else if (arg_root) { + char *p; + + p = prefix_root(arg_root, i.argument); + if (!p) + return log_oom(); + free_and_replace(i.argument, p); } path_simplify(i.argument, false); @@ -2738,7 +2747,6 @@ static int parse_line(const char *fname, unsigned line, const char *buffer, bool p = prefix_root(arg_root, i.path); if (!p) return log_oom(); - free_and_replace(i.path, p); } From b0458daf947aa4cd3965dc2eeda95cd745fdd0b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 5 Jun 2019 14:57:06 +0200 Subject: [PATCH 2/2] man: add "quick reference" to tmpfiles.d(5) The synopsis section would describe config file paths, but not their syntax. Let's add a short table that so that it's possible to quickly remind oneself what the different letter mean. --- man/tmpfiles.d.xml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/man/tmpfiles.d.xml b/man/tmpfiles.d.xml index 67bd1dc724..26afc116b7 100644 --- a/man/tmpfiles.d.xml +++ b/man/tmpfiles.d.xml @@ -36,6 +36,37 @@ … /usr/share/user-tmpfiles.d/*.conf + + #Type Path Mode User Group Age Argument +f /file/to/create mode user group - content +F /file/to/create-or-truncate mode user group - content +w /file/to/write-to - - - - content +d /directory/to/create-and-cleanup mode user group cleanup-age - +D /directory/to/create-and-remove mode user group cleanup-age - +e /directory/to/cleanup mode user group cleanup-age - +v /subvolume/to/create mode user group - - +v /subvolume-or-directory/to/create mode user group - - +Q /subvolume/to/create mode user group - - +p /fifo/to/create mode user group - - +L /symlink/to/create - - - - symlink/target/path +c /dev/char-device-to-create mode user group - - +b /dev/block-device-to-create mode user group - - +# p+, L+, c+, b+ create target unconditionally +C /target/to/create - - - - /source/to/copy +x /path-or-glob/to/ignore - - - - - +X /path-or-glob/to/ignore/recursively - - - - - +r /empty/dir/to/remove - - - - - +R /dir/to/remove/recursively - - - - - +z /path-or-glob/to/adjust/mode mode user group - MAC context +Z /path-or-glob/to/adjust/mode/recursively mode user group - MAC context +t /path-or-glob/to/set/xattrs - - - - xattrs +T /path-or-glob/to/set/xattrs/recursively - - - - xattrs +h /path-or-glob/to/set/attrs - - - - file attrs +H /path-or-glob/to/set/attrs/recursively - - - - file attrs +a /path-or-glob/to/set/acls - - - - POSIX ACLs +A /path-or-glob/to/set/acls/recursively - - - - POSIX ACLs +# a+, A+ append ACLs +