summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Dudka <address@hidden>2010-12-22 15:03:48 +0100
committerAndreas Gruenbacher <agruen@linbit.com>2011-05-25 18:14:36 +0200
commit2c053e75d44016dd6b07649a356c1ce55dbe1028 (patch)
tree7e8fd1c4ec7102c8e49b448cea3b33ae5fd2ff06
parent3c6518e3e604dafbd806663c161166fde672b82d (diff)
downloadattr-2c053e75d44016dd6b07649a356c1ce55dbe1028.tar.gz
walk_tree: do not follow symlink to directory with -h
reported by Jean-Pierre André at https://bugzilla.redhat.com/660613
-rw-r--r--libmisc/walk_tree.c3
-rw-r--r--man/man1/getfattr.18
-rw-r--r--test/attr.test8
-rw-r--r--test/root/getfattr.test8
4 files changed, 16 insertions, 11 deletions
diff --git a/libmisc/walk_tree.c b/libmisc/walk_tree.c
index 30ff92a..2be9d47 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 53beb84..5ad2177 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 d394562..4a14c2f 100644
--- a/test/attr.test
+++ b/test/attr.test
@@ -217,6 +217,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 6fdb135..0c5d5dc 100644
--- a/test/root/getfattr.test
+++ b/test/root/getfattr.test
@@ -51,13 +51,7 @@ Make sure we follow symlinks on the command line only when we should:
> user.test="test"
>
- $ getfattr -m- -Rhd here | ../sort-getfattr-output
- > # file: here/f
- > user.test="test"
- >
- > # file: here/l
- > trusted.test="test"
- >
+ $ getfattr -m- -Rhd here
$ getfattr -m- -RLhd here | ../sort-getfattr-output
> # file: here/f