[PATCH] Re: SMB module authentication rewrite patch



On Wed, 2005-01-12 at 03:30, Nielsen wrote:
Narayana Pattipati wrote:
> b) Entering smb://domain;username machine throws a password dialog but
> it never authenticated user. Even after giving correct password, the
> authentication dialog keeps coming.  This is use case while adding a 
> network place from network: location. User can either enter username or
> go without user name. If user enters a username there, url becomes as
> mentioned above, and user will encounter the problem.

True, that's odd. I'll look into it.

> I will let you know if I see any other issues with the patch.
I had a look at the code and figured out the reason for this.

The problem will be there when smb uri  is in the following forms:
- smb://username machine
- smb://domain;username machine
- smb://domain;@machine

When url is like this, while processing the uri (initial_authentication()) and while prompting for authentication (prompt_authentication()), assumptions have been made about the availability of domain name.  Same is true while caching also.

Also, after invoking the authentication for say password only (username, domain are available through url), the return values from gnome_vfs_module_callback_invoke() are filled into username and domain also, even though user is not prompted for them. User is just prompted for password. So, just fill in password.

The attached patch takes care of these issues and makes smb browsing work when url happens to be in the above forms.

Please have a look at the patch.

Regards,
Narayana
--- gnome-vfs/modules/smb-method.c	2005-01-13 02:54:30.638740376 +0530
+++ gnome-vfs-new/modules/smb-method.c	2005-01-13 02:55:29.509790616 +0530
@@ -373,20 +373,12 @@ add_cached_server (SMBCCTX *context, SMB
 
 	cache_access_failed = FALSE;
 
-	if (current_auth_context && current_auth_context->uri != NULL) {
-		toplevel = (GnomeVFSToplevelURI *)current_auth_context->uri;
-
-		if (toplevel->user_name == NULL ||
-		    toplevel->user_name[0] == 0) {
-			default_user = g_new0 (SmbDefaultUser, 1);
-			default_user->server_name = string_dup_nzero (server_name);
-			default_user->share_name = string_dup_nzero (share_name);
-			default_user->username = string_dup_nzero (username);
-			default_user->domain = string_dup_nzero (domain);
-			g_hash_table_replace (default_user_hashtable, default_user, default_user);
-		}
-	}
-
+	default_user = g_new0 (SmbDefaultUser, 1);
+	default_user->server_name = string_dup_nzero (server_name);
+	default_user->share_name = string_dup_nzero (share_name);
+	default_user->username = string_dup_nzero (username);
+	default_user->domain = string_dup_nzero (domain);
+	g_hash_table_replace (default_user_hashtable, default_user, default_user);
 	return 0;
 }
 
@@ -734,8 +726,10 @@ initial_authentication (SmbAuthContext *
 			DEBUG_SMB(("[auth] User from URI: %s\n", actx->use_user));
 		}
 
+	} 
+
 	/* Lookup a default user and domain */
-	} else {
+	if (actx->use_user == NULL || actx->use_domain == NULL) {
 		
 		/* lookup default user/domain */
 		lookup.server_name = actx->for_server;
@@ -841,6 +835,10 @@ prompt_authentication (SmbAuthContext *a
 	if (actx->uri && ((GnomeVFSToplevelURI*)actx->uri)->user_name == NULL) {
 		in_args.flags |= GNOME_VFS_MODULE_CALLBACK_FULL_AUTHENTICATION_NEED_USERNAME |
 	  			 GNOME_VFS_MODULE_CALLBACK_FULL_AUTHENTICATION_NEED_DOMAIN;
+	} else if (actx->use_user == NULL) {
+		in_args.flags |= GNOME_VFS_MODULE_CALLBACK_FULL_AUTHENTICATION_NEED_USERNAME; 
+	} else if (actx->use_domain == NULL) {
+		in_args.flags |= GNOME_VFS_MODULE_CALLBACK_FULL_AUTHENTICATION_NEED_DOMAIN;
 	}
 
 	in_args.uri = get_auth_display_uri (actx);
@@ -864,10 +862,12 @@ prompt_authentication (SmbAuthContext *a
 
 	if (invoked) {
 		cancelled = out_args.abort_auth;
-		g_free (actx->use_user);
-		actx->use_user = string_dup_nzero (out_args.username);
-		g_free (actx->use_domain);
-		actx->use_domain = string_dup_nzero (out_args.domain);
+		if (actx->use_user == NULL) {
+			actx->use_user = string_dup_nzero (out_args.username);
+		}
+		if (actx->use_domain == NULL) {
+			actx->use_domain = string_dup_nzero (out_args.domain);
+		}
 		g_free (actx->use_password);
 		actx->use_password = out_args.password ? g_strdup (out_args.password) : NULL;
 		g_free (actx->keyring);


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