"Matthew \"Cheetah\" Gabeler-Lee" <[EMAIL PROTECTED]> wrote:
> Subject: coreutils: chown --dereference changes gid when it shouldn't
> Version: 5.2.1-2
>
> If one uses chown with --dereference to only set the owner, it incorrectly
> may change the group as well.  It will set the owner of the pointed-to item
> to the owner requested, but then also change the group to the group of the
> symlink.
>
> This happens because chown reads owner and group from the filename passed,
> but then, if --dereference is in effect, runs the chown against the file
> pointed to.  The offending code is in src/chown-core.c, approximately lines
> 211 to 225, and also in the chown_files function.  In dereference mode, it
> needs to not only apply the changes to the dereferenced file, but also to
> read the current ownership from the dereferenced file.

Thanks for the report.
This is fixed upstream, in coreutils-5.3.0.
For reference, here's what I did to show that:

  # touch f
  # chown 1:2 f
  # ln -s f slink
  # ./chown --deref 4 slink
  # stat -c '%g' f; echo
  2
  # /bin/chown --deref 4 slink
  # stat -c '%g' f; echo
  0


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to