X-Git-Url: http://git.samba.org/?a=blobdiff_plain;f=source3%2Flibsmb%2Fclidfs.c;h=f853e4e6701f6b062e1a90c6108d6b6902ec6d6f;hb=7f25e0da7348d786a36fa14403938b4f209fb52b;hp=4597e63c98f4243a8c8f192c921564e3b5e62653;hpb=263036a798b4c431f03dae20d33f90585d2b0cab;p=metze%2Fsamba%2Fwip.git diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index 4597e63c98f4..f853e4e6701f 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -38,9 +38,6 @@ struct client_connection { char *mount; }; -/* global state....globals reek! */ -int max_protocol = PROTOCOL_NT1; - static struct cm_cred_struct { char *username; char *password; @@ -52,11 +49,6 @@ static struct cm_cred_struct { static void cm_set_password(const char *newpass); -static int port; -static int name_type = 0x20; -static bool have_ip; -static struct sockaddr_storage dest_ss; - static struct client_connection *connections; static bool cli_check_msdfs_proxy(TALLOC_CTX *ctx, @@ -113,7 +105,10 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx, const char *server, const char *share, bool show_sessetup, - bool force_encrypt) + bool force_encrypt, + int max_protocol, + int port, + int name_type) { struct cli_state *c = NULL; struct nmb_name called, calling; @@ -133,8 +128,11 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx, } sharename = servicename; if (*sharename == '\\') { - server = sharename+2; - sharename = strchr_m(server,'\\'); + sharename += 2; + if (server == NULL) { + server = sharename; + } + sharename = strchr_m(sharename,'\\'); if (!sharename) { return NULL; } @@ -151,17 +149,19 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx, again: zero_sockaddr(&ss); - if (have_ip) - ss = dest_ss; /* have to open a new connection */ - if (!(c=cli_initialise()) || (cli_set_port(c, port) != port)) { + if (!(c=cli_initialise())) { d_printf("Connection to %s failed\n", server_n); if (c) { cli_shutdown(c); } return NULL; } + if (port) { + cli_set_port(c, port); + } + status = cli_connect(c, server_n, &ss); if (!NT_STATUS_IS_OK(status)) { d_printf("Connection to %s failed (Error %s)\n", @@ -171,6 +171,9 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx, return NULL; } + if (max_protocol == 0) { + max_protocol = PROTOCOL_NT1; + } c->protocol = max_protocol; c->use_kerberos = cm_creds.use_kerberos; c->fallback_after_kerberos = cm_creds.fallback_after_kerberos; @@ -265,7 +268,9 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx, lp_workgroup())) { cli_shutdown(c); return do_connect(ctx, newserver, - newshare, false, force_encrypt); + newshare, false, + force_encrypt, max_protocol, + port, name_type); } /* must be a normal share */ @@ -309,10 +314,11 @@ static void cli_cm_set_mntpoint(struct cli_state *c, const char *mnt) } if (p) { - char *name = clean_name(NULL, p->mount); + char *name = clean_name(NULL, mnt); if (!name) { return; } + TALLOC_FREE(p->mount); p->mount = talloc_strdup(p, name); TALLOC_FREE(name); } @@ -348,7 +354,10 @@ static struct cli_state *cli_cm_connect(TALLOC_CTX *ctx, const char *server, const char *share, bool show_hdr, - bool force_encrypt) + bool force_encrypt, + int max_protocol, + int port, + int name_type) { struct client_connection *node; @@ -358,7 +367,9 @@ static struct cli_state *cli_cm_connect(TALLOC_CTX *ctx, return NULL; } - node->cli = do_connect(ctx, server, share, show_hdr, force_encrypt); + node->cli = do_connect(ctx, server, share, + show_hdr, force_encrypt, max_protocol, + port, name_type); if ( !node->cli ) { TALLOC_FREE( node ); @@ -411,7 +422,10 @@ struct cli_state *cli_cm_open(TALLOC_CTX *ctx, const char *server, const char *share, bool show_hdr, - bool force_encrypt) + bool force_encrypt, + int max_protocol, + int port, + int name_type) { struct cli_state *c; @@ -420,7 +434,8 @@ struct cli_state *cli_cm_open(TALLOC_CTX *ctx, c = cli_cm_find(server, share); if (!c) { c = cli_cm_connect(ctx, referring_cli, - server, share, show_hdr, force_encrypt); + server, share, show_hdr, force_encrypt, + max_protocol, port, name_type); } return c; @@ -492,22 +507,6 @@ void cli_cm_set_credentials(struct user_auth_info *auth_info) /**************************************************************************** ****************************************************************************/ -void cli_cm_set_port(int port_number) -{ - port = port_number; -} - -/**************************************************************************** -****************************************************************************/ - -void cli_cm_set_dest_name_type(int type) -{ - name_type = type; -} - -/**************************************************************************** -****************************************************************************/ - void cli_cm_set_signing_state(int state) { cm_creds.signing_state = state; @@ -550,15 +549,6 @@ void cli_cm_set_fallback_after_kerberos(void) cm_creds.fallback_after_kerberos = true; } -/**************************************************************************** -****************************************************************************/ - -void cli_cm_set_dest_ss(struct sockaddr_storage *pss) -{ - dest_ss = *pss; - have_ip = true; -} - /********************************************************************** split a dfs path into the server, share name, and extrapath components **********************************************************************/ @@ -795,9 +785,10 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx, if (p + node_offset > endp) { goto out; } - clistr_pull_talloc(ctx, cli, &referrals[i].dfspath, - p+node_offset, -1, - STR_TERMINATE|STR_UNICODE ); + clistr_pull_talloc(ctx, cli->inbuf, + &referrals[i].dfspath, + p+node_offset, -1, + STR_TERMINATE|STR_UNICODE); if (!referrals[i].dfspath) { goto out; @@ -909,7 +900,10 @@ bool cli_resolve_path(TALLOC_CTX *ctx, if (!(cli_ipc = cli_cm_open(ctx, rootcli, rootcli->desthost, "IPC$", false, - (rootcli->trans_enc_state != NULL)))) { + (rootcli->trans_enc_state != NULL), + rootcli->protocol, + 0, + 0x20))) { return false; } @@ -954,7 +948,10 @@ bool cli_resolve_path(TALLOC_CTX *ctx, server, share, false, - (rootcli->trans_enc_state != NULL))) == NULL) { + (rootcli->trans_enc_state != NULL), + rootcli->protocol, + 0, + 0x20)) == NULL) { d_printf("Unable to follow dfs referral [\\%s\\%s]\n", server, share ); return false;