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).
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user