arrfab / rpms / httpd

Forked from rpms/httpd 5 years ago
Clone

Blame SOURCES/httpd-2.4.6-sslmultiproxy.patch

28b219
28b219
Ugly hack to enable mod_ssl and mod_nss to "share" hooks.
28b219
28b219
--- httpd-2.4.6/modules/ssl/mod_ssl.c.sslmultiproxy
28b219
+++ httpd-2.4.6/modules/ssl/mod_ssl.c
28b219
@@ -369,6 +369,9 @@ static SSLConnRec *ssl_init_connection_c
28b219
     return sslconn;
28b219
 }
28b219
 
28b219
+static typeof(ssl_proxy_enable) *othermod_proxy_enable;
28b219
+static typeof(ssl_engine_disable) *othermod_engine_disable;
28b219
+
28b219
 int ssl_proxy_enable(conn_rec *c)
28b219
 {
28b219
     SSLSrvConfigRec *sc;
28b219
@@ -377,6 +380,12 @@ int ssl_proxy_enable(conn_rec *c)
28b219
     sc = mySrvConfig(sslconn->server);
28b219
 
28b219
     if (!sc->proxy_enabled) {
28b219
+        if (othermod_proxy_enable) {
28b219
+            ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, c,
28b219
+                          "mod_ssl proxy not configured, passing through to other module.");
28b219
+            return othermod_proxy_enable(c);
28b219
+        }
28b219
+
28b219
         ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, c, APLOGNO(01961)
28b219
                       "SSL Proxy requested for %s but not enabled "
28b219
                       "[Hint: SSLProxyEngine]", sc->vhost_id);
28b219
@@ -396,6 +405,10 @@ int ssl_engine_disable(conn_rec *c)
28b219
 
28b219
     SSLConnRec *sslconn = myConnConfig(c);
28b219
 
28b219
+    if (othermod_engine_disable) {
28b219
+        othermod_engine_disable(c);
28b219
+    }
28b219
+
28b219
     if (sslconn) {
28b219
         sc = mySrvConfig(sslconn->server);
28b219
     }
28b219
@@ -612,6 +625,9 @@ static void ssl_register_hooks(apr_pool_
28b219
     ap_hook_post_read_request(ssl_hook_ReadReq, pre_prr,NULL, APR_HOOK_MIDDLE);
28b219
 
28b219
     ssl_var_register(p);
28b219
+    
28b219
+    othermod_proxy_enable = APR_RETRIEVE_OPTIONAL_FN(ssl_proxy_enable);
28b219
+    othermod_engine_disable = APR_RETRIEVE_OPTIONAL_FN(ssl_engine_disable);
28b219
 
28b219
     APR_REGISTER_OPTIONAL_FN(ssl_proxy_enable);
28b219
     APR_REGISTER_OPTIONAL_FN(ssl_engine_disable);
28b219
--- httpd-2.4.6/modules/ssl/ssl_engine_vars.c.sslmultiproxy
28b219
+++ httpd-2.4.6/modules/ssl/ssl_engine_vars.c
28b219
@@ -53,10 +53,15 @@ static void  ssl_var_lookup_ssl_cipher_b
28b219
 static char *ssl_var_lookup_ssl_version(apr_pool_t *p, char *var);
28b219
 static char *ssl_var_lookup_ssl_compress_meth(SSL *ssl);
28b219
 
28b219
+static APR_OPTIONAL_FN_TYPE(ssl_is_https) *othermod_is_https;
28b219
+static APR_OPTIONAL_FN_TYPE(ssl_var_lookup) *othermod_var_lookup;
28b219
+
28b219
 static int ssl_is_https(conn_rec *c)
28b219
 {
28b219
     SSLConnRec *sslconn = myConnConfig(c);
28b219
-    return sslconn && sslconn->ssl;
28b219
+    
28b219
+    return (sslconn && sslconn->ssl)
28b219
+        || (othermod_is_https && othermod_is_https(c));
28b219
 }
28b219
 
28b219
 static const char var_interface[] = "mod_ssl/" AP_SERVER_BASEREVISION;
28b219
@@ -106,6 +111,9 @@ void ssl_var_register(apr_pool_t *p)
28b219
 {
28b219
     char *cp, *cp2;
28b219
 
28b219
+    othermod_is_https = APR_RETRIEVE_OPTIONAL_FN(ssl_is_https);
28b219
+    othermod_var_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
28b219
+
28b219
     APR_REGISTER_OPTIONAL_FN(ssl_is_https);
28b219
     APR_REGISTER_OPTIONAL_FN(ssl_var_lookup);
28b219
     APR_REGISTER_OPTIONAL_FN(ssl_ext_list);
28b219
@@ -241,6 +249,15 @@ char *ssl_var_lookup(apr_pool_t *p, serv
28b219
      */
28b219
     if (result == NULL && c != NULL) {
28b219
         SSLConnRec *sslconn = myConnConfig(c);
28b219
+
28b219
+        if (strlen(var) > 4 && strcEQn(var, "SSL_", 4)
28b219
+            && (!sslconn || !sslconn->ssl) && othermod_var_lookup) {
28b219
+            /* For an SSL_* variable, if mod_ssl is not enabled for
28b219
+             * this connection and another SSL module is present, pass
28b219
+             * through to that module. */
28b219
+            return othermod_var_lookup(p, s, c, r, var);
28b219
+        }
28b219
+
28b219
         if (strlen(var) > 4 && strcEQn(var, "SSL_", 4)
28b219
             && sslconn && sslconn->ssl)
28b219
             result = ssl_var_lookup_ssl(p, c, r, var+4);