From 8579567d9d9f2d45ef9b6cf2e60fa6e175f97d74 Mon Sep 17 00:00:00 2001
From: Michael Krelin <hacker@klever.net>
Date: Sat, 28 Jul 2007 21:20:34 +0200
Subject: [PATCH] let ssl in libpq and jabberd coexist peacefully.
To let the two implementations coexist it's important to hint libpq on ssl
being initialized already before establishing connection to the database. One
possible fix is to raise appropriate flag in ssl module and check it in
authreg_pgsql.
Signed-off-by: Michael Krelin <hacker@klever.net>
---
storage/authreg_pgsql.c | 8 ++++++++
sx/ssl.c | 4 ++++
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/storage/authreg_pgsql.c b/storage/authreg_pgsql.c
index cb68e7d..5f1583d 100644
|
a
|
b
|
|
| 302 | 302 | return 1; |
| 303 | 303 | } |
| 304 | 304 | |
| | 305 | #ifdef HAVE_SSL |
| | 306 | extern int sx_openssl_initialized; |
| | 307 | #endif |
| | 308 | |
| 305 | 309 | /** start me up */ |
| 306 | 310 | int ar_init(authreg_t ar) { |
| 307 | 311 | char *host, *port, *dbname, *user, *pass, *conninfo; |
| … |
… |
|
| 391 | 395 | free(setpassword); |
| 392 | 396 | free(delete); |
| 393 | 397 | |
| | 398 | #ifdef HAVE_SSL |
| | 399 | if(sx_openssl_initialized) |
| | 400 | PQinitSSL(0); |
| | 401 | #endif |
| 394 | 402 | conninfo = config_get_one(ar->c2s->config,"authreg.pgsql.conninfo",0); |
| 395 | 403 | if(conninfo) { |
| 396 | 404 | /* don't log connection info for it can contain password */ |
diff --git a/sx/ssl.c b/sx/ssl.c
index 62c4258..9359f4d 100644
|
a
|
b
|
|
| 628 | 628 | SSL_CTX_free((SSL_CTX *) p->private); |
| 629 | 629 | } |
| 630 | 630 | |
| | 631 | int sx_openssl_initialized = 0; |
| | 632 | |
| 631 | 633 | /** args: pemfile */ |
| 632 | 634 | int sx_ssl_init(sx_env_t env, sx_plugin_t p, va_list args) { |
| 633 | 635 | char *pemfile, *cachain; |
| … |
… |
|
| 653 | 655 | SSL_library_init(); |
| 654 | 656 | SSL_load_error_strings(); |
| 655 | 657 | |
| | 658 | sx_openssl_initialized = 1; |
| | 659 | |
| 656 | 660 | /* create the context */ |
| 657 | 661 | ctx = SSL_CTX_new(SSLv23_method()); |
| 658 | 662 | if(ctx == NULL) { |