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