RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 665049 - getfattr follows the links despite option -h
Summary: getfattr follows the links despite option -h
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: attr
Version: 6.0
Hardware: Unspecified
OS: Linux
low
high
Target Milestone: rc
: ---
Assignee: Kamil Dudka
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On: 660613
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-12-22 14:54 UTC by Kamil Dudka
Modified: 2011-09-07 13:07 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Prior to this update, the getfattr utility followed symbolic links to directories even if the "-h" (or "--no-dereference") option was specified. Additionally, the description in the getfattr(1) man page related to the aforementioned functionality was not intelligible. These problems have been fixed in this update so that getfattr with the "-h" option no longer follows symbolic links and the related content of the getfattr(1) man page is now intelligible.
Clone Of: 660613
Environment:
Last Closed: 2011-09-07 13:07:29 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1272 0 normal SHIPPED_LIVE attr bug fix update 2011-09-07 13:07:08 UTC

Description Kamil Dudka 2010-12-22 14:54:12 UTC
+++ This bug was initially created as a clone of Bug #660613 +++

Description of problem:

When the argument is a symbolic link to a directory, getfacl displays the attributes for the whole directory, despite option -h forbidding to follow the link.

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

Fedora 14, acl-2.2.49-8, libacl-2.2.49-8

How reproducible:

Always

Steps to Reproduce:
1. mount with option user_xattr
2. create a target file in an inner directory (eg. src/target)
3. set an xattr ("setfattr -v blue -n user.color src/target")
4. create a symlink to the directory ("ln -s src symlink")
5. display the xattr of the symlink ("getfattr -h -e hex -n user.color symlink")
  
Actual results:

The symlink is followed and the contents of the target directory is examined

Expected results:

Per manual, the option -h prevents the symlink from being followed

Additional info:

--- Additional comment from jean-pierre.andre on 2010-12-07 11:54:12 CET ---

Oops, this is about getfattr, not getfacl, the versions are attr-2.4.44-5 and libattr-2.4.44-5

--- Additional comment from kdudka on 2010-12-07 18:31:15 CET ---

Thanks for reporting the bug!  It looks indeed broken to me.  The following patch fixes it:

diff --git a/libmisc/walk_tree.c b/libmisc/walk_tree.c
--- a/libmisc/walk_tree.c
+++ b/libmisc/walk_tree.c
@@ -60,7 +60,8 @@ static int walk_tree_rec(const char *path, int walk_flags,
                                     void *), void *arg, int depth)
 {
        int follow_symlinks = (walk_flags & WALK_TREE_LOGICAL) ||
-                             (!(walk_flags & WALK_TREE_PHYSICAL) &&
+                             ((walk_flags & WALK_TREE_DEREFERENCE) &&
+                              !(walk_flags & WALK_TREE_PHYSICAL) &&
                               depth == 0);
        int have_dir_stat = 0, flags = walk_flags, err;
        struct entry_handle dir;

I'll prepare some regression test and post it on the upstream ML.

--- Additional comment from jean-pierre.andre on 2010-12-07 21:43:26 CET ---

Behaves as expected with fix applied. Thanks.

--- Additional comment from agruen on 2010-12-15 02:49:55 CET ---

What kernel version did you test this on?  I'm getting the following buggy 
result from "getfattr -h -n user.color link" with Kamil's fix:

  getxattr("link", "user.color", 0x0, 0) = -1 EPERM (Operation not permitted)

This shouldn't be; we should be getting -ENODATA here.  This seems to be due to a bug in kernel commit f1f2d871l whic hfirst showed up in v2.6.19-rc5.  I'm currently testing a fix for that.

--- Additional comment from jean-pierre.andre on 2010-12-15 09:57:47 CET ---

I also get the EPERM (kernel 2.6.35.6-48, attr 2.4.44-5) both with unpatched attr or patched as suggested by Kamil.

$ touch target
$ ln -s target symlink
$ getfattr -h -e hex -n user.color symlink
symlink: user.color: Operation not permitted
$ strace getfattr -h -e hex -n user.color symlink
[...]
lstat("symlink", {st_mode=S_IFLNK|0777, st_size=6, ...}) = 0
lgetxattr("symlink", "user.color", 0x0, 0) = -1 EPERM (Operation not permitted)

Same result for a symlink to a directory (also when requested by root).
This appears as specific to the user name space. In the system name space, I get the expected result (this is with patched attr, otherwise the full directory is examined). The above was on ext3, below is on ntfs.

$ ls -l "/vista/Documents and Settings"
lrwxrwxrwx 2 root root 60 Nov  2  2006 /vista/Documents and Settings -> /vista/Users
$ getfattr -e hex -n system.ntfs_object_id "/vista/Documents and Settings"
/vista/Documents and Settings: system.ntfs_object_id: No such attribute
$ strace getfattr -e hex -n system.ntfs_object_id "/vista/Documents and Settings"
getxattr("/vista/Documents and Settings", "system.ntfs_object_id", 0x0, 0) = -1 ENODATA (No data available)

--- Additional comment from jean-pierre.andre on 2010-12-15 10:06:40 CET ---

I should have put a -h in the last example in my previous post. Here it is :

strace getfattr -h -e hex -n system.ntfs_object_id "/vista/Documents and Settings"
lgetxattr("/vista/Documents and Settings", "system.ntfs_object_id", 0x0, 0) = -1 ENODATA (No data available)

--- Additional comment from kdudka on 2010-12-22 14:49:47 CET ---

Right, I am running 2.6.35.6-48.fc14.x86_64 and also getting EPERM on the symlink.  But we should definitely not follow symlinks when -h is given.  So the fix for getfattr goes the right direction I think.

Note the reproducer from comment #5 did not repeat the original bug for me,  the reproducer from comment #0 did.  The bug is specific to directory tree traversal.

--- Additional comment from kdudka on 2010-12-22 15:49:06 CET ---

fixed in attr-2.4.44-6.fc15

Comment 1 Kamil Dudka 2010-12-22 16:51:05 UTC
proposed upstream:

http://lists.gnu.org/archive/html/acl-devel/2010-12/msg00003.html

Comment 2 RHEL Program Management 2011-01-07 15:32:38 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. Red Hat invites you to
ask your support representative to propose this request, if
appropriate and relevant, in the next release of Red Hat
Enterprise Linux. If you would like it considered as an
exception in the current release, please ask your support
representative.

Comment 5 Kamil Dudka 2011-06-27 15:59:43 UTC
upstream commit:

http://git.savannah.gnu.org/cgit/attr.git/commit/?id=2c053e7

Comment 7 Petr Kovar 2011-06-29 11:12:04 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Prior to this update, the getfattr utility followed symbolic links to directories even if the "-h" (or "--no-dereference") option was specified. Additionally, the description in the getfattr(1) man page related to the aforementioned functionality was not intelligible. These problems have been fixed in this update so that getfattr with the "-h" option no longer follows symbolic links and the related content of the getfattr(1) man page is now intelligible.

Comment 14 errata-xmlrpc 2011-09-07 13:07:29 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 therefore 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-2011-1272.html


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