Lines 220-225
Link Here
|
220 |
s = '"%s"' % s |
220 |
s = '"%s"' % s |
221 |
return s |
221 |
return s |
222 |
|
222 |
|
|
|
223 |
def get_apache_version(): |
224 |
|
225 |
print "Checking Apache version...." |
226 |
httpd = quoteIfSpace(HTTPD) |
227 |
cmd = '%s -v' % (httpd) |
228 |
(stdin,stdout) = os.popen2(cmd) |
229 |
|
230 |
version_str = None |
231 |
for line in stdout: |
232 |
if line.startswith('Server version'): |
233 |
version_str = line.strip() |
234 |
break |
235 |
|
236 |
if version_str: |
237 |
version_str = version_str.split('/')[1] |
238 |
major,minor,patch = version_str.split('.',3) |
239 |
version = '%s.%s' % (major,minor) |
240 |
else: |
241 |
|
242 |
print "Can't determine Apache version. Assuming 2.0" |
243 |
version = '2.0' |
244 |
print version |
245 |
return version |
246 |
|
247 |
APACHE_VERSION = get_apache_version() |
248 |
|
223 |
class HttpdCtrl: |
249 |
class HttpdCtrl: |
224 |
# a mixin providing ways to control httpd |
250 |
# a mixin providing ways to control httpd |
225 |
|
251 |
|
Lines 289-302
Link Here
|
289 |
Listen(PORT), |
315 |
Listen(PORT), |
290 |
PythonOption('PythonOptionTest sample_value'), |
316 |
PythonOption('PythonOptionTest sample_value'), |
291 |
DocumentRoot(DOCUMENT_ROOT), |
317 |
DocumentRoot(DOCUMENT_ROOT), |
292 |
LoadModule("python_module %s" % quoteIfSpace(MOD_PYTHON_SO)), |
318 |
LoadModule("python_module %s" % quoteIfSpace(MOD_PYTHON_SO))) |
293 |
IfModule("!mod_auth.c", |
319 |
|
|
|
320 |
if APACHE_VERSION == '2.2': |
321 |
# mod_auth has been split into mod_auth_basic and some other modules |
322 |
s.append(IfModule("!mod_auth_basic.c", |
323 |
LoadModule("auth_basic_module %s" % |
324 |
quoteIfSpace(os.path.join(modpath, "mod_auth_basic.so"))))) |
325 |
|
326 |
# Default KeepAliveTimeout is 5 for apache 2.2, but 15 in apache 2.0 |
327 |
# Explicitly set the value so it's the same as 2.0 |
328 |
s.append(KeepAliveTimeout("15")) |
329 |
else: |
330 |
s.append(IfModule("!mod_auth.c", |
294 |
LoadModule("auth_module %s" % |
331 |
LoadModule("auth_module %s" % |
295 |
quoteIfSpace(os.path.join(modpath, "mod_auth.so"))))) |
332 |
quoteIfSpace(os.path.join(modpath, "mod_auth.so"))))) |
296 |
|
333 |
|
|
|
334 |
s.append("\n# --APPENDED-- \n\n"+append) |
335 |
|
297 |
f = open(CONFIG, "w") |
336 |
f = open(CONFIG, "w") |
298 |
f.write(str(s)) |
337 |
f.write(str(s)) |
299 |
f.write("\n# --APPENDED-- \n\n"+append) |
|
|
300 |
f.close() |
338 |
f.close() |
301 |
|
339 |
|
302 |
def startHttpd(self,extra=''): |
340 |
def startHttpd(self,extra=''): |
Lines 595-601
Link Here
|
595 |
|
633 |
|
596 |
def test_req_requires_conf(self): |
634 |
def test_req_requires_conf(self): |
597 |
|
635 |
|
598 |
c = VirtualHost("*", |
636 |
if APACHE_VERSION == '2.2': |
|
|
637 |
# Apache 2.2 needs AuthBasicAuthoritative Off |
638 |
# This is necessary when combining mod_auth_basic with third-party |
639 |
# modules that are not configured with the AuthBasicProvider |
640 |
# directive. |
641 |
c = VirtualHost("*", |
599 |
ServerName("test_req_requires"), |
642 |
ServerName("test_req_requires"), |
600 |
DocumentRoot(DOCUMENT_ROOT), |
643 |
DocumentRoot(DOCUMENT_ROOT), |
601 |
Directory(DOCUMENT_ROOT, |
644 |
Directory(DOCUMENT_ROOT, |
Lines 603-610
Link Here
|
603 |
AuthName("blah"), |
646 |
AuthName("blah"), |
604 |
AuthType("basic"), |
647 |
AuthType("basic"), |
605 |
Require("valid-user"), |
648 |
Require("valid-user"), |
|
|
649 |
AuthBasicAuthoritative("Off"), |
606 |
PythonAuthenHandler("tests::req_requires"), |
650 |
PythonAuthenHandler("tests::req_requires"), |
607 |
PythonDebug("On"))) |
651 |
PythonDebug("On"))) |
|
|
652 |
|
653 |
else: |
654 |
# This configuration is suitable for Apache 2.0 |
655 |
c = VirtualHost("*", |
656 |
ServerName("test_req_requires"), |
657 |
DocumentRoot(DOCUMENT_ROOT), |
658 |
Directory(DOCUMENT_ROOT, |
659 |
SetHandler("mod_python"), |
660 |
AuthName("blah"), |
661 |
AuthType("basic"), |
662 |
Require("valid-user"), |
663 |
PythonAuthenHandler("tests::req_requires"), |
664 |
PythonDebug("On"))) |
665 |
|
608 |
return str(c) |
666 |
return str(c) |
609 |
|
667 |
|
610 |
def test_req_requires(self): |
668 |
def test_req_requires(self): |