]> git.ipfire.org Git - thirdparty/systemd.git/commit
chase: check the result is a directory or regular file only when the resolved path...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 28 Jul 2025 18:25:17 +0000 (03:25 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 28 Jul 2025 18:37:48 +0000 (03:37 +0900)
commit1cabb6905b98ecc11bfb1fd8305c8f5c089e5c32
tree5759402012e45003582347a65a546315d9170c5f
parentbe876c5933a5eb223565e70773746a4b49d49c9f
chase: check the result is a directory or regular file only when the resolved path exists

Otherwise, if it is called with CHASE_NONEXISTENT, when we call
stat_verify_directory()/_regular() the struct stat is for one of the
parent directory, rather than for the result path.

With this change, we can safely specify CHASE_MUST_BE_DIRECTORY/REGULAR
with CHASE_NONEXISTENT.

More importantly, chaseat() internally sets CHASE_MUST_BE_DIRECTORY when
the input path ends with "/", "/,", "/..". Hence, without this change,
we cannot specify CHASE_NONEXISTENT safely.

Follow-up for 90b9f7a07e6f57825f416f6ce2db0a9f2086754b.
src/basic/chase.c