Skip to content

Commit

Permalink
nm: replace libgnomekeyring with libsecret
Browse files Browse the repository at this point in the history
The former is deprecated and the newer API is nicer anyway.
  • Loading branch information
lkundrak committed Mar 29, 2016
1 parent ad13678 commit 67a7821
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 35 deletions.
5 changes: 2 additions & 3 deletions src/frontends/gnome/auth-dialog/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ libexec_PROGRAMS = nm-strongswan-auth-dialog
nm_strongswan_auth_dialog_CPPFLAGS = \
$(GTK_CFLAGS) \
$(LIBGNOMEUI_CFLAGS) \
$(GNOMEKEYRING_CFLAGS) \
$(LIBSECRET_CFLAGS) \
$(NETWORK_MANAGER_CFLAGS) \
$(NM_UTILS_CFLAGS) \
-DG_DISABLE_DEPRECATED \
Expand All @@ -16,7 +16,6 @@ nm_strongswan_auth_dialog_SOURCES = \

nm_strongswan_auth_dialog_LDADD = \
$(GTK_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(LIBSECRET_LIBS) \
$(GNOMEKEYRING_LIBS) \
$(NM_UTILS_LIBS)

39 changes: 8 additions & 31 deletions src/frontends/gnome/auth-dialog/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gnome-keyring.h>
#include <libsecret/secret.h>
#include <libgnomeui/libgnomeui.h>
#include <nm-vpn-plugin.h>
#include <nm-setting-vpn.h>
Expand All @@ -31,35 +31,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
*/
Expand Down Expand Up @@ -162,7 +133,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"))
Expand Down Expand Up @@ -231,6 +207,7 @@ int main (int argc, char *argv[])
if (pass)
{
printf("password\n%s\n", pass);
g_free(pass);
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/frontends/gnome/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ AM_GLIB_GNU_GETTEXT

PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6)
PKG_CHECK_MODULES(LIBGNOMEUI, libgnomeui-2.0)
PKG_CHECK_MODULES(GNOMEKEYRING, gnome-keyring-1)
PKG_CHECK_MODULES(LIBSECRET, libsecret-1)
PKG_CHECK_EXISTS([libnm-glib],
[PKG_CHECK_MODULES(NM_UTILS, NetworkManager >= 0.9.0 libnm-util libnm-glib libnm-glib-vpn)],
[PKG_CHECK_MODULES(NM_UTILS, NetworkManager >= 0.9.0 libnm-util libnm_glib libnm_glib_vpn)]
Expand Down
1 change: 1 addition & 0 deletions src/frontends/gnome/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Build-Depends: cdbs,
libnm-glib-dev (>= 0.9),
libnm-glib-vpn-dev (>= 0.9),
libgnomeui-dev,
libsecret-1-dev,
automake,
gnome-common,
Standards-Version: 3.8.3
Expand Down

0 comments on commit 67a7821

Please sign in to comment.