Git init
[framework/base/acl.git] / packaging / 02-499076-physical-walk.patch
1 commit d539830d19b35df0c12c0b7d36c1f6c428f34a91
2 Author: M. Steinborn <gnugv_maintainer@yahoo.de>
3 Date:   Fri Jan 22 14:37:04 2010 -0800
4
5     setfacl: make sure that -R only calls stat(2) on symlinks when it needs to
6     
7     Fixes http://savannah.nongnu.org/bugs/?28131
8     
9     Signed-off-by: Brandon Philips <bphilips@suse.de>
10
11 diff --git a/setfacl/setfacl.c b/setfacl/setfacl.c
12 index 802f060..731e417 100644
13 --- a/setfacl/setfacl.c
14 +++ b/setfacl/setfacl.c
15 @@ -76,7 +76,7 @@ struct option long_options[] = {
16  const char *progname;
17  const char *cmd_line_options, *cmd_line_spec;
18  
19 -int walk_flags = WALK_TREE_DEREFERENCE;
20 +int walk_flags = WALK_TREE_DEREFERENCE_TOPLEVEL;
21  int opt_recalculate;  /* recalculate mask entry (0=default, 1=yes, -1=no) */
22  int opt_promote;  /* promote access ACL to default ACL */
23  int opt_test;  /* do not write to the file system.
24 @@ -590,13 +590,15 @@ int main(int argc, char *argv[])
25                                 break;
26  
27                         case 'L':  /* follow symlinks */
28 -                               walk_flags |= WALK_TREE_LOGICAL;
29 +                               walk_flags |= WALK_TREE_LOGICAL | WALK_TREE_DEREFERENCE;
30                                 walk_flags &= ~WALK_TREE_PHYSICAL;
31                                 break;
32  
33                         case 'P':  /* do not follow symlinks */
34                                 walk_flags |= WALK_TREE_PHYSICAL;
35 -                               walk_flags &= ~WALK_TREE_LOGICAL;
36 +                               walk_flags |= WALK_TREE_PHYSICAL;
37 +                               walk_flags &= ~(WALK_TREE_LOGICAL | WALK_TREE_DEREFERENCE |
38 +                                               WALK_TREE_DEREFERENCE_TOPLEVEL);
39                                 break;
40  
41                         case 't':  /* test mode */
42 diff --git a/test/misc.test b/test/misc.test
43 index 7c62c64..d5d7680 100644
44 --- a/test/misc.test
45 +++ b/test/misc.test
46 @@ -424,3 +424,31 @@ Now, chmod should change the group_obj entry
47         > 
48  
49         $ rmdir d
50 +
51 +Dangling symlink test http://savannah.nongnu.org/bugs/?28131
52 +
53 +       $ mkdir d
54 +       $ ln -s d/a d/b
55 +       $ getfacl -R d
56 +       > # file: d
57 +       > # owner: %TUSER
58 +       > # group: %TGROUP
59 +       > user::rwx
60 +       > group::rwx
61 +       > other::r-x
62 +       > 
63 +       $ setfacl -R -m u:bin:rw d
64 +       $ getfacl -RL d
65 +       > getfacl: d/b: No such file or directory
66 +       > # file: d
67 +       > # owner: %TUSER
68 +       > # group: %TGROUP
69 +       > user::rwx
70 +       > user:bin:rw-
71 +       > group::rwx
72 +       > mask::rwx
73 +       > other::r-x
74 +       > 
75 +       $ setfacl -RL -m u:bin:rw d
76 +       > setfacl: d/b: No such file or directory
77 +       $ rm -R d