Mercurial > pidgin.yaz
comparison plugins/ssl/ssl-nss.c @ 7862:01e6e9c46a01
[gaim-migrate @ 8516]
" Patch 1: sslconn.patch
Fixes a buglet where ssl_init() would not actually
init the
loaded SSL plugin until the second time it was called." --Bill Tompkins (obobo)
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sun, 14 Dec 2003 16:35:35 +0000 |
parents | f9ed27be344e |
children | 495d3dbb4e84 |
comparison
equal
deleted
inserted
replaced
7861:271ef14bc97d | 7862:01e6e9c46a01 |
---|---|
48 | 48 |
49 #define GAIM_SSL_NSS_DATA(gsc) ((GaimSslNssData *)gsc->private_data) | 49 #define GAIM_SSL_NSS_DATA(gsc) ((GaimSslNssData *)gsc->private_data) |
50 | 50 |
51 static const PRIOMethods *_nss_methods = NULL; | 51 static const PRIOMethods *_nss_methods = NULL; |
52 static PRDescIdentity _identity; | 52 static PRDescIdentity _identity; |
53 | |
54 static void | |
55 ssl_nss_init_nss(void) | |
56 { | |
57 PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1); | |
58 NSS_NoDB_Init(NULL); | |
59 | |
60 /* TODO: Fix this so autoconf does the work trying to find this lib. */ | |
61 SECMOD_AddNewModule("Builtins", | |
62 #ifndef _WIN32 | |
63 LIBDIR "/libnssckbi.so", | |
64 #else | |
65 "nssckbi.dll", | |
66 #endif | |
67 0, 0); | |
68 NSS_SetDomesticPolicy(); | |
69 | |
70 _identity = PR_GetUniqueIdentity("Gaim"); | |
71 _nss_methods = PR_GetDefaultIOMethods(); | |
72 } | |
53 | 73 |
54 static SECStatus | 74 static SECStatus |
55 ssl_auth_cert(void *arg, PRFileDesc *socket, PRBool checksig, | 75 ssl_auth_cert(void *arg, PRFileDesc *socket, PRBool checksig, |
56 PRBool is_server) | 76 PRBool is_server) |
57 { | 77 { |
120 } | 140 } |
121 | 141 |
122 static gboolean | 142 static gboolean |
123 ssl_nss_init(void) | 143 ssl_nss_init(void) |
124 { | 144 { |
125 PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1); | 145 return TRUE; |
126 NSS_NoDB_Init(NULL); | |
127 | |
128 /* TODO: Fix this so autoconf does the work trying to find this lib. */ | |
129 SECMOD_AddNewModule("Builtins", | |
130 #ifndef _WIN32 | |
131 LIBDIR "/libnssckbi.so", | |
132 #else | |
133 "nssckbi.dll", | |
134 #endif | |
135 0, 0); | |
136 NSS_SetDomesticPolicy(); | |
137 | |
138 _identity = PR_GetUniqueIdentity("Gaim"); | |
139 _nss_methods = PR_GetDefaultIOMethods(); | |
140 | |
141 return TRUE; | |
142 } | 146 } |
143 | 147 |
144 static void | 148 static void |
145 ssl_nss_uninit(void) | 149 ssl_nss_uninit(void) |
146 { | 150 { |
263 | 267 |
264 static gboolean | 268 static gboolean |
265 plugin_load(GaimPlugin *plugin) | 269 plugin_load(GaimPlugin *plugin) |
266 { | 270 { |
267 #ifdef HAVE_NSS | 271 #ifdef HAVE_NSS |
268 gaim_ssl_set_ops(&ssl_ops); | 272 if (!gaim_ssl_get_ops()) { |
269 | 273 gaim_ssl_set_ops(&ssl_ops); |
274 } | |
275 | |
276 /* Init NSS now, so others can use it even if sslconn never does */ | |
277 ssl_nss_init_nss(); | |
270 return TRUE; | 278 return TRUE; |
271 #else | 279 #else |
272 return FALSE; | 280 return FALSE; |
273 #endif | 281 #endif |
274 } | 282 } |
275 | 283 |
276 static gboolean | 284 static gboolean |
277 plugin_unload(GaimPlugin *plugin) | 285 plugin_unload(GaimPlugin *plugin) |
278 { | 286 { |
279 #ifdef HAVE_NSS | 287 #ifdef HAVE_NSS |
280 gaim_ssl_set_ops(NULL); | 288 if (gaim_ssl_get_ops() == &ssl_ops) { |
289 gaim_ssl_set_ops(NULL); | |
290 } | |
281 #endif | 291 #endif |
282 | 292 |
283 return TRUE; | 293 return TRUE; |
284 } | 294 } |
285 | 295 |