[epiphany] Remove dependency on NSS



commit 4b34246355d286fd6cf7b2becb78f139deac7782
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Mon May 16 15:05:06 2016 -0500

    Remove dependency on NSS
    
    Let's not keep this dependency around just to support direct upgrades
    from pre-2009 Epiphany straight to GNOME 3.22.

 configure.ac                |   18 ---
 lib/Makefile.am             |    7 -
 lib/ephy-nss-glue.c         |  312 -------------------------------------------
 lib/ephy-nss-glue.h         |   27 ----
 lib/ephy-profile-migrator.c |  310 ++----------------------------------------
 5 files changed, 15 insertions(+), 659 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8a64639..25eca05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -136,24 +136,6 @@ AC_SEARCH_LIBS([backtrace], [c execinfo])
 
 AC_CHECK_HEADERS([X11/XF86keysym.h])
 
-# ***
-# NSS
-# ***
-
-AC_MSG_CHECKING([whether NSS support is requested])
-AC_ARG_ENABLE([nss],
-        [AS_HELP_STRING([--enable-nss], [Enable NSS support (default: enabled)])],
-        [], [enable_nss=yes])
-AC_MSG_RESULT([$enable_nss])
-
-if test "$enable_nss" = "yes"; then
-   PKG_CHECK_MODULES([NSS], [nss])
-
-   AC_DEFINE([ENABLE_NSS], [1], [Define to compile with NSS support])
-fi
-
-AM_CONDITIONAL([ENABLE_NSS],[test "$enable_nss" = "yes"])
-
 # *******************************
 # Internationalization
 # ******************************* 
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 4dc98e6..b130c16 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -103,13 +103,6 @@ ephy_profile_migrator_LDADD = \
        libephymisc.la \
        $(DEPENDENCIES_LIBS)
 
-if ENABLE_NSS
-ephy_profile_migrator_SOURCES += \
-       ephy-nss-glue.c \
-       ephy-nss-glue.h
-ephy_profile_migrator_LDADD += $(NSS_LIBS)
-endif # ENABLE_NSS
-
 ephy_profile_migrator_CPPFLAGS = \
        -I$(top_builddir)/lib \
        -I$(srcdir)/history \
diff --git a/lib/ephy-profile-migrator.c b/lib/ephy-profile-migrator.c
index b613f79..97ea554 100644
--- a/lib/ephy-profile-migrator.c
+++ b/lib/ephy-profile-migrator.c
@@ -38,9 +38,6 @@
 #include "ephy-settings.h"
 #include "ephy-sqlite-connection.h"
 #include "ephy-web-app-utils.h"
-#ifdef ENABLE_NSS
-#include "ephy-nss-glue.h"
-#endif
 
 #include <fcntl.h>
 #include <glib/gi18n.h>
@@ -126,291 +123,6 @@ migrate_cookies (void)
   g_free (dest);
 }
 
