Bug 215373

Summary: chgrp alters uid of a file when run on symlinks
Product: Red Hat Enterprise Linux 4 Reporter: Bryn M. Reeves <bmr>
Component: coreutilsAssignee: Tim Waugh <twaugh>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 4.4CC: jan.iven, meyering, sbhouchen
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2007-0786 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-11-15 16:09:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch correcting behavior of chgrp on symlinks none

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):
coreutils-5.2.1-31.4

How reproducible:
Always

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.

http://rhn.redhat.com/errata/RHBA-2007-0786.html