blob: 0c5d5dcf7f8d80136d61b53d32cd6f3437f79f7e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
$ mkdir d
$ cd d
$ touch f
$ setfattr -n user.test -v test f
$ ln -s f l
$ setfattr -h -n trusted.test -v test l
This case should be obvious:
$ getfattr -m- -d f
> # file: f
> user.test="test"
>
Without -h, we dereference symlinks:
$ getfattr -m- -d l
> # file: l
> user.test="test"
>
With -h, we do not dereference symlinks:
$ getfattr -m- -hd l
> # file: l
> trusted.test="test"
>
Do the same for symlinks we find in a directory hierarchy:
$ getfattr -m- -Rd . | ../sort-getfattr-output
> # file: f
> user.test="test"
>
> # file: l
> user.test="test"
>
$ getfattr -m- -Rhd . | ../sort-getfattr-output
> # file: f
> user.test="test"
>
> # file: l
> trusted.test="test"
>
Make sure we follow symlinks on the command line only when we should:
$ ln -s . here
$ getfattr -m- -Rd here | ../sort-getfattr-output
> # file: here/f
> user.test="test"
>
> # file: here/l
> user.test="test"
>
$ getfattr -m- -Rhd here
$ getfattr -m- -RLhd here | ../sort-getfattr-output
> # file: here/f
> user.test="test"
>
> # file: here/l
> trusted.test="test"
>
$ getfattr -m- -RPhd here
Make sure we recurse into sub-directories:
$ mkdir sub
$ mv f l sub
$ getfattr -m- -Rd . | ../sort-getfattr-output
> # file: sub/f
> user.test="test"
>
> # file: sub/l
> user.test="test"
>
$ getfattr -m- -Rhd . | ../sort-getfattr-output
> # file: sub/f
> user.test="test"
>
> # file: sub/l
> trusted.test="test"
>
Make sure we follow symlinks to directories only when we should:
$ mkdir sub2
$ ln -s ../sub sub2/to-sub
$ getfattr -m- -Rhd sub2
$ getfattr -m- -RLhd sub2 | ../sort-getfattr-output
> # file: sub2/to-sub/f
> user.test="test"
>
> # file: sub2/to-sub/l
> trusted.test="test"
>
$ getfattr -m- -RPhd sub2
Symlink loop detection:
$ ln -s .. sub/up
$ getfattr -m- -RLhd . | ../sort-getfattr-output
> # file: sub/f
> user.test="test"
>
> # file: sub/l
> trusted.test="test"
>
> # file: sub2/to-sub/f
> user.test="test"
>
> # file: sub2/to-sub/l
> trusted.test="test"
>
$ cd ..
$ rm -rf d
|