From ec94410d508aaeb3498c7ae887d829ff8a77e4d8 Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Fri, 11 Sep 2009 12:14:39 +0300 Subject: ephy-nss-glue.c: ask for the NSS master password if needed It was possible to set a master password for NSS through the certificate manager extension, so we have to support this. Bug #594694 --- src/ephy-nss-glue.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src') diff --git a/src/ephy-nss-glue.c b/src/ephy-nss-glue.c index 84992e782..d60326cdb 100644 --- a/src/ephy-nss-glue.c +++ b/src/ephy-nss-glue.c @@ -37,10 +37,50 @@ #include #include #include +#include static gboolean nss_initialized = FALSE; static PK11SlotInfo *db_slot = NULL; +static char* +ask_for_nss_password (PK11SlotInfo *slot, + PRBool retry, + void *arg) +{ + GtkWidget *dialog; + GtkWidget *entry; + gint result; + char *password = NULL; + + if (retry) + return NULL; + + dialog = gtk_message_dialog_new (NULL, + 0, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_OK_CANCEL, + _("Master password needed")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + _("The passwords from the previous version (Gecko) are locked with a master password. If you want Epiphany to import them, please enter your master password below.")); + entry = gtk_entry_new (); + gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), entry); + gtk_widget_show (entry); + + result = gtk_dialog_run (GTK_DIALOG (dialog)); + + switch (result) { + case GTK_RESPONSE_OK: + password = PL_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); + break; + default: + break; + } + + gtk_widget_destroy (dialog); + return password; +} + gboolean ephy_nss_glue_init () { char *config_dir, *modspec; @@ -65,6 +105,10 @@ gboolean ephy_nss_glue_init () if (!db_slot) return FALSE; + /* It's possibly to set a master password for NSS through the + certificate manager extension, so we must support that too */ + PK11_SetPasswordFunc (ask_for_nss_password); + nss_initialized = TRUE; return TRUE; @@ -77,6 +121,8 @@ void ephy_nss_glue_close () db_slot = NULL; } + PK11_SetPasswordFunc (NULL); + NSS_Shutdown (); nss_initialized = FALSE; -- cgit v1.2.3