Commit 6225374a authored by Michael Catanzaro's avatar Michael Catanzaro
Browse files

Do not run new migrator if the main profile has been migrated

This is ephy *profile* migrator. It runs on a per-profile basis. i.e.
each web app runs migrators separately. So this migration step could run
once for a profile dir, then again far in the future when an old web app
is opened. But passwords are global state, not stored in the profile dir,
and we want to run this migration only once. This is tricky to fix, but
it's easier if we relax the constraint to "never run this migrator if it
has been run already for the default profile dir." That's because we don't
really care if a couple web app passwords get converted from insecure to
secure, which is not a big problem and indicates the user probably never
uses Epiphany except for web apps anyway. We just don't want all the user's
passwords to get converted mysteriously because he happens to open a web
app. So check the migration version for the default profile dir and abort
if this migrator has already run there. This way we avoid adding a new flag
file to clutter the profile dir just to check if this migrator has run.

https://bugzilla.gnome.org/show_bug.cgi?id=752738
parent b0e4bdf3
......@@ -1031,8 +1031,30 @@ migrate_insecure_passwords (void)
SecretService *service;
GHashTable *attributes;
GList *items;
int default_profile_migration_version;
GError *error = NULL;
/* This is ephy *profile* migrator. It runs on a per-profile basis. i.e.
* each web app runs migrators separately. So this migration step could run
* once for a profile dir, then again far in the future when an old web app
* is opened. But passwords are global state, not stored in the profile dir,
* and we want to run this migration only once. This is tricky to fix, but
* it's easier if we relax the constraint to "never run this migrator if it
* has been run already for the default profile dir." That's because we don't
* really care if a couple web app passwords get converted from insecure to
* secure, which is not a big problem and indicates the user probably never
* uses Epiphany except for web apps anyway. We just don't want all the user's
* passwords to get converted mysteriously because he happens to open a web
* app. So check the migration version for the default profile dir and abort
* if this migrator has already run there. This way we avoid adding a new flag
* file to clutter the profile dir just to check if this migrator has run.
*/
default_profile_migration_version = ephy_profile_utils_get_migration_version_for_profile_dir (ephy_default_dot_dir ());
if (default_profile_migration_version >= EPHY_INSECURE_PASSWORDS_MIGRATION_VERSION) {
LOG ("Skipping insecure password migration because default profile has already migrated");
return;
}
service = secret_service_get_sync (SECRET_SERVICE_LOAD_COLLECTIONS, NULL, &error);
if (error != NULL) {
g_warning ("Failed to get secret service proxy, insecure passwords will not be migrated: %s", error->message);
......
......@@ -25,17 +25,19 @@
#include "ephy-debug.h"
#include "ephy-file-helpers.h"
#include <string.h>
#define PROFILE_MIGRATION_FILE ".migrated"
int
ephy_profile_utils_get_migration_version ()
ephy_profile_utils_get_migration_version_for_profile_dir (const char *profile_directory)
{
char *migrated_file, *contents = NULL;
gsize size;
int result = 0;
int latest = 0;
migrated_file = g_build_filename (ephy_dot_dir (),
migrated_file = g_build_filename (profile_directory,
PROFILE_MIGRATION_FILE,
NULL);
......@@ -49,7 +51,8 @@ ephy_profile_utils_get_migration_version ()
if (result != 1)
latest = 0;
} else if (ephy_dot_dir_is_default () == FALSE) {
} else if (strcmp (ephy_dot_dir (), profile_directory) == 0 &&
ephy_dot_dir_is_default () == FALSE) {
/* Since version 8, we need to migrate also profile directories
other than the default one. Profiles in such directories work
perfectly fine without going through the first 7 migration
......@@ -64,6 +67,12 @@ ephy_profile_utils_get_migration_version ()
return latest;
}
int
ephy_profile_utils_get_migration_version (void)
{
return ephy_profile_utils_get_migration_version_for_profile_dir (ephy_dot_dir ());
}
gboolean
ephy_profile_utils_set_migration_version (int version)
{
......
......@@ -23,12 +23,14 @@
#include <glib.h>
#define EPHY_PROFILE_MIGRATION_VERSION 11
#define EPHY_INSECURE_PASSWORDS_MIGRATION_VERSION 11
#define EPHY_HISTORY_FILE "ephy-history.db"
#define EPHY_BOOKMARKS_FILE "ephy-bookmarks.xml"
#define EPHY_BOOKMARKS_FILE_RDF "bookmarks.rdf"
int ephy_profile_utils_get_migration_version (void);
int ephy_profile_utils_get_migration_version_for_profile_dir (const char *profile_directory);
gboolean ephy_profile_utils_set_migration_version (int version);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment