1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-04 08:22:08 +03:00

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 a5ea01bf15)
This commit is contained in:
Gerald Carter
2005-03-10 23:41:19 +00:00
committed by Gerald (Jerry) Carter
parent a9a218f5e6
commit 9d65e07784
4 changed files with 1294 additions and 574 deletions

View File

@ -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;