chase: drop CHASE_AT_RESOLVE_IN_ROOT when AT_FDCWD or root dir fd is specified

If we get AT_FDCWD or root dir fd, we always resolve symlinks relative to the host's root.
Hence, the flag is meaningless.
This commit is contained in:
Yu Watanabe
2023-03-30 16:29:37 +09:00
parent c4406ff710
commit e115daa6a8
+14
View File
@@ -164,6 +164,20 @@ int chaseat(
* the mount point is emitted. CHASE_WARN cannot be used in PID 1.
*/
if (FLAGS_SET(flags, CHASE_AT_RESOLVE_IN_ROOT)) {
/* If we get AT_FDCWD or dir_fd points to "/", then we always resolve symlinks relative to
* the host's root. Hence, CHASE_AT_RESOLVE_IN_ROOT is meaningless. */
if (dir_fd >= 0)
r = dir_fd_is_root(dir_fd);
else
r = true;
if (r < 0)
return r;
if (r > 0)
flags &= ~CHASE_AT_RESOLVE_IN_ROOT;
}
if (!(flags &
(CHASE_AT_RESOLVE_IN_ROOT|CHASE_NONEXISTENT|CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_STEP|
CHASE_PROHIBIT_SYMLINKS|CHASE_MKDIR_0755)) &&