summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-05-07 16:23:27 +0200
committerVolker Lendecke <vl@samba.org>2009-05-07 16:37:54 +0200
commitb35967edba35965f4e8242759a7d9d1d9ded980f (patch)
treec4e8f455b1fa6e5cd1eba0922a96abd8b152b144 /source3
parent599b9fe86eba932171bb4ec13347ed28ea5edebd (diff)
downloadsamba-b35967edba35965f4e8242759a7d9d1d9ded980f.tar.gz
samba-b35967edba35965f4e8242759a7d9d1d9ded980f.tar.bz2
samba-b35967edba35965f4e8242759a7d9d1d9ded980f.zip
Make cli_session_setup_guest chainable
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h4
-rw-r--r--source3/libsmb/cliconnect.c40
2 files changed, 35 insertions, 9 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c8b79278ea..c11d77d66f 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2169,6 +2169,10 @@ NTSTATUS cli_session_setup(struct cli_state *cli,
const char *pass, int passlen,
const char *ntpass, int ntpasslen,
const char *workgroup);
+struct tevent_req *cli_session_setup_guest_create(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ struct tevent_req **psmbreq);
struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct cli_state *cli);
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index ffe2960967..48a4f1f703 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -169,13 +169,15 @@ static uint32 cli_session_setup_capabilities(struct cli_state *cli)
struct cli_session_setup_guest_state {
struct cli_state *cli;
uint16_t vwv[16];
+ struct iovec bytes;
};
static void cli_session_setup_guest_done(struct tevent_req *subreq);
-struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli)
+struct tevent_req *cli_session_setup_guest_create(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ struct tevent_req **psmbreq)
{
struct tevent_req *req, *subreq;
struct cli_session_setup_guest_state *state;
@@ -212,16 +214,36 @@ struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), "Unix", 5, NULL);
bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), "Samba", 6, NULL);
- if (tevent_req_nomem(bytes, req)) {
- return tevent_req_post(req, ev);
+ if (bytes == NULL) {
+ TALLOC_FREE(req);
+ return NULL;
}
- subreq = cli_smb_send(state, ev, cli, SMBsesssetupX, 0, 13, vwv,
- talloc_get_size(bytes), bytes);
- if (tevent_req_nomem(subreq, req)) {
- return tevent_req_post(req, ev);
+ state->bytes.iov_base = bytes;
+ state->bytes.iov_len = talloc_get_size(bytes);
+
+ subreq = cli_smb_req_create(state, ev, cli, SMBsesssetupX, 0, 13, vwv,
+ 1, &state->bytes);
+ if (subreq == NULL) {
+ TALLOC_FREE(req);
+ return NULL;
}
tevent_req_set_callback(subreq, cli_session_setup_guest_done, req);
+ *psmbreq = subreq;
+ return req;
+}
+
+struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli)
+{
+ struct tevent_req *req, *subreq;
+
+ req = cli_session_setup_guest_create(mem_ctx, ev, cli, &subreq);
+ if ((req == NULL) || !cli_smb_req_send(subreq)) {
+ TALLOC_FREE(req);
+ return NULL;
+ }
return req;
}