Bug 215373 - chgrp alters uid of a file when run on symlinks
Summary: chgrp alters uid of a file when run on symlinks
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: coreutils   
(Show other bugs)
Version: 4.4
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: Tim Waugh
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2006-11-13 18:37 UTC by Bryn M. Reeves
Modified: 2018-10-19 21:30 UTC (History)
3 users (show)

Fixed In Version: RHBA-2007-0786
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-11-15 16:09:13 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch correcting behavior of chgrp on symlinks (1.22 KB, patch)
2006-11-13 18:37 UTC, Bryn M. Reeves
no flags Details | Diff

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2007:0786 normal SHIPPED_LIVE coreutils bug fix update 2007-11-14 18:38:41 UTC

Description Bryn M. Reeves 2006-11-13 18:37:13 UTC
+++ This bug was initially created as a clone of Bug #171422 +++

Description of problem:
chgrp alters the ownership of a file when operating on a symbolic link. The same
behavior was reported in the FC4 coreutils and fixed in FC5 (coreutils-5.93-1).

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. create a file owned by user/group 'a'
2. create a symlink to the file owned by user/group 'b'
3. run chgrp on the symlink to change group ownership of the target to 'b'

Actual results:
Both the user & group ownership are assigned to 'b'

The problem happens because chgrp assumes it's OK to stat the argument and
simply propagate the uid to the file it is chgrping (src/chown-core.c:211).

That's OK in most cases but if the ownership of the link & target differ, the
ownership is incorrectly copied from the link to the target.

The FC4 version of this bug (bug 171422) was closed RAWHIDE when FC5 rebased the
package & there have been a large number of changes to this part of coreutils in
the meantime.

The attached patch attempts to take the minimum changes from  5.93 to correct
this behavior; we check if we're operating on a link & re-stat the file to get
the correct ownership.

Comment 1 Bryn M. Reeves 2006-11-13 18:37:14 UTC
Created attachment 141083 [details]
Patch correcting behavior of chgrp on symlinks

Comment 16 errata-xmlrpc 2007-11-15 16:09:13 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


Note You need to log in before you can comment on or make changes to this bug.