Changeset ba5add7


Ignore:
Timestamp:
2008-02-17T01:39:39Z (16 years ago)
Author:
Sven Moritz Hallberg <sm@…>
Branches:
master
Children:
82e8fe8
Parents:
fd9fa52
Message:

explicitly initialize ssl in order to avoid gnutls and libotr fighting over the global state of libgcrypt

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • lib/ssl_bogus.c

    rfd9fa52 rba5add7  
    2727
    2828int ssl_errno;
     29
     30void ssl_init( void )
     31{
     32}
    2933
    3034void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
  • lib/ssl_client.h

    rfd9fa52 rba5add7  
    4747
    4848
     49/* Perform any global initialization the SSL library might need. */
     50G_MODULE_EXPORT void ssl_init( void );
     51
    4952/* Connect to host:port, call the given function when the connection is
    5053   ready to be used for SSL traffic. This is all done asynchronously, no
  • lib/ssl_gnutls.c

    rfd9fa52 rba5add7  
    6060static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond );
    6161
     62
     63void ssl_init( void )
     64{
     65        gnutls_global_init();
     66        initialized = TRUE;
     67        atexit( gnutls_global_deinit );
     68}
    6269
    6370void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
     
    122129        if( !initialized )
    123130        {
    124                 gnutls_global_init();
    125                 initialized = TRUE;
    126                 atexit( gnutls_global_deinit );
     131                ssl_init();
    127132        }
    128133       
  • lib/ssl_nss.c

    rfd9fa52 rba5add7  
    9191
    9292
     93void ssl_init( void )
     94{
     95        PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);
     96        NSS_NoDB_Init(NULL);
     97        NSS_SetDomesticPolicy();
     98        initialized = TRUE;
     99}
     100
    93101void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
    94102{
     
    107115        if( !initialized )
    108116        {
    109                 PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);
    110                 NSS_NoDB_Init(NULL);
    111                 NSS_SetDomesticPolicy();
     117                ssl_init();
    112118        }
    113119
  • lib/ssl_openssl.c

    rfd9fa52 rba5add7  
    5656static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond );
    5757
     58
     59void ssl_init( void );
     60{
     61        initialized = TRUE;
     62        SSLeay_add_ssl_algorithms();
     63}
    5864
    5965void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
     
    115121        if( !initialized )
    116122        {
    117                 initialized = TRUE;
    118                 SSLeay_add_ssl_algorithms();
     123                ssl_init();
    119124        }
    120125       
  • otr.c

    rfd9fa52 rba5add7  
    112112
    113113/* main function for the forked keygen slave */
    114 void keygen_child_main(OtrlUserState us, int infd, int outfd);
     114void keygen_child_main(const char *nick, int infd, int outfd);
    115115
    116116/* mainloop handler for when a keygen finishes */
     
    15271527                        /* child process */
    15281528                        signal(SIGTERM, exit);
    1529                         keygen_child_main(irc->otr->us, to[0], from[1]);
     1529                        keygen_child_main(irc->nick, to[0], from[1]);
    15301530                        exit(0);
    15311531                }
     
    15481548                        kg=&((*kg)->next);
    15491549                *kg = g_new0(kg_t, 1);
    1550                 (*kg)->accountname = handle;
    1551                 (*kg)->protocol = protocol;
     1550                (*kg)->accountname = g_strdup(handle);
     1551                (*kg)->protocol = g_strdup(protocol);
    15521552        } else {
    15531553                /* send our job over and remember it */
     
    15551555                fprintf(irc->otr->to, "%s\n%s\n", handle, protocol);
    15561556                fflush(irc->otr->to);
    1557                 irc->otr->sent_accountname = handle;
    1558                 irc->otr->sent_protocol = protocol;
    1559         }
    1560 }
    1561 
    1562 void keygen_child_main(OtrlUserState us, int infd, int outfd)
    1563 {
     1557                irc->otr->sent_accountname = g_strdup(handle);
     1558                irc->otr->sent_protocol = g_strdup(protocol);
     1559        }
     1560}
     1561
     1562void keygen_child_main(const char *nick, int infd, int outfd)
     1563{
     1564        OtrlUserState us;
     1565        char *kf;
    15641566        FILE *input, *output;
    15651567        char filename[128], accountname[512], protocol[512];
    15661568        gcry_error_t e;
    15671569        int tempfd;
     1570       
     1571        us = otrl_userstate_create();
     1572        kf = g_strdup_printf("%s%s.otr_keys", global.conf->configdir, nick);
     1573        otrl_privkey_read(us, kf);
     1574        g_free(kf);
    15681575       
    15691576        input = fdopen(infd, "r");
     
    16201627       
    16211628        /* forget this job */
     1629        g_free(irc->otr->sent_accountname);
     1630        g_free(irc->otr->sent_protocol);
    16221631        irc->otr->sent_accountname = NULL;
    16231632        irc->otr->sent_protocol = NULL;
  • otr.h

    rfd9fa52 rba5add7  
    5151/* representing a keygen job */
    5252typedef struct kg {
    53         const char *accountname;
    54         const char *protocol;
     53        char *accountname;
     54        char *protocol;
    5555       
    5656        struct kg *next;
     
    6565       
    6666        /* active keygen job (NULL if none) */
    67         const char *sent_accountname;
    68         const char *sent_protocol;
     67        char *sent_accountname;
     68        char *sent_protocol;
    6969       
    7070        /* keygen jobs waiting to be sent to slave */
  • unix.c

    rfd9fa52 rba5add7  
    3131#include "help.h"
    3232#include "ipc.h"
     33#include "lib/ssl_client.h"
    3334#include <signal.h>
    3435#include <unistd.h>
     
    5556        b_main_init();
    5657        nogaim_init();
     58        /* Ugly Note: libotr and gnutls both use libgcrypt. libgcrypt
     59           has a process-global config state whose initialization happpens
     60           twice if libotr and gnutls are used together. libotr installs custom
     61           memory management functions for libgcrypt while our gnutls module
     62           uses the defaults. Therefore we initialize OTR after SSL. *sigh* */
     63        ssl_init();
    5764        otr_init();
    5865       
Note: See TracChangeset for help on using the changeset viewer.