summaryrefslogtreecommitdiff
path: root/source4/libcli/smb_composite
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2005-10-10 19:57:55 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:39 -0500
commitd617556ef50863d6a03c81a04f0f6b05848a250e (patch)
treec5963dd3778e2cb2f6e3b4942649f1d9e3195677 /source4/libcli/smb_composite
parent3dfe8c22b835c34453b23b654cd5649d698da3cb (diff)
downloadsamba-d617556ef50863d6a03c81a04f0f6b05848a250e.tar.gz
samba-d617556ef50863d6a03c81a04f0f6b05848a250e.tar.bz2
samba-d617556ef50863d6a03c81a04f0f6b05848a250e.zip
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)
Diffstat (limited to 'source4/libcli/smb_composite')
-rw-r--r--source4/libcli/smb_composite/connect.c83
-rw-r--r--source4/libcli/smb_composite/fetchfile.c1
-rw-r--r--source4/libcli/smb_composite/fsinfo.c1
-rw-r--r--source4/libcli/smb_composite/smb_composite.h2
4 files changed, 85 insertions, 2 deletions
diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c
index 53cc8a9ac0..925d5ddb38 100644
--- a/source4/libcli/smb_composite/connect.c
+++ b/source4/libcli/smb_composite/connect.c
@@ -30,9 +30,10 @@
/* the stages of this call */
enum connect_stage {CONNECT_RESOLVE,
CONNECT_SOCKET,
- CONNECT_SESSION_REQUEST,
+ CONNECT_SESSION_REQUEST,
CONNECT_NEGPROT,
CONNECT_SESSION_SETUP,
+ CONNECT_SESSION_SETUP_ANON,
CONNECT_TCON};
struct connect_state {
@@ -101,7 +102,59 @@ static NTSTATUS connect_tcon(struct composite_context *c,
/*
- a session setup request has competed
+ a session setup request with anonymous fallback has completed
+*/
+static NTSTATUS connect_session_setup_anon(struct composite_context *c,
+ struct smb_composite_connect *io)
+{
+ struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
+ NTSTATUS status;
+
+ status = smb_composite_sesssetup_recv(state->creq);
+ NT_STATUS_NOT_OK_RETURN(status);
+
+ io->out.anonymous_fallback_done = True;
+
+ state->session->vuid = state->io_setup->out.vuid;
+
+ /* setup for a tconx */
+ io->out.tree = smbcli_tree_init(state->session, state, True);
+ NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
+
+ state->io_tcon = talloc(c, union smb_tcon);
+ NT_STATUS_HAVE_NO_MEMORY(state->io_tcon);
+
+ /* connect to a share using a tree connect */
+ state->io_tcon->generic.level = RAW_TCON_TCONX;
+ state->io_tcon->tconx.in.flags = 0;
+ state->io_tcon->tconx.in.password = data_blob(NULL, 0);
+
+ state->io_tcon->tconx.in.path = talloc_asprintf(state->io_tcon,
+ "\\\\%s\\%s",
+ io->in.called_name,
+ io->in.service);
+ NT_STATUS_HAVE_NO_MEMORY(state->io_tcon->tconx.in.path);
+ if (!io->in.service_type) {
+ state->io_tcon->tconx.in.device = "?????";
+ } else {
+ state->io_tcon->tconx.in.device = io->in.service_type;
+ }
+
+ state->req = smb_raw_tcon_send(io->out.tree, state->io_tcon);
+ NT_STATUS_HAVE_NO_MEMORY(state->req);
+ if (state->req->state == SMBCLI_REQUEST_ERROR) {
+ return state->req->status;
+ }
+
+ state->req->async.fn = request_handler;
+ state->req->async.private = c;
+ state->stage = CONNECT_TCON;
+
+ return NT_STATUS_OK;
+}
+
+/*
+ a session setup request has completed
*/
static NTSTATUS connect_session_setup(struct composite_context *c,
struct smb_composite_connect *io)
@@ -110,6 +163,29 @@ static NTSTATUS connect_session_setup(struct composite_context *c,
NTSTATUS status;
status = smb_composite_sesssetup_recv(state->creq);
+
+ if (!NT_STATUS_IS_OK(status) &&
+ !cli_credentials_is_anonymous(state->io->in.credentials) &&
+ io->in.fallback_to_anonymous) {
+
+ state->io_setup->in.credentials = cli_credentials_init(state);
+ NT_STATUS_HAVE_NO_MEMORY(state->io_setup->in.credentials);
+ cli_credentials_set_conf(state->io_setup->in.credentials);
+ cli_credentials_set_anonymous(state->io_setup->in.credentials);
+
+ state->creq = smb_composite_sesssetup_send(state->session,
+ state->io_setup);
+ NT_STATUS_HAVE_NO_MEMORY(state->creq);
+ if (state->creq->state == COMPOSITE_STATE_ERROR) {
+ return state->creq->status;
+ }
+ state->creq->async.fn = composite_handler;
+ state->creq->async.private_data = c;
+ state->stage = CONNECT_SESSION_SETUP_ANON;
+
+ return NT_STATUS_OK;
+ }
+
NT_STATUS_NOT_OK_RETURN(status);
state->session->vuid = state->io_setup->out.vuid;
@@ -318,6 +394,9 @@ static void state_handler(struct composite_context *c)
case CONNECT_SESSION_SETUP:
c->status = connect_session_setup(c, state->io);
break;
+ case CONNECT_SESSION_SETUP_ANON:
+ c->status = connect_session_setup_anon(c, state->io);
+ break;
case CONNECT_TCON:
c->status = connect_tcon(c, state->io);
break;
diff --git a/source4/libcli/smb_composite/fetchfile.c b/source4/libcli/smb_composite/fetchfile.c
index 8aa91bf3a9..1891ee956c 100644
--- a/source4/libcli/smb_composite/fetchfile.c
+++ b/source4/libcli/smb_composite/fetchfile.c
@@ -144,6 +144,7 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc
state->connect->in.service = io->in.service;
state->connect->in.service_type = io->in.service_type;
state->connect->in.credentials = io->in.credentials;
+ state->connect->in.fallback_to_anonymous = False;
state->connect->in.workgroup = io->in.workgroup;
state->creq = smb_composite_connect_send(state->connect, state, event_ctx);
diff --git a/source4/libcli/smb_composite/fsinfo.c b/source4/libcli/smb_composite/fsinfo.c
index fa9f18d132..1d3860e5c6 100644
--- a/source4/libcli/smb_composite/fsinfo.c
+++ b/source4/libcli/smb_composite/fsinfo.c
@@ -149,6 +149,7 @@ struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree,
state->connect->in.service = io->in.service;
state->connect->in.service_type = io->in.service_type;
state->connect->in.credentials = io->in.credentials;
+ state->connect->in.fallback_to_anonymous = False;
state->connect->in.workgroup = io->in.workgroup;
c->state = COMPOSITE_STATE_IN_PROGRESS;
diff --git a/source4/libcli/smb_composite/smb_composite.h b/source4/libcli/smb_composite/smb_composite.h
index ec3a7af22d..7ab0127440 100644
--- a/source4/libcli/smb_composite/smb_composite.h
+++ b/source4/libcli/smb_composite/smb_composite.h
@@ -90,10 +90,12 @@ struct smb_composite_connect {
const char *service;
const char *service_type;
struct cli_credentials *credentials;
+ BOOL fallback_to_anonymous;
const char *workgroup;
} in;
struct {
struct smbcli_tree *tree;
+ BOOL anonymous_fallback_done;
} out;
};