gvfs r1374 - in trunk: . daemon
- From: carlosgc svn gnome org
- To: svn-commits-list gnome org
- Subject: gvfs r1374 - in trunk: . daemon
- Date: Mon, 25 Feb 2008 20:08:28 +0000 (GMT)
Author: carlosgc
Date: Mon Feb 25 20:08:28 2008
New Revision: 1374
URL: http://svn.gnome.org/viewvc/gvfs?rev=1374&view=rev
Log:
2008-02-25 Carlos Garcia Campos <carlosgc gnome org>
* daemon/gvfsbackendsftp.c:
* daemon/gvfsbackendsmb.c:
Update to gvfskeyring api changes
* daemon/gvfskeyring.c:
* daemon/gvfskeyring.h:
Add object, authtype and port parameters for both save and
lookup.
Modified:
trunk/ChangeLog
trunk/daemon/gvfsbackendsftp.c
trunk/daemon/gvfsbackendsmb.c
trunk/daemon/gvfskeyring.c
trunk/daemon/gvfskeyring.h
Modified: trunk/daemon/gvfsbackendsftp.c
==============================================================================
--- trunk/daemon/gvfsbackendsftp.c (original)
+++ trunk/daemon/gvfsbackendsftp.c Mon Feb 25 20:08:28 2008
@@ -24,6 +24,7 @@
#include <config.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
@@ -658,6 +659,38 @@
return TRUE;
}
+static const gchar *
+get_authtype_from_password_line (const char *password_line)
+{
+ return g_str_has_prefix (password_line, "Enter passphrase for key") ?
+ "publickey" : "password";
+}
+
+static char *
+get_object_from_password_line (const char *password_line)
+{
+ char *chr, *ptr, *object = NULL;
+
+ if (g_str_has_prefix (password_line, "Enter passphrase for key"))
+ {
+ ptr = strchr (password_line, '\'');
+ if (ptr != NULL)
+ {
+ ptr += 1;
+ chr = strchr (ptr, '\'');
+ if (chr != NULL)
+ {
+ object = g_strndup (ptr, chr - ptr);
+ }
+ else
+ {
+ object = g_strdup (ptr);
+ }
+ }
+ }
+ return object;
+}
+
static gboolean
handle_login (GVfsBackend *backend,
GMountSource *mount_source,
@@ -680,6 +713,8 @@
GPasswordSave password_save = G_PASSWORD_SAVE_NEVER;
gsize bytes_written;
gboolean password_in_keyring = FALSE;
+ const gchar *authtype = NULL;
+ gchar *object = NULL;
if (op_backend->client_vendor == SFTP_VENDOR_SSH)
prompt_fd = stderr_fd;
@@ -751,12 +786,21 @@
g_str_has_suffix (buffer, "Password:") ||
g_str_has_prefix (buffer, "Enter passphrase for key"))
{
+ authtype = get_authtype_from_password_line (buffer);
+ object = get_object_from_password_line (buffer);
+
/* If password is in keyring at this point is because it failed */
if (!op_backend->tmp_password && (password_in_keyring ||
!g_vfs_keyring_lookup_password (op_backend->user,
op_backend->host,
NULL,
"sftp",
+ object,
+ authtype,
+ op_backend->port != -1 ?
+ op_backend->port
+ :
+ 0,
NULL,
NULL,
&new_password)))
@@ -906,10 +950,17 @@
op_backend->host,
NULL,
"sftp",
+ object,
+ authtype,
+ op_backend->port != -1 ?
+ op_backend->port
+ :
+ 0,
new_password,
password_save);
}
+ g_free (object);
g_free (new_password);
g_object_unref (prompt_stream);
g_object_unref (reply_stream);
Modified: trunk/daemon/gvfsbackendsmb.c
==============================================================================
--- trunk/daemon/gvfsbackendsmb.c (original)
+++ trunk/daemon/gvfsbackendsmb.c Mon Feb 25 20:08:28 2008
@@ -188,6 +188,9 @@
in_keyring = g_vfs_keyring_lookup_password (backend->user,
backend->server,
backend->domain,
+ NULL,
+ NULL,
+ 0,
"smb",
&ask_user,
&ask_domain,
@@ -562,6 +565,9 @@
op_backend->server,
op_backend->last_domain,
"smb",
+ NULL,
+ NULL,
+ 0,
op_backend->last_password,
op_backend->password_save);
Modified: trunk/daemon/gvfskeyring.c
==============================================================================
--- trunk/daemon/gvfskeyring.c (original)
+++ trunk/daemon/gvfskeyring.c Mon Feb 25 20:08:28 2008
@@ -33,7 +33,7 @@
g_vfs_keyring_is_available (void)
{
#ifdef HAVE_KEYRING
- return gnome_keyring_is_available ();
+ return gnome_keyring_is_available ();
#else
return FALSE;
#endif
@@ -44,35 +44,38 @@
const gchar *host,
const gchar *domain,
const gchar *protocol,
+ const gchar *object,
+ const gchar *authtype,
+ guint32 port,
gchar **username_out,
gchar **domain_out,
gchar **password_out)
{
#ifdef HAVE_KEYRING
- GnomeKeyringNetworkPasswordData *pwd_data;
- GnomeKeyringResult result;
- GList *plist;
+ GnomeKeyringNetworkPasswordData *pwd_data;
+ GnomeKeyringResult result;
+ GList *plist;
- if (!gnome_keyring_is_available ())
- return FALSE;
+ if (!gnome_keyring_is_available ())
+ return FALSE;
- result = gnome_keyring_find_network_password_sync (
+ result = gnome_keyring_find_network_password_sync (
username,
domain,
host,
- NULL,
+ object,
protocol,
- NULL,
- 0,
+ authtype,
+ port,
&plist);
- if (result != GNOME_KEYRING_RESULT_OK || plist == NULL)
- return FALSE;
+ if (result != GNOME_KEYRING_RESULT_OK || plist == NULL)
+ return FALSE;
- /* We use the first result, which is the least specific match */
- pwd_data = (GnomeKeyringNetworkPasswordData *)plist->data;
+ /* We use the first result, which is the least specific match */
+ pwd_data = (GnomeKeyringNetworkPasswordData *)plist->data;
- *password_out = g_strdup (pwd_data->password);
+ *password_out = g_strdup (pwd_data->password);
if (username_out)
*username_out = g_strdup (pwd_data->user);
@@ -80,9 +83,9 @@
if (domain_out)
*domain_out = g_strdup (pwd_data->domain);
- gnome_keyring_network_password_list_free (plist);
-
- return TRUE;
+ gnome_keyring_network_password_list_free (plist);
+
+ return TRUE;
#else
return FALSE;
#endif /* HAVE_KEYRING */
@@ -93,6 +96,9 @@
const gchar *host,
const gchar *domain,
const gchar *protocol,
+ const gchar *object,
+ const gchar *authtype,
+ guint32 port,
const gchar *password,
GPasswordSave flags)
{
@@ -101,8 +107,8 @@
const gchar *keyring;
guint32 item_id;
- if (!gnome_keyring_is_available ())
- return FALSE;
+ if (!gnome_keyring_is_available ())
+ return FALSE;
if (flags == G_PASSWORD_SAVE_NEVER)
return FALSE;
@@ -114,10 +120,10 @@
username,
domain,
host,
- NULL,
+ object,
protocol,
- NULL,
- 0,
+ authtype,
+ port,
password,
&item_id);
Modified: trunk/daemon/gvfskeyring.h
==============================================================================
--- trunk/daemon/gvfskeyring.h (original)
+++ trunk/daemon/gvfskeyring.h Mon Feb 25 20:08:28 2008
@@ -32,6 +32,9 @@
const gchar *host,
const gchar *domain,
const gchar *protocol,
+ const gchar *object,
+ const gchar *authtype,
+ guint32 port,
gchar **username_out,
gchar **domain_out,
gchar **password);
@@ -39,6 +42,9 @@
const gchar *host,
const gchar *domain,
const gchar *protocol,
+ const gchar *object,
+ const gchar *authtype,
+ guint32 port,
const gchar *password,
GPasswordSave flags);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]