Show More
@@ -1,182 +1,182 b'' | |||
|
1 | 1 | #require unix-permissions |
|
2 | 2 | |
|
3 | 3 | test that new files created in .hg inherit the permissions from .hg/store |
|
4 | 4 | |
|
5 | 5 | $ mkdir dir |
|
6 | 6 | |
|
7 | 7 | just in case somebody has a strange $TMPDIR |
|
8 | 8 | |
|
9 | 9 | $ chmod g-s dir |
|
10 | 10 | $ cd dir |
|
11 | 11 | |
|
12 | 12 | $ cat >printmodes.py <<EOF |
|
13 | 13 | > from __future__ import absolute_import, print_function |
|
14 | 14 | > import os |
|
15 | 15 | > import sys |
|
16 | 16 | > |
|
17 | 17 | > allnames = [] |
|
18 | 18 | > isdir = {} |
|
19 | 19 | > for root, dirs, files in os.walk(sys.argv[1]): |
|
20 | 20 | > for d in dirs: |
|
21 | 21 | > name = os.path.join(root, d) |
|
22 | 22 | > isdir[name] = 1 |
|
23 | 23 | > allnames.append(name) |
|
24 | 24 | > for f in files: |
|
25 | 25 | > name = os.path.join(root, f) |
|
26 | 26 | > allnames.append(name) |
|
27 | 27 | > allnames.sort() |
|
28 | 28 | > for name in allnames: |
|
29 | 29 | > suffix = name in isdir and '/' or '' |
|
30 | 30 | > print('%05o %s%s' % (os.lstat(name).st_mode & 0o7777, name, suffix)) |
|
31 | 31 | > EOF |
|
32 | 32 | |
|
33 | 33 | $ cat >mode.py <<EOF |
|
34 | 34 | > from __future__ import absolute_import, print_function |
|
35 | 35 | > import os |
|
36 | 36 | > import sys |
|
37 | 37 | > print('%05o' % os.lstat(sys.argv[1]).st_mode) |
|
38 | 38 | > EOF |
|
39 | 39 | |
|
40 | 40 | $ umask 077 |
|
41 | 41 | |
|
42 | 42 | $ hg init repo |
|
43 | 43 | $ cd repo |
|
44 | 44 | |
|
45 | 45 | $ chmod 0770 .hg/store .hg/cache .hg/wcache |
|
46 | 46 | |
|
47 | 47 | before commit |
|
48 | 48 | store can be written by the group, other files cannot |
|
49 | 49 | store is setgid |
|
50 | 50 | |
|
51 | 51 | $ "$PYTHON" ../printmodes.py . |
|
52 | 52 | 00700 ./.hg/ |
|
53 | 53 | 00600 ./.hg/00changelog.i |
|
54 | 54 | 00770 ./.hg/cache/ |
|
55 | 55 | 00600 ./.hg/requires |
|
56 | 56 | 00770 ./.hg/store/ |
|
57 | 57 | 00770 ./.hg/wcache/ |
|
58 | 58 | |
|
59 | 59 | $ mkdir dir |
|
60 | 60 | $ touch foo dir/bar |
|
61 | 61 | $ hg ci -qAm 'add files' |
|
62 | 62 | |
|
63 | 63 | after commit |
|
64 | 64 | working dir files can only be written by the owner |
|
65 | 65 | files created in .hg can be written by the group |
|
66 | 66 | (in particular, store/**, dirstate, branch cache file, undo files) |
|
67 | 67 | new directories are setgid |
|
68 | 68 | |
|
69 | 69 | $ "$PYTHON" ../printmodes.py . |
|
70 | 70 | 00700 ./.hg/ |
|
71 | 71 | 00600 ./.hg/00changelog.i |
|
72 | 72 | 00770 ./.hg/cache/ |
|
73 | 73 | 00660 ./.hg/cache/branch2-served |
|
74 | 74 | 00660 ./.hg/cache/manifestfulltextcache (reporevlogstore !) |
|
75 | 75 | 00660 ./.hg/cache/rbc-names-v1 |
|
76 | 76 | 00660 ./.hg/cache/rbc-revs-v1 |
|
77 | 77 | 00660 ./.hg/dirstate |
|
78 | 78 | 00660 ./.hg/fsmonitor.state (fsmonitor !) |
|
79 | 79 | 00660 ./.hg/last-message.txt |
|
80 | 80 | 00600 ./.hg/requires |
|
81 | 81 | 00770 ./.hg/store/ |
|
82 | 82 | 00660 ./.hg/store/00changelog.i |
|
83 | 83 | 00660 ./.hg/store/00manifest.i |
|
84 | 84 | 00770 ./.hg/store/data/ |
|
85 | 85 | 00770 ./.hg/store/data/dir/ |
|
86 | 86 | 00660 ./.hg/store/data/dir/bar.i (reporevlogstore !) |
|
87 | 87 | 00660 ./.hg/store/data/foo.i (reporevlogstore !) |
|
88 | 88 | 00770 ./.hg/store/data/dir/bar/ (reposimplestore !) |
|
89 | 89 | 00660 ./.hg/store/data/dir/bar/b80de5d138758541c5f05265ad144ab9fa86d1db (reposimplestore !) |
|
90 | 90 | 00660 ./.hg/store/data/dir/bar/index (reposimplestore !) |
|
91 | 91 | 00770 ./.hg/store/data/foo/ (reposimplestore !) |
|
92 | 92 | 00660 ./.hg/store/data/foo/b80de5d138758541c5f05265ad144ab9fa86d1db (reposimplestore !) |
|
93 | 93 | 00660 ./.hg/store/data/foo/index (reposimplestore !) |
|
94 | 94 | 00660 ./.hg/store/fncache (repofncache !) |
|
95 | 95 | 00660 ./.hg/store/phaseroots |
|
96 | 96 | 00660 ./.hg/store/undo |
|
97 | 97 | 00660 ./.hg/store/undo.backupfiles |
|
98 | 98 | 00660 ./.hg/store/undo.phaseroots |
|
99 | 99 | 00660 ./.hg/undo.backup.dirstate |
|
100 | 100 | 00660 ./.hg/undo.bookmarks |
|
101 | 101 | 00660 ./.hg/undo.branch |
|
102 | 102 | 00660 ./.hg/undo.desc |
|
103 | 103 | 00660 ./.hg/undo.dirstate |
|
104 | 104 | 00770 ./.hg/wcache/ |
|
105 | 105 | 00711 ./.hg/wcache/checkisexec |
|
106 |
007 |
|
|
106 | 007.. ./.hg/wcache/checklink (re) | |
|
107 | 107 | 00600 ./.hg/wcache/checklink-target |
|
108 | 108 | 00700 ./dir/ |
|
109 | 109 | 00600 ./dir/bar |
|
110 | 110 | 00600 ./foo |
|
111 | 111 | |
|
112 | 112 | $ umask 007 |
|
113 | 113 | $ hg init ../push |
|
114 | 114 | |
|
115 | 115 | before push |
|
116 | 116 | group can write everything |
|
117 | 117 | |
|
118 | 118 | $ "$PYTHON" ../printmodes.py ../push |
|
119 | 119 | 00770 ../push/.hg/ |
|
120 | 120 | 00660 ../push/.hg/00changelog.i |
|
121 | 121 | 00770 ../push/.hg/cache/ |
|
122 | 122 | 00660 ../push/.hg/requires |
|
123 | 123 | 00770 ../push/.hg/store/ |
|
124 | 124 | 00770 ../push/.hg/wcache/ |
|
125 | 125 | |
|
126 | 126 | $ umask 077 |
|
127 | 127 | $ hg -q push ../push |
|
128 | 128 | |
|
129 | 129 | after push |
|
130 | 130 | group can still write everything |
|
131 | 131 | |
|
132 | 132 | $ "$PYTHON" ../printmodes.py ../push |
|
133 | 133 | 00770 ../push/.hg/ |
|
134 | 134 | 00660 ../push/.hg/00changelog.i |
|
135 | 135 | 00770 ../push/.hg/cache/ |
|
136 | 136 | 00660 ../push/.hg/cache/branch2-base |
|
137 | 137 | 00660 ../push/.hg/dirstate |
|
138 | 138 | 00660 ../push/.hg/requires |
|
139 | 139 | 00770 ../push/.hg/store/ |
|
140 | 140 | 00660 ../push/.hg/store/00changelog.i |
|
141 | 141 | 00660 ../push/.hg/store/00manifest.i |
|
142 | 142 | 00770 ../push/.hg/store/data/ |
|
143 | 143 | 00770 ../push/.hg/store/data/dir/ |
|
144 | 144 | 00660 ../push/.hg/store/data/dir/bar.i (reporevlogstore !) |
|
145 | 145 | 00660 ../push/.hg/store/data/foo.i (reporevlogstore !) |
|
146 | 146 | 00770 ../push/.hg/store/data/dir/bar/ (reposimplestore !) |
|
147 | 147 | 00660 ../push/.hg/store/data/dir/bar/b80de5d138758541c5f05265ad144ab9fa86d1db (reposimplestore !) |
|
148 | 148 | 00660 ../push/.hg/store/data/dir/bar/index (reposimplestore !) |
|
149 | 149 | 00770 ../push/.hg/store/data/foo/ (reposimplestore !) |
|
150 | 150 | 00660 ../push/.hg/store/data/foo/b80de5d138758541c5f05265ad144ab9fa86d1db (reposimplestore !) |
|
151 | 151 | 00660 ../push/.hg/store/data/foo/index (reposimplestore !) |
|
152 | 152 | 00660 ../push/.hg/store/fncache (repofncache !) |
|
153 | 153 | 00660 ../push/.hg/store/undo |
|
154 | 154 | 00660 ../push/.hg/store/undo.backupfiles |
|
155 | 155 | 00660 ../push/.hg/store/undo.phaseroots |
|
156 | 156 | 00660 ../push/.hg/undo.bookmarks |
|
157 | 157 | 00660 ../push/.hg/undo.branch |
|
158 | 158 | 00660 ../push/.hg/undo.desc |
|
159 | 159 | 00660 ../push/.hg/undo.dirstate |
|
160 | 160 | 00770 ../push/.hg/wcache/ |
|
161 | 161 | |
|
162 | 162 | |
|
163 | 163 | Test that we don't lose the setgid bit when we call chmod. |
|
164 | 164 | Not all systems support setgid directories (e.g. HFS+), so |
|
165 | 165 | just check that directories have the same mode. |
|
166 | 166 | |
|
167 | 167 | $ cd .. |
|
168 | 168 | $ hg init setgid |
|
169 | 169 | $ cd setgid |
|
170 | 170 | $ chmod g+rwx .hg/store |
|
171 | 171 | $ chmod g+s .hg/store 2> /dev/null || true |
|
172 | 172 | $ mkdir dir |
|
173 | 173 | $ touch dir/file |
|
174 | 174 | $ hg ci -qAm 'add dir/file' |
|
175 | 175 | $ storemode=`"$PYTHON" ../mode.py .hg/store` |
|
176 | 176 | $ dirmode=`"$PYTHON" ../mode.py .hg/store/data/dir` |
|
177 | 177 | $ if [ "$storemode" != "$dirmode" ]; then |
|
178 | 178 | > echo "$storemode != $dirmode" |
|
179 | 179 | > fi |
|
180 | 180 | $ cd .. |
|
181 | 181 | |
|
182 | 182 | $ cd .. # g-s dir |
General Comments 0
You need to be logged in to leave comments.
Login now