]> git.ipfire.org Git - thirdparty/systemd.git/commit
fs-util: prefer glibc's fchmodat() if possible
authorLuca Boccassi <luca.boccassi@gmail.com>
Tue, 23 Sep 2025 22:13:23 +0000 (23:13 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 24 Sep 2025 06:48:42 +0000 (08:48 +0200)
commit696b1263dc78858f96345a366933c66d53ae4899
tree1d47c7d9e4894acd027e636fbc05967b5f220b8a
parent264608e8c33ca89853fec561a76e2f30a95e5cfd
fs-util: prefer glibc's fchmodat() if possible

Since v2.39 glibc's fchmodat() will call into the kernel's fchmodat2()
if flags are passed:

https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=65341f7bbea824d2ff9d37db15d8be162df42bd3;hp=c52c2c32db15aba8bbe1a0b4d3235f97d9c1a525

On older versions, if the flag is anything other than AT_SYMLINK_NOFOLLOW,
it returns EINVAL, so we can detect it and call the kernel syscall directly
ourselves.

Using the glibc wrappers when possible is prefereable so that programs
like fakeroot can intercept its calls and redirect them.

Follow-up for adecfb3bc0be0def49433277fcad5333893756cc
src/basic/fs-util.c