path-util: simplify check_x_access()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 19 Jan 2021 19:43:32 +0000 (04:43 +0900)
committerLennart Poettering <lennart@poettering.net>
Wed, 20 Jan 2021 16:43:36 +0000 (17:43 +0100)
commit888f65ace6296ed61285d31db846babf1c11885e
tree9185e4435ce17fdc2bce797f92ebd1bc64327532
parentaac5fbff0b03e85ea156cf0bd821bd90c1b89096
path-util: simplify check_x_access()

Follow-up for ece852c84592220c3d6bb5a055fd8b84ea097290.

This addresses the following comments by the Lennart:
---
hmm, so this now does two access() calls for the case where the fd is
not requested, and opens things up for races (theoretically, …). now,
the access() code path was in place for optimization, but if an optimization
is less sexy than the original (and i think it is less sexy, since more
than one syscall, and non-atomic), i think we shouldn't do the optimization.

maybe we should just always use open(O_PATH) now, and then fstat() it to
check if regular file, and then access_fd() it for checking if its executable.
src/basic/path-util.c