On 14/11/2026 07:38, Collin Funk wrote:
Thai Duong <[email protected]> writes:
Thanks, will do!
And thanks to you for the report! It was reported by Anthropic's OSS
scanner as well, which is interesting. I'll reference both reports in
the commit message.
I've attached a patch that should fix the issue. However, I'm going to
hold off on pushing until I write some additional tests tomorrow, since
the changes mean chown/chmod can be called from two separate places, one
of which is shared with 'cp' and 'mv'.
Avoiding this race, and some other ones around this area, means using
reflinks less on macOS, which I am not super happy about. As far as I
know, Linux is the only operating system with the ability to reflink
from two file descriptors. The macOS API is marginally better than
Solaris since you can reflink from a source file descriptor, but you
still need to open the destination afterward, which may be replaced with
something else.
This change looks good.
There is a new dependency where the lchmodat() used with `install -s`
introduces a new dependency on /proc being available on glibc < 2.39,
or on kernels < 6.6, but I have a separate patch to gnulib to provide
a fallback on such systems, so I think this patch is fine.
This patch also changes things so the final permission is set (say +x)
in the case where close() fails due to a delayed EIO.
But I don't think that's a practical concern as install(1) doesn't
provide atomic replacement of the destination anyway,
which would be the way to robustly handle this and other races.
thank you,
Padraig