Subject: Re: bug#29788: chown: recursive operation with "-H" flag does not work as documented

From: Paul Eggert <[email-masked]>
Date: Thu, 21 Dec 2017 08:58:18 -0800

On 12/20/2017 03:12 PM, Michael Orlitzky wrote:
> This is where I started off, but POSIX doesn't say anything about the
> "--dereference" flag.

Yes, well, a fundamental problem here is that POSIX is confused. The -H, 
-L, and -P options are clearly intended to control whether symlinks are 
followed, and the -h option is also intended to control the same thing, 
and POSIX doesn't say what happens when the two conflict. For example, 
'chown -RHh symlink-to-dir' clearly conflicts (-L means command-line 
symlinks to directories are followed, whereas -h means they are not), 
and POSIX does not say how to resolve the conflict.

The situation is further complicated by the fact that GNU chown treats 
-h as an option that affects all files, not just command-line files as 
POSIX would have it. And that GNU chown has a --dereference option that 
is intended to be the inverse of the -h option.

I think the *intent* of the GNU code is that -h/--dereference controls 
only whether lchown or chown is used, and that -H/-L/-P control only 
whether symlinks to directories are followed in a recursive chown. But 
(a) that's not what the code really does, (b) the intent does not 
conform to POSIX, (c) the code does not conform to POSIX either, and (d) 
as mentioned above, POSIX is broken. It's a true mess.