From 535a80feab336c85e821a405fc7e6b3606b357ef Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 5 Sep 2013 15:31:29 +0100 Subject: [PATCH] Remove further remnants of gnome-keyring support --- configure.ac | 21 ------- src/mcd-account-manager-default.c | 71 +--------------------- src/mcd-account-manager-default.h | 1 - tests/account-store-default.c | 48 --------------- tests/account-store-default.h | 2 - tests/account-store.c | 30 +-------- .../account-storage/default-keyring-storage.py | 2 - 7 files changed, 4 insertions(+), 171 deletions(-) diff --git a/configure.ac b/configure.ac index ef22fc5..d786888 100644 --- a/configure.ac +++ b/configure.ac @@ -173,28 +173,8 @@ AC_ARG_ENABLE(aegis, AM_CONDITIONAL(ENABLE_AEGIS, [test x$aegis_enabled = xyes]) -keyring_enabled="no" -AC_MSG_CHECKING(whether to build with gnome-keyring support) -AC_ARG_ENABLE(gnome-keyring, - [ --enable-gnome-keyring build with gnome-keyring support. default=no], - [ - AC_MSG_RESULT(${enableval}) - keyring_enabled="${enableval}" - ], - [ - AC_MSG_RESULT(no) - keyring_enabled="no" - ] -) - PKG_PROG_PKG_CONFIG() -if test "x$keyring_enabled" = xauto -then - PKG_CHECK_EXISTS([gnome-keyring-1], [keyring_enabled=yes], - [keyring_enabled=no]) -fi - dnl libaccounts-glib SSO libaccounts_sso_enabled="no" AC_MSG_CHECKING(whether to build with libaccounts-glib SSO suport) @@ -394,7 +374,6 @@ Configure summary: Features: Plugin API documentation.....: ${enable_gtk_doc} - Gnome Keyring................: ${keyring_enabled} Network Manager integration..: ${have_nm} ConnMan integration..........: ${have_connman} Connectivity GSetting........: ${enable_conn_setting} diff --git a/src/mcd-account-manager-default.c b/src/mcd-account-manager-default.c index da84bd3..e73fca1 100644 --- a/src/mcd-account-manager-default.c +++ b/src/mcd-account-manager-default.c @@ -77,7 +77,6 @@ mcd_account_manager_default_init (McdAccountManagerDefault *self) DEBUG ("mcd_account_manager_default_init"); self->filename = account_filename_in (g_get_user_data_dir ()); self->keyfile = g_key_file_new (); - self->secrets = g_key_file_new (); self->removed = g_key_file_new (); self->removed_accounts = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); @@ -101,42 +100,14 @@ _set (const McpAccountStorage *self, const gchar *val) { McdAccountManagerDefault *amd = MCD_ACCOUNT_MANAGER_DEFAULT (self); -#if ENABLE_GNOME_KEYRING - gboolean secret; -#endif amd->save = TRUE; -#if ENABLE_GNOME_KEYRING - /* if we have a keyring, secrets are segregated */ - secret = mcp_account_manager_parameter_is_secret (am, account, key); - - /* remove it from both sets, then re-add it to the right one if non-null */ - g_key_file_remove_key (amd->secrets, account, key, NULL); - g_key_file_remove_key (amd->keyfile, account, key, NULL); - - if (val != NULL) - { - if (secret) - g_key_file_set_value (amd->secrets, account, key, val); - else - g_key_file_set_value (amd->keyfile, account, key, val); - } - - /* if we removed the account before, it now exists again, so... */ - g_hash_table_remove (amd->removed_accounts, account); - - /* likewise the param should no longer be on the deleted list */ - g_key_file_remove_key (amd->removed, account, key, NULL); -#else - if (val != NULL) g_key_file_set_value (amd->keyfile, account, key, val); else g_key_file_remove_key (amd->keyfile, account, key, NULL); -#endif - return TRUE; } @@ -152,16 +123,7 @@ _get (const McpAccountStorage *self, { gchar *v = NULL; -#if ENABLE_GNOME_KEYRING - if (mcp_account_manager_parameter_is_secret (am, account, key)) - v = g_key_file_get_value (amd->secrets, account, key, NULL); - - /* fall back to public source if secret was not in keyring */ - if (v == NULL) - v = g_key_file_get_value (amd->keyfile, account, key, NULL); -#else v = g_key_file_get_value (amd->keyfile, account, key, NULL); -#endif if (v == NULL) return FALSE; @@ -189,28 +151,6 @@ _get (const McpAccountStorage *self, } g_strfreev (keys); - -#if ENABLE_GNOME_KEYRING - keys = g_key_file_get_keys (amd->secrets, account, &n, NULL); - - if (keys == NULL) - n = 0; - - for (i = 0; i < n; i++) - { - gchar *v = g_key_file_get_value (amd->secrets, account, keys[i], NULL); - - if (v != NULL) - { - mcp_account_manager_set_value (am, account, keys[i], v); - mcp_account_manager_parameter_make_secret (am, account, keys[i]); - } - - g_free (v); - } - - g_strfreev (keys); -#endif } return TRUE; @@ -254,25 +194,16 @@ _delete (const McpAccountStorage *self, GStrv keys; gboolean save = FALSE; -#if ENABLE_GNOME_KEYRING - save = g_key_file_remove_key (amd->secrets, account, key, NULL); - if (g_key_file_remove_key (amd->keyfile, account, key, NULL)) - save = TRUE; -#else save = g_key_file_remove_key (amd->keyfile, account, key, NULL); -#endif if (save) amd->save = TRUE; keys = g_key_file_get_keys (amd->keyfile, account, &n, NULL); - /* if that was the last parameter, the account is gone too: * - * note that secret parameters don't keep an account alive - * - * when the last public param dies, the account dies with it */ + /* if that was the last parameter, the account is gone too */ if (keys == NULL || n == 0) { - g_key_file_remove_group (amd->secrets, account, NULL); g_key_file_remove_group (amd->keyfile, account, NULL); } diff --git a/src/mcd-account-manager-default.h b/src/mcd-account-manager-default.h index 99635bf..b16bc4f 100644 --- a/src/mcd-account-manager-default.h +++ b/src/mcd-account-manager-default.h @@ -50,7 +50,6 @@ G_BEGIN_DECLS typedef struct { GObject parent; GKeyFile *keyfile; - GKeyFile *secrets; GKeyFile *removed; GHashTable *removed_accounts; gchar *filename; diff --git a/tests/account-store-default.c b/tests/account-store-default.c index 7c9c16e..7f4c8c3 100644 --- a/tests/account-store-default.c +++ b/tests/account-store-default.c @@ -89,27 +89,6 @@ default_set (const gchar *account, { GKeyFile *keyfile = NULL; -#if ENABLE_GNOME_KEYRING - /* we want to catch, for instance, param-password or param-proxy-password */ - if (g_str_has_prefix (key, "param-") && g_str_has_suffix (key, "-password")) - { - GnomeKeyringResult result = GNOME_KEYRING_RESULT_CANCELLED; - gchar *name = - g_strdup_printf ("account: %s; param: %s", account, - key + strlen ("param-")); - - result = gnome_keyring_store_password_sync (&keyring_schema, NULL, - name, value, - "account", account, - "param", key + strlen ("param-"), - NULL); - - g_free (name); - - return result == GNOME_KEYRING_RESULT_OK; - } -#endif - keyfile = default_keyfile (); if (keyfile == NULL) @@ -141,30 +120,3 @@ default_list (void) { return g_key_file_get_groups (default_keyfile (), NULL); } - -guint -default_count_passwords (void) -{ -#if ENABLE_GNOME_KEYRING - GnomeKeyringResult ok = GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON; - GnomeKeyringAttributeList *match = gnome_keyring_attribute_list_new (); - GList *items = NULL; - guint n = 0; - - ok = gnome_keyring_find_items_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET, - match, &items); - - if (ok != GNOME_KEYRING_RESULT_OK) - goto finished; - - n = g_list_length (items); - gnome_keyring_found_list_free (items); - - finished: - gnome_keyring_attribute_list_free (match); - - return n; -#else - return 0; -#endif -} diff --git a/tests/account-store-default.h b/tests/account-store-default.h index 2436e93..739f95c 100644 --- a/tests/account-store-default.h +++ b/tests/account-store-default.h @@ -38,6 +38,4 @@ gboolean default_exists (const gchar *account); GStrv default_list (void); -guint default_count_passwords (void); - #endif diff --git a/tests/account-store.c b/tests/account-store.c index 95be121..75860d8 100644 --- a/tests/account-store.c +++ b/tests/account-store.c @@ -51,7 +51,6 @@ typedef struct { gboolean (*delete) (const gchar *account); gboolean (*exists) (const gchar *account); GStrv (*list) (void); - guint (*count_passwords) (void); } Backend; typedef enum { @@ -60,8 +59,7 @@ typedef enum { OP_SET, OP_DELETE, OP_EXISTS, - OP_LIST, - OP_COUNT_PASSWORDS + OP_LIST } Operation; const Backend backends[] = { @@ -70,8 +68,7 @@ const Backend backends[] = { default_set, default_delete, default_exists, - default_list, - default_count_passwords }, + default_list }, #if ENABLE_LIBACCOUNTS_SSO { "libaccounts", @@ -79,8 +76,7 @@ const Backend backends[] = { libaccounts_set, libaccounts_delete, libaccounts_exists, - libaccounts_list, - NULL }, + libaccounts_list }, #endif { NULL } @@ -133,8 +129,6 @@ int main (int argc, char **argv) op = OP_EXISTS; else if (g_str_equal (op_name, "list")) op = OP_LIST; - else if (g_str_equal (op_name, "count-passwords")) - op = OP_COUNT_PASSWORDS; switch (op) { @@ -173,11 +167,6 @@ int main (int argc, char **argv) usage (argv[0], "op '%s' requires an backend", op_name); break; - case OP_COUNT_PASSWORDS: - if (argc < 3) - usage (argv[0], "op '%s' requires an backend", op_name); - break; - case OP_UNKNOWN: usage (argv[0], "Unknown operation: %s", op_name); } @@ -215,19 +204,6 @@ int main (int argc, char **argv) g_strfreev (list); break; - case OP_COUNT_PASSWORDS: - if (store->count_passwords == NULL) - { - g_printerr ("Password-counting is unimplemented\n"); - } - else - { - guint n = store->count_passwords (); - output = g_strdup_printf ("%u", n); - success = TRUE; - } - break; - default: output = g_strdup ("Unknown operation"); } diff --git a/tests/twisted/account-storage/default-keyring-storage.py b/tests/twisted/account-storage/default-keyring-storage.py index b0b2010..2d3b2fc 100644 --- a/tests/twisted/account-storage/default-keyring-storage.py +++ b/tests/twisted/account-storage/default-keyring-storage.py @@ -194,8 +194,6 @@ AutomaticPresence=2;available;; assert 'param-password' not in kf[group] pwd = account_store('get', 'default', 'param-password') assertEquals(None, pwd) - pwd = account_store('count-passwords', 'default') - assertEquals('0', pwd) # Write out an account configuration in the old keyfile, to test # migration -- 1.8.4.rc3