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