mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-06 00:00:47 -04:00
nm: Replace libgnomekeyring with libsecret
The former is deprecated and the newer API is nicer anyway.
This commit is contained in:
parent
b86b6b8282
commit
a88831a018
@ -3,7 +3,7 @@ nm_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 \
|
||||
@ -17,6 +17,5 @@ nm_strongswan_auth_dialog_SOURCES = \
|
||||
nm_strongswan_auth_dialog_LDADD = \
|
||||
$(GTK_LIBS) \
|
||||
$(LIBGNOMEUI_LIBS) \
|
||||
$(GNOMEKEYRING_LIBS) \
|
||||
$(LIBSECRET_LIBS) \
|
||||
$(NM_UTILS_LIBS)
|
||||
|
||||
|
@ -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>
|
||||
@ -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
|
||||
*/
|
||||
@ -118,7 +89,7 @@ int main (int argc, char *argv[])
|
||||
gchar *name = NULL, *uuid = NULL, *service = NULL, *keyring = NULL, *pass;
|
||||
GOptionContext *context;
|
||||
char *agent, *type;
|
||||
guint32 itemid, minlen = 0;
|
||||
guint32 minlen = 0;
|
||||
GtkWidget *dialog;
|
||||
GOptionEntry entries[] = {
|
||||
{ "reprompt", 'r', 0, G_OPTION_ARG_NONE, &retry, "Reprompt for passwords", NULL},
|
||||
@ -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"))
|
||||
@ -216,12 +192,15 @@ too_short_retry:
|
||||
case GNOME_PASSWORD_DIALOG_REMEMBER_NOTHING:
|
||||
break;
|
||||
case GNOME_PASSWORD_DIALOG_REMEMBER_SESSION:
|
||||
keyring = "session";
|
||||
keyring = SECRET_COLLECTION_SESSION;
|
||||
/* FALL */
|
||||
case GNOME_PASSWORD_DIALOG_REMEMBER_FOREVER:
|
||||
if (gnome_keyring_set_network_password_sync(keyring,
|
||||
g_get_user_name(), NULL, name, "password", service, NULL, 0,
|
||||
pass, &itemid) != GNOME_KEYRING_RESULT_OK)
|
||||
if (!secret_password_store_sync(SECRET_SCHEMA_COMPAT_NETWORK,
|
||||
keyring, "", pass, NULL, NULL,
|
||||
"user", g_get_user_name(),
|
||||
"server", name,
|
||||
"protocol", service,
|
||||
NULL))
|
||||
{
|
||||
g_warning ("storing password in keyring failed");
|
||||
}
|
||||
@ -231,6 +210,7 @@ too_short_retry:
|
||||
if (pass)
|
||||
{
|
||||
printf("password\n%s\n", pass);
|
||||
g_free(pass);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -45,7 +45,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)]
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user