summaryrefslogtreecommitdiff
path: root/source3/libsmb/libsmb_cache.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-03-10 23:41:19 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:55:58 -0500
commit9d65e0778425b1e49e789178999ce98e59395569 (patch)
tree730fb1edede29d3bd73a0eff3fd1250c7d120116 /source3/libsmb/libsmb_cache.c
parenta9a218f5e64aac1f7fb0608520010ed75d437a4c (diff)
downloadsamba-9d65e0778425b1e49e789178999ce98e59395569.tar.gz
samba-9d65e0778425b1e49e789178999ce98e59395569.tar.bz2
samba-9d65e0778425b1e49e789178999ce98e59395569.zip
r5735: rest of derrel's patch for BUG 2308; had to move the options structure from the _SMBCCTX to the internals structure to maintain binary compatibility (derrel, we should talk more about this)
(This used to be commit a5ea01bf15758bb2be26ba16784dc0975be783bf)
Diffstat (limited to 'source3/libsmb/libsmb_cache.c')
-rw-r--r--source3/libsmb/libsmb_cache.c55
1 files changed, 47 insertions, 8 deletions
diff --git a/source3/libsmb/libsmb_cache.c b/source3/libsmb/libsmb_cache.c
index ddb2753523..dabf5a527d 100644
--- a/source3/libsmb/libsmb_cache.c
+++ b/source3/libsmb/libsmb_cache.c
@@ -1,3 +1,4 @@
+
/*
Unix SMB/CIFS implementation.
SMB client library implementation (server cache)
@@ -23,12 +24,8 @@
#include "includes.h"
-/*
- * Define this to get the real SMBCFILE and SMBCSRV structures
- */
-#define _SMBC_INTERNAL
#include "include/libsmbclient.h"
-
+#include "../include/libsmb_internal.h"
/*
* Structure we use if internal caching mechanism is used
* nothing fancy here.
@@ -115,11 +112,53 @@ static SMBCSRV * smbc_get_cached_server(SMBCCTX * context, const char * server,
/* Search the cache lines */
for (srv=((struct smbc_server_cache *)context->server_cache);srv;srv=srv->next) {
+
if (strcmp(server,srv->server_name) == 0 &&
- strcmp(share,srv->share_name) == 0 &&
strcmp(workgroup,srv->workgroup) == 0 &&
- strcmp(user, srv->username) == 0)
- return srv->server;
+ strcmp(user, srv->username) == 0) {
+
+ /* If the share name matches, we're cool */
+ if (strcmp(share, srv->share_name) == 0) {
+ return srv->server;
+ }
+
+ /*
+ * We only return an empty share name or the attribute
+ * server on an exact match (which would have been
+ * caught above).
+ */
+ if (*share == '\0' || strcmp(share, "*IPC$") == 0)
+ continue;
+
+ /*
+ * Never return an empty share name or the attribute
+ * server if it wasn't what was requested.
+ */
+ if (*srv->share_name == '\0' ||
+ strcmp(srv->share_name, "*IPC$") == 0)
+ continue;
+
+ /*
+ * If we're only allowing one share per server, then
+ * a connection to the server (other than the
+ * attribute server connection) is cool.
+ */
+ if (context->options.one_share_per_server) {
+ /*
+ * The currently connected share name
+ * doesn't match the requested share, so
+ * disconnect from the current share.
+ */
+ if (! cli_tdis(&srv->server->cli)) {
+ /* Sigh. Couldn't disconnect. */
+ cli_shutdown(&srv->server->cli);
+ context->callbacks.remove_cached_srv_fn(context, srv->server);
+ continue;
+ }
+
+ return srv->server;
+ }
+ }
}
return NULL;