From d77df0ab3fceaca84932f90948a24eec4f576fb0 Mon Sep 17 00:00:00 2001
From: dequis <dx@dxzone.com.ar>
Date: Wed, 9 Jul 2014 07:58:30 -0300
Subject: [PATCH] Fix the NSS init after fork bug, and clean up lies in unix.c
This might look like a simple diff, but those 'lies' made this not very
straightforward.
The NSS bug itself is simple: NSS detects a fork happened after the
initialization, and refuses to work because shared CSPRNG state is bad.
The bug has been around for long time. I've been aware of it for 5
months, which says something about this mess. Trac link:
http://bugs.bitlbee.org/bitlbee/ticket/785
This wasn't a big deal because the main users of NSS (redhat) already
applied a different patch in their packages that workarounded the issue
somewhat accidentally. And this is the ticket for the 'lies' in unix.c:
http://bugs.bitlbee.org/bitlbee/ticket/1159
Basically a conflict with libotr that doesn't happen anymore. Read that
ticket for details on why ignoring those comments is acceptable.
Anyway: yay!
---
irc.c | 6 ++++++
unix.c | 9 ---------
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/irc.c b/irc.c
index 187004c..f864e31 100644
|
a
|
b
|
|
| 26 | 26 | #include "bitlbee.h" |
| 27 | 27 | #include "ipc.h" |
| 28 | 28 | #include "dcc.h" |
| | 29 | #include "lib/ssl_client.h" |
| 29 | 30 | |
| 30 | 31 | GSList *irc_connection_list; |
| 31 | 32 | GSList *irc_plugins; |
| … |
… |
irc_t *irc_new( int fd ) |
| 170 | 171 | #ifdef WITH_PURPLE |
| 171 | 172 | nogaim_init(); |
| 172 | 173 | #endif |
| | 174 | |
| | 175 | /* SSL library initialization also should be done after the fork, to |
| | 176 | avoid shared CSPRNG state. This is required by NSS, which refuses to |
| | 177 | work if a fork is detected */ |
| | 178 | ssl_init(); |
| 173 | 179 | |
| 174 | 180 | for( l = irc_plugins; l; l = l->next ) |
| 175 | 181 | { |
diff --git a/unix.c b/unix.c
index 1ea24af..329b33c 100644
|
a
|
b
|
|
| 31 | 31 | #include "protocols/nogaim.h" |
| 32 | 32 | #include "help.h" |
| 33 | 33 | #include "ipc.h" |
| 34 | | #include "lib/ssl_client.h" |
| 35 | 34 | #include "md5.h" |
| 36 | 35 | #include "misc.h" |
| 37 | 36 | #include <signal.h> |
| … |
… |
int main( int argc, char *argv[] ) |
| 81 | 80 | nogaim_init(); |
| 82 | 81 | #endif |
| 83 | 82 | |
| 84 | | /* Ugly Note: libotr and gnutls both use libgcrypt. libgcrypt |
| 85 | | has a process-global config state whose initialization happpens |
| 86 | | twice if libotr and gnutls are used together. libotr installs custom |
| 87 | | memory management functions for libgcrypt while our gnutls module |
| 88 | | uses the defaults. Therefore we initialize OTR after SSL. *sigh* */ |
| 89 | | ssl_init(); |
| 90 | 83 | #ifdef OTR_BI |
| 91 | 84 | otr_init(); |
| 92 | 85 | #endif |
| 93 | | /* And in case OTR is loaded as a plugin, it'll also get loaded after |
| 94 | | this point. */ |
| 95 | 86 | |
| 96 | 87 | srand( time( NULL ) ^ getpid() ); |
| 97 | 88 | |