From a12afcc8638b06f5cdd4f05f672ca13c06ad1ec1 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Wed, 21 Oct 2015 12:20:13 +0200 Subject: [PATCH 08/10] nm: replace libgnomekeyring with libsecret The former is deprecated and the newer API is nicer anyway. --- auth-dialog/Makefile.am | 4 ++-- auth-dialog/main.c | 39 ++++++++------------------------------- configure.ac | 2 +- 3 files changed, 11 insertions(+), 34 deletions(-) diff --git a/auth-dialog/Makefile.am b/auth-dialog/Makefile.am index 4dcf1d2..f57e510 100644 --- a/auth-dialog/Makefile.am +++ b/auth-dialog/Makefile.am @@ -2,7 +2,7 @@ libexec_PROGRAMS = nm-strongswan-auth-dialog nm_strongswan_auth_dialog_CPPFLAGS = \ $(GTK_CFLAGS) \ - $(GNOMEKEYRING_CFLAGS) \ + $(LIBSECRET_CFLAGS) \ $(LIBNM_CFLAGS) \ $(LIBNMA_CFLAGS) \ -DG_DISABLE_DEPRECATED \ @@ -15,7 +15,7 @@ nm_strongswan_auth_dialog_SOURCES = \ nm_strongswan_auth_dialog_LDADD = \ $(GTK_LIBS) \ - $(GNOMEKEYRING_LIBS) \ + $(LIBSECRET_LIBS) \ $(LIBNM_LIBS) \ $(LIBNMA_LIBS) diff --git a/auth-dialog/main.c b/auth-dialog/main.c index d1f3096..c8ef1e1 100644 --- a/auth-dialog/main.c +++ b/auth-dialog/main.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include @@ -34,35 +34,6 @@ #define NM_DBUS_SERVICE_STRONGSWAN "org.freedesktop.NetworkManager.strongswan" /** - * lookup a password in the keyring - */ -static char *lookup_password(char *name, char *service) -{ - GList *list; - GList *iter; - char *pass = NULL; - - if (gnome_keyring_find_network_password_sync(g_get_user_name(), NULL, name, - NULL, service, NULL, 0, &list) != GNOME_KEYRING_RESULT_OK) - { - return NULL; - } - - for (iter = list; iter; iter = iter->next) - { - GnomeKeyringNetworkPasswordData *data = iter->data; - - if (strcmp(data->object, "password") == 0 && data->password) - { - pass = g_strdup(data->password); - break; - } - } - gnome_keyring_network_password_list_free(list); - return pass; -} - -/** * Wait for quit input */ static void wait_for_quit (void) @@ -164,7 +135,12 @@ int main (int argc, char *argv[]) if (!strcmp(type, "eap") || !strcmp(type, "key") || !strcmp(type, "psk") || !strcmp(type, "smartcard")) { - pass = lookup_password(name, service); + pass = secret_password_lookup_sync(SECRET_SCHEMA_COMPAT_NETWORK, NULL, NULL, + "user", g_get_user_name(), + "server", name, + "protocol", service, + NULL); + if ((!pass || retry) && allow_interaction) { if (!strcmp(type, "eap")) @@ -213,6 +189,7 @@ too_short_retry: if (pass) { printf("password\n%s\n", pass); + g_free(pass); } } else diff --git a/configure.ac b/configure.ac index 823ae79..4291612 100644 --- a/configure.ac +++ b/configure.ac @@ -43,7 +43,7 @@ IT_PROG_INTLTOOL([0.35]) AM_GLIB_GNU_GETTEXT PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6) -PKG_CHECK_MODULES(GNOMEKEYRING, gnome-keyring-1) +PKG_CHECK_MODULES(LIBSECRET, libsecret-1) PKG_CHECK_MODULES(LIBNM_GLIB, NetworkManager >= 1.1.0 libnm-util libnm-glib libnm-glib-vpn) PKG_CHECK_MODULES(LIBNMA, libnma >= 1.1.0) -- 2.4.3