-#ifdef ENABLE_NSS
-static char *
-decrypt (const char *data)
-{
-  unsigned char *plain;
-  gsize out_len;
-
-  /* The old style password is encoded in base64. They are identified
-   * by a leading '~'. Otherwise, we should decrypt the text.
-   */
-  plain = g_base64_decode (data, &out_len);
-  if (data[0] != '~') {
-    char *decrypted;
-
-    decrypted = ephy_nss_glue_decrypt (plain, out_len);
-    g_free (plain);
-    plain = (unsigned char *)decrypted;
-  }
-
-  return (char *)plain;
-}
-
-static void
-parse_and_decrypt_signons (const char *signons,
-                           gboolean    handle_forms)
-{
-  int version;
-  gchar **lines;
-  guint i;
-  guint length;
-
-  lines = g_strsplit (signons, "\r\n", -1);
-  if (!g_ascii_strncasecmp (lines[0], "#2c", 3))
-    version = 1;
-  else if (!g_ascii_strncasecmp (lines[0], "#2d", 3))
-    version = 2;
-  else if (!g_ascii_strncasecmp (lines[0], "#2e", 3))
-    version = 3;
-  else
-    goto out;
-
-  /* Skip the never-saved list */
-  for (i = 1; lines[i] && !g_str_equal (lines[i], "."); i++) {
-    ;
-  }
-
-  i++;
-
-  /*
-   * Read saved passwords. The information is stored in blocks
-   * separated by lines that only contain a dot. We find a block by
-   * the separator and parse them one by one.
-   */
-  length = g_strv_length (lines);
-
-  while (i < length) {
-    size_t begin = i;
-    size_t end = i + 1;
-    const char *realmBracketBegin = " (";
-    const char *realmBracketEnd = ")";
-    SoupURI *uri = NULL;
-    char *realm = NULL;
-
-    while (lines[end] && !g_str_equal (lines[end], "."))
-      end++;
-
-    i = end + 1;
-
-    /* A block has at least five lines */
-    if (end - begin < 5)
-      continue;
-
-    /* The first line is the site URL.
-     * For HTTP authentication logins, the URL may contain http realm,
-     * which will be in bracket:
-     *   sitename:8080 (realm)
-     */
-    if (g_strstr_len (lines[begin], -1, realmBracketBegin)) {
-      char *start_ptr, *end_ptr;
-      char *full_url, *url;
-      glong start, ending;
-
-      /* In this case the scheme may not exist. We assume that the
-       * scheme is HTTP.
-       */
-      if (!g_strstr_len (lines[begin], -1, "://"))
-        full_url = g_strconcat ("http://";, lines[begin], NULL);
-      else
-        full_url = g_strdup (lines[begin]);
-
-      start_ptr = g_strstr_len (full_url, -1, realmBracketBegin);
-      start = g_utf8_pointer_to_offset (full_url, start_ptr);
-      url = g_utf8_substring (full_url, 0, start);
-      url = g_strstrip (url);
-      uri = soup_uri_new (url);
-      g_free (url);
-
-      start += strlen (realmBracketBegin);
-      end_ptr = g_strstr_len (full_url, -1, realmBracketEnd) - 1;
-      ending = g_utf8_pointer_to_offset (full_url, end_ptr);
-      realm = g_utf8_substring (full_url, start, ending);
-
-      g_free (full_url);
-    } else {
-      /* Don't have HTTP realm. It is the URL that the following
-       * password belongs to.
-       */
-      uri = soup_uri_new (lines[begin]);
-    }
-
-    if (!SOUP_URI_VALID_FOR_HTTP (uri)) {
-      soup_uri_free (uri);
-      g_free (realm);
-      continue;
-    }
-
-    ++begin;
-
-    /* There may be multiple username/password pairs for this site.
-     * In this case, they are saved in one block without a separated
-     * line (contains a dot).
-     */
-    while (begin + 4 < end) {
-      char *username = NULL;
-      char *password = NULL;
-      char *form_username = NULL;
-      char *form_password = NULL;
-
-      /* The username */
-      if (handle_forms) {
-        form_username = g_strdup (lines[begin++]);
-      } else {
-        begin++; /* Skip username element */
-      }
-      username = decrypt (lines[begin++]);
-
-      /* The password */
-      /* The element name has a leading '*' */
-      if (lines[begin][0] == '*') {
-        if (handle_forms) {
-          form_password = g_strdup (lines[begin++]);
-        } else {
-          begin++; /* Skip password element */
-        }
-        password = decrypt (lines[begin++]);
-      } else {
-        /* Maybe the file is broken, skip to the next block */
-        g_free (username);
-        break;
-      }
-
-      /* The action attribute for from the form element. This line
-       * exists in version 2 or above
-       */
-      if (version >= 2) {
-        begin++;
-
-        /* Version 3 has an extra line for further use */
-        if (version == 3)
-          begin++;
-      }
-
-      if (handle_forms && !realm &&
-          username && password &&
-          !g_str_equal (username, "") &&
-          !g_str_equal (form_username, "") &&
-          !g_str_equal (form_password, "*")) {
-        char *u = soup_uri_to_string (uri, FALSE);
-        /* We skip the '*' at the beginning of form_password. */
-        ephy_form_auth_data_store (u,
-                                   form_username,
-                                   form_password + 1,
-                                   username,
-                                   password,
-                                   NULL, NULL);
-        g_free (u);
-      } else if (!handle_forms && realm &&
-                 username && password &&
-                 !g_str_equal (username, "") &&
-                 form_username == NULL && form_password == NULL) {
-        char *u = soup_uri_to_string (uri, FALSE);
-        secret_password_store_sync (SECRET_SCHEMA_COMPAT_NETWORK,
-                                    SECRET_COLLECTION_DEFAULT,
-                                    u, password, NULL, NULL,
-                                    "user", username,
-                                    "domain", realm,
-                                    "server", uri->host,
-                                    "protocol", uri->scheme,
-                                    "port", (gint)uri->port,
-                                    NULL);
-      }
-
-      g_free (username);
-      g_free (password);
-      g_free (form_username);
-      g_free (form_password);
-    }
-
-    soup_uri_free (uri);
-    g_free (realm);
-  }
-
- out:
-  g_strfreev (lines);
-}
-#endif
-
-static void
-migrate_passwords (void)
-{
-#ifdef ENABLE_NSS
-  char *dest, *contents, *gecko_passwords_backup;
-  gsize length;
-  GError *error = NULL;
-
-  dest = g_build_filename (ephy_dot_dir (),
-                           "mozilla", "epiphany", "signons3.txt",
-                           NULL);
-  if (!g_file_test (dest, G_FILE_TEST_EXISTS)) {
-    g_free (dest);
-    dest = g_build_filename (ephy_dot_dir (),
-                             "mozilla", "epiphany", "signons2.txt",
-                             NULL);
-    if (!g_file_test (dest, G_FILE_TEST_EXISTS)) {
-      g_free (dest);
-      return;
-    }
-  }
-
-  if (!ephy_nss_glue_init ())
-    return;
-
-  if (!g_file_get_contents (dest, &contents, &length, &error)) {
-    g_free (dest);
-  }
-
-  parse_and_decrypt_signons (contents, FALSE);
-
-  /* Save the contents in a backup directory for future data
-     extraction when we support more features */
-  gecko_passwords_backup = g_build_filename (ephy_dot_dir (),
-                                             "gecko-passwords.txt", NULL);
-
-  if (!g_file_set_contents (gecko_passwords_backup, contents,
-                            -1, &error)) {
-    g_error_free (error);
-  }
-
-  g_free (gecko_passwords_backup);
-  g_free (contents);
-
-  ephy_nss_glue_close ();
-#endif
-}
-
-static void
-migrate_passwords2 (void)
-{
-#ifdef ENABLE_NSS
-  char *dest, *contents;
-  gsize length;
-  GError *error = NULL;
-
-  dest = g_build_filename (ephy_dot_dir (),
-                           "gecko-passwords.txt",
-                           NULL);
-  if (!g_file_test (dest, G_FILE_TEST_EXISTS)) {
-    g_free (dest);
-    return;
-  }
-
-  if (!ephy_nss_glue_init ())
-    return;
-
-  if (!g_file_get_contents (dest, &contents, &length, &error)) {
-    g_free (dest);
-  }
-
-  parse_and_decrypt_signons (contents, TRUE);
-  g_free (contents);
-
-  ephy_nss_glue_close ();
-#endif
-}
-
 /* History migration */
 
 static EphyHistoryService *history_service = NULL;
@@ -986,15 +698,23 @@ migrate_app_desktop_file_categories (void)
   ephy_web_application_free_application_list (web_apps);
 }
 
+static void
+migrate_nothing (void)
+{
+  /* Used to replace migrators that have been removed. E.g. we used to have
+   * three password migrators that depended on NSS, but supporting ancient
+   * user profiles from almost a decade ago is not worth depending on NSS.
+   *
+   * Note that you cannot simply remove a migrator from the migrators struct,
+   * as that would mess up tracking of which migrators have been run.
+   */
+}
+
 const EphyProfileMigrator migrators[] = {
   migrate_cookies,
-  migrate_passwords,
-  /* Yes, again! Version 2 had some bugs, so we need to run
-     migrate_passwords again to possibly migrate more passwords*/
-  migrate_passwords,
-  /* Very similar to migrate_passwords, but this migrates
-   * login/passwords for page forms, which we previously ignored */
-  migrate_passwords2,
+  migrate_nothing,
+  migrate_nothing,
+  migrate_nothing,
   migrate_history,
   migrate_tabs_visibility,
   migrate_web_app_links,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]