acl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Acl-devel] [PATCH 1/2] walk_tree: do not follow symlink to director


From: Andreas Gruenbacher
Subject: Re: [Acl-devel] [PATCH 1/2] walk_tree: do not follow symlink to directory with -h
Date: Wed, 25 May 2011 18:17:52 +0200
User-agent: KMail/1.12.4 (Linux/2.6.36-rc7+; KDE/4.3.5; i686; ; )

Kamil,

On Wednesday 22 December 2010 15:32:04 Kamil Dudka wrote:
> Hello,
> 
> attached is a proposed fix for <https://bugzilla.redhat.com/660613>.

This patch introduces an even more subtle interaction between -h, -R, -L, and
-P.  I can live with it if we clarify in the man page what's going on.  Are
you fine with this patch?


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
-- 

Thanks,
Andreas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]