From c9726df59804003d571eb94baf2694122d5ea514 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 28 Aug 2013 14:44:58 +0100 Subject: [PATCH] Remove gnome-keyring support Bug: https://bugs.freedesktop.org/show_bug.cgi?id=32578 --- configure.ac | 12 - mission-control-plugins/account-storage.c | 5 +- src/Makefile.am | 8 - src/mcd-account-manager-default.c | 366 --------------------- tests/Makefile.am | 15 - tests/account-store-default.c | 127 +------ tests/account-store.c | 35 -- tests/keyring-command.c | 174 ---------- tests/twisted/Makefile.am | 8 - .../account-storage/default-keyring-storage.py | 95 +----- tests/twisted/mc-debug-server.c | 26 -- tests/twisted/tools/exec-with-log.sh.in | 6 - 12 files changed, 7 insertions(+), 870 deletions(-) delete mode 100644 tests/keyring-command.c diff --git a/configure.ac b/configure.ac index 4b7d335..7f912fc 100644 --- a/configure.ac +++ b/configure.ac @@ -195,18 +195,6 @@ then [keyring_enabled=no]) fi -AM_CONDITIONAL(ENABLE_GNOME_KEYRING, [test x$keyring_enabled = xyes]) - -if test "x$keyring_enabled" = xyes -then - PKG_CHECK_MODULES([GNOME_KEYRING], [gnome-keyring-1]) - AC_SUBST([GNOME_KEYRING_LIBS]) - AC_SUBST([GNOME_KEYRING_CFLAGS]) - AC_DEFINE([ENABLE_GNOME_KEYRING], [1], [Define whether gnome-keyring support is enabled]) -else - AC_DEFINE([ENABLE_GNOME_KEYRING], [0], [Define whether gnome-keyring support is enabled]) -fi - dnl libaccounts-glib SSO libaccounts_sso_enabled="no" AC_MSG_CHECKING(whether to build with libaccounts-glib SSO suport) diff --git a/mission-control-plugins/account-storage.c b/mission-control-plugins/account-storage.c index c807e85..3991c0c 100644 --- a/mission-control-plugins/account-storage.c +++ b/mission-control-plugins/account-storage.c @@ -464,9 +464,8 @@ mcp_account_storage_iface_implement_create ( * are higher priority. * * Plugins at a higher priority then MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_KEYRING - * will have the opportunity to "steal" passwords from the gnome keyring: - * Plugins at a lower priority than this will not receive secret parameters - * from MC as the keyring plugin will already have claimed them. + * used to have the opportunity to "steal" passwords from the gnome keyring. + * It is no longer significant. * * Plugins at a lower priority than the default plugin will never be asked to * store any details, although they may still be asked to list them at startup diff --git a/src/Makefile.am b/src/Makefile.am index 4d679cd..62f83b1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,10 +11,6 @@ INCLUDES = \ AM_CFLAGS = $(ERROR_CFLAGS) -if ENABLE_GNOME_KEYRING -INCLUDES += $(GNOME_KEYRING_CFLAGS) -endif - mc_headers = \ mcd-account.h \ mcd-account-conditions.h \ @@ -101,10 +97,6 @@ libmcd_convenience_la_LIBADD = \ $(UPOWER_GLIB_LIBS) \ $(NULL) -if ENABLE_GNOME_KEYRING -libmcd_convenience_la_LIBADD += $(GNOME_KEYRING_LIBS) -endif - if ENABLE_LIBACCOUNTS_SSO libmcd_convenience_la_LIBADD += $(LIBACCOUNTS_SSO_LIBS) INCLUDES += $(LIBACCOUNTS_SSO_CFLAGS) diff --git a/src/mcd-account-manager-default.c b/src/mcd-account-manager-default.c index 889486d..da84bd3 100644 --- a/src/mcd-account-manager-default.c +++ b/src/mcd-account-manager-default.c @@ -37,361 +37,6 @@ #define PLUGIN_DESCRIPTION "GKeyFile (default) account storage backend" #define INITIAL_CONFIG "# Telepathy accounts\n" -#if ENABLE_GNOME_KEYRING -#include - -GnomeKeyringPasswordSchema keyring_schema = - { GNOME_KEYRING_ITEM_GENERIC_SECRET, - { { "account", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, - { "param", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, - { NULL, 0 } } }; - -typedef struct -{ - gchar *account; - gchar *name; - gboolean set; -} KeyringSetData; - -static void -_keyring_set_cb (GnomeKeyringResult result, - gpointer data) -{ - KeyringSetData *ksd = data; - - if (result != GNOME_KEYRING_RESULT_OK) - g_warning ("failed to save %s.%s : %s", ksd->account, ksd->name, - gnome_keyring_result_to_message (result)); - else - DEBUG ("%s %s.%s in gnome keyring", - ksd->set ? "saved" : "deleted", - ksd->account, - ksd->name); - - g_free (ksd->account); - g_free (ksd->name); - g_slice_free(KeyringSetData, ksd); -} - -static void -_delete_from_keyring (const McpAccountStorage *self, - const McpAccountManager *am, - const gchar *account, - const gchar *key) -{ - McdAccountManagerDefault *amd = MCD_ACCOUNT_MANAGER_DEFAULT (self); - - if (key == NULL) - { - /* flag the whole account as purged */ - gchar *removed = g_strdup (account); - g_hash_table_replace (amd->removed_accounts, removed, removed); - g_key_file_remove_group (amd->secrets, removed, NULL); - } - else - { - /* remember to forget this one param */ - g_key_file_set_value (amd->removed, account, key, ""); - g_key_file_remove_key (amd->secrets, account, key, NULL); - } -} - -static void -_keyring_remove_account (const McpAccountStorage *self, - const McpAccountManager *am, - const gchar *account) -{ - GList *i; - GList *items; - GnomeKeyringAttributeList *match = gnome_keyring_attribute_list_new (); - GnomeKeyringResult ok; - - gnome_keyring_attribute_list_append_string (match, "account", account); - - ok = gnome_keyring_find_items_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET, - match, &items); - - if (ok != GNOME_KEYRING_RESULT_OK) - goto finished; - - for (i = items; i != NULL; i = g_list_next (i)) - { - GnomeKeyringFound *found = i->data; - gnome_keyring_item_delete_sync (found->keyring, found->item_id); - } - - finished: - gnome_keyring_attribute_list_free (match); -} - -static void -_keyring_commit_one (const McdAccountManagerDefault *amd, - const McpAccountManager *am, - const gchar *account_name) -{ - gsize j; - gsize k; - GStrv keys = g_key_file_get_keys (amd->secrets, account_name, &k, NULL); - - if (keys == NULL) - k = 0; - - for (j = 0; j < k; j++) - { - gchar *name = g_strdup_printf ("account: %s; param: %s", - account_name, keys[j]); - gchar *val = g_key_file_get_value (amd->secrets, - account_name, keys[j], NULL); - gchar *key = keys[j]; - KeyringSetData *ksd = g_slice_new0 (KeyringSetData); - - /* for compatibility with old gnome keyring code we must strip * - * the param- prefix from the name before saving to the keyring */ - if (g_str_has_prefix (key, "param-")) - key += strlen ("param-"); - - ksd->account = g_strdup (account_name); - ksd->name = g_strdup (keys[j]); - ksd->set = TRUE; - - gnome_keyring_store_password (&keyring_schema, NULL, - name, val, _keyring_set_cb, ksd, NULL, - "account", account_name, - "param", key, - NULL); - - g_free (val); - g_free (name); - } - - g_strfreev (keys); -} - -static void -_keyring_commit (const McpAccountStorage *self, - const McpAccountManager *am, - const gchar *account_name) -{ - McdAccountManagerDefault *amd = MCD_ACCOUNT_MANAGER_DEFAULT (self); - gsize n; - gsize i; - GStrv accts; - GHashTableIter iter = { 0 }; - gchar *account = NULL; - - if (!gnome_keyring_is_available ()) - return; - - /* purge any entirely removed accounts */ - g_hash_table_iter_init (&iter, amd->removed_accounts); - - while (g_hash_table_iter_next (&iter, (gpointer *) &account, NULL)) - _keyring_remove_account (self, am, (gchar *) account); - - g_hash_table_remove_all (amd->removed_accounts); - - /* purge deleted parameters for remaining accounts */ - accts = g_key_file_get_groups (amd->removed, &n); - - for (i = 0; i < n; i++) - { - gsize j; - gsize k; - GStrv keys = g_key_file_get_keys (amd->removed, accts[i], &k, NULL); - - if (keys == NULL) - k = 0; - - for (j = 0; j < k; j++) - { - KeyringSetData *ksd = g_slice_new0 (KeyringSetData); - const gchar *key = keys[j]; - - /* for compatibility with old gnome keyring code we must strip * - * the param- prefix from the name before saving to the keyring */ - if (g_str_has_prefix (key, "param-")) - key += strlen ("param-"); - - ksd->account = g_strdup (accts[i]); - ksd->name = g_strdup (key); - ksd->set = FALSE; - - gnome_keyring_delete_password (&keyring_schema, - _keyring_set_cb, ksd, NULL, - "account", accts[i], - "param", key, - NULL); - } - - g_strfreev (keys); - } - - g_strfreev (accts); - - /* forget about all the purged params completely */ - g_key_file_load_from_data (amd->removed, "#\n", -1, 0, NULL); - - if (account_name == NULL) - { - /* ok, write out the values for all the accounts we have: */ - accts = g_key_file_get_groups (amd->secrets, &n); - - for (i = 0; i < n; i++) - _keyring_commit_one (amd, am, accts[i]); - - g_strfreev (accts); - } - else - { - _keyring_commit_one (amd, am, account_name); - } -} - -static void -_get_secrets_from_keyring (const McpAccountStorage *self, - const McpAccountManager *am, - const gchar *account) -{ - McdAccountManagerDefault *amd = MCD_ACCOUNT_MANAGER_DEFAULT (self); - GnomeKeyringResult ok = GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON; - GnomeKeyringAttributeList *match = gnome_keyring_attribute_list_new (); - GList *items = NULL; - GList *i; - - gnome_keyring_attribute_list_append_string (match, "account", account); - - ok = gnome_keyring_find_items_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET, - match, &items); - - if (ok != GNOME_KEYRING_RESULT_OK) - goto finished; - - for (i = items; i != NULL; i = g_list_next (i)) - { - gsize j; - GnomeKeyringFound *entry = i->data; - GnomeKeyringAttributeList *data = entry->attributes; - - for (j = 0; j < data->len; j++) - { - GnomeKeyringAttribute *attr = - &(gnome_keyring_attribute_list_index (data, j)); - const gchar *name = attr->name; - const gchar *value = NULL; - const gchar *param = NULL; - - switch (attr->type) - { - case GNOME_KEYRING_ATTRIBUTE_TYPE_STRING: - if (g_strcmp0 ("param", name) == 0) - { - param = attr->value.string; - value = entry->secret; - } - break; - - default: - g_warning ("Unsupported value type for %s.%s", account, name); - } - - if (!tp_strdiff (param, "password")) - { - /* Empathy 3.0 was meant to migrate passwords from MC to - * itself, but it couldn't complete the migration by - * deleting the password from MC, because MC had several - * bugs that meant deleting passwords didn't work. To atone - * for our past sins, detect an incomplete migration and - * complete it. */ - GnomeKeyringResult empathy_ok = - GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON; - GnomeKeyringAttributeList *empathy_match = - gnome_keyring_attribute_list_new (); - GList *empathy_items = NULL; - - gnome_keyring_attribute_list_append_string (empathy_match, - "account-id", account); - gnome_keyring_attribute_list_append_string (empathy_match, - "param-name", "password"); - - empathy_ok = gnome_keyring_find_items_sync ( - GNOME_KEYRING_ITEM_GENERIC_SECRET, empathy_match, - &empathy_items); - - if (empathy_ok == GNOME_KEYRING_RESULT_OK && - empathy_items != NULL) - { - KeyringSetData *ksd = g_slice_new0 (KeyringSetData); - - DEBUG ("An Empathy 3.0 password migration wasn't finished " - "due to fd.o #42088. Finishing it now by deleting the " - "password for %s", account); - - ksd->account = g_strdup (account); - ksd->name = g_strdup ("password"); - ksd->set = FALSE; - - gnome_keyring_delete_password (&keyring_schema, - _keyring_set_cb, ksd, NULL, - "account", account, - "param", "password", - NULL); - - /* behave as if it had already been deleted, i.e. we never - * actually found it... */ - param = NULL; - value = NULL; - } - - gnome_keyring_found_list_free (empathy_items); - } - - if (param != NULL && value != NULL) - { - gchar *key = g_strdup_printf ("param-%s", param); - - g_key_file_set_value (amd->secrets, account, key, value); - mcp_account_manager_parameter_make_secret (am, account, key); - - g_free (key); - } - } - } - - gnome_keyring_found_list_free (items); - - finished: - gnome_keyring_attribute_list_free (match); -} - -#else - -static void -_delete_from_keyring (const McpAccountStorage *self, - const McpAccountManager *am, - const gchar *account, - const gchar *key) -{ - return; -} - -static void -_keyring_commit (const McpAccountStorage *self, - const McpAccountManager *am, - const gchar *account_name) -{ - return; -} - -static void -_get_secrets_from_keyring (const McpAccountStorage *self, - const McpAccountManager *am, - const gchar *account) -{ - return; -} - -#endif - static void account_storage_iface_init (McpAccountStorageIface *, gpointer); @@ -602,7 +247,6 @@ _delete (const McpAccountStorage *self, { if (g_key_file_remove_group (amd->keyfile, account, NULL)) amd->save = TRUE; - _delete_from_keyring (self, am, account, NULL); } else { @@ -630,13 +274,6 @@ _delete (const McpAccountStorage *self, { g_key_file_remove_group (amd->secrets, account, NULL); g_key_file_remove_group (amd->keyfile, account, NULL); - _delete_from_keyring (self, am, account, NULL); - } - else - { - /* always delete from keyring, even if we didn't previously - * think it was secret - we might have been wrong */ - _delete_from_keyring (self, am, account, key); } g_strfreev (keys); @@ -690,8 +327,6 @@ _commit (const McpAccountStorage *self, g_free (data); - _keyring_commit (self, am, account); - return rval; } @@ -801,7 +436,6 @@ _list (const McpAccountStorage *self, for (i = 0; i < n; i++) { - _get_secrets_from_keyring (self, am, accounts[i]); rval = g_list_prepend (rval, g_strdup (accounts[i])); } diff --git a/tests/Makefile.am b/tests/Makefile.am index c02550f..cf7edc9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,10 +10,6 @@ INCLUDES = \ AM_CFLAGS = $(ERROR_CFLAGS) -if ENABLE_GNOME_KEYRING -INCLUDES += $(GNOME_KEYRING_CFLAGS) -endif - SUBDIRS = . twisted TEST_EXECUTABLES = \ @@ -23,10 +19,6 @@ TEST_EXECUTABLES = \ NON_TEST_EXECUTABLES = account-store tease-the-minotaur -if ENABLE_GNOME_KEYRING -NON_TEST_EXECUTABLES += keyring-command -endif - noinst_PROGRAMS = $(TEST_EXECUTABLES) $(NON_TEST_EXECUTABLES) TESTS = $(TEST_EXECUTABLES) @@ -48,13 +40,6 @@ account_store_SOURCES = \ account-store-default.c \ account-store-default.h -if ENABLE_GNOME_KEYRING -account_store_LDADD += $(GNOME_KEYRING_LIBS) - -keyring_command_LDADD = $(GLIB_LIBS) $(GNOME_KEYRING_LIBS) -keyring_command_SOURCES = keyring-command.c -endif - if ENABLE_LIBACCOUNTS_SSO account_store_SOURCES += account-store-libaccounts.c account-store-libaccounts.h account_store_LDADD += $(LIBACCOUNTS_SSO_LIBS) diff --git a/tests/account-store-default.c b/tests/account-store-default.c index 513799a..c3e357d 100644 --- a/tests/account-store-default.c +++ b/tests/account-store-default.c @@ -25,125 +25,6 @@ #include "account-store-default.h" -#if ENABLE_GNOME_KEYRING -#include - -GnomeKeyringPasswordSchema keyring_schema = - { GNOME_KEYRING_ITEM_GENERIC_SECRET, - { { "account", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, - { "param", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, - { NULL, 0 } } }; - -static gboolean -_keyring_remove_account (const gchar *acct) -{ - GList *i; - GList *items; - GnomeKeyringAttributeList *match = gnome_keyring_attribute_list_new (); - GnomeKeyringResult ok; - - gnome_keyring_attribute_list_append_string (match, "account", acct); - - ok = gnome_keyring_find_items_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET, - match, &items); - - if (ok != GNOME_KEYRING_RESULT_OK) - goto finished; - - for (i = items; i != NULL; i = g_list_next (i)) - { - GnomeKeyringFound *found = i->data; - ok = gnome_keyring_item_delete_sync (found->keyring, found->item_id); - if (ok != GNOME_KEYRING_RESULT_OK) - break; - } - - finished: - gnome_keyring_attribute_list_free (match); - - return ok = GNOME_KEYRING_RESULT_OK; -} - -static gchar * -_get_secret_from_keyring (const gchar *account, const gchar *key) -{ - GnomeKeyringResult ok = GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON; - GnomeKeyringAttributeList *match = gnome_keyring_attribute_list_new (); - GList *items = NULL; - GList *i; - gchar *secret = NULL; - - /* for compatibility with old gnome keyring code we must strip * - * the param- prefix from the name before loading from the keyring */ - if (g_str_has_prefix (key, "param-")) - key += strlen ("param-"); - - gnome_keyring_attribute_list_append_string (match, "account", account); - - ok = gnome_keyring_find_items_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET, - match, &items); - - if (ok != GNOME_KEYRING_RESULT_OK) - goto finished; - - for (i = items; i != NULL; i = g_list_next (i)) - { - gsize j; - GnomeKeyringFound *entry = i->data; - GnomeKeyringAttributeList *data = entry->attributes; - - for (j = 0; j < data->len; j++) - { - GnomeKeyringAttribute *attr = - &(gnome_keyring_attribute_list_index (data, j)); - const gchar *name = attr->name; - const gchar *value = NULL; - const gchar *param = NULL; - - switch (attr->type) - { - case GNOME_KEYRING_ATTRIBUTE_TYPE_STRING: - if (g_strcmp0 ("param", name) == 0) - { - param = attr->value.string; - value = entry->secret; - } - break; - - default: - g_warning ("Unsupported value type for %s.%s", account, name); - } - - if (param != NULL && value != NULL && g_str_equal (param, key)) - secret = g_strdup (value); - } - } - - gnome_keyring_found_list_free (items); - - finished: - gnome_keyring_attribute_list_free (match); - - return secret; -} - -#else - -static gchar * -_get_secret_from_keyring (const gchar *account, - const gchar *key) -{ - return NULL; -} - -static gboolean -_keyring_remove_account (const gchar *acct) -{ - return TRUE; -} - -#endif - static const gchar *default_config (void) { return g_build_filename (g_get_user_data_dir (), "telepathy", @@ -204,12 +85,7 @@ default_get (const gchar *account, if (g_str_has_prefix (key, "param-")) pkey = key + strlen("param-"); - value = _get_secret_from_keyring (account, pkey); - - if (value == NULL) - value = g_key_file_get_string (default_keyfile (), account, key, NULL); - - return value; + return g_key_file_get_string (default_keyfile (), account, key, NULL); } gboolean @@ -256,7 +132,6 @@ default_delete (const gchar *account) GKeyFile *keyfile = default_keyfile (); g_key_file_remove_group (keyfile, account, NULL); - _keyring_remove_account (account); return commit_changes (); } diff --git a/tests/account-store.c b/tests/account-store.c index 7e609a1..95be121 100644 --- a/tests/account-store.c +++ b/tests/account-store.c @@ -89,37 +89,6 @@ const Backend backends[] = { static void usage (const gchar *name, const gchar *fmt, ...) G_GNUC_NORETURN; -#if ENABLE_GNOME_KEYRING -#include - -static void -setup_default_keyring (void) -{ - GnomeKeyringResult result; - - g_debug ("Setting default keyring to: %s", g_getenv ("MC_KEYRING_NAME")); - - if (g_getenv ("MC_KEYRING_NAME") != NULL) - { - const gchar *keyring_name = g_getenv ("MC_KEYRING_NAME"); - - g_debug ("MC Keyring name: %s", keyring_name); - - if ((result = gnome_keyring_set_default_keyring_sync (keyring_name)) == - GNOME_KEYRING_RESULT_OK) - { - g_debug ("Successfully set up temporary keyring %s for tests", - keyring_name); - } - else - { - g_warning ("Failed to set %s as the default keyring: %s", - keyring_name, gnome_keyring_result_to_message (result)); - } - } -} -#endif - int main (int argc, char **argv) { int i; @@ -136,10 +105,6 @@ int main (int argc, char **argv) g_type_init (); g_set_application_name (argv[0]); -#if ENABLE_GNOME_KEYRING - setup_default_keyring (); -#endif - if (argc < 3) usage (argv[0], ""); diff --git a/tests/keyring-command.c b/tests/keyring-command.c deleted file mode 100644 index 0ffd221..0000000 --- a/tests/keyring-command.c +++ /dev/null @@ -1,174 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 8 -*- */ -/* - * This file is part of mission-control - * - * Copyright (C) 2007-2010 Nokia Corporation - * Copyright (C) 2010 Collabora Ltd. - * - * Contact: Naba Kumar - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include "config.h" - -#include -#include -#include -#include - - -static gboolean -create_keyring (gchar *keyring_name) -{ - GnomeKeyringResult result; - - result = gnome_keyring_create_sync (keyring_name, ""); - - if (result == GNOME_KEYRING_RESULT_OK) - return TRUE; - - g_warning ("Failed to create keyring %s: %s", keyring_name, - gnome_keyring_result_to_message (result)); - - return FALSE; -} - -static gchar * -create_random_keyring (void) -{ - gchar *keyring_name = NULL; - GnomeKeyringResult result; - - while (TRUE) - { - keyring_name = g_strdup_printf ("mc-test-%u", g_random_int ()); - - result = gnome_keyring_create_sync (keyring_name, ""); - - if (result == GNOME_KEYRING_RESULT_OK) - { - return keyring_name; - } - else if (result == GNOME_KEYRING_RESULT_KEYRING_ALREADY_EXISTS) - { - g_free (keyring_name); - keyring_name = NULL; - continue; - } - else - { - g_warning ("Failed to create keyring %s: %s", keyring_name, - gnome_keyring_result_to_message (result)); - g_free (keyring_name); - return NULL; - } - } - - g_assert_not_reached (); -} - -static gboolean -remove_keyring (gchar *keyring_name) -{ - GnomeKeyringResult result; - - result = gnome_keyring_delete_sync (keyring_name); - - if (result == GNOME_KEYRING_RESULT_OK) - { - return TRUE; - } - else - { - g_warning ("Failed to remove keyring %s: %s", keyring_name, - gnome_keyring_result_to_message (result)); - return FALSE; - } -} - -static void -show_help (gchar *name) -{ - g_printf ("%s - utility for creating and removing gnome keyrings\n", name); - g_printf ("Usage: %s create [KEYRING]\n", name); - g_printf (" %s remove KEYRING\n", name); -} - -int -main (int argc, char **argv) -{ - g_type_init (); - - if (argc < 2) - { - show_help (argv[0]); - return 0; - } - - if (!g_strcmp0 (argv[1], "create")) - { - if (argc < 3) - { - gchar *keyring_name = create_random_keyring (); - - if (keyring_name) - { - g_printf("%s\n", keyring_name); - g_free (keyring_name); - return 0; - } - else - { - return -1; - } - } - else - { - if (create_keyring (argv[2])) - { - g_printf("%s\n", argv[2]); - return 0; - } - else - { - return -1; - } - } - } - - if (!g_strcmp0 (argv[1], "remove")) - { - if (argc < 3) - { - show_help (argv[0]); - return -1; - } - - if (remove_keyring (argv[2])) - { - return 0; - } - else - { - return -1; - } - } - - show_help (argv[0]); - return -1; -} - diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index 7542e46..03bb60f 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -218,10 +218,6 @@ INCLUDES = \ -DMC_DISABLE_DEPRECATED \ -DLIBDIR="@libdir@" -DLIBVERSION="0" -if ENABLE_GNOME_KEYRING -INCLUDES += $(GNOME_KEYRING_CFLAGS) -endif - TESTS = TMPSUFFIX = foo @@ -241,10 +237,6 @@ BASIC_TESTS_ENVIRONMENT = \ MC_MANAGER_DIR=@abs_top_srcdir@/tests/twisted/telepathy/managers \ G_DEBUG=fatal_criticals -if ENABLE_GNOME_KEYRING -BASIC_TESTS_ENVIRONMENT += MC_TEST_GNOME_KEYRING=1 -endif - if ENABLE_LIBACCOUNTS_SSO BASIC_TESTS_ENVIRONMENT += AG_DEBUG=all \ ACCOUNTS=@abs_top_builddir@/tests/twisted/tmp-$(TMPSUFFIX) \ diff --git a/tests/twisted/account-storage/default-keyring-storage.py b/tests/twisted/account-storage/default-keyring-storage.py index f41bc17..b0b2010 100644 --- a/tests/twisted/account-storage/default-keyring-storage.py +++ b/tests/twisted/account-storage/default-keyring-storage.py @@ -1,3 +1,5 @@ +# Test for default account storage backend. +# # Copyright (C) 2009-2010 Nokia Corporation # Copyright (C) 2009-2010 Collabora Ltd. # @@ -32,29 +34,6 @@ from mctest import ( ) import constants as cs -# FIXME: this test relies on tools in the builddir. It won't work when -# the tests are installed and run without a builddir. - -use_keyring = False -if ('MC_TEST_GNOME_KEYRING' in os.environ and - os.environ['MC_TEST_GNOME_KEYRING'] == '1'): - use_keyring = True - -def create_keyring(): - if not use_keyring: - return - - keyring = os.popen('../keyring-command create').read() - if not keyring or keyring.startswith('**'): - return None - return keyring[:-1] - -def remove_keyring(name): - if not use_keyring: - return - - os.system('../keyring-command remove ' + name) - # This doesn't escape its parameters before passing them to the shell, # so be careful. def account_store(op, backend, key=None, value=None, @@ -79,49 +58,6 @@ def account_store(op, backend, key=None, value=None, else: return None -def start_gnome_keyring_daemon(ctl_dir): - if not use_keyring: - return - - os.chmod(ctl_dir, 0700) - # Ugh. We have to put XDG_DATA_DIRS back the way we found them because - # otherwise it won't find its schemas and everything goes horribly wrong. - env = os.popen('/usr/bin/env XDG_DATA_DIRS=/usr/local/share:/usr/share gnome-keyring-daemon -d --control-directory=' + ctl_dir).read() - env_file = open(ctl_dir + '/gnome-keyring-env', 'w') - - for line in env.split('\n'): - if line: - k, v = line.split('=', 1) - print "Adding to env: %s=%s" % (k, v) - os.environ[k] = v - env_file.write('%s=%s\n' % (k, v)) - - # Wait for gnome-keyring to start. We shouldn't have to do this, but, - # whatever. Happily, we have a tool which can do this for us. - os.system('../../util/mc-wait-for-name org.freedesktop.secrets') - - keyring_name = create_keyring() - assert keyring_name - print "Created new keyring name, putting to env", keyring_name - os.environ['MC_KEYRING_NAME'] = keyring_name - env_file.write('MC_KEYRING_NAME=%s\n' % keyring_name) - env_file.close() - -def stop_gnome_keyring_daemon(): - if not use_keyring: - return - - keyring_name = os.environ['MC_KEYRING_NAME'] - keyring_daemon_pid = os.environ['GNOME_KEYRING_PID'] - - if keyring_name: - print "Removing keyring", keyring_name - remove_keyring(keyring_name) - - if keyring_daemon_pid: - print "Killing keyring daemon, pid =", keyring_daemon_pid - os.kill(int(keyring_daemon_pid), 15) - def test(q, bus, mc): ctl_dir = os.environ['MC_ACCOUNT_DIR'] old_key_file_name = os.path.join(ctl_dir, 'accounts.cfg') @@ -177,12 +113,8 @@ def test(q, bus, mc): pwd = account_store('get', 'default', 'param-password') assert pwd == params['password'], pwd - # If we're using GNOME keyring, the password should not be in the - # keyfile - if use_keyring: - assert 'param-password' not in kf[group] - else: - assert kf[group]['param-password'] == params['password'], kf + # We no longer use gnome-keyring, so the password is stored as clear-text. + assert kf[group]['param-password'] == params['password'], kf # Reactivate MC account_manager, properties, interfaces = resuscitate_mc(q, bus, mc) @@ -211,22 +143,9 @@ def test(q, bus, mc): kf = keyfile_read(new_key_file_name) assert group not in kf, kf - if use_keyring: - # the password has been deleted from the keyring too - pwd = account_store('get', 'default', 'param-password') - assertEquals(None, pwd) - # Tell MC to die, again tell_mc_to_die(q, bus) - # Write out an account configuration in which the password is in - # both the keyfile and the keyring - - - if use_keyring: - account_store('set', 'default', 'param-password', - 'password_in_keyring') - low_prio_key_file_name = os.path.join( os.environ['XDG_DATA_DIRS'].split(':')[0], 'telepathy', 'mission-control', 'accounts.cfg') @@ -254,10 +173,6 @@ AutomaticPresence=2;available;; assert not os.path.exists(new_key_file_name) assert os.path.exists(low_prio_key_file_name) - if use_keyring: - pwd = account_store('get', 'default', 'param-password') - assertEquals('password_in_keyring', pwd) - # Delete the password (only), like Empathy 3.0-3.4 do when migrating account_iface.UpdateParameters({}, ['password']) q.expect('dbus-signal', @@ -314,6 +229,4 @@ if __name__ == '__main__': os.mkdir(ctl_dir, 0700) except OSError: pass - start_gnome_keyring_daemon(ctl_dir) exec_test(test, {}, timeout=10, use_fake_accounts_service=False) - stop_gnome_keyring_daemon() diff --git a/tests/twisted/mc-debug-server.c b/tests/twisted/mc-debug-server.c index 15944fe..edbce4b 100644 --- a/tests/twisted/mc-debug-server.c +++ b/tests/twisted/mc-debug-server.c @@ -35,10 +35,6 @@ #include -#if ENABLE_GNOME_KEYRING -#include -#endif - #include "mcd-service.h" TpDBusDaemon *bus_daemon = NULL; @@ -148,9 +144,6 @@ main (int argc, char **argv) int ret = 1; GMainLoop *teardown_loop; guint linger_time = 5; -#if ENABLE_GNOME_KEYRING - GnomeKeyringResult result; -#endif g_type_init (); @@ -195,25 +188,6 @@ main (int argc, char **argv) tp_proxy_get_dbus_connection (bus_daemon)); dbus_connection_add_filter (connection, dbus_filter_function, NULL, NULL); -#if ENABLE_GNOME_KEYRING - if (g_getenv ("MC_KEYRING_NAME") != NULL) - { - const gchar *keyring_name = g_getenv ("MC_KEYRING_NAME"); - - if ((result = gnome_keyring_set_default_keyring_sync (keyring_name)) == - GNOME_KEYRING_RESULT_OK) - { - g_debug ("Successfully set up temporary keyring %s for tests", - keyring_name); - } - else - { - g_warning ("Failed to set %s as the default keyring: %s", - keyring_name, gnome_keyring_result_to_message (result)); - } - } -#endif - mcd = mcd_service_new (); /* Listen for suicide notification */ diff --git a/tests/twisted/tools/exec-with-log.sh.in b/tests/twisted/tools/exec-with-log.sh.in index 74bc56d..7c2bfd5 100644 --- a/tests/twisted/tools/exec-with-log.sh.in +++ b/tests/twisted/tools/exec-with-log.sh.in @@ -62,12 +62,6 @@ if test "z$MC_EXECUTABLE" = z; then MC_EXECUTABLE=@abs_top_builddir@/tests/twisted/mc-debug-server fi -if test -f "$MC_ACCOUNT_DIR/gnome-keyring-env"; then - cat "$MC_ACCOUNT_DIR/gnome-keyring-env" - . "$MC_ACCOUNT_DIR/gnome-keyring-env" - export GNOME_KEYRING_CONTROL GNOME_KEYRING_PID MC_KEYRING_NAME SSH_AUTH_SOCK -fi - GSETTINGS_SCHEMA_DIR=@abs_top_builddir@/data export GSETTINGS_SCHEMA_DIR -- 1.8.4.rc3