From: David Michael Date: Mon, 25 Feb 2019 18:26:07 +0000 (-0500) Subject: tmpfiles: pass arg_root to chase_symlinks as the root prefix X-Git-Tag: v242-rc1~208^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3aa4adcafa046da7c41ef2e5411fc8dd8feecaa;p=thirdparty%2Fsystemd.git tmpfiles: pass arg_root to chase_symlinks as the root prefix This informs chase_symlinks that symlinks should be treated as if the path given by --root= is the root of their file system. With the parent commit, this allows tmpfiles to create files as the root user under a prefix that may be owned by an unprivileged user. In particular, this fixes the case where tmpfiles generates initial files in a staging root directory for packaging under a directory owned by the unprivileged packager user (e.g. in Gentoo). --- diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 6296a8acdf2..801e79b01d7 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -856,7 +856,7 @@ static int path_open_parent_safe(const char *path) { if (!dn) return log_oom(); - fd = chase_symlinks(dn, NULL, CHASE_OPEN|CHASE_SAFE|CHASE_WARN, NULL); + fd = chase_symlinks(dn, arg_root, CHASE_OPEN|CHASE_SAFE|CHASE_WARN, NULL); if (fd < 0 && fd != -ENOLINK) return log_error_errno(fd, "Failed to validate path %s: %m", path); @@ -877,7 +877,7 @@ static int path_open_safe(const char *path) { "Failed to open invalid path '%s'.", path); - fd = chase_symlinks(path, NULL, CHASE_OPEN|CHASE_SAFE|CHASE_WARN|CHASE_NOFOLLOW, NULL); + fd = chase_symlinks(path, arg_root, CHASE_OPEN|CHASE_SAFE|CHASE_WARN|CHASE_NOFOLLOW, NULL); if (fd < 0 && fd != -ENOLINK) return log_error_errno(fd, "Failed to validate path %s: %m", path); @@ -2256,7 +2256,7 @@ static int process_item(Item *i, OperationMask operation) { i->done |= operation; - r = chase_symlinks(i->path, NULL, CHASE_NO_AUTOFS|CHASE_WARN, NULL); + r = chase_symlinks(i->path, arg_root, CHASE_NO_AUTOFS|CHASE_WARN, NULL); if (r == -EREMOTE) { log_notice_errno(r, "Skipping %s", i->path); return 0;