summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-01-03 13:03:42 +0100
committerVolker Lendecke <vl@samba.org>2010-01-03 21:14:57 +0100
commit37ac16a88f20ef9a4a8d0fdfa1349a16f818696d (patch)
tree24ecab274779b59cc2223f5927a36b6cf272a263
parent99f292479f1253c4cb1845461ae9edec8f155133 (diff)
downloadsamba-37ac16a88f20ef9a4a8d0fdfa1349a16f818696d.tar.gz
samba-37ac16a88f20ef9a4a8d0fdfa1349a16f818696d.tar.bz2
samba-37ac16a88f20ef9a4a8d0fdfa1349a16f818696d.zip
s3: Convert cli_ulogoff to the async API
-rw-r--r--source3/include/proto.h6
-rw-r--r--source3/libsmb/cliconnect.c91
-rw-r--r--source3/torture/torture.c11
3 files changed, 89 insertions, 19 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 635cc73bb3..b3921c468e 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2165,7 +2165,11 @@ struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct cli_state *cli);
NTSTATUS cli_session_setup_guest_recv(struct tevent_req *req);
-bool cli_ulogoff(struct cli_state *cli);
+struct tevent_req *cli_ulogoff_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli);
+NTSTATUS cli_ulogoff_recv(struct tevent_req *req);
+NTSTATUS cli_ulogoff(struct cli_state *cli);
struct tevent_req *cli_tcon_andx_create(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 bd718bc70a..31216b8240 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -1463,25 +1463,88 @@ NTSTATUS cli_session_setup(struct cli_state *cli,
Send a uloggoff.
*****************************************************************************/
-bool cli_ulogoff(struct cli_state *cli)
+struct cli_ulogoff_state {
+ struct cli_state *cli;
+ uint16_t vwv[2];
+};
+
+static void cli_ulogoff_done(struct tevent_req *subreq);
+
+struct tevent_req *cli_ulogoff_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli)
{
- memset(cli->outbuf,'\0',smb_size);
- cli_set_message(cli->outbuf,2,0,True);
- SCVAL(cli->outbuf,smb_com,SMBulogoffX);
- cli_setup_packet(cli);
- SSVAL(cli->outbuf,smb_vwv0,0xFF);
- SSVAL(cli->outbuf,smb_vwv2,0); /* no additional info */
+ struct tevent_req *req, *subreq;
+ struct cli_ulogoff_state *state;
- cli_send_smb(cli);
- if (!cli_receive_smb(cli))
- return False;
+ req = tevent_req_create(mem_ctx, &state, struct cli_ulogoff_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->cli = cli;
- if (cli_is_error(cli)) {
- return False;
+ SCVAL(state->vwv+0, 0, 0xFF);
+ SCVAL(state->vwv+1, 0, 0);
+ SSVAL(state->vwv+2, 0, 0);
+
+ subreq = cli_smb_send(state, ev, cli, SMBulogoffX, 0, 2, state->vwv,
+ 0, NULL);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, cli_ulogoff_done, req);
+ return req;
+}
+
+static void cli_ulogoff_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct cli_ulogoff_state *state = tevent_req_data(
+ req, struct cli_ulogoff_state);
+ NTSTATUS status;
+
+ status = cli_smb_recv(subreq, 0, NULL, NULL, NULL, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
}
+ state->cli->vuid = -1;
+ tevent_req_done(req);
+}
+
+NTSTATUS cli_ulogoff_recv(struct tevent_req *req)
+{
+ return tevent_req_simple_recv_ntstatus(req);
+}
- cli->vuid = -1;
- return True;
+NTSTATUS cli_ulogoff(struct cli_state *cli)
+{
+ struct tevent_context *ev;
+ struct tevent_req *req;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+ if (cli_has_async_calls(cli)) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+ ev = tevent_context_init(talloc_tos());
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = cli_ulogoff_send(ev, ev, cli);
+ if (req == NULL) {
+ goto fail;
+ }
+ if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+ goto fail;
+ }
+ status = cli_ulogoff_recv(req);
+fail:
+ TALLOC_FREE(ev);
+ if (!NT_STATUS_IS_OK(status)) {
+ cli_set_error(cli, status);
+ }
+ return status;
}
/****************************************************************************
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 4dd595dbe6..f89f320631 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -5325,9 +5325,10 @@ static bool run_sesssetup_bench(int dummy)
d_printf("\r%d ", (int)c->vuid);
- if (!cli_ulogoff(c)) {
+ status = cli_ulogoff(c);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) cli_ulogoff failed: %s\n",
- __location__, cli_errstr(c));
+ __location__, nt_errstr(status));
return false;
}
c->vuid = 0;
@@ -6046,6 +6047,7 @@ static bool run_uid_regression_test(int dummy)
int16_t old_vuid;
int16_t old_cnum;
bool correct = True;
+ NTSTATUS status;
printf("starting uid regression test\n");
@@ -6058,9 +6060,10 @@ static bool run_uid_regression_test(int dummy)
/* Ok - now save then logoff our current user. */
old_vuid = cli->vuid;
- if (!cli_ulogoff(cli)) {
+ status = cli_ulogoff(cli);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) cli_ulogoff failed: %s\n",
- __location__, cli_errstr(cli));
+ __location__, nt_errstr(status));
correct = false;
goto out;
}