Index: smb-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/smb-method.c,v
retrieving revision 1.19
diff -u -r1.19 smb-method.c
--- smb-method.c	11 Feb 2005 15:58:20 -0000	1.19
+++ smb-method.c	11 Feb 2005 19:01:39 -0000
@@ -130,6 +130,9 @@
 	gchar *use_user;		/* Set by perform_authentication */
 	gchar *use_domain;		/* Set by perform_authentication */
 	gchar *use_password;		/* Set by perform_authentication */
+     
+        /* Used in chat between add_cached_server and perform_authentication */
+        gboolean connect_success;       /* Set by add_cached_server */
 	
 } SmbAuthContext;
 
@@ -138,9 +141,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,
@@ -362,7 +362,8 @@
 
 	g_hash_table_insert (server_cache, entry, entry);
 
-	cache_access_failed = FALSE;
+        g_return_val_if_fail (current_auth_context != NULL, 0);
+        current_auth_context->connect_success = TRUE;
 	return 0;
 }
 
@@ -382,11 +383,11 @@
 	res = g_hash_table_lookup (server_cache, &entry);
 
 	if (res != NULL) {
-		cache_access_failed = FALSE;
+                DEBUG_SMB(("get_cached_server: returning cached server\n"));
+		current_auth_context->connect_success = TRUE;
 		res->last_time = time (NULL);
 		return res->server;
 	}
-	cache_access_failed = TRUE;
 	return NULL;
 }
 
@@ -1054,7 +1055,6 @@
 	DEBUG_SMB(("[auth] Initializing Authentication\n"));
 	memset (actx, 0, sizeof(*actx));
 	actx->uri = uri;
-	cache_access_failed = FALSE;
 }
 
 static int
@@ -1064,7 +1064,7 @@
 	int ret = -1;
 	
 	/* IMPORTANT: We are IN the lock at this point */
-	DEBUG_SMB(("[auth] perform_authentication called.\n"));
+	DEBUG_SMB(("[auth] result code: %d\n", actx->res));
 	
 	switch (actx->res) {
 	case GNOME_VFS_OK:
@@ -1075,7 +1075,9 @@
 	case GNOME_VFS_ERROR_ACCESS_DENIED:
 	case GNOME_VFS_ERROR_NOT_PERMITTED:
 	case GNOME_VFS_ERROR_LOGIN_FAILED:
-		auth_failed = TRUE;
+                
+                /* Hack around problems in libsmbclient */
+                auth_failed = actx->connect_success ? FALSE : TRUE;
 		break;
 	
 	/* Other errors mean we're done */
@@ -1085,8 +1087,8 @@
 		return -1;
 	}
 	
-	/* TODO: What about cache_access_failed? */
-	
+        /* Reset flag for successful connect on last pass */	
+        actx->connect_success = FALSE;
 	actx->passes++;
 
 	/* First pass */
