Show More
@@ -1,369 +1,374 b'' | |||||
1 | import os, stat |
|
1 | import os, stat | |
2 | import re |
|
2 | import re | |
3 | import socket |
|
3 | import socket | |
4 | import sys |
|
4 | import sys | |
5 | import tempfile |
|
5 | import tempfile | |
6 |
|
6 | |||
7 | tempprefix = 'hg-hghave-' |
|
7 | tempprefix = 'hg-hghave-' | |
8 |
|
8 | |||
9 | checks = { |
|
9 | checks = { | |
10 | "true": (lambda: True, "yak shaving"), |
|
10 | "true": (lambda: True, "yak shaving"), | |
11 | "false": (lambda: False, "nail clipper"), |
|
11 | "false": (lambda: False, "nail clipper"), | |
12 | } |
|
12 | } | |
13 |
|
13 | |||
14 | def check(name, desc): |
|
14 | def check(name, desc): | |
15 | def decorator(func): |
|
15 | def decorator(func): | |
16 | checks[name] = (func, desc) |
|
16 | checks[name] = (func, desc) | |
17 | return func |
|
17 | return func | |
18 | return decorator |
|
18 | return decorator | |
19 |
|
19 | |||
20 | def matchoutput(cmd, regexp, ignorestatus=False): |
|
20 | def matchoutput(cmd, regexp, ignorestatus=False): | |
21 | """Return True if cmd executes successfully and its output |
|
21 | """Return True if cmd executes successfully and its output | |
22 | is matched by the supplied regular expression. |
|
22 | is matched by the supplied regular expression. | |
23 | """ |
|
23 | """ | |
24 | r = re.compile(regexp) |
|
24 | r = re.compile(regexp) | |
25 | fh = os.popen(cmd) |
|
25 | fh = os.popen(cmd) | |
26 | s = fh.read() |
|
26 | s = fh.read() | |
27 | try: |
|
27 | try: | |
28 | ret = fh.close() |
|
28 | ret = fh.close() | |
29 | except IOError: |
|
29 | except IOError: | |
30 | # Happen in Windows test environment |
|
30 | # Happen in Windows test environment | |
31 | ret = 1 |
|
31 | ret = 1 | |
32 | return (ignorestatus or ret is None) and r.search(s) |
|
32 | return (ignorestatus or ret is None) and r.search(s) | |
33 |
|
33 | |||
34 | @check("baz", "GNU Arch baz client") |
|
34 | @check("baz", "GNU Arch baz client") | |
35 | def has_baz(): |
|
35 | def has_baz(): | |
36 | return matchoutput('baz --version 2>&1', r'baz Bazaar version') |
|
36 | return matchoutput('baz --version 2>&1', r'baz Bazaar version') | |
37 |
|
37 | |||
38 | @check("bzr", "Canonical's Bazaar client") |
|
38 | @check("bzr", "Canonical's Bazaar client") | |
39 | def has_bzr(): |
|
39 | def has_bzr(): | |
40 | try: |
|
40 | try: | |
41 | import bzrlib |
|
41 | import bzrlib | |
42 | return bzrlib.__doc__ is not None |
|
42 | return bzrlib.__doc__ is not None | |
43 | except ImportError: |
|
43 | except ImportError: | |
44 | return False |
|
44 | return False | |
45 |
|
45 | |||
46 | @check("bzr114", "Canonical's Bazaar client >= 1.14") |
|
46 | @check("bzr114", "Canonical's Bazaar client >= 1.14") | |
47 | def has_bzr114(): |
|
47 | def has_bzr114(): | |
48 | try: |
|
48 | try: | |
49 | import bzrlib |
|
49 | import bzrlib | |
50 | return (bzrlib.__doc__ is not None |
|
50 | return (bzrlib.__doc__ is not None | |
51 | and bzrlib.version_info[:2] >= (1, 14)) |
|
51 | and bzrlib.version_info[:2] >= (1, 14)) | |
52 | except ImportError: |
|
52 | except ImportError: | |
53 | return False |
|
53 | return False | |
54 |
|
54 | |||
55 | @check("cvs", "cvs client/server") |
|
55 | @check("cvs", "cvs client/server") | |
56 | def has_cvs(): |
|
56 | def has_cvs(): | |
57 | re = r'Concurrent Versions System.*?server' |
|
57 | re = r'Concurrent Versions System.*?server' | |
58 | return matchoutput('cvs --version 2>&1', re) and not has_msys() |
|
58 | return matchoutput('cvs --version 2>&1', re) and not has_msys() | |
59 |
|
59 | |||
60 | @check("cvs112", "cvs client/server >= 1.12") |
|
60 | @check("cvs112", "cvs client/server >= 1.12") | |
61 | def has_cvs112(): |
|
61 | def has_cvs112(): | |
62 | re = r'Concurrent Versions System \(CVS\) 1.12.*?server' |
|
62 | re = r'Concurrent Versions System \(CVS\) 1.12.*?server' | |
63 | return matchoutput('cvs --version 2>&1', re) and not has_msys() |
|
63 | return matchoutput('cvs --version 2>&1', re) and not has_msys() | |
64 |
|
64 | |||
65 | @check("darcs", "darcs client") |
|
65 | @check("darcs", "darcs client") | |
66 | def has_darcs(): |
|
66 | def has_darcs(): | |
67 | return matchoutput('darcs --version', r'2\.[2-9]', True) |
|
67 | return matchoutput('darcs --version', r'2\.[2-9]', True) | |
68 |
|
68 | |||
69 | @check("mtn", "monotone client (>= 1.0)") |
|
69 | @check("mtn", "monotone client (>= 1.0)") | |
70 | def has_mtn(): |
|
70 | def has_mtn(): | |
71 | return matchoutput('mtn --version', r'monotone', True) and not matchoutput( |
|
71 | return matchoutput('mtn --version', r'monotone', True) and not matchoutput( | |
72 | 'mtn --version', r'monotone 0\.', True) |
|
72 | 'mtn --version', r'monotone 0\.', True) | |
73 |
|
73 | |||
74 | @check("eol-in-paths", "end-of-lines in paths") |
|
74 | @check("eol-in-paths", "end-of-lines in paths") | |
75 | def has_eol_in_paths(): |
|
75 | def has_eol_in_paths(): | |
76 | try: |
|
76 | try: | |
77 | fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix, suffix='\n\r') |
|
77 | fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix, suffix='\n\r') | |
78 | os.close(fd) |
|
78 | os.close(fd) | |
79 | os.remove(path) |
|
79 | os.remove(path) | |
80 | return True |
|
80 | return True | |
81 | except (IOError, OSError): |
|
81 | except (IOError, OSError): | |
82 | return False |
|
82 | return False | |
83 |
|
83 | |||
84 | @check("execbit", "executable bit") |
|
84 | @check("execbit", "executable bit") | |
85 | def has_executablebit(): |
|
85 | def has_executablebit(): | |
86 | try: |
|
86 | try: | |
87 | EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH |
|
87 | EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH | |
88 | fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix) |
|
88 | fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix) | |
89 | try: |
|
89 | try: | |
90 | os.close(fh) |
|
90 | os.close(fh) | |
91 | m = os.stat(fn).st_mode & 0777 |
|
91 | m = os.stat(fn).st_mode & 0777 | |
92 | new_file_has_exec = m & EXECFLAGS |
|
92 | new_file_has_exec = m & EXECFLAGS | |
93 | os.chmod(fn, m ^ EXECFLAGS) |
|
93 | os.chmod(fn, m ^ EXECFLAGS) | |
94 | exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0777) == m) |
|
94 | exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0777) == m) | |
95 | finally: |
|
95 | finally: | |
96 | os.unlink(fn) |
|
96 | os.unlink(fn) | |
97 | except (IOError, OSError): |
|
97 | except (IOError, OSError): | |
98 | # we don't care, the user probably won't be able to commit anyway |
|
98 | # we don't care, the user probably won't be able to commit anyway | |
99 | return False |
|
99 | return False | |
100 | return not (new_file_has_exec or exec_flags_cannot_flip) |
|
100 | return not (new_file_has_exec or exec_flags_cannot_flip) | |
101 |
|
101 | |||
102 | @check("icasefs", "case insensitive file system") |
|
102 | @check("icasefs", "case insensitive file system") | |
103 | def has_icasefs(): |
|
103 | def has_icasefs(): | |
104 | # Stolen from mercurial.util |
|
104 | # Stolen from mercurial.util | |
105 | fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix) |
|
105 | fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix) | |
106 | os.close(fd) |
|
106 | os.close(fd) | |
107 | try: |
|
107 | try: | |
108 | s1 = os.stat(path) |
|
108 | s1 = os.stat(path) | |
109 | d, b = os.path.split(path) |
|
109 | d, b = os.path.split(path) | |
110 | p2 = os.path.join(d, b.upper()) |
|
110 | p2 = os.path.join(d, b.upper()) | |
111 | if path == p2: |
|
111 | if path == p2: | |
112 | p2 = os.path.join(d, b.lower()) |
|
112 | p2 = os.path.join(d, b.lower()) | |
113 | try: |
|
113 | try: | |
114 | s2 = os.stat(p2) |
|
114 | s2 = os.stat(p2) | |
115 | return s2 == s1 |
|
115 | return s2 == s1 | |
116 | except OSError: |
|
116 | except OSError: | |
117 | return False |
|
117 | return False | |
118 | finally: |
|
118 | finally: | |
119 | os.remove(path) |
|
119 | os.remove(path) | |
120 |
|
120 | |||
121 | @check("fifo", "named pipes") |
|
121 | @check("fifo", "named pipes") | |
122 | def has_fifo(): |
|
122 | def has_fifo(): | |
123 | if getattr(os, "mkfifo", None) is None: |
|
123 | if getattr(os, "mkfifo", None) is None: | |
124 | return False |
|
124 | return False | |
125 | name = tempfile.mktemp(dir='.', prefix=tempprefix) |
|
125 | name = tempfile.mktemp(dir='.', prefix=tempprefix) | |
126 | try: |
|
126 | try: | |
127 | os.mkfifo(name) |
|
127 | os.mkfifo(name) | |
128 | os.unlink(name) |
|
128 | os.unlink(name) | |
129 | return True |
|
129 | return True | |
130 | except OSError: |
|
130 | except OSError: | |
131 | return False |
|
131 | return False | |
132 |
|
132 | |||
133 | @check("killdaemons", 'killdaemons.py support') |
|
133 | @check("killdaemons", 'killdaemons.py support') | |
134 | def has_killdaemons(): |
|
134 | def has_killdaemons(): | |
135 | return True |
|
135 | return True | |
136 |
|
136 | |||
137 | @check("cacheable", "cacheable filesystem") |
|
137 | @check("cacheable", "cacheable filesystem") | |
138 | def has_cacheable_fs(): |
|
138 | def has_cacheable_fs(): | |
139 | from mercurial import util |
|
139 | from mercurial import util | |
140 |
|
140 | |||
141 | fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix) |
|
141 | fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix) | |
142 | os.close(fd) |
|
142 | os.close(fd) | |
143 | try: |
|
143 | try: | |
144 | return util.cachestat(path).cacheable() |
|
144 | return util.cachestat(path).cacheable() | |
145 | finally: |
|
145 | finally: | |
146 | os.remove(path) |
|
146 | os.remove(path) | |
147 |
|
147 | |||
148 | @check("lsprof", "python lsprof module") |
|
148 | @check("lsprof", "python lsprof module") | |
149 | def has_lsprof(): |
|
149 | def has_lsprof(): | |
150 | try: |
|
150 | try: | |
151 | import _lsprof |
|
151 | import _lsprof | |
152 | _lsprof.Profiler # silence unused import warning |
|
152 | _lsprof.Profiler # silence unused import warning | |
153 | return True |
|
153 | return True | |
154 | except ImportError: |
|
154 | except ImportError: | |
155 | return False |
|
155 | return False | |
156 |
|
156 | |||
157 | @check("gettext", "GNU Gettext (msgfmt)") |
|
157 | @check("gettext", "GNU Gettext (msgfmt)") | |
158 | def has_gettext(): |
|
158 | def has_gettext(): | |
159 | return matchoutput('msgfmt --version', 'GNU gettext-tools') |
|
159 | return matchoutput('msgfmt --version', 'GNU gettext-tools') | |
160 |
|
160 | |||
161 | @check("git", "git command line client") |
|
161 | @check("git", "git command line client") | |
162 | def has_git(): |
|
162 | def has_git(): | |
163 | return matchoutput('git --version 2>&1', r'^git version') |
|
163 | return matchoutput('git --version 2>&1', r'^git version') | |
164 |
|
164 | |||
165 | @check("docutils", "Docutils text processing library") |
|
165 | @check("docutils", "Docutils text processing library") | |
166 | def has_docutils(): |
|
166 | def has_docutils(): | |
167 | try: |
|
167 | try: | |
168 | from docutils.core import publish_cmdline |
|
168 | from docutils.core import publish_cmdline | |
169 | publish_cmdline # silence unused import |
|
169 | publish_cmdline # silence unused import | |
170 | return True |
|
170 | return True | |
171 | except ImportError: |
|
171 | except ImportError: | |
172 | return False |
|
172 | return False | |
173 |
|
173 | |||
174 | def getsvnversion(): |
|
174 | def getsvnversion(): | |
175 | m = matchoutput('svn --version --quiet 2>&1', r'^(\d+)\.(\d+)') |
|
175 | m = matchoutput('svn --version --quiet 2>&1', r'^(\d+)\.(\d+)') | |
176 | if not m: |
|
176 | if not m: | |
177 | return (0, 0) |
|
177 | return (0, 0) | |
178 | return (int(m.group(1)), int(m.group(2))) |
|
178 | return (int(m.group(1)), int(m.group(2))) | |
179 |
|
179 | |||
180 | @check("svn15", "subversion client and admin tools >= 1.5") |
|
180 | @check("svn15", "subversion client and admin tools >= 1.5") | |
181 | def has_svn15(): |
|
181 | def has_svn15(): | |
182 | return getsvnversion() >= (1, 5) |
|
182 | return getsvnversion() >= (1, 5) | |
183 |
|
183 | |||
184 | @check("svn13", "subversion client and admin tools >= 1.3") |
|
184 | @check("svn13", "subversion client and admin tools >= 1.3") | |
185 | def has_svn13(): |
|
185 | def has_svn13(): | |
186 | return getsvnversion() >= (1, 3) |
|
186 | return getsvnversion() >= (1, 3) | |
187 |
|
187 | |||
188 | @check("svn", "subversion client and admin tools") |
|
188 | @check("svn", "subversion client and admin tools") | |
189 | def has_svn(): |
|
189 | def has_svn(): | |
190 | return matchoutput('svn --version 2>&1', r'^svn, version') and \ |
|
190 | return matchoutput('svn --version 2>&1', r'^svn, version') and \ | |
191 | matchoutput('svnadmin --version 2>&1', r'^svnadmin, version') |
|
191 | matchoutput('svnadmin --version 2>&1', r'^svnadmin, version') | |
192 |
|
192 | |||
193 | @check("svn-bindings", "subversion python bindings") |
|
193 | @check("svn-bindings", "subversion python bindings") | |
194 | def has_svn_bindings(): |
|
194 | def has_svn_bindings(): | |
195 | try: |
|
195 | try: | |
196 | import svn.core |
|
196 | import svn.core | |
197 | version = svn.core.SVN_VER_MAJOR, svn.core.SVN_VER_MINOR |
|
197 | version = svn.core.SVN_VER_MAJOR, svn.core.SVN_VER_MINOR | |
198 | if version < (1, 4): |
|
198 | if version < (1, 4): | |
199 | return False |
|
199 | return False | |
200 | return True |
|
200 | return True | |
201 | except ImportError: |
|
201 | except ImportError: | |
202 | return False |
|
202 | return False | |
203 |
|
203 | |||
204 | @check("p4", "Perforce server and client") |
|
204 | @check("p4", "Perforce server and client") | |
205 | def has_p4(): |
|
205 | def has_p4(): | |
206 | return (matchoutput('p4 -V', r'Rev\. P4/') and |
|
206 | return (matchoutput('p4 -V', r'Rev\. P4/') and | |
207 | matchoutput('p4d -V', r'Rev\. P4D/')) |
|
207 | matchoutput('p4d -V', r'Rev\. P4D/')) | |
208 |
|
208 | |||
209 | @check("symlink", "symbolic links") |
|
209 | @check("symlink", "symbolic links") | |
210 | def has_symlink(): |
|
210 | def has_symlink(): | |
211 | if getattr(os, "symlink", None) is None: |
|
211 | if getattr(os, "symlink", None) is None: | |
212 | return False |
|
212 | return False | |
213 | name = tempfile.mktemp(dir='.', prefix=tempprefix) |
|
213 | name = tempfile.mktemp(dir='.', prefix=tempprefix) | |
214 | try: |
|
214 | try: | |
215 | os.symlink(".", name) |
|
215 | os.symlink(".", name) | |
216 | os.unlink(name) |
|
216 | os.unlink(name) | |
217 | return True |
|
217 | return True | |
218 | except (OSError, AttributeError): |
|
218 | except (OSError, AttributeError): | |
219 | return False |
|
219 | return False | |
220 |
|
220 | |||
221 | @check("hardlink", "hardlinks") |
|
221 | @check("hardlink", "hardlinks") | |
222 | def has_hardlink(): |
|
222 | def has_hardlink(): | |
223 | from mercurial import util |
|
223 | from mercurial import util | |
224 | fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix) |
|
224 | fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix) | |
225 | os.close(fh) |
|
225 | os.close(fh) | |
226 | name = tempfile.mktemp(dir='.', prefix=tempprefix) |
|
226 | name = tempfile.mktemp(dir='.', prefix=tempprefix) | |
227 | try: |
|
227 | try: | |
228 | try: |
|
228 | try: | |
229 | util.oslink(fn, name) |
|
229 | util.oslink(fn, name) | |
230 | os.unlink(name) |
|
230 | os.unlink(name) | |
231 | return True |
|
231 | return True | |
232 | except OSError: |
|
232 | except OSError: | |
233 | return False |
|
233 | return False | |
234 | finally: |
|
234 | finally: | |
235 | os.unlink(fn) |
|
235 | os.unlink(fn) | |
236 |
|
236 | |||
237 | @check("tla", "GNU Arch tla client") |
|
237 | @check("tla", "GNU Arch tla client") | |
238 | def has_tla(): |
|
238 | def has_tla(): | |
239 | return matchoutput('tla --version 2>&1', r'The GNU Arch Revision') |
|
239 | return matchoutput('tla --version 2>&1', r'The GNU Arch Revision') | |
240 |
|
240 | |||
241 | @check("gpg", "gpg client") |
|
241 | @check("gpg", "gpg client") | |
242 | def has_gpg(): |
|
242 | def has_gpg(): | |
243 | return matchoutput('gpg --version 2>&1', r'GnuPG') |
|
243 | return matchoutput('gpg --version 2>&1', r'GnuPG') | |
244 |
|
244 | |||
245 | @check("unix-permissions", "unix-style permissions") |
|
245 | @check("unix-permissions", "unix-style permissions") | |
246 | def has_unix_permissions(): |
|
246 | def has_unix_permissions(): | |
247 | d = tempfile.mkdtemp(dir='.', prefix=tempprefix) |
|
247 | d = tempfile.mkdtemp(dir='.', prefix=tempprefix) | |
248 | try: |
|
248 | try: | |
249 | fname = os.path.join(d, 'foo') |
|
249 | fname = os.path.join(d, 'foo') | |
250 | for umask in (077, 007, 022): |
|
250 | for umask in (077, 007, 022): | |
251 | os.umask(umask) |
|
251 | os.umask(umask) | |
252 | f = open(fname, 'w') |
|
252 | f = open(fname, 'w') | |
253 | f.close() |
|
253 | f.close() | |
254 | mode = os.stat(fname).st_mode |
|
254 | mode = os.stat(fname).st_mode | |
255 | os.unlink(fname) |
|
255 | os.unlink(fname) | |
256 | if mode & 0777 != ~umask & 0666: |
|
256 | if mode & 0777 != ~umask & 0666: | |
257 | return False |
|
257 | return False | |
258 | return True |
|
258 | return True | |
259 | finally: |
|
259 | finally: | |
260 | os.rmdir(d) |
|
260 | os.rmdir(d) | |
261 |
|
261 | |||
262 | @check("unix-socket", "AF_UNIX socket family") |
|
262 | @check("unix-socket", "AF_UNIX socket family") | |
263 | def has_unix_socket(): |
|
263 | def has_unix_socket(): | |
264 | return getattr(socket, 'AF_UNIX', None) is not None |
|
264 | return getattr(socket, 'AF_UNIX', None) is not None | |
265 |
|
265 | |||
266 | @check("root", "root permissions") |
|
266 | @check("root", "root permissions") | |
267 | def has_root(): |
|
267 | def has_root(): | |
268 | return getattr(os, 'geteuid', None) and os.geteuid() == 0 |
|
268 | return getattr(os, 'geteuid', None) and os.geteuid() == 0 | |
269 |
|
269 | |||
270 | @check("pyflakes", "Pyflakes python linter") |
|
270 | @check("pyflakes", "Pyflakes python linter") | |
271 | def has_pyflakes(): |
|
271 | def has_pyflakes(): | |
272 | return matchoutput("sh -c \"echo 'import re' 2>&1 | pyflakes\"", |
|
272 | return matchoutput("sh -c \"echo 'import re' 2>&1 | pyflakes\"", | |
273 | r"<stdin>:1: 're' imported but unused", |
|
273 | r"<stdin>:1: 're' imported but unused", | |
274 | True) |
|
274 | True) | |
275 |
|
275 | |||
276 | @check("pygments", "Pygments source highlighting library") |
|
276 | @check("pygments", "Pygments source highlighting library") | |
277 | def has_pygments(): |
|
277 | def has_pygments(): | |
278 | try: |
|
278 | try: | |
279 | import pygments |
|
279 | import pygments | |
280 | pygments.highlight # silence unused import warning |
|
280 | pygments.highlight # silence unused import warning | |
281 | return True |
|
281 | return True | |
282 | except ImportError: |
|
282 | except ImportError: | |
283 | return False |
|
283 | return False | |
284 |
|
284 | |||
285 | @check("python243", "python >= 2.4.3") |
|
285 | @check("python243", "python >= 2.4.3") | |
286 | def has_python243(): |
|
286 | def has_python243(): | |
287 | return sys.version_info >= (2, 4, 3) |
|
287 | return sys.version_info >= (2, 4, 3) | |
288 |
|
288 | |||
289 | @check("json", "some json module available") |
|
289 | @check("json", "some json module available") | |
290 | def has_json(): |
|
290 | def has_json(): | |
291 | try: |
|
291 | try: | |
292 | import json |
|
292 | import json | |
293 | json.dumps |
|
293 | json.dumps | |
294 | return True |
|
294 | return True | |
295 | except ImportError: |
|
295 | except ImportError: | |
296 | try: |
|
296 | try: | |
297 | import simplejson as json |
|
297 | import simplejson as json | |
298 | json.dumps |
|
298 | json.dumps | |
299 | return True |
|
299 | return True | |
300 | except ImportError: |
|
300 | except ImportError: | |
301 | pass |
|
301 | pass | |
302 | return False |
|
302 | return False | |
303 |
|
303 | |||
304 | @check("outer-repo", "outer repo") |
|
304 | @check("outer-repo", "outer repo") | |
305 | def has_outer_repo(): |
|
305 | def has_outer_repo(): | |
306 | # failing for other reasons than 'no repo' imply that there is a repo |
|
306 | # failing for other reasons than 'no repo' imply that there is a repo | |
307 | return not matchoutput('hg root 2>&1', |
|
307 | return not matchoutput('hg root 2>&1', | |
308 | r'abort: no repository found', True) |
|
308 | r'abort: no repository found', True) | |
309 |
|
309 | |||
310 | @check("ssl", ("(python >= 2.6 ssl module and python OpenSSL) " |
|
310 | @check("ssl", ("(python >= 2.6 ssl module and python OpenSSL) " | |
311 | "OR python >= 2.7.9 ssl")) |
|
311 | "OR python >= 2.7.9 ssl")) | |
312 | def has_ssl(): |
|
312 | def has_ssl(): | |
313 | try: |
|
313 | try: | |
314 | import ssl |
|
314 | import ssl | |
315 | if getattr(ssl, 'create_default_context', False): |
|
315 | if getattr(ssl, 'create_default_context', False): | |
316 | return True |
|
316 | return True | |
317 | import OpenSSL |
|
317 | import OpenSSL | |
318 | OpenSSL.SSL.Context |
|
318 | OpenSSL.SSL.Context | |
319 | return True |
|
319 | return True | |
320 | except ImportError: |
|
320 | except ImportError: | |
321 | return False |
|
321 | return False | |
322 |
|
322 | |||
|
323 | @check("defaultcacerts", "can verify SSL certs by system's CA certs store") | |||
|
324 | def has_defaultcacerts(): | |||
|
325 | from mercurial import sslutil | |||
|
326 | return sslutil._defaultcacerts() | |||
|
327 | ||||
323 | @check("windows", "Windows") |
|
328 | @check("windows", "Windows") | |
324 | def has_windows(): |
|
329 | def has_windows(): | |
325 | return os.name == 'nt' |
|
330 | return os.name == 'nt' | |
326 |
|
331 | |||
327 | @check("system-sh", "system() uses sh") |
|
332 | @check("system-sh", "system() uses sh") | |
328 | def has_system_sh(): |
|
333 | def has_system_sh(): | |
329 | return os.name != 'nt' |
|
334 | return os.name != 'nt' | |
330 |
|
335 | |||
331 | @check("serve", "platform and python can manage 'hg serve -d'") |
|
336 | @check("serve", "platform and python can manage 'hg serve -d'") | |
332 | def has_serve(): |
|
337 | def has_serve(): | |
333 | return os.name != 'nt' # gross approximation |
|
338 | return os.name != 'nt' # gross approximation | |
334 |
|
339 | |||
335 | @check("test-repo", "running tests from repository") |
|
340 | @check("test-repo", "running tests from repository") | |
336 | def has_test_repo(): |
|
341 | def has_test_repo(): | |
337 | t = os.environ["TESTDIR"] |
|
342 | t = os.environ["TESTDIR"] | |
338 | return os.path.isdir(os.path.join(t, "..", ".hg")) |
|
343 | return os.path.isdir(os.path.join(t, "..", ".hg")) | |
339 |
|
344 | |||
340 | @check("tic", "terminfo compiler and curses module") |
|
345 | @check("tic", "terminfo compiler and curses module") | |
341 | def has_tic(): |
|
346 | def has_tic(): | |
342 | try: |
|
347 | try: | |
343 | import curses |
|
348 | import curses | |
344 | curses.COLOR_BLUE |
|
349 | curses.COLOR_BLUE | |
345 | return matchoutput('test -x "`which tic`"', '') |
|
350 | return matchoutput('test -x "`which tic`"', '') | |
346 | except ImportError: |
|
351 | except ImportError: | |
347 | return False |
|
352 | return False | |
348 |
|
353 | |||
349 | @check("msys", "Windows with MSYS") |
|
354 | @check("msys", "Windows with MSYS") | |
350 | def has_msys(): |
|
355 | def has_msys(): | |
351 | return os.getenv('MSYSTEM') |
|
356 | return os.getenv('MSYSTEM') | |
352 |
|
357 | |||
353 | @check("aix", "AIX") |
|
358 | @check("aix", "AIX") | |
354 | def has_aix(): |
|
359 | def has_aix(): | |
355 | return sys.platform.startswith("aix") |
|
360 | return sys.platform.startswith("aix") | |
356 |
|
361 | |||
357 | @check("osx", "OS X") |
|
362 | @check("osx", "OS X") | |
358 | def has_osx(): |
|
363 | def has_osx(): | |
359 | return sys.platform == 'darwin' |
|
364 | return sys.platform == 'darwin' | |
360 |
|
365 | |||
361 | @check("absimport", "absolute_import in __future__") |
|
366 | @check("absimport", "absolute_import in __future__") | |
362 | def has_absimport(): |
|
367 | def has_absimport(): | |
363 | import __future__ |
|
368 | import __future__ | |
364 | from mercurial import util |
|
369 | from mercurial import util | |
365 | return util.safehasattr(__future__, "absolute_import") |
|
370 | return util.safehasattr(__future__, "absolute_import") | |
366 |
|
371 | |||
367 | @check("py3k", "running with Python 3.x") |
|
372 | @check("py3k", "running with Python 3.x") | |
368 | def has_py3k(): |
|
373 | def has_py3k(): | |
369 | return 3 == sys.version_info[0] |
|
374 | return 3 == sys.version_info[0] |
@@ -1,299 +1,299 b'' | |||||
1 | #require serve ssl |
|
1 | #require serve ssl | |
2 |
|
2 | |||
3 | Proper https client requires the built-in ssl from Python 2.6. |
|
3 | Proper https client requires the built-in ssl from Python 2.6. | |
4 |
|
4 | |||
5 | Certificates created with: |
|
5 | Certificates created with: | |
6 | printf '.\n.\n.\n.\n.\nlocalhost\nhg@localhost\n' | \ |
|
6 | printf '.\n.\n.\n.\n.\nlocalhost\nhg@localhost\n' | \ | |
7 | openssl req -newkey rsa:512 -keyout priv.pem -nodes -x509 -days 9000 -out pub.pem |
|
7 | openssl req -newkey rsa:512 -keyout priv.pem -nodes -x509 -days 9000 -out pub.pem | |
8 | Can be dumped with: |
|
8 | Can be dumped with: | |
9 | openssl x509 -in pub.pem -text |
|
9 | openssl x509 -in pub.pem -text | |
10 |
|
10 | |||
11 | $ cat << EOT > priv.pem |
|
11 | $ cat << EOT > priv.pem | |
12 | > -----BEGIN PRIVATE KEY----- |
|
12 | > -----BEGIN PRIVATE KEY----- | |
13 | > MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEApjCWeYGrIa/Vo7LH |
|
13 | > MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEApjCWeYGrIa/Vo7LH | |
14 | > aRF8ou0tbgHKE33Use/whCnKEUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8 |
|
14 | > aRF8ou0tbgHKE33Use/whCnKEUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8 | |
15 | > j/xgSwIDAQABAkBxHC6+Qlf0VJXGlb6NL16yEVVTQxqDS6hA9zqu6TZjrr0YMfzc |
|
15 | > j/xgSwIDAQABAkBxHC6+Qlf0VJXGlb6NL16yEVVTQxqDS6hA9zqu6TZjrr0YMfzc | |
16 | > EGNIiZGt7HCBL0zO+cPDg/LeCZc6HQhf0KrhAiEAzlJq4hWWzvguWFIJWSoBeBUG |
|
16 | > EGNIiZGt7HCBL0zO+cPDg/LeCZc6HQhf0KrhAiEAzlJq4hWWzvguWFIJWSoBeBUG | |
17 | > MF1ACazQO7PYE8M0qfECIQDONHHP0SKZzz/ZwBZcAveC5K61f/v9hONFwbeYulzR |
|
17 | > MF1ACazQO7PYE8M0qfECIQDONHHP0SKZzz/ZwBZcAveC5K61f/v9hONFwbeYulzR | |
18 | > +wIgc9SvbtgB/5Yzpp//4ZAEnR7oh5SClCvyB+KSx52K3nECICbhQphhoXmI10wy |
|
18 | > +wIgc9SvbtgB/5Yzpp//4ZAEnR7oh5SClCvyB+KSx52K3nECICbhQphhoXmI10wy | |
19 | > aMTellaq0bpNMHFDziqH9RsqAHhjAiEAgYGxfzkftt5IUUn/iFK89aaIpyrpuaAh |
|
19 | > aMTellaq0bpNMHFDziqH9RsqAHhjAiEAgYGxfzkftt5IUUn/iFK89aaIpyrpuaAh | |
20 | > HY8gUVkVRVs= |
|
20 | > HY8gUVkVRVs= | |
21 | > -----END PRIVATE KEY----- |
|
21 | > -----END PRIVATE KEY----- | |
22 | > EOT |
|
22 | > EOT | |
23 |
|
23 | |||
24 | $ cat << EOT > pub.pem |
|
24 | $ cat << EOT > pub.pem | |
25 | > -----BEGIN CERTIFICATE----- |
|
25 | > -----BEGIN CERTIFICATE----- | |
26 | > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNV |
|
26 | > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNV | |
27 | > BAMMCWxvY2FsaG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEw |
|
27 | > BAMMCWxvY2FsaG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEw | |
28 | > MTAxNDIwMzAxNFoXDTM1MDYwNTIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0 |
|
28 | > MTAxNDIwMzAxNFoXDTM1MDYwNTIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0 | |
29 | > MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhvc3QwXDANBgkqhkiG9w0BAQEFAANL |
|
29 | > MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhvc3QwXDANBgkqhkiG9w0BAQEFAANL | |
30 | > ADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnKEUm34rDaXQd4lxxX |
|
30 | > ADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnKEUm34rDaXQd4lxxX | |
31 | > 6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA+amm |
|
31 | > 6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA+amm | |
32 | > r24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQw |
|
32 | > r24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQw | |
33 | > DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAFArvQFiAZJgQczRsbYlG1xl |
|
33 | > DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAFArvQFiAZJgQczRsbYlG1xl | |
34 | > t+truk37w5B3m3Ick1ntRcQrqs+hf0CO1q6Squ144geYaQ8CDirSR92fICELI1c= |
|
34 | > t+truk37w5B3m3Ick1ntRcQrqs+hf0CO1q6Squ144geYaQ8CDirSR92fICELI1c= | |
35 | > -----END CERTIFICATE----- |
|
35 | > -----END CERTIFICATE----- | |
36 | > EOT |
|
36 | > EOT | |
37 | $ cat priv.pem pub.pem >> server.pem |
|
37 | $ cat priv.pem pub.pem >> server.pem | |
38 | $ PRIV=`pwd`/server.pem |
|
38 | $ PRIV=`pwd`/server.pem | |
39 |
|
39 | |||
40 | $ cat << EOT > pub-other.pem |
|
40 | $ cat << EOT > pub-other.pem | |
41 | > -----BEGIN CERTIFICATE----- |
|
41 | > -----BEGIN CERTIFICATE----- | |
42 | > MIIBqzCCAVWgAwIBAgIJALwZS731c/ORMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNV |
|
42 | > MIIBqzCCAVWgAwIBAgIJALwZS731c/ORMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNV | |
43 | > BAMMCWxvY2FsaG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEw |
|
43 | > BAMMCWxvY2FsaG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEw | |
44 | > MTAxNDIwNDUxNloXDTM1MDYwNTIwNDUxNlowMTESMBAGA1UEAwwJbG9jYWxob3N0 |
|
44 | > MTAxNDIwNDUxNloXDTM1MDYwNTIwNDUxNlowMTESMBAGA1UEAwwJbG9jYWxob3N0 | |
45 | > MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhvc3QwXDANBgkqhkiG9w0BAQEFAANL |
|
45 | > MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhvc3QwXDANBgkqhkiG9w0BAQEFAANL | |
46 | > ADBIAkEAsxsapLbHrqqUKuQBxdpK4G3m2LjtyrTSdpzzzFlecxd5yhNP6AyWrufo |
|
46 | > ADBIAkEAsxsapLbHrqqUKuQBxdpK4G3m2LjtyrTSdpzzzFlecxd5yhNP6AyWrufo | |
47 | > K4VMGo2xlu9xOo88nDSUNSKPuD09MwIDAQABo1AwTjAdBgNVHQ4EFgQUoIB1iMhN |
|
47 | > K4VMGo2xlu9xOo88nDSUNSKPuD09MwIDAQABo1AwTjAdBgNVHQ4EFgQUoIB1iMhN | |
48 | > y868rpQ2qk9dHnU6ebswHwYDVR0jBBgwFoAUoIB1iMhNy868rpQ2qk9dHnU6ebsw |
|
48 | > y868rpQ2qk9dHnU6ebswHwYDVR0jBBgwFoAUoIB1iMhNy868rpQ2qk9dHnU6ebsw | |
49 | > DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJ544f125CsE7J2t55PdFaF6 |
|
49 | > DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJ544f125CsE7J2t55PdFaF6 | |
50 | > bBlNBb91FCywBgSjhBjf+GG3TNPwrPdc3yqeq+hzJiuInqbOBv9abmMyq8Wsoig= |
|
50 | > bBlNBb91FCywBgSjhBjf+GG3TNPwrPdc3yqeq+hzJiuInqbOBv9abmMyq8Wsoig= | |
51 | > -----END CERTIFICATE----- |
|
51 | > -----END CERTIFICATE----- | |
52 | > EOT |
|
52 | > EOT | |
53 |
|
53 | |||
54 | pub.pem patched with other notBefore / notAfter: |
|
54 | pub.pem patched with other notBefore / notAfter: | |
55 |
|
55 | |||
56 | $ cat << EOT > pub-not-yet.pem |
|
56 | $ cat << EOT > pub-not-yet.pem | |
57 | > -----BEGIN CERTIFICATE----- |
|
57 | > -----BEGIN CERTIFICATE----- | |
58 | > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNVBAMMCWxvY2Fs |
|
58 | > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNVBAMMCWxvY2Fs | |
59 | > aG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTM1MDYwNTIwMzAxNFoXDTM1MDYw |
|
59 | > aG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTM1MDYwNTIwMzAxNFoXDTM1MDYw | |
60 | > NTIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhv |
|
60 | > NTIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhv | |
61 | > c3QwXDANBgkqhkiG9w0BAQEFAANLADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnK |
|
61 | > c3QwXDANBgkqhkiG9w0BAQEFAANLADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnK | |
62 | > EUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA |
|
62 | > EUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA | |
63 | > +ammr24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQwDAYDVR0T |
|
63 | > +ammr24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQwDAYDVR0T | |
64 | > BAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJXV41gWnkgC7jcpPpFRSUSZaxyzrXmD1CIqQf0WgVDb |
|
64 | > BAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJXV41gWnkgC7jcpPpFRSUSZaxyzrXmD1CIqQf0WgVDb | |
65 | > /12E0vR2DuZitgzUYtBaofM81aTtc0a2/YsrmqePGm0= |
|
65 | > /12E0vR2DuZitgzUYtBaofM81aTtc0a2/YsrmqePGm0= | |
66 | > -----END CERTIFICATE----- |
|
66 | > -----END CERTIFICATE----- | |
67 | > EOT |
|
67 | > EOT | |
68 | $ cat priv.pem pub-not-yet.pem > server-not-yet.pem |
|
68 | $ cat priv.pem pub-not-yet.pem > server-not-yet.pem | |
69 |
|
69 | |||
70 | $ cat << EOT > pub-expired.pem |
|
70 | $ cat << EOT > pub-expired.pem | |
71 | > -----BEGIN CERTIFICATE----- |
|
71 | > -----BEGIN CERTIFICATE----- | |
72 | > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNVBAMMCWxvY2Fs |
|
72 | > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNVBAMMCWxvY2Fs | |
73 | > aG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEwMTAxNDIwMzAxNFoXDTEwMTAx |
|
73 | > aG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEwMTAxNDIwMzAxNFoXDTEwMTAx | |
74 | > NDIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhv |
|
74 | > NDIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhv | |
75 | > c3QwXDANBgkqhkiG9w0BAQEFAANLADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnK |
|
75 | > c3QwXDANBgkqhkiG9w0BAQEFAANLADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnK | |
76 | > EUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA |
|
76 | > EUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA | |
77 | > +ammr24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQwDAYDVR0T |
|
77 | > +ammr24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQwDAYDVR0T | |
78 | > BAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJfk57DTRf2nUbYaMSlVAARxMNbFGOjQhAUtY400GhKt |
|
78 | > BAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJfk57DTRf2nUbYaMSlVAARxMNbFGOjQhAUtY400GhKt | |
79 | > 2uiKCNGKXVXD3AHWe13yHc5KttzbHQStE5Nm/DlWBWQ= |
|
79 | > 2uiKCNGKXVXD3AHWe13yHc5KttzbHQStE5Nm/DlWBWQ= | |
80 | > -----END CERTIFICATE----- |
|
80 | > -----END CERTIFICATE----- | |
81 | > EOT |
|
81 | > EOT | |
82 | $ cat priv.pem pub-expired.pem > server-expired.pem |
|
82 | $ cat priv.pem pub-expired.pem > server-expired.pem | |
83 |
|
83 | |||
84 | $ hg init test |
|
84 | $ hg init test | |
85 | $ cd test |
|
85 | $ cd test | |
86 | $ echo foo>foo |
|
86 | $ echo foo>foo | |
87 | $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg |
|
87 | $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg | |
88 | $ echo foo>foo.d/foo |
|
88 | $ echo foo>foo.d/foo | |
89 | $ echo bar>foo.d/bAr.hg.d/BaR |
|
89 | $ echo bar>foo.d/bAr.hg.d/BaR | |
90 | $ echo bar>foo.d/baR.d.hg/bAR |
|
90 | $ echo bar>foo.d/baR.d.hg/bAR | |
91 | $ hg commit -A -m 1 |
|
91 | $ hg commit -A -m 1 | |
92 | adding foo |
|
92 | adding foo | |
93 | adding foo.d/bAr.hg.d/BaR |
|
93 | adding foo.d/bAr.hg.d/BaR | |
94 | adding foo.d/baR.d.hg/bAR |
|
94 | adding foo.d/baR.d.hg/bAR | |
95 | adding foo.d/foo |
|
95 | adding foo.d/foo | |
96 | $ hg serve -p $HGPORT -d --pid-file=../hg0.pid --certificate=$PRIV |
|
96 | $ hg serve -p $HGPORT -d --pid-file=../hg0.pid --certificate=$PRIV | |
97 | $ cat ../hg0.pid >> $DAEMON_PIDS |
|
97 | $ cat ../hg0.pid >> $DAEMON_PIDS | |
98 |
|
98 | |||
99 | cacert not found |
|
99 | cacert not found | |
100 |
|
100 | |||
101 | $ hg in --config web.cacerts=no-such.pem https://localhost:$HGPORT/ |
|
101 | $ hg in --config web.cacerts=no-such.pem https://localhost:$HGPORT/ | |
102 | abort: could not find web.cacerts: no-such.pem |
|
102 | abort: could not find web.cacerts: no-such.pem | |
103 | [255] |
|
103 | [255] | |
104 |
|
104 | |||
105 | Test server address cannot be reused |
|
105 | Test server address cannot be reused | |
106 |
|
106 | |||
107 | #if windows |
|
107 | #if windows | |
108 | $ hg serve -p $HGPORT --certificate=$PRIV 2>&1 |
|
108 | $ hg serve -p $HGPORT --certificate=$PRIV 2>&1 | |
109 | abort: cannot start server at ':$HGPORT': |
|
109 | abort: cannot start server at ':$HGPORT': | |
110 | [255] |
|
110 | [255] | |
111 | #else |
|
111 | #else | |
112 | $ hg serve -p $HGPORT --certificate=$PRIV 2>&1 |
|
112 | $ hg serve -p $HGPORT --certificate=$PRIV 2>&1 | |
113 | abort: cannot start server at ':$HGPORT': Address already in use |
|
113 | abort: cannot start server at ':$HGPORT': Address already in use | |
114 | [255] |
|
114 | [255] | |
115 | #endif |
|
115 | #endif | |
116 | $ cd .. |
|
116 | $ cd .. | |
117 |
|
117 | |||
118 | OS X has a dummy CA cert that enables use of the system CA store when using |
|
118 | OS X has a dummy CA cert that enables use of the system CA store when using | |
119 | Apple's OpenSSL. This trick do not work with plain OpenSSL. |
|
119 | Apple's OpenSSL. This trick do not work with plain OpenSSL. | |
120 |
|
120 | |||
121 | $ DISABLEOSXDUMMYCERT= |
|
121 | $ DISABLEOSXDUMMYCERT= | |
122 | #if osx |
|
122 | #if defaultcacerts | |
123 | $ hg clone https://localhost:$HGPORT/ copy-pull |
|
123 | $ hg clone https://localhost:$HGPORT/ copy-pull | |
124 | abort: error: *certificate verify failed* (glob) |
|
124 | abort: error: *certificate verify failed* (glob) | |
125 | [255] |
|
125 | [255] | |
126 |
|
126 | |||
127 | $ DISABLEOSXDUMMYCERT="--config=web.cacerts=" |
|
127 | $ DISABLEOSXDUMMYCERT="--config=web.cacerts=" | |
128 | #endif |
|
128 | #endif | |
129 |
|
129 | |||
130 | clone via pull |
|
130 | clone via pull | |
131 |
|
131 | |||
132 | $ hg clone https://localhost:$HGPORT/ copy-pull $DISABLEOSXDUMMYCERT |
|
132 | $ hg clone https://localhost:$HGPORT/ copy-pull $DISABLEOSXDUMMYCERT | |
133 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
133 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) | |
134 | requesting all changes |
|
134 | requesting all changes | |
135 | adding changesets |
|
135 | adding changesets | |
136 | adding manifests |
|
136 | adding manifests | |
137 | adding file changes |
|
137 | adding file changes | |
138 | added 1 changesets with 4 changes to 4 files |
|
138 | added 1 changesets with 4 changes to 4 files | |
139 | updating to branch default |
|
139 | updating to branch default | |
140 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
140 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
141 | $ hg verify -R copy-pull |
|
141 | $ hg verify -R copy-pull | |
142 | checking changesets |
|
142 | checking changesets | |
143 | checking manifests |
|
143 | checking manifests | |
144 | crosschecking files in changesets and manifests |
|
144 | crosschecking files in changesets and manifests | |
145 | checking files |
|
145 | checking files | |
146 | 4 files, 1 changesets, 4 total revisions |
|
146 | 4 files, 1 changesets, 4 total revisions | |
147 | $ cd test |
|
147 | $ cd test | |
148 | $ echo bar > bar |
|
148 | $ echo bar > bar | |
149 | $ hg commit -A -d '1 0' -m 2 |
|
149 | $ hg commit -A -d '1 0' -m 2 | |
150 | adding bar |
|
150 | adding bar | |
151 | $ cd .. |
|
151 | $ cd .. | |
152 |
|
152 | |||
153 | pull without cacert |
|
153 | pull without cacert | |
154 |
|
154 | |||
155 | $ cd copy-pull |
|
155 | $ cd copy-pull | |
156 | $ echo '[hooks]' >> .hg/hgrc |
|
156 | $ echo '[hooks]' >> .hg/hgrc | |
157 | $ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup" >> .hg/hgrc |
|
157 | $ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup" >> .hg/hgrc | |
158 | $ hg pull $DISABLEOSXDUMMYCERT |
|
158 | $ hg pull $DISABLEOSXDUMMYCERT | |
159 | pulling from https://localhost:$HGPORT/ |
|
159 | pulling from https://localhost:$HGPORT/ | |
160 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
160 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) | |
161 | searching for changes |
|
161 | searching for changes | |
162 | adding changesets |
|
162 | adding changesets | |
163 | adding manifests |
|
163 | adding manifests | |
164 | adding file changes |
|
164 | adding file changes | |
165 | added 1 changesets with 1 changes to 1 files |
|
165 | added 1 changesets with 1 changes to 1 files | |
166 | changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=https://localhost:$HGPORT/ |
|
166 | changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=https://localhost:$HGPORT/ | |
167 | (run 'hg update' to get a working copy) |
|
167 | (run 'hg update' to get a working copy) | |
168 | $ cd .. |
|
168 | $ cd .. | |
169 |
|
169 | |||
170 | cacert configured in local repo |
|
170 | cacert configured in local repo | |
171 |
|
171 | |||
172 | $ cp copy-pull/.hg/hgrc copy-pull/.hg/hgrc.bu |
|
172 | $ cp copy-pull/.hg/hgrc copy-pull/.hg/hgrc.bu | |
173 | $ echo "[web]" >> copy-pull/.hg/hgrc |
|
173 | $ echo "[web]" >> copy-pull/.hg/hgrc | |
174 | $ echo "cacerts=`pwd`/pub.pem" >> copy-pull/.hg/hgrc |
|
174 | $ echo "cacerts=`pwd`/pub.pem" >> copy-pull/.hg/hgrc | |
175 | $ hg -R copy-pull pull --traceback |
|
175 | $ hg -R copy-pull pull --traceback | |
176 | pulling from https://localhost:$HGPORT/ |
|
176 | pulling from https://localhost:$HGPORT/ | |
177 | searching for changes |
|
177 | searching for changes | |
178 | no changes found |
|
178 | no changes found | |
179 | $ mv copy-pull/.hg/hgrc.bu copy-pull/.hg/hgrc |
|
179 | $ mv copy-pull/.hg/hgrc.bu copy-pull/.hg/hgrc | |
180 |
|
180 | |||
181 | cacert configured globally, also testing expansion of environment |
|
181 | cacert configured globally, also testing expansion of environment | |
182 | variables in the filename |
|
182 | variables in the filename | |
183 |
|
183 | |||
184 | $ echo "[web]" >> $HGRCPATH |
|
184 | $ echo "[web]" >> $HGRCPATH | |
185 | $ echo 'cacerts=$P/pub.pem' >> $HGRCPATH |
|
185 | $ echo 'cacerts=$P/pub.pem' >> $HGRCPATH | |
186 | $ P=`pwd` hg -R copy-pull pull |
|
186 | $ P=`pwd` hg -R copy-pull pull | |
187 | pulling from https://localhost:$HGPORT/ |
|
187 | pulling from https://localhost:$HGPORT/ | |
188 | searching for changes |
|
188 | searching for changes | |
189 | no changes found |
|
189 | no changes found | |
190 | $ P=`pwd` hg -R copy-pull pull --insecure |
|
190 | $ P=`pwd` hg -R copy-pull pull --insecure | |
191 | pulling from https://localhost:$HGPORT/ |
|
191 | pulling from https://localhost:$HGPORT/ | |
192 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
192 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) | |
193 | searching for changes |
|
193 | searching for changes | |
194 | no changes found |
|
194 | no changes found | |
195 |
|
195 | |||
196 | cacert mismatch |
|
196 | cacert mismatch | |
197 |
|
197 | |||
198 | $ hg -R copy-pull pull --config web.cacerts=pub.pem https://127.0.0.1:$HGPORT/ |
|
198 | $ hg -R copy-pull pull --config web.cacerts=pub.pem https://127.0.0.1:$HGPORT/ | |
199 | pulling from https://127.0.0.1:$HGPORT/ |
|
199 | pulling from https://127.0.0.1:$HGPORT/ | |
200 | abort: 127.0.0.1 certificate error: certificate is for localhost |
|
200 | abort: 127.0.0.1 certificate error: certificate is for localhost | |
201 | (configure hostfingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca or use --insecure to connect insecurely) |
|
201 | (configure hostfingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca or use --insecure to connect insecurely) | |
202 | [255] |
|
202 | [255] | |
203 | $ hg -R copy-pull pull --config web.cacerts=pub.pem https://127.0.0.1:$HGPORT/ --insecure |
|
203 | $ hg -R copy-pull pull --config web.cacerts=pub.pem https://127.0.0.1:$HGPORT/ --insecure | |
204 | pulling from https://127.0.0.1:$HGPORT/ |
|
204 | pulling from https://127.0.0.1:$HGPORT/ | |
205 | warning: 127.0.0.1 certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
205 | warning: 127.0.0.1 certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) | |
206 | searching for changes |
|
206 | searching for changes | |
207 | no changes found |
|
207 | no changes found | |
208 | $ hg -R copy-pull pull --config web.cacerts=pub-other.pem |
|
208 | $ hg -R copy-pull pull --config web.cacerts=pub-other.pem | |
209 | pulling from https://localhost:$HGPORT/ |
|
209 | pulling from https://localhost:$HGPORT/ | |
210 | abort: error: *certificate verify failed* (glob) |
|
210 | abort: error: *certificate verify failed* (glob) | |
211 | [255] |
|
211 | [255] | |
212 | $ hg -R copy-pull pull --config web.cacerts=pub-other.pem --insecure |
|
212 | $ hg -R copy-pull pull --config web.cacerts=pub-other.pem --insecure | |
213 | pulling from https://localhost:$HGPORT/ |
|
213 | pulling from https://localhost:$HGPORT/ | |
214 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
214 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) | |
215 | searching for changes |
|
215 | searching for changes | |
216 | no changes found |
|
216 | no changes found | |
217 |
|
217 | |||
218 | Test server cert which isn't valid yet |
|
218 | Test server cert which isn't valid yet | |
219 |
|
219 | |||
220 | $ hg -R test serve -p $HGPORT1 -d --pid-file=hg1.pid --certificate=server-not-yet.pem |
|
220 | $ hg -R test serve -p $HGPORT1 -d --pid-file=hg1.pid --certificate=server-not-yet.pem | |
221 | $ cat hg1.pid >> $DAEMON_PIDS |
|
221 | $ cat hg1.pid >> $DAEMON_PIDS | |
222 | $ hg -R copy-pull pull --config web.cacerts=pub-not-yet.pem https://localhost:$HGPORT1/ |
|
222 | $ hg -R copy-pull pull --config web.cacerts=pub-not-yet.pem https://localhost:$HGPORT1/ | |
223 | pulling from https://localhost:$HGPORT1/ |
|
223 | pulling from https://localhost:$HGPORT1/ | |
224 | abort: error: *certificate verify failed* (glob) |
|
224 | abort: error: *certificate verify failed* (glob) | |
225 | [255] |
|
225 | [255] | |
226 |
|
226 | |||
227 | Test server cert which no longer is valid |
|
227 | Test server cert which no longer is valid | |
228 |
|
228 | |||
229 | $ hg -R test serve -p $HGPORT2 -d --pid-file=hg2.pid --certificate=server-expired.pem |
|
229 | $ hg -R test serve -p $HGPORT2 -d --pid-file=hg2.pid --certificate=server-expired.pem | |
230 | $ cat hg2.pid >> $DAEMON_PIDS |
|
230 | $ cat hg2.pid >> $DAEMON_PIDS | |
231 | $ hg -R copy-pull pull --config web.cacerts=pub-expired.pem https://localhost:$HGPORT2/ |
|
231 | $ hg -R copy-pull pull --config web.cacerts=pub-expired.pem https://localhost:$HGPORT2/ | |
232 | pulling from https://localhost:$HGPORT2/ |
|
232 | pulling from https://localhost:$HGPORT2/ | |
233 | abort: error: *certificate verify failed* (glob) |
|
233 | abort: error: *certificate verify failed* (glob) | |
234 | [255] |
|
234 | [255] | |
235 |
|
235 | |||
236 | Fingerprints |
|
236 | Fingerprints | |
237 |
|
237 | |||
238 | $ echo "[hostfingerprints]" >> copy-pull/.hg/hgrc |
|
238 | $ echo "[hostfingerprints]" >> copy-pull/.hg/hgrc | |
239 | $ echo "localhost = 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca" >> copy-pull/.hg/hgrc |
|
239 | $ echo "localhost = 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca" >> copy-pull/.hg/hgrc | |
240 | $ echo "127.0.0.1 = 914f1aff87249c09b6859b88b1906d30756491ca" >> copy-pull/.hg/hgrc |
|
240 | $ echo "127.0.0.1 = 914f1aff87249c09b6859b88b1906d30756491ca" >> copy-pull/.hg/hgrc | |
241 |
|
241 | |||
242 | - works without cacerts |
|
242 | - works without cacerts | |
243 | $ hg -R copy-pull id https://localhost:$HGPORT/ --config web.cacerts= |
|
243 | $ hg -R copy-pull id https://localhost:$HGPORT/ --config web.cacerts= | |
244 | 5fed3813f7f5 |
|
244 | 5fed3813f7f5 | |
245 |
|
245 | |||
246 | - fails when cert doesn't match hostname (port is ignored) |
|
246 | - fails when cert doesn't match hostname (port is ignored) | |
247 | $ hg -R copy-pull id https://localhost:$HGPORT1/ |
|
247 | $ hg -R copy-pull id https://localhost:$HGPORT1/ | |
248 | abort: certificate for localhost has unexpected fingerprint 28:ff:71:bf:65:31:14:23:ad:62:92:b4:0e:31:99:18:fc:83:e3:9b |
|
248 | abort: certificate for localhost has unexpected fingerprint 28:ff:71:bf:65:31:14:23:ad:62:92:b4:0e:31:99:18:fc:83:e3:9b | |
249 | (check hostfingerprint configuration) |
|
249 | (check hostfingerprint configuration) | |
250 | [255] |
|
250 | [255] | |
251 |
|
251 | |||
252 |
|
252 | |||
253 | - ignores that certificate doesn't match hostname |
|
253 | - ignores that certificate doesn't match hostname | |
254 | $ hg -R copy-pull id https://127.0.0.1:$HGPORT/ |
|
254 | $ hg -R copy-pull id https://127.0.0.1:$HGPORT/ | |
255 | 5fed3813f7f5 |
|
255 | 5fed3813f7f5 | |
256 |
|
256 | |||
257 | HGPORT1 is reused below for tinyproxy tests. Kill that server. |
|
257 | HGPORT1 is reused below for tinyproxy tests. Kill that server. | |
258 | $ "$TESTDIR/killdaemons.py" hg1.pid |
|
258 | $ "$TESTDIR/killdaemons.py" hg1.pid | |
259 |
|
259 | |||
260 | Prepare for connecting through proxy |
|
260 | Prepare for connecting through proxy | |
261 |
|
261 | |||
262 | $ "$TESTDIR/tinyproxy.py" $HGPORT1 localhost >proxy.log </dev/null 2>&1 & |
|
262 | $ "$TESTDIR/tinyproxy.py" $HGPORT1 localhost >proxy.log </dev/null 2>&1 & | |
263 | $ while [ ! -f proxy.pid ]; do sleep 0; done |
|
263 | $ while [ ! -f proxy.pid ]; do sleep 0; done | |
264 | $ cat proxy.pid >> $DAEMON_PIDS |
|
264 | $ cat proxy.pid >> $DAEMON_PIDS | |
265 |
|
265 | |||
266 | $ echo "[http_proxy]" >> copy-pull/.hg/hgrc |
|
266 | $ echo "[http_proxy]" >> copy-pull/.hg/hgrc | |
267 | $ echo "always=True" >> copy-pull/.hg/hgrc |
|
267 | $ echo "always=True" >> copy-pull/.hg/hgrc | |
268 | $ echo "[hostfingerprints]" >> copy-pull/.hg/hgrc |
|
268 | $ echo "[hostfingerprints]" >> copy-pull/.hg/hgrc | |
269 | $ echo "localhost =" >> copy-pull/.hg/hgrc |
|
269 | $ echo "localhost =" >> copy-pull/.hg/hgrc | |
270 |
|
270 | |||
271 | Test unvalidated https through proxy |
|
271 | Test unvalidated https through proxy | |
272 |
|
272 | |||
273 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --insecure --traceback |
|
273 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --insecure --traceback | |
274 | pulling from https://localhost:$HGPORT/ |
|
274 | pulling from https://localhost:$HGPORT/ | |
275 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
275 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) | |
276 | searching for changes |
|
276 | searching for changes | |
277 | no changes found |
|
277 | no changes found | |
278 |
|
278 | |||
279 | Test https with cacert and fingerprint through proxy |
|
279 | Test https with cacert and fingerprint through proxy | |
280 |
|
280 | |||
281 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub.pem |
|
281 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub.pem | |
282 | pulling from https://localhost:$HGPORT/ |
|
282 | pulling from https://localhost:$HGPORT/ | |
283 | searching for changes |
|
283 | searching for changes | |
284 | no changes found |
|
284 | no changes found | |
285 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull https://127.0.0.1:$HGPORT/ |
|
285 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull https://127.0.0.1:$HGPORT/ | |
286 | pulling from https://127.0.0.1:$HGPORT/ |
|
286 | pulling from https://127.0.0.1:$HGPORT/ | |
287 | searching for changes |
|
287 | searching for changes | |
288 | no changes found |
|
288 | no changes found | |
289 |
|
289 | |||
290 | Test https with cert problems through proxy |
|
290 | Test https with cert problems through proxy | |
291 |
|
291 | |||
292 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub-other.pem |
|
292 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub-other.pem | |
293 | pulling from https://localhost:$HGPORT/ |
|
293 | pulling from https://localhost:$HGPORT/ | |
294 | abort: error: *certificate verify failed* (glob) |
|
294 | abort: error: *certificate verify failed* (glob) | |
295 | [255] |
|
295 | [255] | |
296 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub-expired.pem https://localhost:$HGPORT2/ |
|
296 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub-expired.pem https://localhost:$HGPORT2/ | |
297 | pulling from https://localhost:$HGPORT2/ |
|
297 | pulling from https://localhost:$HGPORT2/ | |
298 | abort: error: *certificate verify failed* (glob) |
|
298 | abort: error: *certificate verify failed* (glob) | |
299 | [255] |
|
299 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now