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