From ef2e26c91b80556af033d3335e55f5dfa6fff31d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Aug 2003 01:53:07 +0000 Subject: first public release of samba4 code (This used to be commit b0510b5428b3461aeb9bbe3cc95f62fc73e2b97f) --- source4/libcli/raw/clitree.c | 290 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100644 source4/libcli/raw/clitree.c (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c new file mode 100644 index 0000000000..2a41273913 --- /dev/null +++ b/source4/libcli/raw/clitree.c @@ -0,0 +1,290 @@ +/* + Unix SMB/CIFS implementation. + SMB client tree context management functions + Copyright (C) Andrew Tridgell 1994-1998 + Copyright (C) James Myers 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +#define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \ + req = cli_request_setup(tree, cmd, wct, buflen); \ + if (!req) return NULL; \ +} while (0) + + +/**************************************************************************** + Initialize the tree context +****************************************************************************/ +struct cli_tree *cli_tree_init(struct cli_session *session) +{ + struct cli_tree *tree; + TALLOC_CTX *mem_ctx = talloc_init("cli_tree"); + if (mem_ctx == NULL) { + return NULL; + } + + tree = talloc_zero(mem_ctx, sizeof(*tree)); + if (!tree) { + talloc_destroy(mem_ctx); + return NULL; + } + + tree->mem_ctx = mem_ctx; + tree->session = session; + tree->session->reference_count++; + + return tree; +} + +/**************************************************************************** +reduce reference count on a tree and destroy if <= 0 +****************************************************************************/ +void cli_tree_close(struct cli_tree *tree) +{ + if (!tree) return; + tree->reference_count--; + if (tree->reference_count <= 0) { + cli_session_close(tree->session); + talloc_destroy(tree->mem_ctx); + } +} + + +/**************************************************************************** + Send a tconX (async send) +****************************************************************************/ +struct cli_request *smb_tree_connect_send(struct cli_tree *tree, union smb_tcon *parms) +{ + struct cli_request *req; + + switch (parms->tcon.level) { + case RAW_TCON_TCON: + SETUP_REQUEST_TREE(SMBtcon, 0, 0); + cli_req_append_ascii4(req, parms->tcon.in.service, STR_ASCII); + cli_req_append_ascii4(req, parms->tcon.in.password,STR_ASCII); + cli_req_append_ascii4(req, parms->tcon.in.dev, STR_ASCII); + break; + + case RAW_TCON_TCONX: + SETUP_REQUEST_TREE(SMBtconX, 4, 0); + SSVAL(req->out.vwv, VWV(0), 0xFF); + SSVAL(req->out.vwv, VWV(1), 0); + SSVAL(req->out.vwv, VWV(2), parms->tconx.in.flags); + SSVAL(req->out.vwv, VWV(3), parms->tconx.in.password.length); + cli_req_append_blob(req, &parms->tconx.in.password); + cli_req_append_string(req, parms->tconx.in.path, STR_TERMINATE | STR_UPPER); + cli_req_append_string(req, parms->tconx.in.device, STR_TERMINATE | STR_ASCII); + break; + } + + if (!cli_request_send(req)) { + cli_request_destroy(req); + return NULL; + } + + return req; +} + +/**************************************************************************** + Send a tconX (async recv) +****************************************************************************/ +NTSTATUS smb_tree_connect_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union smb_tcon *parms) +{ + char *p; + + if (!cli_request_receive(req) || + cli_request_is_error(req)) { + goto failed; + } + + switch (parms->tcon.level) { + case RAW_TCON_TCON: + CLI_CHECK_WCT(req, 2); + parms->tcon.out.max_xmit = SVAL(req->in.vwv, VWV(0)); + parms->tcon.out.cnum = SVAL(req->in.vwv, VWV(1)); + break; + + case RAW_TCON_TCONX: + ZERO_STRUCT(parms->tconx.out); + CLI_CHECK_MIN_WCT(req, 0); /* this depends on the protocol level */ + parms->tconx.out.cnum = SVAL(req->in.hdr, HDR_TID); + if (req->in.wct >= 4) { + parms->tconx.out.options = SVAL(req->in.vwv, VWV(3)); + } + + /* output is actual service name */ + p = req->in.data; + if (!p) break; + + p += cli_req_pull_string(req, mem_ctx, &parms->tconx.out.dev_type, + p, -1, STR_ASCII | STR_TERMINATE); + p += cli_req_pull_string(req, mem_ctx, &parms->tconx.out.fs_type, + p, -1, STR_TERMINATE); + break; + } + +failed: + return cli_request_destroy(req); +} + +/**************************************************************************** + Send a tconX (sync interface) +****************************************************************************/ +NTSTATUS smb_tree_connect(struct cli_tree *tree, TALLOC_CTX *mem_ctx, union smb_tcon *parms) +{ + struct cli_request *req = smb_tree_connect_send(tree, parms); + return smb_tree_connect_recv(req, mem_ctx, parms); +} + + +/**************************************************************************** + Send a tree disconnect. +****************************************************************************/ +NTSTATUS smb_tree_disconnect(struct cli_tree *tree) +{ + struct cli_request *req; + + if (!tree) return NT_STATUS_OK; + req = cli_request_setup(tree, SMBtdis, 0, 0); + + if (cli_request_send(req)) { + cli_request_receive(req); + } + return cli_request_destroy(req); +} + + +/* + a convenient function to establish a cli_tree from scratch, using reasonable default + parameters +*/ +NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, + const char *my_name, + const char *dest_host, int port, + const char *service, const char *service_type, + const char *user, const char *domain, + const char *password) +{ + struct cli_socket *sock; + struct cli_transport *transport; + struct cli_session *session; + struct cli_tree *tree; + NTSTATUS status; + struct nmb_name calling; + struct nmb_name called; + union smb_sesssetup setup; + union smb_tcon tcon; + TALLOC_CTX *mem_ctx; + + *ret_tree = NULL; + + sock = cli_sock_init(); + if (!sock) { + return NT_STATUS_NO_MEMORY; + } + + /* open a TCP socket to the server */ + if (!cli_sock_connect_byname(sock, dest_host, port)) { + DEBUG(2,("Failed to establish socket connection - %s\n", strerror(errno))); + return NT_STATUS_UNSUCCESSFUL; + } + + transport = cli_transport_init(sock); + if (!transport) { + cli_sock_close(sock); + return NT_STATUS_NO_MEMORY; + } + + /* send a NBT session request, if applicable */ + make_nmb_name(&calling, my_name, 0x0); + make_nmb_name(&called, dest_host, 0x20); + + if (!cli_transport_connect(transport, &calling, &called)) { + cli_transport_close(transport); + return NT_STATUS_UNSUCCESSFUL; + } + + + /* negotiate protocol options with the server */ + status = smb_raw_negotiate(transport); + if (!NT_STATUS_IS_OK(status)) { + cli_transport_close(transport); + return status; + } + + session = cli_session_init(transport); + if (!session) { + cli_transport_close(transport); + return NT_STATUS_NO_MEMORY; + } + + /* prepare a session setup to establish a security context */ + setup.generic.level = RAW_SESSSETUP_GENERIC; + setup.generic.in.sesskey = transport->negotiate.sesskey; + setup.generic.in.capabilities = CAP_UNICODE | CAP_STATUS32 | + CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | + CAP_W2K_SMBS | CAP_LARGE_READX | CAP_LARGE_WRITEX; + setup.generic.in.password = password; + setup.generic.in.user = user; + setup.generic.in.domain = domain; + + mem_ctx = talloc_init("tcon"); + if (!mem_ctx) { + cli_tree_close(tree); + return NT_STATUS_NO_MEMORY; + } + + status = smb_raw_session_setup(session, mem_ctx, &setup); + if (!NT_STATUS_IS_OK(status)) { + cli_session_close(session); + talloc_destroy(mem_ctx); + return status; + } + + session->vuid = setup.generic.out.vuid; + + tree = cli_tree_init(session); + if (!tree) { + cli_session_close(session); + talloc_destroy(mem_ctx); + return NT_STATUS_NO_MEMORY; + } + + /* connect to a share using a tree connect */ + tcon.generic.level = RAW_TCON_TCONX; + tcon.tconx.in.flags = 0; + tcon.tconx.in.password = data_blob(NULL, 0); + tcon.tconx.in.path = service; + tcon.tconx.in.device = service_type; + + status = smb_tree_connect(tree, mem_ctx, &tcon); + if (!NT_STATUS_IS_OK(status)) { + cli_tree_close(tree); + talloc_destroy(mem_ctx); + return status; + } + + tree->tid = tcon.tconx.out.cnum; + tree->device = talloc_strdup(tree->mem_ctx, tcon.tconx.out.dev_type); + tree->fs_type = talloc_strdup(tree->mem_ctx, tcon.tconx.out.fs_type); + + talloc_destroy(mem_ctx); + + *ret_tree = tree; + return NT_STATUS_OK; +} -- cgit From e063ea70ad05d9a8cc927ddbcf61aa3b4ea04ade Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Aug 2003 02:01:01 +0000 Subject: use the \\server\share form of tconx to work with servers that don't cope with the simpler form (This used to be commit 295cc63fb8d99d403c863a7b30cb30382070a6f9) --- source4/libcli/raw/clitree.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 2a41273913..60e8610bd8 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -269,10 +269,13 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, tcon.generic.level = RAW_TCON_TCONX; tcon.tconx.in.flags = 0; tcon.tconx.in.password = data_blob(NULL, 0); - tcon.tconx.in.path = service; + asprintf(&tcon.tconx.in.path, "\\\\%s\\%s", dest_host, service); tcon.tconx.in.device = service_type; status = smb_tree_connect(tree, mem_ctx, &tcon); + + free(tcon.tconx.in.path); + if (!NT_STATUS_IS_OK(status)) { cli_tree_close(tree); talloc_destroy(mem_ctx); -- cgit From d3bc355533af429be645bb1c965350fa532d03d4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 15 Aug 2003 15:14:14 +0000 Subject: some servers don't return a fs_type and dev_type (This used to be commit eaec1bdaadd744c63fb270b3807bc284dfadb37d) --- source4/libcli/raw/clitree.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 60e8610bd8..a088ae7023 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -283,8 +283,12 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, } tree->tid = tcon.tconx.out.cnum; - tree->device = talloc_strdup(tree->mem_ctx, tcon.tconx.out.dev_type); - tree->fs_type = talloc_strdup(tree->mem_ctx, tcon.tconx.out.fs_type); + if (tcon.tconx.out.dev_type) { + tree->device = talloc_strdup(tree->mem_ctx, tcon.tconx.out.dev_type); + } + if (tcon.tconx.out.fs_type) { + tree->fs_type = talloc_strdup(tree->mem_ctx, tcon.tconx.out.fs_type); + } talloc_destroy(mem_ctx); -- cgit From 8e4ab747b02207671203d40cd2a78692da78faef Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 15 Aug 2003 18:33:43 +0000 Subject: more fixes from the IRIX compiler (thanks herb!) (This used to be commit 4cf3839b727c77a727abb558bd9473119a092913) --- source4/libcli/raw/clitree.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index a088ae7023..1e9104308e 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -121,7 +121,6 @@ NTSTATUS smb_tree_connect_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, uni case RAW_TCON_TCONX: ZERO_STRUCT(parms->tconx.out); - CLI_CHECK_MIN_WCT(req, 0); /* this depends on the protocol level */ parms->tconx.out.cnum = SVAL(req->in.hdr, HDR_TID); if (req->in.wct >= 4) { parms->tconx.out.options = SVAL(req->in.vwv, VWV(3)); @@ -245,7 +244,6 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, mem_ctx = talloc_init("tcon"); if (!mem_ctx) { - cli_tree_close(tree); return NT_STATUS_NO_MEMORY; } -- cgit From 7db3bbc0482789efd68cd043459a1822a439f4da Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 2 Jan 2004 01:04:59 +0000 Subject: Autodetect service_type in cli_tree_full_connection() if the caller passes in NULL. (This used to be commit b63ebaa770940a276ab63583a13d8cc349b6efe6) --- source4/libcli/raw/clitree.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 1e9104308e..1114c8a9c5 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -268,6 +268,12 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, tcon.tconx.in.flags = 0; tcon.tconx.in.password = data_blob(NULL, 0); asprintf(&tcon.tconx.in.path, "\\\\%s\\%s", dest_host, service); + if (!service_type) { + if (strequal(service, "IPC$")) + service_type = "IPC"; + else + service_type = "?????"; + } tcon.tconx.in.device = service_type; status = smb_tree_connect(tree, mem_ctx, &tcon); -- cgit From ff4a1461684bcf57da70067e4d40b0c5e183eed7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 15 Jan 2004 23:19:07 +0000 Subject: * fixed a segv when -U is not used in smbtorture. * fixed the handling of anonymous logins (This used to be commit 7cbc4ad8710ad33387145bfc9974d0ed4b0fb231) --- source4/libcli/raw/clitree.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 1114c8a9c5..b35bf67c94 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -238,9 +238,15 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, setup.generic.in.capabilities = CAP_UNICODE | CAP_STATUS32 | CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | CAP_W2K_SMBS | CAP_LARGE_READX | CAP_LARGE_WRITEX; - setup.generic.in.password = password; - setup.generic.in.user = user; - setup.generic.in.domain = domain; + if (!user || !user[0]) { + setup.generic.in.password = NULL; + setup.generic.in.user = ""; + setup.generic.in.domain = ""; + } else { + setup.generic.in.password = password; + setup.generic.in.user = user; + setup.generic.in.domain = domain; + } mem_ctx = talloc_init("tcon"); if (!mem_ctx) { -- cgit From 4f0e5e069064c11a8efc407cd42412d38534d0d2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 5 Jul 2004 23:28:49 +0000 Subject: r1345: add extended security spnego support to the smb client code set lp_use_spnego = False, because I can't get it working yet but I commit it so others can help me metze (This used to be commit 2445cceba9ab9bd928c8bc50927a39509e4526b0) --- source4/libcli/raw/clitree.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index b35bf67c94..3b16c4c336 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -235,9 +235,7 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, /* prepare a session setup to establish a security context */ setup.generic.level = RAW_SESSSETUP_GENERIC; setup.generic.in.sesskey = transport->negotiate.sesskey; - setup.generic.in.capabilities = CAP_UNICODE | CAP_STATUS32 | - CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | - CAP_W2K_SMBS | CAP_LARGE_READX | CAP_LARGE_WRITEX; + setup.generic.in.capabilities = transport->negotiate.capabilities; if (!user || !user[0]) { setup.generic.in.password = NULL; setup.generic.in.user = ""; -- cgit From 2c87cb390d9c46bb1259c4fae95f4a44be97297b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 Jul 2004 18:32:53 +0000 Subject: r1409: if we have no user name don't use extended security the capabilities in the union smb_sesssetup should be used to decide if we can use extented security metze (This used to be commit e3760fcc17cc645d942f0fc7f7325976391309ea) --- source4/libcli/raw/clitree.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 3b16c4c336..f1513ea51c 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -240,6 +240,7 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, setup.generic.in.password = NULL; setup.generic.in.user = ""; setup.generic.in.domain = ""; + setup.generic.in.capabilities &= ~CAP_EXTENDED_SECURITY; } else { setup.generic.in.password = password; setup.generic.in.user = user; -- cgit From e053c719ab0f270dbad46dfb9e6eeae22e3b833d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 12 Jul 2004 09:02:09 +0000 Subject: r1460: Avoid a compile warning. Andrew Bartlett (This used to be commit 10a973da88441b255eda7cbc263ef5c4f2f0fcae) --- source4/libcli/raw/clitree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index f1513ea51c..fcb0a9a660 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -189,6 +189,7 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, union smb_sesssetup setup; union smb_tcon tcon; TALLOC_CTX *mem_ctx; + char *in_path = NULL; *ret_tree = NULL; @@ -272,7 +273,9 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, tcon.generic.level = RAW_TCON_TCONX; tcon.tconx.in.flags = 0; tcon.tconx.in.password = data_blob(NULL, 0); - asprintf(&tcon.tconx.in.path, "\\\\%s\\%s", dest_host, service); + + asprintf(in_path, "\\\\%s\\%s", dest_host, service); + tcon.tconx.in.path = in_path; if (!service_type) { if (strequal(service, "IPC$")) service_type = "IPC"; @@ -283,7 +286,7 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, status = smb_tree_connect(tree, mem_ctx, &tcon); - free(tcon.tconx.in.path); + SAFE_FREE(in_path); if (!NT_STATUS_IS_OK(status)) { cli_tree_close(tree); -- cgit From bff4e6963c0b7b58a0886a207f4da0398377157f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 12 Jul 2004 15:34:34 +0000 Subject: r1469: fix a segfault and compiler warning, introduced by the "compiler warning fix" in rev 1460... metze (This used to be commit ffb7ba35cdb2fb19b8271a3585eef075948bef9c) --- source4/libcli/raw/clitree.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index fcb0a9a660..a580ded010 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -272,9 +272,8 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, /* connect to a share using a tree connect */ tcon.generic.level = RAW_TCON_TCONX; tcon.tconx.in.flags = 0; - tcon.tconx.in.password = data_blob(NULL, 0); - - asprintf(in_path, "\\\\%s\\%s", dest_host, service); + tcon.tconx.in.password = data_blob(NULL, 0); + asprintf(&in_path, "\\\\%s\\%s", dest_host, service); tcon.tconx.in.path = in_path; if (!service_type) { if (strequal(service, "IPC$")) -- cgit From c5fbb6f23c2d399c7510bc552cdb1a27b1ef66a8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 4 Aug 2004 13:23:35 +0000 Subject: r1654: rename cli_ -> smbcli_ rename CLI_ -> SMBCLI_ metze (This used to be commit 8441750fd9427dd6fe477f27e603821b4026f038) --- source4/libcli/raw/clitree.c | 100 +++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index a580ded010..b9d572fd56 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -22,7 +22,7 @@ #include "includes.h" #define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \ - req = cli_request_setup(tree, cmd, wct, buflen); \ + req = smbcli_request_setup(tree, cmd, wct, buflen); \ if (!req) return NULL; \ } while (0) @@ -30,10 +30,10 @@ /**************************************************************************** Initialize the tree context ****************************************************************************/ -struct cli_tree *cli_tree_init(struct cli_session *session) +struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session) { - struct cli_tree *tree; - TALLOC_CTX *mem_ctx = talloc_init("cli_tree"); + struct smbcli_tree *tree; + TALLOC_CTX *mem_ctx = talloc_init("smbcli_tree"); if (mem_ctx == NULL) { return NULL; } @@ -54,12 +54,12 @@ struct cli_tree *cli_tree_init(struct cli_session *session) /**************************************************************************** reduce reference count on a tree and destroy if <= 0 ****************************************************************************/ -void cli_tree_close(struct cli_tree *tree) +void smbcli_tree_close(struct smbcli_tree *tree) { if (!tree) return; tree->reference_count--; if (tree->reference_count <= 0) { - cli_session_close(tree->session); + smbcli_session_close(tree->session); talloc_destroy(tree->mem_ctx); } } @@ -68,16 +68,16 @@ void cli_tree_close(struct cli_tree *tree) /**************************************************************************** Send a tconX (async send) ****************************************************************************/ -struct cli_request *smb_tree_connect_send(struct cli_tree *tree, union smb_tcon *parms) +struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, union smb_tcon *parms) { - struct cli_request *req; + struct smbcli_request *req; switch (parms->tcon.level) { case RAW_TCON_TCON: SETUP_REQUEST_TREE(SMBtcon, 0, 0); - cli_req_append_ascii4(req, parms->tcon.in.service, STR_ASCII); - cli_req_append_ascii4(req, parms->tcon.in.password,STR_ASCII); - cli_req_append_ascii4(req, parms->tcon.in.dev, STR_ASCII); + smbcli_req_append_ascii4(req, parms->tcon.in.service, STR_ASCII); + smbcli_req_append_ascii4(req, parms->tcon.in.password,STR_ASCII); + smbcli_req_append_ascii4(req, parms->tcon.in.dev, STR_ASCII); break; case RAW_TCON_TCONX: @@ -86,14 +86,14 @@ struct cli_request *smb_tree_connect_send(struct cli_tree *tree, union smb_tcon SSVAL(req->out.vwv, VWV(1), 0); SSVAL(req->out.vwv, VWV(2), parms->tconx.in.flags); SSVAL(req->out.vwv, VWV(3), parms->tconx.in.password.length); - cli_req_append_blob(req, &parms->tconx.in.password); - cli_req_append_string(req, parms->tconx.in.path, STR_TERMINATE | STR_UPPER); - cli_req_append_string(req, parms->tconx.in.device, STR_TERMINATE | STR_ASCII); + smbcli_req_append_blob(req, &parms->tconx.in.password); + smbcli_req_append_string(req, parms->tconx.in.path, STR_TERMINATE | STR_UPPER); + smbcli_req_append_string(req, parms->tconx.in.device, STR_TERMINATE | STR_ASCII); break; } - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -103,18 +103,18 @@ struct cli_request *smb_tree_connect_send(struct cli_tree *tree, union smb_tcon /**************************************************************************** Send a tconX (async recv) ****************************************************************************/ -NTSTATUS smb_tree_connect_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union smb_tcon *parms) +NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_tcon *parms) { char *p; - if (!cli_request_receive(req) || - cli_request_is_error(req)) { + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { goto failed; } switch (parms->tcon.level) { case RAW_TCON_TCON: - CLI_CHECK_WCT(req, 2); + SMBCLI_CHECK_WCT(req, 2); parms->tcon.out.max_xmit = SVAL(req->in.vwv, VWV(0)); parms->tcon.out.cnum = SVAL(req->in.vwv, VWV(1)); break; @@ -130,23 +130,23 @@ NTSTATUS smb_tree_connect_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, uni p = req->in.data; if (!p) break; - p += cli_req_pull_string(req, mem_ctx, &parms->tconx.out.dev_type, + p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.dev_type, p, -1, STR_ASCII | STR_TERMINATE); - p += cli_req_pull_string(req, mem_ctx, &parms->tconx.out.fs_type, + p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.fs_type, p, -1, STR_TERMINATE); break; } failed: - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /**************************************************************************** Send a tconX (sync interface) ****************************************************************************/ -NTSTATUS smb_tree_connect(struct cli_tree *tree, TALLOC_CTX *mem_ctx, union smb_tcon *parms) +NTSTATUS smb_tree_connect(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_tcon *parms) { - struct cli_request *req = smb_tree_connect_send(tree, parms); + struct smbcli_request *req = smb_tree_connect_send(tree, parms); return smb_tree_connect_recv(req, mem_ctx, parms); } @@ -154,35 +154,35 @@ NTSTATUS smb_tree_connect(struct cli_tree *tree, TALLOC_CTX *mem_ctx, union smb_ /**************************************************************************** Send a tree disconnect. ****************************************************************************/ -NTSTATUS smb_tree_disconnect(struct cli_tree *tree) +NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree) { - struct cli_request *req; + struct smbcli_request *req; if (!tree) return NT_STATUS_OK; - req = cli_request_setup(tree, SMBtdis, 0, 0); + req = smbcli_request_setup(tree, SMBtdis, 0, 0); - if (cli_request_send(req)) { - cli_request_receive(req); + if (smbcli_request_send(req)) { + smbcli_request_receive(req); } - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /* - a convenient function to establish a cli_tree from scratch, using reasonable default + a convenient function to establish a smbcli_tree from scratch, using reasonable default parameters */ -NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, +NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, const char *my_name, const char *dest_host, int port, const char *service, const char *service_type, const char *user, const char *domain, const char *password) { - struct cli_socket *sock; - struct cli_transport *transport; - struct cli_session *session; - struct cli_tree *tree; + struct smbcli_socket *sock; + struct smbcli_transport *transport; + struct smbcli_session *session; + struct smbcli_tree *tree; NTSTATUS status; struct nmb_name calling; struct nmb_name called; @@ -193,20 +193,20 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, *ret_tree = NULL; - sock = cli_sock_init(); + sock = smbcli_sock_init(); if (!sock) { return NT_STATUS_NO_MEMORY; } /* open a TCP socket to the server */ - if (!cli_sock_connect_byname(sock, dest_host, port)) { + if (!smbcli_sock_connect_byname(sock, dest_host, port)) { DEBUG(2,("Failed to establish socket connection - %s\n", strerror(errno))); return NT_STATUS_UNSUCCESSFUL; } - transport = cli_transport_init(sock); + transport = smbcli_transport_init(sock); if (!transport) { - cli_sock_close(sock); + smbcli_sock_close(sock); return NT_STATUS_NO_MEMORY; } @@ -214,8 +214,8 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, make_nmb_name(&calling, my_name, 0x0); make_nmb_name(&called, dest_host, 0x20); - if (!cli_transport_connect(transport, &calling, &called)) { - cli_transport_close(transport); + if (!smbcli_transport_connect(transport, &calling, &called)) { + smbcli_transport_close(transport); return NT_STATUS_UNSUCCESSFUL; } @@ -223,13 +223,13 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, /* negotiate protocol options with the server */ status = smb_raw_negotiate(transport); if (!NT_STATUS_IS_OK(status)) { - cli_transport_close(transport); + smbcli_transport_close(transport); return status; } - session = cli_session_init(transport); + session = smbcli_session_init(transport); if (!session) { - cli_transport_close(transport); + smbcli_transport_close(transport); return NT_STATUS_NO_MEMORY; } @@ -255,16 +255,16 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, status = smb_raw_session_setup(session, mem_ctx, &setup); if (!NT_STATUS_IS_OK(status)) { - cli_session_close(session); + smbcli_session_close(session); talloc_destroy(mem_ctx); return status; } session->vuid = setup.generic.out.vuid; - tree = cli_tree_init(session); + tree = smbcli_tree_init(session); if (!tree) { - cli_session_close(session); + smbcli_session_close(session); talloc_destroy(mem_ctx); return NT_STATUS_NO_MEMORY; } @@ -288,7 +288,7 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, SAFE_FREE(in_path); if (!NT_STATUS_IS_OK(status)) { - cli_tree_close(tree); + smbcli_tree_close(tree); talloc_destroy(mem_ctx); return status; } -- cgit From 1129c7808354dc04f7725be505fd23c0bf11a29d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 18 Aug 2004 20:13:08 +0000 Subject: r1897: added a choose_called_name() function that allows us to more sanely handle connections using the IP as the server name, while not trying for NBT name resolution on names like "192" and "192.168.1.2". also removed the ip address argument to smbcli_socket_connect() as it isn't used and doesn't really make sense. (This used to be commit 2ce4028842556328da4da0de9bee942bed02cc62) --- source4/libcli/raw/clitree.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index b9d572fd56..97c0910451 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -173,11 +173,11 @@ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree) parameters */ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, - const char *my_name, - const char *dest_host, int port, - const char *service, const char *service_type, - const char *user, const char *domain, - const char *password) + const char *my_name, + const char *dest_host, int port, + const char *service, const char *service_type, + const char *user, const char *domain, + const char *password) { struct smbcli_socket *sock; struct smbcli_transport *transport; @@ -212,7 +212,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, /* send a NBT session request, if applicable */ make_nmb_name(&calling, my_name, 0x0); - make_nmb_name(&called, dest_host, 0x20); + choose_called_name(&called, dest_host, 0x20); if (!smbcli_transport_connect(transport, &calling, &called)) { smbcli_transport_close(transport); -- cgit From b83ba93eaeb2dcb0bf11615591d886fda84e4162 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 21 Aug 2004 01:54:46 +0000 Subject: r1983: a completely new implementation of talloc This version does the following: 1) talloc_free(), talloc_realloc() and talloc_steal() lose their (redundent) first arguments 2) you can use _any_ talloc pointer as a talloc context to allocate more memory. This allows you to create complex data structures where the top level structure is the logical parent of the next level down, and those are the parents of the level below that. Then destroy either the lot with a single talloc_free() or destroy any sub-part with a talloc_free() of that part 3) you can name any pointer. Use talloc_named() which is just like talloc() but takes the printf style name argument as well as the parent context and the size. The whole thing ends up being a very simple piece of code, although some of the pointer walking gets hairy. So far, I'm just using the new talloc() like the old one. The next step is to actually take advantage of the new interface properly. Expect some new commits soon that simplify some common coding styles in samba4 by using the new talloc(). (This used to be commit e35bb094c52e550b3105dd1638d8d90de71d854f) --- source4/libcli/raw/clitree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 97c0910451..57e322da32 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -70,7 +70,7 @@ void smbcli_tree_close(struct smbcli_tree *tree) ****************************************************************************/ struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, union smb_tcon *parms) { - struct smbcli_request *req; + struct smbcli_request *req = NULL; switch (parms->tcon.level) { case RAW_TCON_TCON: -- cgit From b7e1ea20dc873a753ff64653987130f03897a4e9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 21 Aug 2004 07:43:29 +0000 Subject: r1985: take advantage of the new talloc in a few more places (This used to be commit 6ffdfd779936ce8c5ca49c5f444e8da2bbeee0a8) --- source4/libcli/raw/clitree.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 57e322da32..2d642a9a8c 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -33,18 +33,13 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session) { struct smbcli_tree *tree; - TALLOC_CTX *mem_ctx = talloc_init("smbcli_tree"); - if (mem_ctx == NULL) { - return NULL; - } - tree = talloc_zero(mem_ctx, sizeof(*tree)); + tree = talloc_named(NULL, sizeof(*tree), "smbcli_tree"); if (!tree) { - talloc_destroy(mem_ctx); return NULL; } - tree->mem_ctx = mem_ctx; + ZERO_STRUCTP(tree); tree->session = session; tree->session->reference_count++; @@ -60,7 +55,7 @@ void smbcli_tree_close(struct smbcli_tree *tree) tree->reference_count--; if (tree->reference_count <= 0) { smbcli_session_close(tree->session); - talloc_destroy(tree->mem_ctx); + talloc_free(tree); } } @@ -295,10 +290,10 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, tree->tid = tcon.tconx.out.cnum; if (tcon.tconx.out.dev_type) { - tree->device = talloc_strdup(tree->mem_ctx, tcon.tconx.out.dev_type); + tree->device = talloc_strdup(tree, tcon.tconx.out.dev_type); } if (tcon.tconx.out.fs_type) { - tree->fs_type = talloc_strdup(tree->mem_ctx, tcon.tconx.out.fs_type); + tree->fs_type = talloc_strdup(tree, tcon.tconx.out.fs_type); } talloc_destroy(mem_ctx); -- cgit From 8293df91bcec574fb4a2b290cc11dd83353264ae Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 8 Sep 2004 00:00:56 +0000 Subject: r2247: talloc_destroy -> talloc_free (This used to be commit 6c1a72c5d667245b1eec94f58e68acd22dd720ce) --- source4/libcli/raw/clitree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 2d642a9a8c..03a49708b3 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -251,7 +251,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, status = smb_raw_session_setup(session, mem_ctx, &setup); if (!NT_STATUS_IS_OK(status)) { smbcli_session_close(session); - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); return status; } @@ -260,7 +260,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, tree = smbcli_tree_init(session); if (!tree) { smbcli_session_close(session); - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); return NT_STATUS_NO_MEMORY; } @@ -284,7 +284,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, if (!NT_STATUS_IS_OK(status)) { smbcli_tree_close(tree); - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); return status; } @@ -296,7 +296,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, tree->fs_type = talloc_strdup(tree, tcon.tconx.out.fs_type); } - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); *ret_tree = tree; return NT_STATUS_OK; -- cgit From 3ea916b2278c202c99c80c02e80e588bd7daedb8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 26 Sep 2004 06:44:08 +0000 Subject: r2654: fixed some more server memory leaks. We are now down to a single leak of 16 bytes, caused by the 16 byte data_blob in the smb_signing code. (This used to be commit 2f1b788e09686e065d22f621f5c0c585192c6740) --- source4/libcli/raw/clitree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 03a49708b3..c383eef768 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -34,7 +34,7 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session) { struct smbcli_tree *tree; - tree = talloc_named(NULL, sizeof(*tree), "smbcli_tree"); + tree = talloc_p(session, struct smbcli_tree); if (!tree) { return NULL; } -- cgit From 954869efdb8b0006fd4457a1c6d56a31c3825421 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 26 Sep 2004 07:04:35 +0000 Subject: r2655: fixed an error in the shutdown of the sock->transport->session->tree smbcli raw context handling (This used to be commit d5fd6388751944f11c34e5124d403d57c8670e3b) --- source4/libcli/raw/clitree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index c383eef768..e3a1a6d341 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -55,7 +55,6 @@ void smbcli_tree_close(struct smbcli_tree *tree) tree->reference_count--; if (tree->reference_count <= 0) { smbcli_session_close(tree->session); - talloc_free(tree); } } @@ -193,6 +192,8 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, return NT_STATUS_NO_MEMORY; } + talloc_set_name_const(sock, "smbcli_tree_full_connection"); + /* open a TCP socket to the server */ if (!smbcli_sock_connect_byname(sock, dest_host, port)) { DEBUG(2,("Failed to establish socket connection - %s\n", strerror(errno))); -- cgit From e3880fa759cfa03222262327854fe7bbe585fe01 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 26 Sep 2004 11:30:20 +0000 Subject: r2660: - converted the libcli/raw/ library to use talloc_increase_ref_count() rather than manual reference counts - properly support SMBexit in the cifs and posix backends - added a logoff method to all backends With these changes the RAW-CONTEXT test now passes against the posix backend (This used to be commit c315d6ac1cc40546fde1474702a6d66d07ee13c8) --- source4/libcli/raw/clitree.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index e3a1a6d341..e0072a31b1 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -26,6 +26,15 @@ if (!req) return NULL; \ } while (0) +/* + destroy a smbcli_tree +*/ +static int tree_destructor(void *ptr) +{ + struct smbcli_tree *tree = ptr; + talloc_free(tree->session); + return 0; +} /**************************************************************************** Initialize the tree context @@ -41,24 +50,11 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session) ZERO_STRUCTP(tree); tree->session = session; - tree->session->reference_count++; + talloc_set_destructor(tree, tree_destructor); return tree; } -/**************************************************************************** -reduce reference count on a tree and destroy if <= 0 -****************************************************************************/ -void smbcli_tree_close(struct smbcli_tree *tree) -{ - if (!tree) return; - tree->reference_count--; - if (tree->reference_count <= 0) { - smbcli_session_close(tree->session); - } -} - - /**************************************************************************** Send a tconX (async send) ****************************************************************************/ @@ -202,7 +198,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, transport = smbcli_transport_init(sock); if (!transport) { - smbcli_sock_close(sock); + talloc_free(sock); return NT_STATUS_NO_MEMORY; } @@ -211,7 +207,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, choose_called_name(&called, dest_host, 0x20); if (!smbcli_transport_connect(transport, &calling, &called)) { - smbcli_transport_close(transport); + talloc_free(transport); return NT_STATUS_UNSUCCESSFUL; } @@ -219,13 +215,13 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, /* negotiate protocol options with the server */ status = smb_raw_negotiate(transport); if (!NT_STATUS_IS_OK(status)) { - smbcli_transport_close(transport); + talloc_free(transport); return status; } session = smbcli_session_init(transport); if (!session) { - smbcli_transport_close(transport); + talloc_free(transport); return NT_STATUS_NO_MEMORY; } @@ -251,7 +247,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, status = smb_raw_session_setup(session, mem_ctx, &setup); if (!NT_STATUS_IS_OK(status)) { - smbcli_session_close(session); + talloc_free(session); talloc_free(mem_ctx); return status; } @@ -260,7 +256,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, tree = smbcli_tree_init(session); if (!tree) { - smbcli_session_close(session); + talloc_free(session); talloc_free(mem_ctx); return NT_STATUS_NO_MEMORY; } @@ -284,7 +280,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, SAFE_FREE(in_path); if (!NT_STATUS_IS_OK(status)) { - smbcli_tree_close(tree); + talloc_free(tree); talloc_free(mem_ctx); return status; } -- cgit From aa12305945df5f1578250b56ae2f3653b051736f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Sep 2004 08:41:39 +0000 Subject: r2680: switched the libcli/raw/ code over to use talloc_reference(), which simplifies things quite a bit (This used to be commit c82a9cf750829c4f6982ca3133295c8599023c4e) --- source4/libcli/raw/clitree.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index e0072a31b1..f19cbf8e28 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -26,16 +26,6 @@ if (!req) return NULL; \ } while (0) -/* - destroy a smbcli_tree -*/ -static int tree_destructor(void *ptr) -{ - struct smbcli_tree *tree = ptr; - talloc_free(tree->session); - return 0; -} - /**************************************************************************** Initialize the tree context ****************************************************************************/ @@ -49,8 +39,7 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session) } ZERO_STRUCTP(tree); - tree->session = session; - talloc_set_destructor(tree, tree_destructor); + tree->session = talloc_reference(tree, session); return tree; } @@ -188,17 +177,16 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, return NT_STATUS_NO_MEMORY; } - talloc_set_name_const(sock, "smbcli_tree_full_connection"); - /* open a TCP socket to the server */ if (!smbcli_sock_connect_byname(sock, dest_host, port)) { + talloc_free(sock); DEBUG(2,("Failed to establish socket connection - %s\n", strerror(errno))); return NT_STATUS_UNSUCCESSFUL; } transport = smbcli_transport_init(sock); + talloc_free(sock); if (!transport) { - talloc_free(sock); return NT_STATUS_NO_MEMORY; } @@ -220,8 +208,8 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, } session = smbcli_session_init(transport); + talloc_free(transport); if (!session) { - talloc_free(transport); return NT_STATUS_NO_MEMORY; } @@ -255,8 +243,8 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, session->vuid = setup.generic.out.vuid; tree = smbcli_tree_init(session); + talloc_free(session); if (!tree) { - talloc_free(session); talloc_free(mem_ctx); return NT_STATUS_NO_MEMORY; } -- cgit From b2f1a29e4348a5bc34a87d72d526e23e421ed9d5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 28 Sep 2004 05:44:59 +0000 Subject: r2710: continue with the new style of providing a parent context whenever possible to a structure creation routine. This makes for much easier global cleanup. (This used to be commit e14ee428ec357fab76a960387a9820a673786e27) --- source4/libcli/raw/clitree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index f19cbf8e28..77fe0ebe2f 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -151,7 +151,8 @@ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree) a convenient function to establish a smbcli_tree from scratch, using reasonable default parameters */ -NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, +NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, + struct smbcli_tree **ret_tree, const char *my_name, const char *dest_host, int port, const char *service, const char *service_type, @@ -172,7 +173,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, *ret_tree = NULL; - sock = smbcli_sock_init(); + sock = smbcli_sock_init(parent_ctx); if (!sock) { return NT_STATUS_NO_MEMORY; } -- cgit From 9f1210a243654fd6d94acdef83f468a33c1b3b3f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 Nov 2004 01:03:22 +0000 Subject: r3419: moved the libcli/raw structures into libcli/raw/libcliraw.h and made them private (This used to be commit 386ac565c452ede1d74e06acb401ca9db99d3ff3) --- source4/libcli/raw/clitree.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 77fe0ebe2f..daa8549099 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "libcli/raw/libcliraw.h" #define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \ req = smbcli_request_setup(tree, cmd, wct, buflen); \ -- cgit From 9112a632f6791ffc3c3c1aadd214cbaba8fe816e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 4 Dec 2004 13:56:25 +0000 Subject: r4063: - change char * -> uint8_t in struct request_buffer - change smbcli_read/write to take void * for the buffers to match read(2)/write(2) all this fixes a lot of gcc-4 warnings metze (This used to be commit b94f92bc6637f748d6f7049f4f9a30b0b8d18a7a) --- source4/libcli/raw/clitree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index daa8549099..b9d0ffbc1f 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -85,7 +85,7 @@ struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, union smb ****************************************************************************/ NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_tcon *parms) { - char *p; + uint8_t *p; if (!smbcli_request_receive(req) || smbcli_request_is_error(req)) { -- cgit From 90b299603f7a8bc03617ae08d2fd7063d249bd24 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 24 Dec 2004 09:57:44 +0000 Subject: r4356: Allow anonymous connections to use NTLMSSP. The silly bugs that prevented this are gone. Andrew Bartlett (This used to be commit 87dad5ec538abad93d621078a82f162675847f9f) --- source4/libcli/raw/clitree.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index b9d0ffbc1f..777279f5f9 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -223,7 +223,6 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, setup.generic.in.password = NULL; setup.generic.in.user = ""; setup.generic.in.domain = ""; - setup.generic.in.capabilities &= ~CAP_EXTENDED_SECURITY; } else { setup.generic.in.password = password; setup.generic.in.user = user; -- cgit From 592fce7fb149ca5e82b14d9c8f13a4da1babe2b7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 13 Jan 2005 18:49:10 +0000 Subject: r4726: - use the name tcon and tid instead of conn and cnum - make use of talloc destructors metze (This used to be commit 8308da6ce4a95f8c10e22949ef00e9e64f2dbb85) --- source4/libcli/raw/clitree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 777279f5f9..0f56c0fe2e 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -96,12 +96,12 @@ NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, case RAW_TCON_TCON: SMBCLI_CHECK_WCT(req, 2); parms->tcon.out.max_xmit = SVAL(req->in.vwv, VWV(0)); - parms->tcon.out.cnum = SVAL(req->in.vwv, VWV(1)); + parms->tcon.out.tid = SVAL(req->in.vwv, VWV(1)); break; case RAW_TCON_TCONX: ZERO_STRUCT(parms->tconx.out); - parms->tconx.out.cnum = SVAL(req->in.hdr, HDR_TID); + parms->tconx.out.tid = SVAL(req->in.hdr, HDR_TID); if (req->in.wct >= 4) { parms->tconx.out.options = SVAL(req->in.vwv, VWV(3)); } @@ -274,7 +274,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, return status; } - tree->tid = tcon.tconx.out.cnum; + tree->tid = tcon.tconx.out.tid; if (tcon.tconx.out.dev_type) { tree->device = talloc_strdup(tree, tcon.tconx.out.dev_type); } -- cgit From 61a3d370b98ca4b75cd61e22f0d6b0f3fb7561b3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 15 Jan 2005 11:58:52 +0000 Subject: r4758: - added async support to the session request code - added async support to the negprot client code - removed two unused parameters from smbcli_full_connection() code - converted smbclient to use smbcli_full_connection() rather than reinventing everything itself (This used to be commit 71cbe2873473e039b4511511302cb63f1c50bce8) --- source4/libcli/raw/clitree.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 0f56c0fe2e..cc7fefd084 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -34,12 +34,11 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session) { struct smbcli_tree *tree; - tree = talloc_p(session, struct smbcli_tree); + tree = talloc_zero(session, struct smbcli_tree); if (!tree) { return NULL; } - ZERO_STRUCTP(tree); tree->session = talloc_reference(tree, session); return tree; @@ -48,7 +47,8 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session) /**************************************************************************** Send a tconX (async send) ****************************************************************************/ -struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, union smb_tcon *parms) +struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, + union smb_tcon *parms) { struct smbcli_request *req = NULL; @@ -83,7 +83,8 @@ struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, union smb /**************************************************************************** Send a tconX (async recv) ****************************************************************************/ -NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_tcon *parms) +NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, + union smb_tcon *parms) { uint8_t *p; @@ -124,7 +125,8 @@ failed: /**************************************************************************** Send a tconX (sync interface) ****************************************************************************/ -NTSTATUS smb_tree_connect(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_tcon *parms) +NTSTATUS smb_tree_connect(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, + union smb_tcon *parms) { struct smbcli_request *req = smb_tree_connect_send(tree, parms); return smb_tree_connect_recv(req, mem_ctx, parms); @@ -203,7 +205,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, /* negotiate protocol options with the server */ - status = smb_raw_negotiate(transport); + status = smb_raw_negotiate(transport, lp_maxprotocol()); if (!NT_STATUS_IS_OK(status)) { talloc_free(transport); return status; -- cgit From 1e776edfc546f01341f153daa80e4155e5ff9855 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Jan 2005 01:28:11 +0000 Subject: r4769: added a smb_composite_connect() function that provides a simple async interface to a complete SMB connection setup. Internally it does: - socket connection - session request (if needed) - negprot - session setup - tcon This is the first example of a composite function that builds on other composite components (the socket connection is a composite function, which is used as a building block for this function). I think this will be quite common in composite functions in the future, building up ever more complex composite functions from smaller building blocks, while hiding the details from the caller. There are two things missing from this now. The first is async name resolution routines (wins, bcast, DNS etc), and the second is that this code currently only does a NT1 style session setup. I'll work on adding spnego and old style session setup support next. (This used to be commit 6bc9e17f5c5236f662c7c8f308d03e6d97379b23) --- source4/libcli/raw/clitree.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index cc7fefd084..7339ca07f1 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -21,6 +21,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" +#include "libcli/composite/composite.h" #define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \ req = smbcli_request_setup(tree, cmd, wct, buflen); \ @@ -289,3 +290,36 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, *ret_tree = tree; return NT_STATUS_OK; } + + +/* + a convenient function to establish a smbcli_tree from scratch +*/ +NTSTATUS async_smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, + struct smbcli_tree **ret_tree, + const char *my_name, + const char *dest_host, int port, + const char *service, const char *service_type, + const char *user, const char *domain, + const char *password) +{ + struct smb_composite_connect io; + NTSTATUS status; + + io.in.dest_host = dest_host; + io.in.port = port; + io.in.called_name = dest_host; + io.in.calling_name = my_name; + io.in.service = service; + io.in.service_type = service_type; + io.in.user = user; + io.in.domain = domain; + io.in.password = password; + + status = smb_composite_connect(&io, parent_ctx); + if (NT_STATUS_IS_OK(status)) { + *ret_tree = io.out.tree; + } + + return status; +} -- cgit From 7cbc768376ed0a839afca64aeea99cd53d0fbc6f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Jan 2005 11:15:08 +0000 Subject: r4777: added a smb_composite_sesssetup() async composite function. This encapsulates all the different session setup methods, including the multi-pass spnego code. I have hooked this into all the places that previously used the RAW_SESSSETUP_GENERIC method, and have removed the old RAW_SESSSETUP_GENERIC code from clisession.c and clitree.c. A nice side effect is that these two modules are now very simple again, back to being "raw" session setup handling, which was what was originally intended. I have also used this to replace the session setup code in the smb_composite_connect() code, and used that to build a very simple replacement for smbcli_tree_full_connection(). As a result, smbclient, smbtorture and all our other SMB connection code now goes via these composite async functions. That should give them a good workout! (This used to be commit 080d0518bc7d6fd4bc3ef783e7d4d2e3275d0799) --- source4/libcli/raw/clitree.c | 147 ++----------------------------------------- 1 file changed, 4 insertions(+), 143 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 7339ca07f1..c6b3fa5ad9 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -1,7 +1,9 @@ /* Unix SMB/CIFS implementation. + SMB client tree context management functions - Copyright (C) Andrew Tridgell 1994-1998 + + Copyright (C) Andrew Tridgell 1994-2005 Copyright (C) James Myers 2003 This program is free software; you can redistribute it and/or modify @@ -152,8 +154,7 @@ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree) /* - a convenient function to establish a smbcli_tree from scratch, using reasonable default - parameters + a convenient function to establish a smbcli_tree from scratch */ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, struct smbcli_tree **ret_tree, @@ -162,146 +163,6 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, const char *service, const char *service_type, const char *user, const char *domain, const char *password) -{ - struct smbcli_socket *sock; - struct smbcli_transport *transport; - struct smbcli_session *session; - struct smbcli_tree *tree; - NTSTATUS status; - struct nmb_name calling; - struct nmb_name called; - union smb_sesssetup setup; - union smb_tcon tcon; - TALLOC_CTX *mem_ctx; - char *in_path = NULL; - - *ret_tree = NULL; - - sock = smbcli_sock_init(parent_ctx); - if (!sock) { - return NT_STATUS_NO_MEMORY; - } - - /* open a TCP socket to the server */ - if (!smbcli_sock_connect_byname(sock, dest_host, port)) { - talloc_free(sock); - DEBUG(2,("Failed to establish socket connection - %s\n", strerror(errno))); - return NT_STATUS_UNSUCCESSFUL; - } - - transport = smbcli_transport_init(sock); - talloc_free(sock); - if (!transport) { - return NT_STATUS_NO_MEMORY; - } - - /* send a NBT session request, if applicable */ - make_nmb_name(&calling, my_name, 0x0); - choose_called_name(&called, dest_host, 0x20); - - if (!smbcli_transport_connect(transport, &calling, &called)) { - talloc_free(transport); - return NT_STATUS_UNSUCCESSFUL; - } - - - /* negotiate protocol options with the server */ - status = smb_raw_negotiate(transport, lp_maxprotocol()); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(transport); - return status; - } - - session = smbcli_session_init(transport); - talloc_free(transport); - if (!session) { - return NT_STATUS_NO_MEMORY; - } - - /* prepare a session setup to establish a security context */ - setup.generic.level = RAW_SESSSETUP_GENERIC; - setup.generic.in.sesskey = transport->negotiate.sesskey; - setup.generic.in.capabilities = transport->negotiate.capabilities; - if (!user || !user[0]) { - setup.generic.in.password = NULL; - setup.generic.in.user = ""; - setup.generic.in.domain = ""; - } else { - setup.generic.in.password = password; - setup.generic.in.user = user; - setup.generic.in.domain = domain; - } - - mem_ctx = talloc_init("tcon"); - if (!mem_ctx) { - return NT_STATUS_NO_MEMORY; - } - - status = smb_raw_session_setup(session, mem_ctx, &setup); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(session); - talloc_free(mem_ctx); - return status; - } - - session->vuid = setup.generic.out.vuid; - - tree = smbcli_tree_init(session); - talloc_free(session); - if (!tree) { - talloc_free(mem_ctx); - return NT_STATUS_NO_MEMORY; - } - - /* connect to a share using a tree connect */ - tcon.generic.level = RAW_TCON_TCONX; - tcon.tconx.in.flags = 0; - tcon.tconx.in.password = data_blob(NULL, 0); - asprintf(&in_path, "\\\\%s\\%s", dest_host, service); - tcon.tconx.in.path = in_path; - if (!service_type) { - if (strequal(service, "IPC$")) - service_type = "IPC"; - else - service_type = "?????"; - } - tcon.tconx.in.device = service_type; - - status = smb_tree_connect(tree, mem_ctx, &tcon); - - SAFE_FREE(in_path); - - if (!NT_STATUS_IS_OK(status)) { - talloc_free(tree); - talloc_free(mem_ctx); - return status; - } - - tree->tid = tcon.tconx.out.tid; - if (tcon.tconx.out.dev_type) { - tree->device = talloc_strdup(tree, tcon.tconx.out.dev_type); - } - if (tcon.tconx.out.fs_type) { - tree->fs_type = talloc_strdup(tree, tcon.tconx.out.fs_type); - } - - talloc_free(mem_ctx); - - *ret_tree = tree; - return NT_STATUS_OK; -} - - -/* - a convenient function to establish a smbcli_tree from scratch -*/ -NTSTATUS async_smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, - struct smbcli_tree **ret_tree, - const char *my_name, - const char *dest_host, int port, - const char *service, const char *service_type, - const char *user, const char *domain, - const char *password) { struct smb_composite_connect io; NTSTATUS status; -- cgit From c06493912b9a8bb39a3d3459b9597daaa5d1c065 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Jan 2005 22:53:00 +0000 Subject: r4810: fixed anonymous connections with smbclient. Thanks to jbm for pointing this out. (This used to be commit 7da0af98a0e0bc743d3c64be30b37cbc45e00737) --- source4/libcli/raw/clitree.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index c6b3fa5ad9..06963d5bc4 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -173,9 +173,13 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.calling_name = my_name; io.in.service = service; io.in.service_type = service_type; - io.in.user = user; io.in.domain = domain; - io.in.password = password; + io.in.user = user; + if (user && user[0]) { + io.in.password = password; + } else { + io.in.password = NULL; + } status = smb_composite_connect(&io, parent_ctx); if (NT_STATUS_IS_OK(status)) { -- cgit From 3e44c4a3ba6acd7d9bc997c012d1863377e9d873 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 24 Jan 2005 00:57:14 +0000 Subject: r4951: some of the code dealing with libcli was getting too complex trying to handle the inverted memory hierarchy that a normal session establishment gave. The inverted hierarchy came from that fact that you first establish a socket, then a transport, then a session and finally a tree. That leads to the socket being at the top of the memory hierarchy and the tree at the bottom, which makes no sense from the users point of view, as they want to be able to free the tree and have everything disappear. The core problem was that the libcli interface didn't distinguish between establishing a primary context and a secondary context. If you establish a 2nd session on a transport then you want the transport to be referenced by the session, whereas if you establish a primary session then you want the transport to be a child of the session. To fix this I have added "parent_ctx" and "primary" arguments to the libcli intialisation functions. This makes using the library much easier, and gives us a memory hierarchy that makes much more sense. I was prompted to do this by a bug in the cifs backend, which was caused by the socket not being properly torn down on a disconnect due to the inverted memory hierarchy. (This used to be commit 5e8fd5f70178992e249805c2e1ddafaf6840739b) --- source4/libcli/raw/clitree.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 06963d5bc4..ce4dafca9f 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -33,16 +33,22 @@ /**************************************************************************** Initialize the tree context ****************************************************************************/ -struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session) +struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session, + TALLOC_CTX *parent_ctx, BOOL primary) { struct smbcli_tree *tree; - tree = talloc_zero(session, struct smbcli_tree); + tree = talloc_zero(parent_ctx, struct smbcli_tree); if (!tree) { return NULL; } - tree->session = talloc_reference(tree, session); + if (primary) { + tree->session = talloc_steal(tree, session); + } else { + tree->session = talloc_reference(tree, session); + } + return tree; } -- cgit From d8da32a2845b99cc4272fedd28dff570331be63e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 13 Feb 2005 09:10:33 +0000 Subject: r5371: on port 139 the called name needs to be in uppercase (This used to be commit c5aef260c4581bfc0d32ec09fac3414156c40230) --- source4/libcli/raw/clitree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index ce4dafca9f..74db1c6952 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -175,8 +175,8 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.dest_host = dest_host; io.in.port = port; - io.in.called_name = dest_host; - io.in.calling_name = my_name; + io.in.called_name = strupper_talloc(parent_ctx, dest_host); + io.in.calling_name = strupper_talloc(parent_ctx, my_name); io.in.service = service; io.in.service_type = service_type; io.in.domain = domain; -- cgit From 13b0776f60f6a0f35a4afc2b3d3c6b5ec9c1ca6a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 23:35:58 +0000 Subject: r5929: Use cli_credentials for the SMB functions as well. Fix a couple of bugs in the new cli_credentials code (This used to be commit 4ad481cfe5cde514d2ef9646147239f3faaa6173) --- source4/libcli/raw/clitree.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 74db1c6952..0559c64dc1 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -167,8 +167,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, const char *my_name, const char *dest_host, int port, const char *service, const char *service_type, - const char *user, const char *domain, - const char *password) + struct cli_credentials *credentials) { struct smb_composite_connect io; NTSTATUS status; @@ -179,10 +178,10 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.calling_name = strupper_talloc(parent_ctx, my_name); io.in.service = service; io.in.service_type = service_type; - io.in.domain = domain; - io.in.user = user; - if (user && user[0]) { - io.in.password = password; + io.in.domain = cli_credentials_get_domain(credentials); + io.in.user = cli_credentials_get_username(credentials); + if (!cli_credentials_is_anonymous(credentials)) { + io.in.password = cli_credentials_get_password(credentials); } else { io.in.password = NULL; } -- cgit From 645711c602313940dcf80ec786557920ecfbf884 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 22 Mar 2005 08:00:45 +0000 Subject: r5941: Commit this patch much earlier than I would normally prefer, but metze needs a working tree... The main volume of this patch was what I started working on today: - Cleans up memory handling around DCE/RPC pipes, to have a parent talloc context. - Uses sepereate inner loops for some of the DCE/RPC tests The other and more important part of this patch fixes issues surrounding the new credentials framwork: This makes the struct cli_credentials always a talloc() structure, rather than on the stack. Parts of the cli_credentials code already assumed this. There were other issues, particularly in the DCERPC over SMB handling, as well as little things that had to be tidied up before test_w2k3.sh would start to pass. Andrew Bartlett (This used to be commit 0453f9d05d2e336fba1f85dbf2718d01fa2bf778) --- source4/libcli/raw/clitree.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 0559c64dc1..f333cf7a98 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -167,7 +167,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, const char *my_name, const char *dest_host, int port, const char *service, const char *service_type, - struct cli_credentials *credentials) + struct cli_credentials *credentials) { struct smb_composite_connect io; NTSTATUS status; @@ -180,11 +180,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.service_type = service_type; io.in.domain = cli_credentials_get_domain(credentials); io.in.user = cli_credentials_get_username(credentials); - if (!cli_credentials_is_anonymous(credentials)) { - io.in.password = cli_credentials_get_password(credentials); - } else { - io.in.password = NULL; - } + io.in.password = cli_credentials_get_password(credentials); status = smb_composite_connect(&io, parent_ctx); if (NT_STATUS_IS_OK(status)) { -- cgit From 2eb3d680625286431a3a60e37b75f47e0738f253 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 24 Mar 2005 04:14:06 +0000 Subject: r6028: A MAJOR update to intergrate the new credentails system fully with GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'. GENSEC now no longer has it's own handling of 'set username' etc, instead it uses cli_credentials calls. In order to link the credentails code right though Samba, a lot of interfaces have changed to remove 'username, domain, password' arguments, and these have been replaced with a single 'struct cli_credentials'. In the session setup code, a new parameter 'workgroup' contains the client/server current workgroup, which seems unrelated to the authentication exchange (it was being filled in from the auth info). This allows in particular kerberos to only call back for passwords when it actually needs to perform the kinit. The kerberos code has been modified not to use the SPNEGO provided 'principal name' (in the mechListMIC), but to instead use the name the host was connected to as. This better matches Microsoft behaviour, is more secure and allows better use of standard kerberos functions. To achieve this, I made changes to our socket code so that the hostname (before name resolution) is now recorded on the socket. In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now in libcli/auth/schannel.c, and it looks much more like a standard GENSEC module. The actual sign/seal code moved to libcli/auth/schannel_sign.c in a previous commit. The schannel credentails structure is now merged with the rest of the credentails, as many of the values (username, workstation, domain) where already present there. This makes handling this in a generic manner much easier, as there is no longer a custom entry-point. The auth_domain module continues to be developed, but is now just as functional as auth_winbind. The changes here are consequential to the schannel changes. The only removed function at this point is the RPC-LOGIN test (simulating the load of a WinXP login), which needs much more work to clean it up (it contains copies of too much code from all over the torture suite, and I havn't been able to penetrate its 'structure'). Andrew Bartlett (This used to be commit 2301a4b38a21aa60917973451687063d83d18d66) --- source4/libcli/raw/clitree.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index f333cf7a98..87c2dbba7c 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -164,7 +164,6 @@ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree) */ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, struct smbcli_tree **ret_tree, - const char *my_name, const char *dest_host, int port, const char *service, const char *service_type, struct cli_credentials *credentials) @@ -175,12 +174,10 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.dest_host = dest_host; io.in.port = port; io.in.called_name = strupper_talloc(parent_ctx, dest_host); - io.in.calling_name = strupper_talloc(parent_ctx, my_name); io.in.service = service; io.in.service_type = service_type; - io.in.domain = cli_credentials_get_domain(credentials); - io.in.user = cli_credentials_get_username(credentials); - io.in.password = cli_credentials_get_password(credentials); + io.in.credentials = credentials; + io.in.workgroup = lp_workgroup(); status = smb_composite_connect(&io, parent_ctx); if (NT_STATUS_IS_OK(status)) { -- cgit From af237084ecd4f9928c6c282b9c5c73598d5c73d6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 16 Jun 2005 11:36:09 +0000 Subject: r7633: this patch started as an attempt to make the dcerpc code use a given event_context for the socket_connect() call, so that when things that use dcerpc are running alongside anything else it doesn't block the whole process during a connect. Then of course I needed to change any code that created a dcerpc connection (such as the auth code) to also take an event context, and anything that called that and so on .... thus the size of the patch. There were 3 places where I punted: - abartlet wanted me to add a gensec_set_event_context() call instead of adding it to the gensec init calls. Andrew, my apologies for not doing this. I didn't do it as adding a new parameter allowed me to catch all the callers with the compiler. Now that its done, we could go back and use gensec_set_event_context() - the ejs code calls auth initialisation, which means it should pass in the event context from the web server. I punted on that. Needs fixing. - I used a NULL event context in dcom_get_pipe(). This is equivalent to what we did already, but should be fixed to use a callers event context. Jelmer, can you think of a clean way to do that? I also cleaned up a couple of things: - libnet_context_destroy() makes no sense. I removed it. - removed some unused vars in various places (This used to be commit 3a3025485bdb8f600ab528c0b4b4eef0c65e3fc9) --- source4/libcli/raw/clitree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 87c2dbba7c..76cb1a43fe 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -166,7 +166,8 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, struct smbcli_tree **ret_tree, const char *dest_host, int port, const char *service, const char *service_type, - struct cli_credentials *credentials) + struct cli_credentials *credentials, + struct event_context *ev) { struct smb_composite_connect io; NTSTATUS status; @@ -179,7 +180,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.credentials = credentials; io.in.workgroup = lp_workgroup(); - status = smb_composite_connect(&io, parent_ctx); + status = smb_composite_connect(&io, parent_ctx, ev); if (NT_STATUS_IS_OK(status)) { *ret_tree = io.out.tree; } -- cgit From 2fa50ab671ba4a7e552e001f0dfde3a7cc330f8e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 9 Aug 2005 03:09:47 +0000 Subject: r9222: Rename smb_tree_connect() to smb_raw_tcon() to match other raw function names. (This used to be commit 26b191b3c9529b2dae5d004819dab46657064408) --- source4/libcli/raw/clitree.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 76cb1a43fe..25f346ef5d 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -56,8 +56,8 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session, /**************************************************************************** Send a tconX (async send) ****************************************************************************/ -struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, - union smb_tcon *parms) +struct smbcli_request *smb_raw_tcon_send(struct smbcli_tree *tree, + union smb_tcon *parms) { struct smbcli_request *req = NULL; @@ -92,8 +92,8 @@ struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, /**************************************************************************** Send a tconX (async recv) ****************************************************************************/ -NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, - union smb_tcon *parms) +NTSTATUS smb_raw_tcon_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, + union smb_tcon *parms) { uint8_t *p; @@ -134,11 +134,11 @@ failed: /**************************************************************************** Send a tconX (sync interface) ****************************************************************************/ -NTSTATUS smb_tree_connect(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, - union smb_tcon *parms) +NTSTATUS smb_raw_tcon(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, + union smb_tcon *parms) { - struct smbcli_request *req = smb_tree_connect_send(tree, parms); - return smb_tree_connect_recv(req, mem_ctx, parms); + struct smbcli_request *req = smb_raw_tcon_send(tree, parms); + return smb_raw_tcon_recv(req, mem_ctx, parms); } -- cgit From 294f0aaf9ca61a72ed33b8f0b999f6871005da73 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Mon, 22 Aug 2005 16:02:11 +0000 Subject: r9479: More fixes for explicit ignoring of returned result to fix Coverity warnings (This used to be commit 4f9f4312e98cce7589fc8e094d08e76cc697ab3d) --- source4/libcli/raw/clitree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 25f346ef5d..74e14db591 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -153,7 +153,7 @@ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree) req = smbcli_request_setup(tree, SMBtdis, 0, 0); if (smbcli_request_send(req)) { - smbcli_request_receive(req); + (void) smbcli_request_receive(req); } return smbcli_request_destroy(req); } -- cgit From ab4d635b92b116b02b88843b4ec4f5b7517bab1a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 26 Sep 2005 11:47:55 +0000 Subject: r10504: - seperate implementation specific stuff, from the generic composite stuff. - don't use SMBCLI_REQUEST_* state's in the genreic composite stuff - move monitor_fn to libnet. NOTE: I have maybe found some bugs, in code that is dirrectly in DONE or ERROR state in the _send() function. I haven't fixed this bugs in this commit! We may need some composite_trigger_*() functions or so. And maybe some other generic helper functions... metze (This used to be commit 4527815a0a9b96e460f301cb1f0c0b3964c166fc) --- source4/libcli/raw/clitree.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 74e14db591..cae93bdbe2 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -24,6 +24,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.h" +#include "libcli/smb_composite/smb_composite.h" #define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \ req = smbcli_request_setup(tree, cmd, wct, buflen); \ -- cgit From d617556ef50863d6a03c81a04f0f6b05848a250e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 10 Oct 2005 19:57:55 +0000 Subject: r10878: Reply to some comments by tridge and metze: * rename the composite helper functions from comp_* to composite_* * Move the lsa initialization to wb_connect_lsa.c * Equip smb_composite_connect with a fallback_to_anonymous The latter two simplify wb_init_domain.c quite a bit. Volker (This used to be commit deb127e04ea01ae93394da5ebffb39d81caeb6d9) --- source4/libcli/raw/clitree.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index cae93bdbe2..990552d64f 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -179,6 +179,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.service = service; io.in.service_type = service_type; io.in.credentials = credentials; + io.in.fallback_to_anonymous = False; io.in.workgroup = lp_workgroup(); status = smb_composite_connect(&io, parent_ctx, ev); -- cgit From 827cbb480c6de7471554c97cb4cef13e5db7b2b3 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 2 Nov 2005 03:08:52 +0000 Subject: r11466: Clear up some memory leaks in smbclient. Andrew Bartlett (This used to be commit 6535959fd7dfddd6bafb77a266ec3a641025f880) --- source4/libcli/raw/clitree.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 990552d64f..96d36c569c 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -172,10 +172,14 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, { struct smb_composite_connect io; NTSTATUS status; + TALLOC_CTX *tmp_ctx = talloc_new(parent_ctx); + if (!tmp_ctx) { + return NT_STATUS_NO_MEMORY; + } io.in.dest_host = dest_host; io.in.port = port; - io.in.called_name = strupper_talloc(parent_ctx, dest_host); + io.in.called_name = strupper_talloc(tmp_ctx, dest_host); io.in.service = service; io.in.service_type = service_type; io.in.credentials = credentials; @@ -186,6 +190,6 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, if (NT_STATUS_IS_OK(status)) { *ret_tree = io.out.tree; } - + talloc_free(tmp_ctx); return status; } -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/libcli/raw/clitree.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 96d36c569c..6e120ed615 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -23,7 +23,6 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" -#include "libcli/composite/composite.h" #include "libcli/smb_composite/smb_composite.h" #define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \ -- cgit From e306c5bf129a981693bd251d45597f1e584ee850 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 10:46:38 +0000 Subject: r15741: move smb2 request structures into the main smb request structs as new levels metze (This used to be commit 91806353174704857dfcc15a730af7232cfde660) --- source4/libcli/raw/clitree.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 6e120ed615..51f2e12457 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -79,6 +79,9 @@ struct smbcli_request *smb_raw_tcon_send(struct smbcli_tree *tree, smbcli_req_append_string(req, parms->tconx.in.path, STR_TERMINATE | STR_UPPER); smbcli_req_append_string(req, parms->tconx.in.device, STR_TERMINATE | STR_ASCII); break; + + case RAW_TCON_SMB2: + return NULL; } if (!smbcli_request_send(req)) { @@ -125,6 +128,10 @@ NTSTATUS smb_raw_tcon_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.fs_type, p, -1, STR_TERMINATE); break; + + case RAW_TCON_SMB2: + req->status = NT_STATUS_INTERNAL_ERROR; + break; } failed: -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/libcli/raw/clitree.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 51f2e12457..a5217d74b2 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -8,7 +8,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -17,8 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From ffeee68e4b72dd94fee57366bd8d38b8c284c3d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 12:42:09 +0000 Subject: r25026: Move param/param.h out of includes.h (This used to be commit abe8349f9b4387961ff3665d8c589d61cd2edf31) --- source4/libcli/raw/clitree.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index a5217d74b2..6a15c25eb9 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -23,6 +23,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" #include "libcli/smb_composite/smb_composite.h" +#include "param/param.h" #define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \ req = smbcli_request_setup(tree, cmd, wct, buflen); \ -- cgit From 37d53832a4623653f706e77985a79d84bd7c6694 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Sep 2007 01:17:46 +0000 Subject: r25398: Parse loadparm context to all lp_*() functions. (This used to be commit 3fcc960839c6e5ca4de2c3c042f12f369ac5f238) --- source4/libcli/raw/clitree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 6a15c25eb9..4ff11f3a69 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -190,7 +190,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.service_type = service_type; io.in.credentials = credentials; io.in.fallback_to_anonymous = False; - io.in.workgroup = lp_workgroup(); + io.in.workgroup = lp_workgroup(global_loadparm); status = smb_composite_connect(&io, parent_ctx, ev); if (NT_STATUS_IS_OK(status)) { -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/libcli/raw/clitree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 4ff11f3a69..54f8ac95a4 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -34,7 +34,7 @@ Initialize the tree context ****************************************************************************/ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session, - TALLOC_CTX *parent_ctx, BOOL primary) + TALLOC_CTX *parent_ctx, bool primary) { struct smbcli_tree *tree; @@ -189,7 +189,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.service = service; io.in.service_type = service_type; io.in.credentials = credentials; - io.in.fallback_to_anonymous = False; + io.in.fallback_to_anonymous = false; io.in.workgroup = lp_workgroup(global_loadparm); status = smb_composite_connect(&io, parent_ctx, ev); -- cgit From 4b0199a5493ea2b88558cc40871e63c1dc8dbb56 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 12 Dec 2007 02:15:29 +0100 Subject: r26409: Pass smb ports along. (This used to be commit 2833f320de1f1fd39c710ad0a61c3fa1bb1df31f) --- source4/libcli/raw/clitree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 54f8ac95a4..890d5470da 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -171,7 +171,7 @@ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree) */ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, struct smbcli_tree **ret_tree, - const char *dest_host, int port, + const char *dest_host, const char **dest_ports, const char *service, const char *service_type, struct cli_credentials *credentials, struct event_context *ev) @@ -184,7 +184,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, } io.in.dest_host = dest_host; - io.in.port = port; + io.in.dest_ports = dest_ports; io.in.called_name = strupper_talloc(tmp_ctx, dest_host); io.in.service = service; io.in.service_type = service_type; -- cgit From 771b347f9b185895390445be96081c781e28a26d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Jan 2008 18:39:01 -0600 Subject: r26644: Janitorial: Pass resolve_context explicitly to various SMB functions, should help fix the build for OpenChange. (This used to be commit 385ffe4f4cc9a21a760c0f00410f56e2592fd507) --- source4/libcli/raw/clitree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 890d5470da..6b14893c4e 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -174,6 +174,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, const char *dest_host, const char **dest_ports, const char *service, const char *service_type, struct cli_credentials *credentials, + struct resolve_context *resolve_ctx, struct event_context *ev) { struct smb_composite_connect io; @@ -192,7 +193,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.fallback_to_anonymous = false; io.in.workgroup = lp_workgroup(global_loadparm); - status = smb_composite_connect(&io, parent_ctx, ev); + status = smb_composite_connect(&io, parent_ctx, resolve_ctx, ev); if (NT_STATUS_IS_OK(status)) { *ret_tree = io.out.tree; } -- cgit From 969b8579c755441092e27b499ecedbd7d725816d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Jan 2008 18:39:15 -0600 Subject: r26646: libcli/smb_composite: Allow specifying SMB parameters in smb_composite_connect structure. AFAIK no global variables will now be used when doing RPC client connections. (This used to be commit 0ef75e4e3cb0e1bd10e367a00f5e9b725587c40a) --- source4/libcli/raw/clitree.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 6b14893c4e..94fa37383b 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -192,6 +192,14 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.credentials = credentials; io.in.fallback_to_anonymous = false; io.in.workgroup = lp_workgroup(global_loadparm); + io.in.max_xmit = lp_max_xmit(global_loadparm); + io.in.max_mux = lp_maxmux(global_loadparm); + io.in.ntstatus_support = lp_nt_status_support(global_loadparm); + io.in.max_protocol = lp_cli_maxprotocol(global_loadparm); + io.in.unicode = lp_unicode(global_loadparm); + io.in.use_spnego = lp_use_spnego(global_loadparm) && lp_nt_status_support(global_loadparm); + + status = smb_composite_connect(&io, parent_ctx, resolve_ctx, ev); if (NT_STATUS_IS_OK(status)) { -- cgit From 425732f688865ebe2bfe568c8278edec50cbdedf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 3 Jan 2008 17:21:58 -0600 Subject: r26651: libsmb: Allow specifying signing policy from higher up. The number of arguments is getting a bit excessive now, so it probably makes sense to pass in the smbcli_options struct rather than all members individually and add a convenience function for obtaining a smbcli_options struct from a loadparm context. (This used to be commit 9f64213463b5bf3bcbf36913139e9a5042e967a2) --- source4/libcli/raw/clitree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 94fa37383b..3d8a6760a1 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -198,8 +198,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.max_protocol = lp_cli_maxprotocol(global_loadparm); io.in.unicode = lp_unicode(global_loadparm); io.in.use_spnego = lp_use_spnego(global_loadparm) && lp_nt_status_support(global_loadparm); - - + io.in.signing = lp_client_signing(global_loadparm); status = smb_composite_connect(&io, parent_ctx, resolve_ctx, ev); if (NT_STATUS_IS_OK(status)) { -- cgit From dcc282590b34537fc1ead61c3300172528273b44 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 3 Jan 2008 17:22:12 -0600 Subject: r26654: libcli/smb_composite: Rather than specifying each of the gazillion options for SMB individually, just specify the smbcli_options struct. (This used to be commit 8a97886e24a4b969aa91409c06f423b71a45f6eb) --- source4/libcli/raw/clitree.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 3d8a6760a1..ae63d94acd 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -175,7 +175,8 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, const char *service, const char *service_type, struct cli_credentials *credentials, struct resolve_context *resolve_ctx, - struct event_context *ev) + struct event_context *ev, + struct smbcli_options *options) { struct smb_composite_connect io; NTSTATUS status; @@ -191,14 +192,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.service_type = service_type; io.in.credentials = credentials; io.in.fallback_to_anonymous = false; - io.in.workgroup = lp_workgroup(global_loadparm); - io.in.max_xmit = lp_max_xmit(global_loadparm); - io.in.max_mux = lp_maxmux(global_loadparm); - io.in.ntstatus_support = lp_nt_status_support(global_loadparm); - io.in.max_protocol = lp_cli_maxprotocol(global_loadparm); - io.in.unicode = lp_unicode(global_loadparm); - io.in.use_spnego = lp_use_spnego(global_loadparm) && lp_nt_status_support(global_loadparm); - io.in.signing = lp_client_signing(global_loadparm); + io.in.options = *options; status = smb_composite_connect(&io, parent_ctx, resolve_ctx, ev); if (NT_STATUS_IS_OK(status)) { -- cgit From 9d09a06920c2de8c6312f3c0a0280faee65fd432 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 6 Jan 2008 22:01:31 -0600 Subject: r26676: libcli: Fill in lp_workgroup() again, should fix my breakage of cifsdd tests. Thanks to Andrew for catching this. Also fixes a typo in sessetup.c. (This used to be commit b97de4a655b989a481d5d001ce9a5d3969d2909c) --- source4/libcli/raw/clitree.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index ae63d94acd..35f3335322 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -192,6 +192,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.service_type = service_type; io.in.credentials = credentials; io.in.fallback_to_anonymous = false; + io.in.workgroup = lp_workgroup(global_loadparm); io.in.options = *options; status = smb_composite_connect(&io, parent_ctx, resolve_ctx, ev); -- cgit From e870cfec9f3512b0f1bd3110d7b975652525e28a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Feb 2008 10:12:33 +1100 Subject: Convert SMB and SMB2 code to use a common buffer handling structure This converts our SMB and SMB2 code to use a common structure "struct request_bufinfo" for information on the buffer bounds of a packet, alignment information and string handling. This allows us to use a common backend for SMB and SMB2 code, while still using all the same string and blob handling functions. Up to now we had been passing a NULL req handle into these common routines from the SMB2 side of the server, which meant that we failed any operation which did a bounds checked string extraction (such as a RenameInformation setinfo call, which is what Vista uses for renaming files) There is still some more work to be done on this - for example we can now remove many of the SMB2 specific buffer handling functions that we had, and use the SMB ones. (This used to be commit ca6d9be6cb6a403a81b18fa6e9a6a0518d7f0f68) --- source4/libcli/raw/clitree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 35f3335322..507bde999a 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -123,9 +123,9 @@ NTSTATUS smb_raw_tcon_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, p = req->in.data; if (!p) break; - p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.dev_type, - p, -1, STR_ASCII | STR_TERMINATE); - p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.fs_type, + p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->tconx.out.dev_type, + p, -1, STR_ASCII | STR_TERMINATE); + p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->tconx.out.fs_type, p, -1, STR_TERMINATE); break; -- cgit From afe3e8172ddaa5e4aa811faceecda4f943d6e2ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 04:53:27 +0200 Subject: Install public header files again and include required prototypes. (This used to be commit 47ffbbf67435904754469544390b67d34c958343) --- source4/libcli/raw/clitree.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 507bde999a..d5075f9271 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -22,6 +22,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" +#include "libcli/raw/raw_proto.h" #include "libcli/smb_composite/smb_composite.h" #include "param/param.h" @@ -33,7 +34,7 @@ /**************************************************************************** Initialize the tree context ****************************************************************************/ -struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session, +_PUBLIC_ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session, TALLOC_CTX *parent_ctx, bool primary) { struct smbcli_tree *tree; @@ -141,7 +142,7 @@ failed: /**************************************************************************** Send a tconX (sync interface) ****************************************************************************/ -NTSTATUS smb_raw_tcon(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, +_PUBLIC_ NTSTATUS smb_raw_tcon(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_tcon *parms) { struct smbcli_request *req = smb_raw_tcon_send(tree, parms); @@ -152,7 +153,7 @@ NTSTATUS smb_raw_tcon(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, /**************************************************************************** Send a tree disconnect. ****************************************************************************/ -NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree) +_PUBLIC_ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree) { struct smbcli_request *req; -- cgit From d67e47e5cd11c928299dc03ce2ff521e2d3cca83 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 24 Apr 2008 16:27:36 +0100 Subject: Add comment explaining why io.in.workgroup isn't important. This protocol feild isn't used by servers (apparently), so we might be able to get rid of it. Andrew Bartlett (This used to be commit 58935acc7c8e97323d5d5979234ef26ef8a100a4) --- source4/libcli/raw/clitree.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/libcli/raw/clitree.c') diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index d5075f9271..15cd70833c 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -193,6 +193,11 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.service_type = service_type; io.in.credentials = credentials; io.in.fallback_to_anonymous = false; + + /* This workgroup gets sent out by the SPNEGO session setup. + * I don't know of any servers that look at it, so we might + * hardcode it to "" some day, when the war on global_loadparm + * is complete -- abartlet 2008-04-28 */ io.in.workgroup = lp_workgroup(global_loadparm); io.in.options = *options; -- cgit