I searched the archives and it appears there was a related discussion in bug#61720, but that focused on aligning the documentation with the behaviour rather than the other way around.

I've been using touch+chown+chmod+chcon with the --reference= option to restore the metadata of a file that's had trivial (semantically insignificant) changes done to it.

This works except when the file in question is a symbolic link: this method does not reliably restore ownership, because 'chown -h --reference=ORIGINAL REPLACEMENT' doesn't actually look at the original symlink, it looks at the file it points at, or completely fails if that is inaccessible or nonexistent.

I would like the 'chown -h' and 'chcon -h' to work the same way as 'touch -h': as well as not following symlinks for targets, they should also not follow a symlink given as --reference=.

I know these would be incompatible changes, but to me this would seem more obvious, useful and consistent. What was the rationale for the existing behaviour, given that the POSIX specs for these commands lack any discussion of symlinks (and mostly they lack '-h' entirely)?

An alternative (or additional) approach would be to add new explicit options (such as '--symlink-reference' and '--follow-reference') to all of the inode metadata manipulation commands including 'chcon', 'chgrp', 'chmod', 'chown', & 'touch'.

I'm willing to provide patches for either or both of these approaches. (Whatever changes are made to 'chown', the corresponding changes would be made to 'chgrp'.)

Stepping back, I'm wondered about regularising the options available to all the file manipulation commands, so 'touch' would gain '-R', '-H', '-L', & '-P', and 'chmod' would gain '-h', '-H', '-L', & '-P' (functionality subject to whether the underlying FS supports fchmodat(..., AT_SYMLINK_NOFOLLOW) aka lchmod), plus the corresponding long options.

I hesitate to volunteer to implement 'touch --recurse' but if there's enough enthusiasm I'll certainly look at it.

Although it's out of scope for this mailing list, it would be ideal if these could be coordinated with the maintainers of 'chattr' (Linux 'e2fsprogs' package) and 'setfacl' (Linux 'acl' package).

Secondly, I note that 'touch -r' copies the atime and mtime separately; it would be nice to be able to have --atime= and --mtime= as separate options, as an alternative to both combined as --time=.
Again, I can provide a patch if this would be acceptable.

-Martin