1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

mod_ssl: Let modssl_set_io_callbacks() whether which callback is needed.

* modules/ssl/ssl_private.h:
  Add conn_rec and server_rec args to modssl_set_io_callbacks().

* modules/ssl/ssl_engine_io.c(modssl_set_io_callbacks):
  Don't set modssl_io_cb for log levels below TRACE4.

* modules/ssl/ssl_engine_io.c(ssl_io_filter_init),
  modules/ssl/ssl_engine_kernel.c(ssl_find_vhost):
  Call modssl_set_io_callbacks() unconditionally.

* modules/ssl/ssl_engine_io.c(modssl_io_cb):
  While at it, (cmd & BIO_CB_WRITE) is enough to differentiate a
  write from read.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918883 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yann Ylavic
2024-07-03 15:06:32 +00:00
parent 1873889b52
commit 0cfc8c3134
3 changed files with 16 additions and 13 deletions

View File

@@ -2281,9 +2281,7 @@ apr_status_t ssl_io_filter_init(conn_rec *c, request_rec *r, SSL *ssl)
apr_pool_cleanup_register(c->pool, (void*)filter_ctx, apr_pool_cleanup_register(c->pool, (void*)filter_ctx,
ssl_io_filter_cleanup, apr_pool_cleanup_null); ssl_io_filter_cleanup, apr_pool_cleanup_null);
if (APLOG_CS_IS_LEVEL(c, mySrvFromConn(c), APLOG_TRACE4)) { modssl_set_io_callbacks(ssl, c, mySrvFromConn(c));
modssl_set_io_callbacks(ssl);
}
return APR_SUCCESS; return APR_SUCCESS;
} }
@@ -2380,6 +2378,8 @@ static long modssl_io_cb(BIO *bio, int cmd, const char *argp,
SSL *ssl; SSL *ssl;
conn_rec *c; conn_rec *c;
server_rec *s; server_rec *s;
/* unused */
#if OPENSSL_VERSION_NUMBER >= 0x30000000L #if OPENSSL_VERSION_NUMBER >= 0x30000000L
(void)argi; (void)argi;
#endif #endif
@@ -2425,9 +2425,9 @@ static long modssl_io_cb(BIO *bio, int cmd, const char *argp,
"%s: %s %" APR_SIZE_T_FMT "/%" APR_SIZE_T_FMT "%s: %s %" APR_SIZE_T_FMT "/%" APR_SIZE_T_FMT
" bytes %s BIO#%pp [mem: %pp] %s", " bytes %s BIO#%pp [mem: %pp] %s",
MODSSL_LIBRARY_NAME, MODSSL_LIBRARY_NAME,
(cmd == (BIO_CB_WRITE|BIO_CB_RETURN) ? "write" : "read"), (cmd & BIO_CB_WRITE) ? "write" : "read",
actual_len, requested_len, actual_len, requested_len,
(cmd == (BIO_CB_WRITE|BIO_CB_RETURN) ? "to" : "from"), (cmd & BIO_CB_WRITE) ? "to" : "from",
bio, argp, dump); bio, argp, dump);
/* /*
* *dump will only be != '\0' if * *dump will only be != '\0' if
@@ -2445,7 +2445,7 @@ static long modssl_io_cb(BIO *bio, int cmd, const char *argp,
"%s: I/O error, %" APR_SIZE_T_FMT "%s: I/O error, %" APR_SIZE_T_FMT
" bytes expected to %s on BIO#%pp [mem: %pp]", " bytes expected to %s on BIO#%pp [mem: %pp]",
MODSSL_LIBRARY_NAME, requested_len, MODSSL_LIBRARY_NAME, requested_len,
(cmd == (BIO_CB_WRITE|BIO_CB_RETURN) ? "write" : "read"), (cmd & BIO_CB_WRITE) ? "write" : "read",
bio, argp); bio, argp);
} }
} }
@@ -2462,10 +2462,15 @@ static APR_INLINE void set_bio_callback(BIO *bio, void *arg)
BIO_set_callback_arg(bio, arg); BIO_set_callback_arg(bio, arg);
} }
void modssl_set_io_callbacks(SSL *ssl) void modssl_set_io_callbacks(SSL *ssl, conn_rec *c, server_rec *s)
{ {
BIO *rbio = SSL_get_rbio(ssl), BIO *rbio, *wbio;
*wbio = SSL_get_wbio(ssl);
if (!APLOG_CS_IS_LEVEL(c, s, APLOG_TRACE4))
return;
rbio = SSL_get_rbio(ssl);
wbio = SSL_get_wbio(ssl);
if (rbio) { if (rbio) {
set_bio_callback(rbio, ssl); set_bio_callback(rbio, ssl);
} }

View File

@@ -2607,9 +2607,7 @@ static int ssl_find_vhost(void *servername, conn_rec *c, server_rec *s)
* (and the first vhost doesn't use APLOG_TRACE4), then * (and the first vhost doesn't use APLOG_TRACE4), then
* we need to set that callback here. * we need to set that callback here.
*/ */
if (APLOGtrace4(s)) { modssl_set_io_callbacks(ssl, c, s);
modssl_set_io_callbacks(ssl);
}
return 1; return 1;
} }

View File

@@ -1053,7 +1053,7 @@ void modssl_callback_keylog(const SSL *ssl, const char *line);
/** I/O */ /** I/O */
apr_status_t ssl_io_filter_init(conn_rec *, request_rec *r, SSL *); apr_status_t ssl_io_filter_init(conn_rec *, request_rec *r, SSL *);
void ssl_io_filter_register(apr_pool_t *); void ssl_io_filter_register(apr_pool_t *);
void modssl_set_io_callbacks(SSL *ssl); void modssl_set_io_callbacks(SSL *ssl, conn_rec *c, server_rec *s);
/* ssl_io_buffer_fill fills the setaside buffering of the HTTP request /* ssl_io_buffer_fill fills the setaside buffering of the HTTP request
* to allow an SSL renegotiation to take place. */ * to allow an SSL renegotiation to take place. */