Subject: bug#70411: [bug] install(1) fails to read /dev/stdin on Darwin

From: Alejandro Colomar <[email-masked]>
Date: Tue, 16 Apr 2024 16:47:39 +0200

Hi Pádraig,

On Tue, Apr 16, 2024 at 03:25:22PM +0100, Pádraig Brady wrote:
> > What version of darwin is this? I can't repro on Darwin 21.6.0 (MacOSX 12.6).
> > The issue seems to be that /dev/stdin returns a varying inode which install(1) doesn't like currently

I don't know.  The reporter didn't tell.  I see you also asked on the
Github original report.

> Note that check originally came from:
> https://github.com/coreutils/coreutils/commit/dea4262fa
> 
> I suppose we could relax the check as follows, for files of apparent size 0
> which would cater for this, and others that may also have unstable inodes.

Hmmmm.  Since you couldn't reprodude it in a recent Darwin, maybe it's
just a bug in an old Darwin.  And since noone else seems to have met
this Darwin's bug, maybe we can just ignore it.  (And if it were a
regression in a more recent Darwin, hopefully they should fix their
kernel.)

I'm not happy relaxing a security check, without making sure that there
are no implications at all.

I vote for claiming only limited support to such a Darwin system.  I
already workarounded it in the Linux man-pages, by not piping to
install(1) in a common task; and nobody else seems to be affected.

Unless you feel confident that it's perfectly fine to do it.  But I have
no sympathy for workarounding Darwin bugs here.

Have a lovely day!
Alex

> 
> cheers,
> Pádraig.
> 
> diff --git a/src/copy.c b/src/copy.c
> index 2145d89d5..fb5f0a1a0 100644
> --- a/src/copy.c
> +++ b/src/copy.c
> @@ -1263,8 +1263,11 @@ copy_reg (char const *src_name, char const *dst_name,
>      }
> 
>    /* Compare the source dev/ino from the open file to the incoming,
> -     saved ones obtained via a previous call to stat.  */
> -  if (! psame_inode (src_sb, &src_open_sb))
> +     saved ones obtained via a previous call to stat.  Restrict
> +     the check to files with an apparent size, to support "files"
> +     with unstable inodes, like /dev/stdin on macOS.  */
> +  if (! psame_inode (src_sb, &src_open_sb)
> +      && (src_sb->st_size || src_open_sb.st_size))
>      {
>        error (0, 0,
>               _("skipping file %s, as it was replaced while being copied"),
> 
> 

-- 
<https://www.alejandro-colomar.es/>