Bug 3446 - authdomain, parsed from smb URL, is ignored
Summary: authdomain, parsed from smb URL, is ignored
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: libsmbclient (show other bugs)
Version: 3.0.21a
Hardware: Other Linux
: P3 normal
Target Milestone: none
Assignee: Derrell Lipman
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-25 09:43 UTC by Derrell Lipman
Modified: 2006-03-22 15:35 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Derrell Lipman 2006-01-25 09:43:43 UTC
From an email message sent by Federico Mena Quintero...

I think I've found a bug in the way the smbcctx.callbacks.auth_fn is
called.

As far as I can tell:

1. You create a SMBCCTX.  You set its ctx->workgroup field to the user's
default workgroup (otherwise, smbc_init_context() will fill it with the
result of lp_workgroup()).

2. You call some method on your context as "my_ctx->foo (...)".  This
may call your auth_fn.

3. There's this code in smbc_open_ctx():

static SMBCFILE *smbc_open_ctx(SMBCCTX *context, const char *fname, int flags, mode_t mode)
	fstring server, share, user, password, workgroup;

	if (smbc_parse_path(context, fname,
                            server, sizeof(server),
                            share, sizeof(share),
                            path, sizeof(path),
                            user, sizeof(user),
                            password, sizeof(password),
                            NULL, 0)) {
		/* error out, etc. */
	}

	/* NOTE HOW THE ABOVE DIDN'T PARSE THE WORKGROUP FROM THE URI */

	fstrcpy(workgroup, context->workgroup);   /* THIS JUST COPIES FROM THE DEFAULT */

	srv = smbc_server(context, server, share, workgroup, user, password);
	...

	/* etc.  Now, in smbc_server(): */

        srv = find_server(context, server, share,
                          workgroup, username, password);

	/* And in find_server(): */

	srv = context->callbacks.get_cached_srv_fn(context, server, share, 
						   workgroup, username);

	if (!auth_called && !srv && (!username[0] || !password[0])) {
		context->callbacks.auth_fn(server, share,
                                           workgroup, sizeof(fstring),
                                           username, sizeof(fstring),
                                           password, sizeof(fstring));

But note how the workgroup that trickles down is the client-supplied
default workgroup, or the result of lp_workgroup(), *NOT* the workgroup
which may be in the URL!

That is, if the URL is "smb://FOO_WORKGROUP;bar_server/sharename/dir",
then the auth_fn will not get FOO_WORKGROUP passed to it.

* Shouldn't smb_parse_path() also return the workgroup, if it is present
in the URI, and the rest of the code should use it if available?  If
not, of course fall back to the default workgroup.

* So, how is auth_fn supposed to guess the correct workgroup?

Gnome-VFS has some convoluted code which first parses the URL on its
own, stores the various parts in semi-global variables, and then fetches
things from there for use in the auth_fn it supplies.
Comment 1 Derrell Lipman 2006-01-28 17:17:05 UTC
Checkin 13214 in the SAMBA_3_0 branch should correct this deficiency.  It works fine in all of my local tests, but I have no domain environment where I can test the new feature.  Please test and let me know how it works.
Comment 2 Derrell Lipman 2006-03-22 15:35:03 UTC
No comments in many weeks.  Assuming it solves the problem.  Closing.