summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2005-03-31 21:16:20 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:56:25 -0500
commit523ba5ed3221bb81eea0428e4d6900e35bd24f03 (patch)
treebde7a9bafcca1e2f2d4644ac8f2011333930d38c
parent8de11f06df03e19fe92f44da10a10eab30e118b2 (diff)
downloadsamba-523ba5ed3221bb81eea0428e4d6900e35bd24f03.tar.gz
samba-523ba5ed3221bb81eea0428e4d6900e35bd24f03.tar.bz2
samba-523ba5ed3221bb81eea0428e4d6900e35bd24f03.zip
r6156: Fixes bug #2543. Properly cache anonmous username when reverting to anonymous login, in libsmbclient.
(This used to be commit cf2dcc110824cb3a4ce4e4bf608de25b7cfc2054)
-rw-r--r--source3/libsmb/libsmbclient.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c
index 657d0925b0..3e8e604ab1 100644
--- a/source3/libsmb/libsmbclient.c
+++ b/source3/libsmb/libsmbclient.c
@@ -558,6 +558,7 @@ SMBCSRV *smbc_server(SMBCCTX *context,
int tried_reverse = 0;
int port_try_first;
int port_try_next;
+ const char *username_used;
zero_ip(&ip);
ZERO_STRUCT(c);
@@ -712,16 +713,26 @@ SMBCSRV *smbc_server(SMBCCTX *context,
return NULL;
}
- if (!cli_session_setup(&c, username,
+ username_used = username;
+
+ if (!cli_session_setup(&c, username_used,
password, strlen(password),
password, strlen(password),
- workgroup) &&
- /* Try an anonymous login if it failed and this was allowed by flags. */
- ((context->flags & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON) ||
- !cli_session_setup(&c, "", "", 1,"", 0, workgroup))) {
- cli_shutdown(&c);
- errno = EPERM;
- return NULL;
+ workgroup)) {
+
+ /* Failed. Try an anonymous login, if allowed by flags. */
+ username_used = "";
+
+ if ((context->flags & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON) ||
+ !cli_session_setup(&c, username_used,
+ password, 1,
+ password, 0,
+ workgroup)) {
+
+ cli_shutdown(&c);
+ errno = EPERM;
+ return NULL;
+ }
}
DEBUG(4,(" session setup ok\n"));
@@ -753,7 +764,7 @@ SMBCSRV *smbc_server(SMBCCTX *context,
/* now add it to the cache (internal or external) */
/* Let the cache function set errno if it wants to */
errno = 0;
- if (context->callbacks.add_cached_srv_fn(context, srv, server, share, workgroup, username)) {
+ if (context->callbacks.add_cached_srv_fn(context, srv, server, share, workgroup, username_used)) {
int saved_errno = errno;
DEBUG(3, (" Failed to add server to cache\n"));
errno = saved_errno;