Blob Blame History Raw
From bad2f36467d1f606eb418542a23949743708304e Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
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 ++-
 test/attr.test      |    8 ++++++++
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/libmisc/walk_tree.c b/libmisc/walk_tree.c
index b82a301..e237e85 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/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 "
-- 
1.7.3.3