gvfs r1327 - in trunk: . daemon
- From: carlosgc svn gnome org
- To: svn-commits-list gnome org
- Subject: gvfs r1327 - in trunk: . daemon
- Date: Fri, 22 Feb 2008 08:50:32 +0000 (GMT)
Author: carlosgc
Date: Fri Feb 22 08:50:32 2008
New Revision: 1327
URL: http://svn.gnome.org/viewvc/gvfs?rev=1327&view=rev
Log:
2008-02-22 Carlos Garcia Campos <carlosgc gnome org>
* daemon/gvfsbackendsftp.c: (handle_login), (do_mount):
Ask for the username in the sftp login when it's not provided.
Modified:
trunk/ChangeLog
trunk/daemon/gvfsbackendsftp.c
Modified: trunk/daemon/gvfsbackendsftp.c
==============================================================================
--- trunk/daemon/gvfsbackendsftp.c (original)
+++ trunk/daemon/gvfsbackendsftp.c Fri Feb 22 08:50:32 2008
@@ -109,6 +109,7 @@
char *host;
gboolean user_specified;
char *user;
+ char *tmp_password;
guint32 my_uid;
guint32 my_gid;
@@ -676,6 +677,7 @@
gboolean aborted = FALSE;
gboolean ret_val;
char *new_password = NULL;
+ char *new_user = NULL;
GPasswordSave password_save = G_PASSWORD_SAVE_NEVER;
gsize bytes_written;
gboolean password_in_keyring = FALSE;
@@ -751,19 +753,21 @@
g_str_has_prefix (buffer, "Enter passphrase for key"))
{
/* If password is in keyring at this point is because it failed */
- if (password_in_keyring ||
+ if (!op_backend->tmp_password && (password_in_keyring ||
!g_vfs_keyring_lookup_password (op_backend->user,
op_backend->host,
NULL,
"sftp",
NULL,
NULL,
- &new_password))
+ &new_password)))
{
GAskPasswordFlags flags = G_ASK_PASSWORD_NEED_PASSWORD;
if (g_vfs_keyring_is_available ())
flags |= G_ASK_PASSWORD_SAVING_SUPPORTED;
+ if (!op_backend->user_specified)
+ flags |= G_ASK_PASSWORD_NEED_USERNAME;
g_free (new_password);
@@ -777,7 +781,7 @@
flags,
&aborted,
&new_password,
- NULL,
+ &new_user,
NULL,
&password_save) ||
aborted)
@@ -789,8 +793,36 @@
break;
}
}
+ else if (op_backend->tmp_password)
+ {
+ /* I already a have a password of a previous login attempt
+ * that failed because the user provided a new user name
+ */
+ new_password = op_backend->tmp_password;
+ op_backend->tmp_password = NULL;
+ }
else
password_in_keyring = TRUE;
+
+ if (new_user && strcmp (new_user, op_backend->user) != 0)
+ {
+ g_free (op_backend->user);
+ op_backend->user = new_user;
+
+ g_free (op_backend->tmp_password);
+ op_backend->tmp_password = new_password;
+ new_password = NULL;
+
+ g_set_error (error,
+ G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+ "Invalid user name");
+ ret_val = FALSE;
+ break;
+ }
+ else if (new_user)
+ {
+ g_free (new_user);
+ }
if (!g_output_stream_write_all (reply_stream,
new_password, strlen (new_password),
@@ -1210,8 +1242,20 @@
if (!res)
{
- g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
- g_error_free (error);
+ if (error->code == G_IO_ERROR_INVALID_ARGUMENT)
+ {
+ /* New username provided by the user,
+ * we need to re-spawn the ssh command
+ */
+ g_error_free (error);
+ do_mount (backend, job, mount_spec, mount_source, is_automount);
+ }
+ else
+ {
+ g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
+ g_error_free (error);
+ }
+
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]