[tracker] libtracker-miner: Migrate from libgnome-keyring to libsecret
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-miner: Migrate from libgnome-keyring to libsecret
- Date: Thu, 3 Jan 2013 17:33:14 +0000 (UTC)
commit 944f39295ff337eefa5de793d0364dbd6fd41bad
Author: Stef Walter <stefw gnome org>
Date: Fri Jul 13 17:27:37 2012 +0200
libtracker-miner: Migrate from libgnome-keyring to libsecret
See: https://live.gnome.org/GnomeGoals/LibsecretMigration
Fixes GB#679870, libsecret migrations
configure.ac | 43 ++++--
src/libtracker-miner/Makefile.am | 2 +-
.../tracker-password-provider-gnome.c | 138 ++++++++++----------
3 files changed, 97 insertions(+), 86 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7afb0dd..a39a3e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -192,7 +192,7 @@ CAMEL_REQUIRED=2.32.0
LIBSTREAMANALYZER_REQUIRED=0.7.0
GEE_REQUIRED=0.3
TAGLIB_REQUIRED=1.6
-GNOME_KEYRING_REQUIRED=2.26
+LIBSECRET_REQUIRED=0.5
LIBGRSS_REQUIRED=0.5
REST_REQUIRED=0.6
NETWORK_MANAGER_REQUIRED=0.8
@@ -924,7 +924,7 @@ AM_CONDITIONAL(BUILD_LIBUNISTRING_PARSER, test "x$with_unicode_support" = "xlibu
AM_CONDITIONAL(BUILD_LIBICU_PARSER, test "x$with_unicode_support" = "xlibicu")
##################################################################
-# Check for libtracker-miner: gnome-keyring for web miner details
+# Check for libtracker-miner: libsecet for web miner details
##################################################################
AC_ARG_ENABLE(gnome_keyring,
@@ -932,27 +932,39 @@ AC_ARG_ENABLE(gnome_keyring,
[enable Gnome Keyring support to store credentials [[default=auto]]]),,
[enable_gnome_keyring=auto])
-if test "x$enable_gnome_keyring" != "xno"; then
- PKG_CHECK_MODULES(GNOME_KEYRING,
- [gnome-keyring-1 >= $GNOME_KEYRING_REQUIRED],
- [have_gnome_keyring=yes],
- [have_gnome_keyring=no])
+AC_ARG_ENABLE(libsecret,
+ AS_HELP_STRING([--enable-libsecret],
+ [enable libsecret support to store login credentials [[default=auto]]]),,
+ [enable_libsecret=auto])
- LIBTRACKER_MINER_CFLAGS="$LIBTRACKER_MINER_CFLAGS $GNOME_KEYRING_CFLAGS"
- LIBTRACKER_MINER_LIBS="$LIBTRACKER_MINER_LIBS $GNOME_KEYRING_LIBS"
+if test "x$enable_gnome_keyring" != "xauto"; then
+ AC_MSG_WARN([The --enable-gnome-keyring option has been deprecated for --enable-libsecret])
- if test "x$have_gnome_keyring" = "xyes"; then
- AC_DEFINE(HAVE_GNOME_KEYRING, [], [Define if we have Gnome Keyring for password storage])
+ # Try to continue as normal
+ enable_libsecret="$enable_gnome_keyring"
+fi
+
+if test "x$enable_libsecret" != "xno"; then
+ PKG_CHECK_MODULES(LIBSECRET,
+ [libsecret-unstable >= $LIBSECRET_REQUIRED],
+ [have_libsecret=yes],
+ [have_libsecret=no])
+
+ LIBTRACKER_MINER_CFLAGS="$LIBTRACKER_MINER_CFLAGS $LIBSECRET_CFLAGS"
+ LIBTRACKER_MINER_LIBS="$LIBTRACKER_MINER_LIBS $LIBSECRET_LIBS"
+
+ if test "x$have_libsecret" = "xyes"; then
+ AC_DEFINE(HAVE_LIBSECRET, [], [Define if we have libsecret for password storage])
fi
fi
-if test "x$enable_gnome_keyring" = "xyes"; then
- if test "x$have_gnome_keyring" != "xyes"; then
- AC_MSG_ERROR([Couldn't find Gnome Keyring >= $GNOME_KEYRING_REQUIRED.])
+if test "x$enable_libsecret" = "xyes"; then
+ if test "x$have_libsecret" != "xyes"; then
+ AC_MSG_ERROR([Couldn't find libsecret >= $LIBSECRET_REQUIRED.])
fi
fi
-AM_CONDITIONAL(HAVE_GNOME_KEYRING, test "x$have_gnome_keyring" = "xyes")
+AM_CONDITIONAL(HAVE_LIBSECRET, test "x$have_libsecret" = "xyes")
##################################################################
# Check for libtracker-miner: network-manager for web miners
@@ -2433,6 +2445,7 @@ Build Configuration:
Support for UPower: $have_upower
Support for Cyrillic languages (enca): $have_enca
Support for network status detection: $have_network_manager
+ Support for keyring data (libsecret): $have_libsecret
Unicode support library: $with_unicode_support
Applications:
diff --git a/src/libtracker-miner/Makefile.am b/src/libtracker-miner/Makefile.am
index f272a5e..1aa4a21 100644
--- a/src/libtracker-miner/Makefile.am
+++ b/src/libtracker-miner/Makefile.am
@@ -123,7 +123,7 @@ libtracker_miner_ TRACKER_API_VERSION@_la_LIBADD = \
$(BUILD_LIBS) \
$(LIBTRACKER_MINER_LIBS)
-if HAVE_GNOME_KEYRING
+if HAVE_LIBSECRET
password_provider_sources = tracker-password-provider-gnome.c
else
password_provider_sources = tracker-password-provider-keyfile.c
diff --git a/src/libtracker-miner/tracker-password-provider-gnome.c b/src/libtracker-miner/tracker-password-provider-gnome.c
index dac977a..85a3cd4 100644
--- a/src/libtracker-miner/tracker-password-provider-gnome.c
+++ b/src/libtracker-miner/tracker-password-provider-gnome.c
@@ -21,7 +21,7 @@
#include <glib-object.h>
-#include <gnome-keyring.h>
+#include <libsecret/secret.h>
#include "tracker-password-provider.h"
@@ -75,11 +75,11 @@ static gchar* password_provider_gnome_get (TrackerPasswordProvide
static gboolean password_provider_gnome_forget (TrackerPasswordProvider *provider,
const gchar *service,
GError **error);
-
-const GnomeKeyringPasswordSchema password_schema = {
- GNOME_KEYRING_ITEM_GENERIC_SECRET,
- { { "service", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
- { "username", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
+static const SecretSchema password_schema = {
+ "org.gnome.Tracker.Miner",
+ SECRET_SCHEMA_DONT_MATCH_NAME,
+ { { "service", SECRET_SCHEMA_ATTRIBUTE_STRING },
+ { "username", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ NULL, 0 }
}
};
@@ -173,23 +173,21 @@ password_provider_gnome_store (TrackerPasswordProvider *provider,
const gchar *password,
GError **error)
{
- GnomeKeyringResult result;
+ GError *secret_error = NULL;
- result = gnome_keyring_store_password_sync (&password_schema,
- NULL,
- description,
- password,
- "service", service,
- "username", username,
- NULL);
+ secret_password_store_sync (&password_schema, NULL, description,
+ password, NULL, &secret_error,
+ "service", service,
+ "username", username,
+ NULL);
- if (result != GNOME_KEYRING_RESULT_OK) {
+ if (secret_error != NULL) {
g_set_error (error,
TRACKER_PASSWORD_PROVIDER_ERROR,
TRACKER_PASSWORD_PROVIDER_ERROR_SERVICE,
"Could not store GNOME keyring password, %s",
- gnome_keyring_result_to_message (result));
-
+ secret_error->message);
+ g_error_free (secret_error);
return FALSE;
}
@@ -202,64 +200,62 @@ password_provider_gnome_get (TrackerPasswordProvider *provider,
gchar **username,
GError **error)
{
- GnomeKeyringAttributeList *search_attributes;
- GnomeKeyringFound *found;
- GnomeKeyringResult result;
GList *found_items = NULL;
+ GHashTable *search_attributes;
+ GHashTable *attributes;
+ GError *secret_error;
+ SecretValue *secret = NULL;
+ SecretItem *found = NULL;
gchar *password;
- gint i;
-
- search_attributes = gnome_keyring_attribute_list_new ();
- gnome_keyring_attribute_list_append_string (search_attributes,
- "service",
- service);
-
- result = gnome_keyring_find_items_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
- search_attributes,
- &found_items);
-
- gnome_keyring_attribute_list_free (search_attributes);
-
- if (result != GNOME_KEYRING_RESULT_OK) {
- if (result == GNOME_KEYRING_RESULT_NO_MATCH) {
- g_set_error_literal (error,
- TRACKER_PASSWORD_PROVIDER_ERROR,
- TRACKER_PASSWORD_PROVIDER_ERROR_NOTFOUND,
- "Could not find GNOME keyring password");
- } else {
- g_set_error (error,
- TRACKER_PASSWORD_PROVIDER_ERROR,
- TRACKER_PASSWORD_PROVIDER_ERROR_SERVICE,
- "Could not fetch GNOME keyring password, %s",
- gnome_keyring_result_to_message (result));
- }
-
- gnome_keyring_found_list_free (found_items);
+ search_attributes = secret_attributes_build (&password_schema,
+ "service", service,
+ NULL);
+
+ found_items = secret_service_search_sync (NULL,
+ &password_schema,
+ search_attributes,
+ SECRET_SEARCH_UNLOCK | SECRET_SEARCH_LOAD_SECRETS,
+ NULL,
+ &secret_error);
+
+ g_hash_table_unref (search_attributes);
+
+ if (secret_error != NULL) {
+ g_set_error (error,
+ TRACKER_PASSWORD_PROVIDER_ERROR,
+ TRACKER_PASSWORD_PROVIDER_ERROR_SERVICE,
+ "Could not fetch GNOME keyring password, %s",
+ secret_error->message);
+ g_error_free (secret_error);
return NULL;
}
- found = found_items->data;
+ if (found_items != NULL) {
+ found = found_items->data;
+ secret = secret_item_get_secret (found);
+ }
+
+ if (secret != NULL) {
+ g_set_error_literal (error,
+ TRACKER_PASSWORD_PROVIDER_ERROR,
+ TRACKER_PASSWORD_PROVIDER_ERROR_NOTFOUND,
+ "Could not find GNOME keyring password");
+ g_list_free_full (found_items, g_object_unref);
+ return NULL;
+ }
/* Find username if we asked for it */
if (username) {
/* Make sure it is always set */
- *username = NULL;
-
- for (i = 0; i < found->attributes->len; ++i) {
- GnomeKeyringAttribute *attr;
-
- attr = &gnome_keyring_attribute_list_index (found->attributes, i);
-
- if (g_ascii_strcasecmp (attr->name, "username") == 0) {
- *username = g_strdup (attr->value.string);
- }
- }
+ attributes = secret_item_get_attributes (found);
+ *username = g_hash_table_lookup (attributes, "user");
+ g_hash_table_unref (attributes);
}
- password = tracker_password_provider_lock_password (found->secret);
-
- gnome_keyring_found_list_free (found_items);
+ password = tracker_password_provider_lock_password (secret_value_get (secret, NULL));
+ secret_value_unref (secret);
+ g_list_free_full (found_items, g_object_unref);
return password;
}
@@ -269,18 +265,21 @@ password_provider_gnome_forget (TrackerPasswordProvider *provider,
const gchar *service,
GError **error)
{
- GnomeKeyringResult result;
+ GError *secret_error = NULL;
- result = gnome_keyring_delete_password_sync (&password_schema,
- "service", service,
- NULL);
+ secret_password_clear_sync (&password_schema,
+ NULL,
+ &secret_error,
+ "service", service,
+ NULL);
- if (result != GNOME_KEYRING_RESULT_OK) {
+ if (secret_error != NULL) {
g_set_error (error,
TRACKER_PASSWORD_PROVIDER_ERROR,
TRACKER_PASSWORD_PROVIDER_ERROR_SERVICE,
"Coult not delete GNOME keyring password, %s",
- gnome_keyring_result_to_message (result));
+ secret_error->message);
+ g_error_free (secret_error);
return FALSE;
}
@@ -305,4 +304,3 @@ tracker_password_provider_get (void)
return instance;
}
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]