62 lines
1.6 KiB
Diff
62 lines
1.6 KiB
Diff
|
diff -up NetworkManager-0.7.0/libnm-util/crypto_nss.c.crypto-init NetworkManager-0.7.0/libnm-util/crypto_nss.c
|
||
|
--- NetworkManager-0.7.0/libnm-util/crypto_nss.c.crypto-init 2008-08-22 12:14:12.000000000 -0400
|
||
|
+++ NetworkManager-0.7.0/libnm-util/crypto_nss.c 2008-09-11 16:22:29.000000000 -0400
|
||
|
@@ -29,27 +29,39 @@
|
||
|
#include <pk11pub.h>
|
||
|
#include <pkcs11t.h>
|
||
|
#include <cert.h>
|
||
|
+#include <prerror.h>
|
||
|
|
||
|
#include "crypto.h"
|
||
|
|
||
|
-static guint32 refcount = 0;
|
||
|
+static gboolean initialized = FALSE;
|
||
|
|
||
|
gboolean
|
||
|
crypto_init (GError **error)
|
||
|
{
|
||
|
- if (refcount == 0) {
|
||
|
- PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 1);
|
||
|
- NSS_NoDB_Init (NULL);
|
||
|
+ SECStatus ret;
|
||
|
+
|
||
|
+ if (initialized)
|
||
|
+ return TRUE;
|
||
|
+
|
||
|
+ PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 1);
|
||
|
+ ret = NSS_NoDB_Init (NULL);
|
||
|
+ if (ret != SECSuccess) {
|
||
|
+ PR_Cleanup ();
|
||
|
+ g_set_error (error, NM_CRYPTO_ERROR,
|
||
|
+ 0,
|
||
|
+ _("Failed to initialize the crypto engine: %d."),
|
||
|
+ PR_GetError ());
|
||
|
+ return FALSE;
|
||
|
}
|
||
|
- refcount++;
|
||
|
+
|
||
|
+ initialized = TRUE;
|
||
|
return TRUE;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
crypto_deinit (void)
|
||
|
{
|
||
|
- refcount--;
|
||
|
- if (refcount == 0) {
|
||
|
+ if (initialized) {
|
||
|
NSS_Shutdown ();
|
||
|
PR_Cleanup ();
|
||
|
}
|
||
|
diff -up NetworkManager-0.7.0/libnm-util/nm-utils.c.crypto-init NetworkManager-0.7.0/libnm-util/nm-utils.c
|
||
|
--- NetworkManager-0.7.0/libnm-util/nm-utils.c.crypto-init 2008-08-22 12:14:12.000000000 -0400
|
||
|
+++ NetworkManager-0.7.0/libnm-util/nm-utils.c 2008-09-11 16:19:25.000000000 -0400
|
||
|
@@ -1152,7 +1152,6 @@ nm_utils_uuid_generate_from_string (cons
|
||
|
|
||
|
out:
|
||
|
g_free (uuid);
|
||
|
- crypto_deinit ();
|
||
|
return buf;
|
||
|
}
|
||
|
|