[evolution-data-server/gnome-2-30] Bug 585301 - Use correct NSS system database where appropriate.
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-2-30] Bug 585301 - Use correct NSS system database where appropriate.
- Date: Fri, 11 Jun 2010 14:50:18 +0000 (UTC)
commit 3a0d1cde025e562f64e8cc6892577942a0d06106
Author: David Woodhouse <David Woodhouse intel com>
Date: Thu Jun 10 13:52:13 2010 +0100
Bug 585301 - Use correct NSS system database where appropriate.
It sucks that we have to look in the /etc/pki/nssdb/pkcs11.txt file to work
out whether the system database is being used, but it's the only way to tell.
(cherry picked from commit bd704bffb6238151437b205ebb5be49cee83d9ed)
camel/camel.c | 51 ++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 40 insertions(+), 11 deletions(-)
---
diff --git a/camel/camel.c b/camel/camel.c
index fc50f09..8c8d6d8 100644
--- a/camel/camel.c
+++ b/camel/camel.c
@@ -59,6 +59,30 @@ static gint initialised = FALSE;
gint camel_application_is_exiting = FALSE;
+#define NSS_SYSTEM_DB "/etc/pki/nssdb"
+
+static gint
+nss_has_system_db(void)
+{
+ int found = FALSE;
+#ifndef G_OS_WIN32
+ FILE *f;
+ char buf[80];
+
+ f = fopen(NSS_SYSTEM_DB "/pkcs11.txt", "r");
+ if (!f)
+ return FALSE;
+
+ /* Check whether the system NSS db is actually enabled */
+ while (fgets(buf, 80, f) && !found) {
+ if (!strcmp(buf, "library=libnsssysinit.so\n"))
+ found = TRUE;
+ }
+ fclose(f);
+#endif
+ return found;
+}
+
gint
camel_init (const gchar *configdir, gboolean nss_init)
{
@@ -98,17 +122,22 @@ camel_init (const gchar *configdir, gboolean nss_init)
nss_configdir = g_win32_locale_filename_from_utf8 (configdir);
#endif
- /* Create the configdir if it does not exist
- * This prevents camel from bailing out on first run */
- g_mkdir_with_parents (configdir, 0700);
-
- /* XXX Currently we store the new shared NSS database in the
- * same location we kept the original NSS databases in,
- * but at least we have safe shared access between Camel
- * and Evolution's S/MIME. Once freedesktop.org comes
- * up with a user-wide shared location, we should use
- * that instead. */
- nss_sql_configdir = g_strconcat ("sql:", nss_configdir, NULL);
+ if (nss_has_system_db ()) {
+ nss_sql_configdir = g_strdup ("sql:" NSS_SYSTEM_DB );
+ } else {
+ /* Create the configdir if it does not exist
+ * This prevents camel from bailing out on first run */
+ g_mkdir_with_parents (configdir, 0700);
+
+ /* XXX Currently we store the new shared NSS database in the
+ * same location we kept the original NSS databases in,
+ * but at least we have safe shared access between Camel
+ * and Evolution's S/MIME. Once freedesktop.org comes
+ * up with a user-wide shared location, we should use
+ * that instead. */
+ nss_sql_configdir = g_strconcat ("sql:", nss_configdir, NULL);
+ }
+
#if NSS_VMAJOR > 3 || (NSS_VMAJOR == 3 && NSS_VMINOR >= 12)
/* See: https://wiki.mozilla.org/NSS_Shared_DB,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]