GNU bug report logs -
#72707
install: need_copy (for "-C") should use stat instead of lstat
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#72707: install: need_copy (for "-C") should use stat instead of lstat
which was filed against the coreutils package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 72707 <at> debbugs.gnu.org.
--
72707: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72707
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (text/plain, inline)]
On 19/08/2024 03:44, Frank Heckenbach wrote:
> install dereferences symlinks given as sources (and I think that's
> good). The "-C" option, however, uses lstat rather than
> stat in need_copy and returns true if !S_ISREG.
>
> So the (dereferenced) file will always be copied despite "-C".
>
> Even worse, since "-p" cannot be combined with "-C", the installed
> file will always get a new timestamp which may trigger rebuilds
> (e.g. if the file is a header) even if nothing was changed, e.g.:
>
> % touch a
> % ln -s a b
> % install -C b c
> % ls --time-style=+%T -l
> total 0
> -rw------- 1 frank frank 0 23:46:51 a
> lrwxrwxrwx 1 frank frank 1 23:46:54 b -> a
> -rwxr-xr-x 1 frank frank 0 23:46:58 c
> % install -C b c
> % ls --time-style=+%T -l
> total 0
> -rw------- 1 frank frank 0 23:46:51 a
> lrwxrwxrwx 1 frank frank 1 23:46:54 b -> a
> -rwxr-xr-x 1 frank frank 0 23:47:06 c
> % install -C b c
> % ls --time-style=+%T -l
> total 0
> -rw------- 1 frank frank 0 23:46:51 a
> lrwxrwxrwx 1 frank frank 1 23:46:54 b -> a
> -rwxr-xr-x 1 frank frank 0 23:47:08 c
> %
>
> I asked Kamil Dudka who implemented "-C" originally and he pointed
> out that requiring both the files to be regular files was suggested
> by Jim Meyering in the review:
> https://lists.gnu.org/archive/html/bug-coreutils/2009-02/msg00106.html
>
> However, I don't see a real reason there, only his question:
> "Have you considered requiring that both files be `regular', too?"
>
> I don't know if install didn't dereference symlinks back then, but
> now that it does, it seems consistent to dereference them in the
> check as well, i.e. use stat rather than lstat.
I agree with your arguments to change this.
I'm not sure if the suggestion above about regular files,
was meant to preclude symlinks.
Marking this as done,
and I'll apply the attached later.
thanks,
Pádraig
[install-C-deref.patch (text/x-patch, attachment)]
[Message part 5 (message/rfc822, inline)]
install dereferences symlinks given as sources (and I think that's
good). The "-C" option, however, uses lstat rather than
stat in need_copy and returns true if !S_ISREG.
So the (dereferenced) file will always be copied despite "-C".
Even worse, since "-p" cannot be combined with "-C", the installed
file will always get a new timestamp which may trigger rebuilds
(e.g. if the file is a header) even if nothing was changed, e.g.:
% touch a
% ln -s a b
% install -C b c
% ls --time-style=+%T -l
total 0
-rw------- 1 frank frank 0 23:46:51 a
lrwxrwxrwx 1 frank frank 1 23:46:54 b -> a
-rwxr-xr-x 1 frank frank 0 23:46:58 c
% install -C b c
% ls --time-style=+%T -l
total 0
-rw------- 1 frank frank 0 23:46:51 a
lrwxrwxrwx 1 frank frank 1 23:46:54 b -> a
-rwxr-xr-x 1 frank frank 0 23:47:06 c
% install -C b c
% ls --time-style=+%T -l
total 0
-rw------- 1 frank frank 0 23:46:51 a
lrwxrwxrwx 1 frank frank 1 23:46:54 b -> a
-rwxr-xr-x 1 frank frank 0 23:47:08 c
%
I asked Kamil Dudka who implemented "-C" originally and he pointed
out that requiring both the files to be regular files was suggested
by Jim Meyering in the review:
https://lists.gnu.org/archive/html/bug-coreutils/2009-02/msg00106.html
However, I don't see a real reason there, only his question:
"Have you considered requiring that both files be `regular', too?"
I don't know if install didn't dereference symlinks back then, but
now that it does, it seems consistent to dereference them in the
check as well, i.e. use stat rather than lstat.
This bug report was last modified 277 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.