[Fwd: [PATCH] Supress eroneous authentications in the SMB module]



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

And now again with the patch...

- -------- Original Message --------
Subject: [PATCH] Supress eroneous authentications in the SMB module
Date: Mon, 14 Feb 2005 18:00:26 -0700
From: Nielsen <nielsen memberwebs com>
To: gnome-vfs-list gnome org <gnome-vfs-list gnome org>

The new authentication code in the SMB module has a prompting issue. Any
time it encounters a EPERM or EACCES it tries to authenticate and throws
up a prompt (when no cached authentication is available or it fails).

This unabashed lust for authentication leads to some problems. For
example open an SMB share that you only have read-only access to. Now
try to rename a file. You'll get a prompt for a user name and password
instead of the expected error message. I guess this could make sense in
a twisted sort of way but it's probably not what the user is expecting.

I'd like to get this fixed before Gnome 2.10. Attached is a patch. This
patch makes the assumption that if we already have a cached connection
then there's no point in trying to reprompt the user for more
credentials. Before committing I'd like to see if anyone thinks this
assumption is an invalid one.

Cheers,
Nate

PS: This will fix bugs that look like:
http://bugzilla.gnome.org/show_bug.cgi?id=167082

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFCEZdSe/sRCNknZa8RAneiAKDTP3IWnYhyHS08sIpASQg9nQylLwCZAav5
t1mMIpRG5Uj4Exwp4BwkXjk=
=yv49
-----END PGP SIGNATURE-----
Index: smb-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/smb-method.c,v
retrieving revision 1.22
diff -u -r1.22 smb-method.c
--- smb-method.c	11 Feb 2005 23:31:11 -0000	1.22
+++ smb-method.c	15 Feb 2005 00:40:06 -0000
@@ -130,6 +130,8 @@
 	gchar *use_user;		/* Set by perform_authentication */
 	gchar *use_domain;		/* Set by perform_authentication */
 	gchar *use_password;		/* Set by perform_authentication */
+
+	gboolean cache_used;            /* Set when cache is used during authentication */
 	
 } SmbAuthContext;
 
@@ -138,9 +140,6 @@
 
 static SmbAuthContext *current_auth_context = NULL;
 
-/* Used to detect failed logins */
-static gboolean cache_access_failed = FALSE;
-
 static void auth_callback (const char *server_name, const char *share_name,
 		     	   char *domain, int domainmaxlen,
 		     	   char *username, int unmaxlen,
@@ -361,8 +360,6 @@
 	entry->last_time = time (NULL);
 
 	g_hash_table_insert (server_cache, entry, entry);
-
-	cache_access_failed = FALSE;
 	return 0;
 }
 
@@ -382,11 +379,10 @@
 	res = g_hash_table_lookup (server_cache, &entry);
 
 	if (res != NULL) {
-		cache_access_failed = FALSE;
+		current_auth_context->cache_used = TRUE;
 		res->last_time = time (NULL);
 		return res->server;
 	}
-	cache_access_failed = TRUE;
 	return NULL;
 }
 
@@ -1073,7 +1069,6 @@
 	DEBUG_SMB(("[auth] Initializing Authentication\n"));
 	memset (actx, 0, sizeof(*actx));
 	actx->uri = uri;
-	cache_access_failed = FALSE;
 }
 
 static int
@@ -1104,8 +1099,6 @@
 		return -1;
 	}
 	
-	/* TODO: What about cache_access_failed? */
-	
 	actx->passes++;
 
 	/* First pass */
@@ -1132,7 +1125,14 @@
 			DEBUG_SMB(("[auth] Operation successful\n"));
 			save_authentication (actx);
 			ret = 0;
-	
+
+		/* If authentication failed, but we already have a connection ... */
+		} else if (actx->cache_used) {
+
+			/* ... we just return the error */
+			DEBUG_SMB(("[auth] Not reauthenticating a cached connection.\n"));
+			ret = -1;
+
 		/* A failed authentication */
 		} else if (actx->auth_called) {
 			


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]