2008-04-10 Dan Williams <dcbw@redhat.com>
* vpn-daemons/vpnc/auth-dialog/main.c - Fix for new location of keyring passwords git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3553 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
2008-04-10 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* vpn-daemons/vpnc/auth-dialog/main.c
|
||||||
|
- Fix for new location of keyring passwords
|
||||||
|
|
||||||
2008-04-10 Tambet Ingo <tambet@gmail.com>
|
2008-04-10 Tambet Ingo <tambet@gmail.com>
|
||||||
|
|
||||||
* auth-dialog/main.c (main): Add the '-i' argument the applet now sends.
|
* auth-dialog/main.c (main): Add the '-i' argument the applet now sends.
|
||||||
|
@@ -35,8 +35,13 @@
|
|||||||
#include "../src/nm-vpnc-service.h"
|
#include "../src/nm-vpnc-service.h"
|
||||||
#include "gnome-two-password-dialog.h"
|
#include "gnome-two-password-dialog.h"
|
||||||
|
|
||||||
|
#define KEYRING_CID_TAG "connection-id"
|
||||||
|
#define KEYRING_SN_TAG "setting-name"
|
||||||
|
#define KEYRING_SK_TAG "setting-key"
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
find_one_password (const char *vpn_name,
|
find_one_password (const char *vpn_id,
|
||||||
|
const char *vpn_name,
|
||||||
const char *vpn_service,
|
const char *vpn_service,
|
||||||
const char *secret_name,
|
const char *secret_name,
|
||||||
gboolean *is_session)
|
gboolean *is_session)
|
||||||
@@ -48,13 +53,13 @@ find_one_password (const char *vpn_name,
|
|||||||
|
|
||||||
ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
|
ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
|
||||||
&found_list,
|
&found_list,
|
||||||
"connection-name",
|
KEYRING_CID_TAG,
|
||||||
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
|
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
|
||||||
vpn_name,
|
vpn_id,
|
||||||
"setting-name",
|
KEYRING_SN_TAG,
|
||||||
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
|
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
|
||||||
NM_SETTING_VPN_PROPERTIES_SETTING_NAME,
|
NM_SETTING_VPN_PROPERTIES_SETTING_NAME,
|
||||||
"setting-key",
|
KEYRING_SK_TAG,
|
||||||
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
|
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
|
||||||
secret_name,
|
secret_name,
|
||||||
NULL);
|
NULL);
|
||||||
@@ -75,17 +80,17 @@ find_one_password (const char *vpn_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GSList *
|
static GSList *
|
||||||
lookup_pass (const char *vpn_name, const char *vpn_service, gboolean *is_session)
|
lookup_pass (const char *vpn_id, const char *vpn_name, const char *vpn_service, gboolean *is_session)
|
||||||
{
|
{
|
||||||
GSList *passwords = NULL;
|
GSList *passwords = NULL;
|
||||||
char *password;
|
char *password;
|
||||||
char *group_password;
|
char *group_password;
|
||||||
|
|
||||||
password = find_one_password (vpn_name, vpn_service, "password", is_session);
|
password = find_one_password (vpn_id, vpn_name, vpn_service, "password", is_session);
|
||||||
if (!password)
|
if (!password)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
group_password = find_one_password (vpn_name, vpn_service, "group-password", is_session);
|
group_password = find_one_password (vpn_id, vpn_name, vpn_service, "group-password", is_session);
|
||||||
if (!group_password) {
|
if (!group_password) {
|
||||||
g_free (password);
|
g_free (password);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -98,7 +103,8 @@ lookup_pass (const char *vpn_name, const char *vpn_service, gboolean *is_session
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
save_vpn_password (const char *vpn_name,
|
save_vpn_password (const char *vpn_id,
|
||||||
|
const char *vpn_name,
|
||||||
const char *vpn_service,
|
const char *vpn_service,
|
||||||
const char *keyring,
|
const char *keyring,
|
||||||
const char *secret_name,
|
const char *secret_name,
|
||||||
@@ -116,13 +122,13 @@ save_vpn_password (const char *vpn_name,
|
|||||||
|
|
||||||
attrs = gnome_keyring_attribute_list_new ();
|
attrs = gnome_keyring_attribute_list_new ();
|
||||||
gnome_keyring_attribute_list_append_string (attrs,
|
gnome_keyring_attribute_list_append_string (attrs,
|
||||||
"connection-name",
|
KEYRING_CID_TAG,
|
||||||
vpn_name);
|
vpn_id);
|
||||||
gnome_keyring_attribute_list_append_string (attrs,
|
gnome_keyring_attribute_list_append_string (attrs,
|
||||||
"setting-name",
|
KEYRING_SN_TAG,
|
||||||
NM_SETTING_VPN_PROPERTIES_SETTING_NAME);
|
NM_SETTING_VPN_PROPERTIES_SETTING_NAME);
|
||||||
gnome_keyring_attribute_list_append_string (attrs,
|
gnome_keyring_attribute_list_append_string (attrs,
|
||||||
"setting-key",
|
KEYRING_SK_TAG,
|
||||||
secret_name);
|
secret_name);
|
||||||
|
|
||||||
ret = gnome_keyring_item_create_sync (keyring,
|
ret = gnome_keyring_item_create_sync (keyring,
|
||||||
@@ -137,7 +143,10 @@ save_vpn_password (const char *vpn_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GSList *
|
static GSList *
|
||||||
get_passwords (const char *vpn_name, const char *vpn_service, gboolean retry)
|
get_passwords (const char *vpn_id,
|
||||||
|
const char *vpn_name,
|
||||||
|
const char *vpn_service,
|
||||||
|
gboolean retry)
|
||||||
{
|
{
|
||||||
GSList *result;
|
GSList *result;
|
||||||
char *prompt;
|
char *prompt;
|
||||||
@@ -153,15 +162,16 @@ get_passwords (const char *vpn_name, const char *vpn_service, gboolean retry)
|
|||||||
keyring_group_password = NULL;
|
keyring_group_password = NULL;
|
||||||
keyring_result = NULL;
|
keyring_result = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (vpn_id != NULL, NULL);
|
||||||
g_return_val_if_fail (vpn_name != NULL, NULL);
|
g_return_val_if_fail (vpn_name != NULL, NULL);
|
||||||
|
|
||||||
/* Use the system user name, since the VPN might have a different user name */
|
/* Use the system user name, since the VPN might have a different user name */
|
||||||
if (!retry) {
|
if (!retry) {
|
||||||
if ((result = lookup_pass (vpn_name, vpn_service, &keyring_is_session)) != NULL) {
|
if ((result = lookup_pass (vpn_id, vpn_name, vpn_service, &keyring_is_session)) != NULL) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((keyring_result = lookup_pass (vpn_name, vpn_service, &keyring_is_session)) != NULL) {
|
if ((keyring_result = lookup_pass (vpn_id, vpn_name, vpn_service, &keyring_is_session)) != NULL) {
|
||||||
keyring_group_password = g_strdup ((char *) keyring_result->data);
|
keyring_group_password = g_strdup ((char *) keyring_result->data);
|
||||||
keyring_password = g_strdup ((char *) (g_slist_next (keyring_result))->data);
|
keyring_password = g_strdup ((char *) (g_slist_next (keyring_result))->data);
|
||||||
}
|
}
|
||||||
@@ -211,12 +221,12 @@ get_passwords (const char *vpn_name, const char *vpn_service, gboolean retry)
|
|||||||
switch (gnome_two_password_dialog_get_remember (GNOME_TWO_PASSWORD_DIALOG (dialog)))
|
switch (gnome_two_password_dialog_get_remember (GNOME_TWO_PASSWORD_DIALOG (dialog)))
|
||||||
{
|
{
|
||||||
case GNOME_TWO_PASSWORD_DIALOG_REMEMBER_SESSION:
|
case GNOME_TWO_PASSWORD_DIALOG_REMEMBER_SESSION:
|
||||||
save_vpn_password (vpn_name, vpn_service, "session", "password", password);
|
save_vpn_password (vpn_id, vpn_name, vpn_service, "session", "password", password);
|
||||||
save_vpn_password (vpn_name, vpn_service, "session", "group-password", group_password);
|
save_vpn_password (vpn_id, vpn_name, vpn_service, "session", "group-password", group_password);
|
||||||
break;
|
break;
|
||||||
case GNOME_TWO_PASSWORD_DIALOG_REMEMBER_FOREVER:
|
case GNOME_TWO_PASSWORD_DIALOG_REMEMBER_FOREVER:
|
||||||
save_vpn_password (vpn_name, vpn_service, NULL, "password", password);
|
save_vpn_password (vpn_id, vpn_name, vpn_service, NULL, "password", password);
|
||||||
save_vpn_password (vpn_name, vpn_service, NULL, "group-password", group_password);
|
save_vpn_password (vpn_id, vpn_name, vpn_service, NULL, "group-password", group_password);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -238,16 +248,16 @@ main (int argc, char *argv[])
|
|||||||
GSList *passwords;
|
GSList *passwords;
|
||||||
static gboolean retry = FALSE;
|
static gboolean retry = FALSE;
|
||||||
static gchar *vpn_name = NULL;
|
static gchar *vpn_name = NULL;
|
||||||
static gchar *vpn_service = NULL;
|
|
||||||
static gchar *vpn_id = NULL;
|
static gchar *vpn_id = NULL;
|
||||||
|
static gchar *vpn_service = NULL;
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
GnomeProgram *program;
|
GnomeProgram *program;
|
||||||
GOptionEntry entries[] =
|
GOptionEntry entries[] =
|
||||||
{
|
{
|
||||||
{ "reprompt", 'r', 0, G_OPTION_ARG_NONE, &retry, "Reprompt for passwords", NULL},
|
{ "reprompt", 'r', 0, G_OPTION_ARG_NONE, &retry, "Reprompt for passwords", NULL},
|
||||||
|
{ "id", 'i', 0, G_OPTION_ARG_STRING, &vpn_id, "ID of VPN connection", NULL},
|
||||||
{ "name", 'n', 0, G_OPTION_ARG_STRING, &vpn_name, "Name of VPN connection", NULL},
|
{ "name", 'n', 0, G_OPTION_ARG_STRING, &vpn_name, "Name of VPN connection", NULL},
|
||||||
{ "service", 's', 0, G_OPTION_ARG_STRING, &vpn_service, "VPN service type", NULL},
|
{ "service", 's', 0, G_OPTION_ARG_STRING, &vpn_service, "VPN service type", NULL},
|
||||||
{ "id", 'i', 0, G_OPTION_ARG_STRING, &vpn_id, "VPN service id", NULL},
|
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
char buf[1];
|
char buf[1];
|
||||||
@@ -268,8 +278,8 @@ main (int argc, char *argv[])
|
|||||||
GNOME_PARAM_NONE);
|
GNOME_PARAM_NONE);
|
||||||
|
|
||||||
|
|
||||||
if (vpn_name == NULL || vpn_service == NULL) {
|
if (vpn_id == NULL || vpn_name == NULL || vpn_service == NULL) {
|
||||||
fprintf (stderr, "Have to supply both name and service\n");
|
fprintf (stderr, "Have to supply ID, name, and service\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +288,7 @@ main (int argc, char *argv[])
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
passwords = get_passwords (vpn_name, vpn_service, retry);
|
passwords = get_passwords (vpn_id, vpn_name, vpn_service, retry);
|
||||||
if (passwords == NULL)
|
if (passwords == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user