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