configure.ac | 10 +++++++--- tests/httpd.conf | 4 ++-- tests/magtests.py | 13 ++++++++++++- tests/t_spnego_proxy.py | 26 +++++++++++++++++++++++++- 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 4cfd454..1424e2e 100644 --- a/configure.ac +++ b/configure.ac @@ -43,7 +43,7 @@ AC_TYPE_UINT32_T # Checks for library functions. AC_CHECK_FUNCS([strcasecmp]) -AC_PATH_PROGS(APACHE, [apache2 httpd apache]) +AC_PATH_PROGS(APACHE, [apache2 httpd2 httpd apache],, ${PATH}:${sbindir}) if test x"$APACHE" == x; then AC_MSG_ERROR([Can't find the apache2/httpd executable!]) fi @@ -87,6 +87,10 @@ AS_IF([test "x${APR}" != "x" -a -x "${APR}"], AC_SUBST(APR_LDFLAGS)], [AC_MSG_FAILURE(["apr-1-config not found. Use --with-apr"])]) +PKG_CHECK_MODULES([APRUTIL], [apr-util-1]) +AC_SUBST([APRUTIL_CFLAGS]) +AC_SUBST([APRUTIL_LIBS]) + # OpenSSL availability and presence of specific functions PKG_CHECK_MODULES([OPENSSL], [openssl]) AC_SUBST([OPENSSL_CFLAGS]) @@ -119,8 +123,8 @@ AC_CHECK_FUNCS(gss_store_cred_into) AC_SUBST([GSSAPI_CFLAGS]) AC_SUBST([GSSAPI_LIBS]) -MAG_CFLAGS="`${APXS} -q CFLAGS` `${APXS} -q EXTRA_CPPFLAGS` `${APR} --cflags` ${GSSAPI_CFLAGS} ${OPENSSL_CFLAGS} -I`${APXS} -q INCLUDEDIR` `${APR} --includes` -fPIC" -MAG_LIBS="`${APR} --libs` ${GSSAPI_LIBS} ${OPENSSL_LIBS}" +MAG_CFLAGS="`${APXS} -q CFLAGS` `${APXS} -q EXTRA_CPPFLAGS` `${APR} --cflags` ${GSSAPI_CFLAGS} ${OPENSSL_CFLAGS} ${APRUTIL_CFLAGS} -I`${APXS} -q INCLUDEDIR` `${APR} --includes` -fPIC" +MAG_LIBS="`${APR} --libs` ${GSSAPI_LIBS} ${OPENSSL_LIBS} ${APRUTIL_LIBS}" LIBTOOL="`${APXS} -q LIBTOOL`" AC_SUBST([MAG_CFLAGS]) diff --git a/tests/httpd.conf b/tests/httpd.conf index 4672cde..76d387a 100644 --- a/tests/httpd.conf +++ b/tests/httpd.conf @@ -71,7 +71,7 @@ LoadModule userdir_module modules/mod_userdir.so LoadModule version_module modules/mod_version.so LoadModule vhost_alias_module modules/mod_vhost_alias.so -LoadModule mpm_prefork_module modules/mod_mpm_prefork.so +#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so @@ -120,7 +120,7 @@ ErrorLog "logs/error_log" LogLevel debug - TypesConfig /etc/mime.types + TypesConfig /etc/httpd2/conf/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType text/html .shtml diff --git a/tests/magtests.py b/tests/magtests.py index 7316788..3c80070 100755 --- a/tests/magtests.py +++ b/tests/magtests.py @@ -414,6 +414,9 @@ def setup_http(testdir, so_dir, wrapenv): distro = "Fedora" moddir = "/etc/httpd/modules" + if not os.path.exists(moddir): + distro = "ALTLinux" + moddir = "/etc/httpd2/modules" if not os.path.exists(moddir): distro = "Debian" moddir = "/usr/lib/apache2/modules" @@ -443,7 +446,15 @@ def setup_http(testdir, so_dir, wrapenv): 'MALLOC_PERTURB_': str(random.randint(0, 32767) % 255 + 1), }) - httpd = "httpd" if distro == "Fedora" else "apache2" + if distro == "Fedora": + httpd = "httpd" + elif distro == "Debian": + httpd = "apache2" + elif distro == "ALTLinux": + httpd = "httpd2" + else: + raise ValueError("Unknown distro") + log = open(httpdstdlog, 'a') httpproc = subprocess.Popen([httpd, '-DFOREGROUND', '-f', config], stdout=log, stderr=log, diff --git a/tests/t_spnego_proxy.py b/tests/t_spnego_proxy.py index bd84653..1cd23d9 100755 --- a/tests/t_spnego_proxy.py +++ b/tests/t_spnego_proxy.py @@ -21,15 +21,39 @@ def getAuthToken(target): return 'Negotiate %s' % b64encode(token).decode() -if __name__ == '__main__': +def getSession(target, proxies): + """Return Session compatible with + https://github.com/psf/requests/issues/5888 + """ s = requests.Session() + s.headers.update({'Proxy-Authorization': getAuthToken(target)}) + s.headers.update({'Authorization': getAuthToken(target)}) + + r = s.get(url, proxies=proxies) + + # https://github.com/psf/requests/issues/5888 + if 'Proxy-Authorization' not in r.request.headers: + class Session5888(requests.Session): + def rebuild_proxies(self, prepared_request, proxies): + super().rebuild_proxies(prepared_request, proxies) + prepared_request.headers.update( + {'Proxy-Authorization': getAuthToken(target)} + ) + + s = Session5888() + + return s + + +if __name__ == '__main__': target = os.environ['NSS_WRAPPER_HOSTNAME'] url = 'http://%s/spnego/' % target proxy = 'http://%s:%s' % (target, os.environ['WRAP_PROXY_PORT']) proxies = {"http": proxy, } + s = getSession(target, proxies) s.headers.update({'Proxy-Authorization': getAuthToken(target)}) s.headers.update({'Authorization': getAuthToken(target)})