File attr-bz665049.patch of Package attr
From 1ef1a4662ee5adec8ca1989130cae2e89eb1b403 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <address@hidden>
Date: Wed, 22 Dec 2010 15:03:48 +0100
Subject: [PATCH] walk_tree: do not follow symlink to directory with -h
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
reported by Jean-Pierre André at https://bugzilla.redhat.com/660613
---
libmisc/walk_tree.c | 3 ++-
man/man1/getfattr.1 | 8 +++++---
test/attr.test | 8 ++++++++
test/root/getfattr.test | 6 ------
4 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/libmisc/walk_tree.c b/libmisc/walk_tree.c
index 2777145..ff1dd52 100644
--- 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;
diff --git a/man/man1/getfattr.1 b/man/man1/getfattr.1
index 40f735d..af4411c 100644
--- a/man/man1/getfattr.1
+++ b/man/man1/getfattr.1
@@ -79,7 +79,8 @@ while strings encoded as hexidecimal and base64 are prefixed with
.TP
.BR \-h ", " \-\-no-dereference
Do not dereference symlinks. Instead of the file a symlink refers to, the
-symlink itself is examined.
+symlink itself is examined. Unless doing a logical (\-L) traversal, do not
+traverse symlinks to directories.
.TP
.BR \-m " \f2pattern\f1, " \-\-match "=\f2pattern\f1"
Only include attributes with names matching the regular expression
@@ -104,8 +105,9 @@ List the attributes of all files and directories recursively.
.TP
.BR \-L ", " \-\-logical
Logical walk, follow symbolic links to directories.
-The default behaviour is to follow symbolic link arguments, and to
-skip symbolic links encountered in subdirectories.
+The default behaviour is to follow symbolic link arguments unless
+\-\-no\-dereference is given, and to skip symbolic links encountered in
+subdirectories.
Only effective in combination with \-R.
.TP
.BR \-P ", " \-\-physical
diff --git a/test/attr.test b/test/attr.test
index 10f10d0..a3e472d 100644
--- a/test/attr.test
+++ b/test/attr.test
@@ -221,6 +221,14 @@ Attributes of symlinks vs. the files pointed to
$ rm f
+Attributes of symlinks vs. the files pointed to in a directory
+
+ $ mkdir src
+ $ touch src/target
+ $ setfattr -n user.color -v blue src/target
+ $ ln -s src symlink
+ $ getfattr -n user.color -h symlink 2>/dev/null
+
Tests for file name that contain special characters
$ touch "f "
diff --git a/test/root/getfattr.test b/test/root/getfattr.test
index c9458e6..e51807d 100644
--- a/test/root/getfattr.test
+++ b/test/root/getfattr.test
@@ -52,12 +52,6 @@ Make sure we follow symlinks on the command line only when we should:
>
$ getfattr -m- -Rhd here
- > # file: here/f
- > user.test="test"
- >
- > # file: here/l
- > trusted.test="test"
- >
$ getfattr -m- -RLhd here
> # file: here/f
--
1.7.4.4