summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-06-05 14:46:04 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-06-05 15:56:45 +0200
commit626f8d1672c57e0ebbe9331d98bd0cf841754bd6 (patch)
treeeddec0cffb072c4a8df9dd2507db52cb959032c9
parent99058cd66ad30707d8eda32d6b256e5c05bbf46a (diff)
downloadsystemd-626f8d1672c57e0ebbe9331d98bd0cf841754bd6.tar.gz
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.
-rw-r--r--src/tmpfiles/tmpfiles.c12
1 files 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);
}