547bcf6
From bad2f36467d1f606eb418542a23949743708304e Mon Sep 17 00:00:00 2001
547bcf6
From: Kamil Dudka <kdudka@redhat.com>
547bcf6
Date: Wed, 22 Dec 2010 15:03:48 +0100
547bcf6
Subject: [PATCH] walk_tree: do not follow symlink to directory with -h
547bcf6
MIME-Version: 1.0
547bcf6
Content-Type: text/plain; charset=UTF-8
547bcf6
Content-Transfer-Encoding: 8bit
547bcf6
547bcf6
reported by Jean-Pierre André at https://bugzilla.redhat.com/660613
547bcf6
---
547bcf6
 libmisc/walk_tree.c |    3 ++-
547bcf6
 test/attr.test      |    8 ++++++++
547bcf6
 2 files changed, 10 insertions(+), 1 deletions(-)
547bcf6
547bcf6
diff --git a/libmisc/walk_tree.c b/libmisc/walk_tree.c
547bcf6
index b82a301..e237e85 100644
547bcf6
--- a/libmisc/walk_tree.c
547bcf6
+++ b/libmisc/walk_tree.c
547bcf6
@@ -60,7 +60,8 @@ static int walk_tree_rec(const char *path, int walk_flags,
547bcf6
 				     void *), void *arg, int depth)
547bcf6
 {
547bcf6
 	int follow_symlinks = (walk_flags & WALK_TREE_LOGICAL) ||
547bcf6
-			      (!(walk_flags & WALK_TREE_PHYSICAL) &&
547bcf6
+			      ((walk_flags & WALK_TREE_DEREFERENCE) &&
547bcf6
+			       !(walk_flags & WALK_TREE_PHYSICAL) &&
547bcf6
 			       depth == 0);
547bcf6
 	int have_dir_stat = 0, flags = walk_flags, err;
547bcf6
 	struct entry_handle dir;
547bcf6
diff --git a/test/attr.test b/test/attr.test
547bcf6
index 10f10d0..a3e472d 100644
547bcf6
--- a/test/attr.test
547bcf6
+++ b/test/attr.test
547bcf6
@@ -221,6 +221,14 @@ Attributes of symlinks vs. the files pointed to
547bcf6
 
547bcf6
 	$ rm f
547bcf6
 
547bcf6
+Attributes of symlinks vs. the files pointed to in a directory
547bcf6
+
547bcf6
+	$ mkdir src
547bcf6
+	$ touch src/target
547bcf6
+	$ setfattr -n user.color -v blue src/target
547bcf6
+	$ ln -s src symlink
547bcf6
+	$ getfattr -n user.color -h symlink 2>/dev/null
547bcf6
+
547bcf6
 Tests for file name that contain special characters
547bcf6
 
547bcf6
 	$ touch "f "
547bcf6
-- 
547bcf6
1.7.3.3
547bcf6