mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
r4782: volker quite rightly pointed out that there is too much of a
proliferation of void* in the composite code. This removes two of the
void* pointers from the main composite structure.
(This used to be commit 5a89a5ed0f
)
This commit is contained in:
parent
5dbebbe2ad
commit
99d30a901f
@ -39,12 +39,6 @@ struct smbcli_composite {
|
||||
/* the currently running sub-request */
|
||||
void *req;
|
||||
|
||||
/* the current requests parameter block */
|
||||
void *req_parms;
|
||||
|
||||
/* the parameters of the whole composite function */
|
||||
void *composite_parms;
|
||||
|
||||
/* a private pointer for use by the composite code */
|
||||
void *private;
|
||||
|
||||
|
@ -36,6 +36,9 @@ struct connect_state {
|
||||
struct smbcli_socket *sock;
|
||||
struct smbcli_transport *transport;
|
||||
struct smbcli_session *session;
|
||||
struct smb_composite_connect *io;
|
||||
union smb_tcon *io_tcon;
|
||||
struct smb_composite_sesssetup *io_setup;
|
||||
};
|
||||
|
||||
|
||||
@ -69,21 +72,21 @@ static NTSTATUS connect_send_negprot(struct smbcli_composite *c,
|
||||
static NTSTATUS connect_tcon(struct smbcli_composite *c,
|
||||
struct smb_composite_connect *io)
|
||||
{
|
||||
struct connect_state *state = c->private;
|
||||
struct smbcli_request *req = c->req;
|
||||
union smb_tcon *io_tcon = c->req_parms;
|
||||
NTSTATUS status;
|
||||
|
||||
status = smb_tree_connect_recv(req, c, io_tcon);
|
||||
status = smb_tree_connect_recv(req, c, state->io_tcon);
|
||||
NT_STATUS_NOT_OK_RETURN(status);
|
||||
|
||||
io->out.tree->tid = io_tcon->tconx.out.tid;
|
||||
if (io_tcon->tconx.out.dev_type) {
|
||||
io->out.tree->tid = state->io_tcon->tconx.out.tid;
|
||||
if (state->io_tcon->tconx.out.dev_type) {
|
||||
io->out.tree->device = talloc_strdup(io->out.tree,
|
||||
io_tcon->tconx.out.dev_type);
|
||||
state->io_tcon->tconx.out.dev_type);
|
||||
}
|
||||
if (io_tcon->tconx.out.fs_type) {
|
||||
if (state->io_tcon->tconx.out.fs_type) {
|
||||
io->out.tree->fs_type = talloc_strdup(io->out.tree,
|
||||
io_tcon->tconx.out.fs_type);
|
||||
state->io_tcon->tconx.out.fs_type);
|
||||
}
|
||||
|
||||
/* all done! */
|
||||
@ -105,44 +108,41 @@ static NTSTATUS connect_session_setup(struct smbcli_composite *c,
|
||||
struct connect_state *state = c->private;
|
||||
struct smbcli_composite *req = c->req;
|
||||
struct smbcli_request *req2;
|
||||
struct smb_composite_sesssetup *io_setup = c->req_parms;
|
||||
union smb_tcon *io_tcon;
|
||||
NTSTATUS status;
|
||||
|
||||
status = smb_composite_sesssetup_recv(req);
|
||||
NT_STATUS_NOT_OK_RETURN(status);
|
||||
|
||||
state->session->vuid = io_setup->out.vuid;
|
||||
state->session->vuid = state->io_setup->out.vuid;
|
||||
|
||||
/* setup for a tconx */
|
||||
io->out.tree = smbcli_tree_init(state->session);
|
||||
NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
|
||||
|
||||
io_tcon = talloc(c, union smb_tcon);
|
||||
NT_STATUS_HAVE_NO_MEMORY(io_tcon);
|
||||
state->io_tcon = talloc(c, union smb_tcon);
|
||||
NT_STATUS_HAVE_NO_MEMORY(state->io_tcon);
|
||||
|
||||
/* connect to a share using a tree connect */
|
||||
io_tcon->generic.level = RAW_TCON_TCONX;
|
||||
io_tcon->tconx.in.flags = 0;
|
||||
io_tcon->tconx.in.password = data_blob(NULL, 0);
|
||||
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);
|
||||
|
||||
io_tcon->tconx.in.path = talloc_asprintf(io_tcon,
|
||||
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(io_tcon->tconx.in.path);
|
||||
NT_STATUS_HAVE_NO_MEMORY(state->io_tcon->tconx.in.path);
|
||||
if (!io->in.service_type) {
|
||||
io_tcon->tconx.in.device = "?????";
|
||||
state->io_tcon->tconx.in.device = "?????";
|
||||
} else {
|
||||
io_tcon->tconx.in.device = io->in.service_type;
|
||||
state->io_tcon->tconx.in.device = io->in.service_type;
|
||||
}
|
||||
|
||||
req2 = smb_tree_connect_send(io->out.tree, io_tcon);
|
||||
req2 = smb_tree_connect_send(io->out.tree, state->io_tcon);
|
||||
NT_STATUS_HAVE_NO_MEMORY(req2);
|
||||
|
||||
req2->async.fn = request_handler;
|
||||
req2->async.private = c;
|
||||
c->req_parms = io_tcon;
|
||||
c->req = req2;
|
||||
c->stage = CONNECT_TCON;
|
||||
|
||||
@ -159,7 +159,6 @@ static NTSTATUS connect_negprot(struct smbcli_composite *c,
|
||||
struct smbcli_request *req = c->req;
|
||||
struct smbcli_composite *req2;
|
||||
NTSTATUS status;
|
||||
struct smb_composite_sesssetup *io_setup;
|
||||
|
||||
status = smb_raw_negotiate_recv(req);
|
||||
NT_STATUS_NOT_OK_RETURN(status);
|
||||
@ -171,22 +170,21 @@ static NTSTATUS connect_negprot(struct smbcli_composite *c,
|
||||
/* get rid of the extra reference to the transport */
|
||||
talloc_free(state->transport);
|
||||
|
||||
io_setup = talloc(c, struct smb_composite_sesssetup);
|
||||
NT_STATUS_HAVE_NO_MEMORY(io_setup);
|
||||
state->io_setup = talloc(c, struct smb_composite_sesssetup);
|
||||
NT_STATUS_HAVE_NO_MEMORY(state->io_setup);
|
||||
|
||||
/* prepare a session setup to establish a security context */
|
||||
io_setup->in.sesskey = state->transport->negotiate.sesskey;
|
||||
io_setup->in.capabilities = state->transport->negotiate.capabilities;
|
||||
io_setup->in.domain = io->in.domain;
|
||||
io_setup->in.user = io->in.user;
|
||||
io_setup->in.password = io->in.password;
|
||||
state->io_setup->in.sesskey = state->transport->negotiate.sesskey;
|
||||
state->io_setup->in.capabilities = state->transport->negotiate.capabilities;
|
||||
state->io_setup->in.domain = io->in.domain;
|
||||
state->io_setup->in.user = io->in.user;
|
||||
state->io_setup->in.password = io->in.password;
|
||||
|
||||
req2 = smb_composite_sesssetup_send(state->session, io_setup);
|
||||
req2 = smb_composite_sesssetup_send(state->session, state->io_setup);
|
||||
NT_STATUS_HAVE_NO_MEMORY(req2);
|
||||
|
||||
req2->async.fn = composite_handler;
|
||||
req2->async.private = c;
|
||||
c->req_parms = io_setup;
|
||||
c->req = req2;
|
||||
c->stage = CONNECT_SESSION_SETUP;
|
||||
|
||||
@ -256,23 +254,23 @@ static NTSTATUS connect_socket(struct smbcli_composite *c,
|
||||
*/
|
||||
static void state_handler(struct smbcli_composite *c)
|
||||
{
|
||||
struct smb_composite_connect *io = c->composite_parms;
|
||||
|
||||
struct connect_state *state = c->private;
|
||||
|
||||
switch (c->stage) {
|
||||
case CONNECT_SOCKET:
|
||||
c->status = connect_socket(c, io);
|
||||
c->status = connect_socket(c, state->io);
|
||||
break;
|
||||
case CONNECT_SESSION_REQUEST:
|
||||
c->status = connect_session_request(c, io);
|
||||
c->status = connect_session_request(c, state->io);
|
||||
break;
|
||||
case CONNECT_NEGPROT:
|
||||
c->status = connect_negprot(c, io);
|
||||
c->status = connect_negprot(c, state->io);
|
||||
break;
|
||||
case CONNECT_SESSION_SETUP:
|
||||
c->status = connect_session_setup(c, io);
|
||||
c->status = connect_session_setup(c, state->io);
|
||||
break;
|
||||
case CONNECT_TCON:
|
||||
c->status = connect_tcon(c, io);
|
||||
c->status = connect_tcon(c, state->io);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -320,8 +318,9 @@ struct smbcli_composite *smb_composite_connect_send(struct smb_composite_connect
|
||||
state->sock = smbcli_sock_init(state);
|
||||
if (state->sock == NULL) goto failed;
|
||||
|
||||
state->io = io;
|
||||
|
||||
c->state = SMBCLI_REQUEST_SEND;
|
||||
c->composite_parms = io;
|
||||
c->stage = CONNECT_SOCKET;
|
||||
c->event_ctx = state->sock->event.ctx;
|
||||
c->private = state;
|
||||
@ -349,8 +348,8 @@ NTSTATUS smb_composite_connect_recv(struct smbcli_composite *c, TALLOC_CTX *mem_
|
||||
status = smb_composite_wait(c);
|
||||
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
struct smb_composite_connect *io = c->composite_parms;
|
||||
talloc_steal(mem_ctx, io->out.tree);
|
||||
struct connect_state *state = c->private;
|
||||
talloc_steal(mem_ctx, state->io->out.tree);
|
||||
}
|
||||
|
||||
talloc_free(c);
|
||||
|
@ -32,6 +32,11 @@ enum loadfile_stage {LOADFILE_OPEN, LOADFILE_READ, LOADFILE_CLOSE};
|
||||
|
||||
static void loadfile_handler(struct smbcli_request *req);
|
||||
|
||||
struct loadfile_state {
|
||||
struct smb_composite_loadfile *io;
|
||||
union smb_open *io_open;
|
||||
union smb_read *io_read;
|
||||
};
|
||||
|
||||
/*
|
||||
setup for the close
|
||||
@ -39,8 +44,8 @@ static void loadfile_handler(struct smbcli_request *req);
|
||||
static NTSTATUS setup_close(struct smbcli_composite *c,
|
||||
struct smbcli_tree *tree, uint16_t fnum)
|
||||
{
|
||||
union smb_close *io_close;
|
||||
struct smbcli_request *req;
|
||||
union smb_close *io_close;
|
||||
|
||||
/* nothing to read, setup the close */
|
||||
io_close = talloc(c, union smb_close);
|
||||
@ -56,7 +61,6 @@ static NTSTATUS setup_close(struct smbcli_composite *c,
|
||||
/* call the handler again when the close is done */
|
||||
req->async.fn = loadfile_handler;
|
||||
req->async.private = c;
|
||||
c->req_parms = io_close;
|
||||
c->req = req;
|
||||
c->stage = LOADFILE_CLOSE;
|
||||
|
||||
@ -70,52 +74,50 @@ static NTSTATUS setup_close(struct smbcli_composite *c,
|
||||
static NTSTATUS loadfile_open(struct smbcli_composite *c,
|
||||
struct smb_composite_loadfile *io)
|
||||
{
|
||||
union smb_open *io_open = c->req_parms;
|
||||
struct loadfile_state *state = c->private;
|
||||
struct smbcli_request *req = c->req;
|
||||
struct smbcli_tree *tree = req->tree;
|
||||
union smb_read *io_read;
|
||||
NTSTATUS status;
|
||||
|
||||
status = smb_raw_open_recv(req, c, io_open);
|
||||
status = smb_raw_open_recv(req, c, state->io_open);
|
||||
NT_STATUS_NOT_OK_RETURN(status);
|
||||
|
||||
/* don't allow stupidly large loads */
|
||||
if (io_open->ntcreatex.out.size > 100*1000*1000) {
|
||||
if (state->io_open->ntcreatex.out.size > 100*1000*1000) {
|
||||
return NT_STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
/* allocate space for the file data */
|
||||
io->out.size = io_open->ntcreatex.out.size;
|
||||
io->out.size = state->io_open->ntcreatex.out.size;
|
||||
io->out.data = talloc_array(c, uint8_t, io->out.size);
|
||||
NT_STATUS_HAVE_NO_MEMORY(io->out.data);
|
||||
|
||||
if (io->out.size == 0) {
|
||||
return setup_close(c, tree, io_open->ntcreatex.out.fnum);
|
||||
return setup_close(c, tree, state->io_open->ntcreatex.out.fnum);
|
||||
}
|
||||
|
||||
/* setup for the read */
|
||||
io_read = talloc(c, union smb_read);
|
||||
NT_STATUS_HAVE_NO_MEMORY(io_read);
|
||||
state->io_read = talloc(c, union smb_read);
|
||||
NT_STATUS_HAVE_NO_MEMORY(state->io_read);
|
||||
|
||||
io_read->readx.level = RAW_READ_READX;
|
||||
io_read->readx.in.fnum = io_open->ntcreatex.out.fnum;
|
||||
io_read->readx.in.offset = 0;
|
||||
io_read->readx.in.mincnt = MIN(32768, io->out.size);
|
||||
io_read->readx.in.maxcnt = io_read->readx.in.mincnt;
|
||||
io_read->readx.in.remaining = 0;
|
||||
io_read->readx.out.data = io->out.data;
|
||||
state->io_read->readx.level = RAW_READ_READX;
|
||||
state->io_read->readx.in.fnum = state->io_open->ntcreatex.out.fnum;
|
||||
state->io_read->readx.in.offset = 0;
|
||||
state->io_read->readx.in.mincnt = MIN(32768, io->out.size);
|
||||
state->io_read->readx.in.maxcnt = state->io_read->readx.in.mincnt;
|
||||
state->io_read->readx.in.remaining = 0;
|
||||
state->io_read->readx.out.data = io->out.data;
|
||||
|
||||
req = smb_raw_read_send(tree, io_read);
|
||||
req = smb_raw_read_send(tree, state->io_read);
|
||||
NT_STATUS_HAVE_NO_MEMORY(req);
|
||||
|
||||
/* call the handler again when the first read is done */
|
||||
req->async.fn = loadfile_handler;
|
||||
req->async.private = c;
|
||||
c->req_parms = io_read;
|
||||
c->req = req;
|
||||
c->stage = LOADFILE_READ;
|
||||
|
||||
talloc_free(io_open);
|
||||
talloc_free(state->io_open);
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
@ -128,26 +130,26 @@ static NTSTATUS loadfile_open(struct smbcli_composite *c,
|
||||
static NTSTATUS loadfile_read(struct smbcli_composite *c,
|
||||
struct smb_composite_loadfile *io)
|
||||
{
|
||||
union smb_read *io_read = c->req_parms;
|
||||
struct loadfile_state *state = c->private;
|
||||
struct smbcli_request *req = c->req;
|
||||
struct smbcli_tree *tree = req->tree;
|
||||
NTSTATUS status;
|
||||
|
||||
status = smb_raw_read_recv(req, io_read);
|
||||
status = smb_raw_read_recv(req, state->io_read);
|
||||
NT_STATUS_NOT_OK_RETURN(status);
|
||||
|
||||
/* we might be done */
|
||||
if (io_read->readx.in.offset +
|
||||
io_read->readx.out.nread == io->out.size) {
|
||||
return setup_close(c, tree, io_read->readx.in.fnum);
|
||||
if (state->io_read->readx.in.offset +
|
||||
state->io_read->readx.out.nread == io->out.size) {
|
||||
return setup_close(c, tree, state->io_read->readx.in.fnum);
|
||||
}
|
||||
|
||||
/* setup for the next read */
|
||||
io_read->readx.in.offset += io_read->readx.out.nread;
|
||||
io_read->readx.in.mincnt = MIN(32768, io->out.size - io_read->readx.in.offset);
|
||||
io_read->readx.out.data = io->out.data + io_read->readx.in.offset;
|
||||
state->io_read->readx.in.offset += state->io_read->readx.out.nread;
|
||||
state->io_read->readx.in.mincnt = MIN(32768, io->out.size - state->io_read->readx.in.offset);
|
||||
state->io_read->readx.out.data = io->out.data + state->io_read->readx.in.offset;
|
||||
|
||||
req = smb_raw_read_send(tree, io_read);
|
||||
req = smb_raw_read_send(tree, state->io_read);
|
||||
NT_STATUS_HAVE_NO_MEMORY(req);
|
||||
|
||||
/* call the handler again when the read is done */
|
||||
@ -185,21 +187,21 @@ static NTSTATUS loadfile_close(struct smbcli_composite *c,
|
||||
static void loadfile_handler(struct smbcli_request *req)
|
||||
{
|
||||
struct smbcli_composite *c = req->async.private;
|
||||
struct smb_composite_loadfile *io = c->composite_parms;
|
||||
struct loadfile_state *state = c->private;
|
||||
|
||||
/* when this handler is called, the stage indicates what
|
||||
call has just finished */
|
||||
switch (c->stage) {
|
||||
case LOADFILE_OPEN:
|
||||
c->status = loadfile_open(c, io);
|
||||
c->status = loadfile_open(c, state->io);
|
||||
break;
|
||||
|
||||
case LOADFILE_READ:
|
||||
c->status = loadfile_read(c, io);
|
||||
c->status = loadfile_read(c, state->io);
|
||||
break;
|
||||
|
||||
case LOADFILE_CLOSE:
|
||||
c->status = loadfile_close(c, io);
|
||||
c->status = loadfile_close(c, state->io);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -219,37 +221,41 @@ struct smbcli_composite *smb_composite_loadfile_send(struct smbcli_tree *tree,
|
||||
struct smb_composite_loadfile *io)
|
||||
{
|
||||
struct smbcli_composite *c;
|
||||
union smb_open *io_open;
|
||||
struct smbcli_request *req;
|
||||
struct loadfile_state *state;
|
||||
|
||||
c = talloc_zero(tree, struct smbcli_composite);
|
||||
if (c == NULL) goto failed;
|
||||
|
||||
state = talloc(c, struct loadfile_state);
|
||||
if (state == NULL) goto failed;
|
||||
|
||||
state->io = io;
|
||||
|
||||
c->private = state;
|
||||
c->state = SMBCLI_REQUEST_SEND;
|
||||
c->composite_parms = io;
|
||||
c->event_ctx = tree->session->transport->socket->event.ctx;
|
||||
|
||||
/* setup for the open */
|
||||
io_open = talloc_zero(c, union smb_open);
|
||||
if (io_open == NULL) goto failed;
|
||||
state->io_open = talloc_zero(c, union smb_open);
|
||||
if (state->io_open == NULL) goto failed;
|
||||
|
||||
io_open->ntcreatex.level = RAW_OPEN_NTCREATEX;
|
||||
io_open->ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
|
||||
io_open->ntcreatex.in.access_mask = SEC_FILE_READ_DATA;
|
||||
io_open->ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
|
||||
io_open->ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;
|
||||
io_open->ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
|
||||
io_open->ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
|
||||
io_open->ntcreatex.in.fname = io->in.fname;
|
||||
state->io_open->ntcreatex.level = RAW_OPEN_NTCREATEX;
|
||||
state->io_open->ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
|
||||
state->io_open->ntcreatex.in.access_mask = SEC_FILE_READ_DATA;
|
||||
state->io_open->ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
|
||||
state->io_open->ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;
|
||||
state->io_open->ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
|
||||
state->io_open->ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
|
||||
state->io_open->ntcreatex.in.fname = io->in.fname;
|
||||
|
||||
/* send the open on its way */
|
||||
req = smb_raw_open_send(tree, io_open);
|
||||
req = smb_raw_open_send(tree, state->io_open);
|
||||
if (req == NULL) goto failed;
|
||||
|
||||
/* setup the callback handler */
|
||||
req->async.fn = loadfile_handler;
|
||||
req->async.private = c;
|
||||
c->req_parms = io_open;
|
||||
c->req = req;
|
||||
c->stage = LOADFILE_OPEN;
|
||||
|
||||
@ -271,8 +277,8 @@ NTSTATUS smb_composite_loadfile_recv(struct smbcli_composite *c, TALLOC_CTX *mem
|
||||
status = smb_composite_wait(c);
|
||||
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
struct smb_composite_loadfile *io = c->composite_parms;
|
||||
talloc_steal(mem_ctx, io->out.data);
|
||||
struct loadfile_state *state = c->private;
|
||||
talloc_steal(mem_ctx, state->io->out.data);
|
||||
}
|
||||
|
||||
talloc_free(c);
|
||||
|
@ -34,6 +34,9 @@ static void savefile_handler(struct smbcli_request *req);
|
||||
|
||||
struct savefile_state {
|
||||
off_t total_written;
|
||||
struct smb_composite_savefile *io;
|
||||
union smb_open *io_open;
|
||||
union smb_write *io_write;
|
||||
};
|
||||
|
||||
|
||||
@ -61,7 +64,6 @@ static NTSTATUS setup_close(struct smbcli_composite *c,
|
||||
c->stage = SAVEFILE_CLOSE;
|
||||
req->async.fn = savefile_handler;
|
||||
req->async.private = c;
|
||||
c->req_parms = io_close;
|
||||
c->req = req;
|
||||
|
||||
return NT_STATUS_OK;
|
||||
@ -74,18 +76,18 @@ static NTSTATUS setup_close(struct smbcli_composite *c,
|
||||
static NTSTATUS savefile_open(struct smbcli_composite *c,
|
||||
struct smb_composite_savefile *io)
|
||||
{
|
||||
union smb_open *io_open = c->req_parms;
|
||||
struct savefile_state *state = c->private;
|
||||
union smb_write *io_write;
|
||||
struct smbcli_request *req = c->req;
|
||||
struct smbcli_tree *tree = req->tree;
|
||||
union smb_write *io_write;
|
||||
NTSTATUS status;
|
||||
uint32_t max_xmit = tree->session->transport->negotiate.max_xmit;
|
||||
|
||||
status = smb_raw_open_recv(c->req, c, io_open);
|
||||
status = smb_raw_open_recv(c->req, c, state->io_open);
|
||||
NT_STATUS_NOT_OK_RETURN(status);
|
||||
|
||||
if (io->in.size == 0) {
|
||||
return setup_close(c, tree, io_open->ntcreatex.out.fnum);
|
||||
return setup_close(c, tree, state->io_open->ntcreatex.out.fnum);
|
||||
}
|
||||
|
||||
/* setup for the first write */
|
||||
@ -93,12 +95,13 @@ static NTSTATUS savefile_open(struct smbcli_composite *c,
|
||||
NT_STATUS_HAVE_NO_MEMORY(io_write);
|
||||
|
||||
io_write->writex.level = RAW_WRITE_WRITEX;
|
||||
io_write->writex.in.fnum = io_open->ntcreatex.out.fnum;
|
||||
io_write->writex.in.fnum = state->io_open->ntcreatex.out.fnum;
|
||||
io_write->writex.in.offset = 0;
|
||||
io_write->writex.in.wmode = 0;
|
||||
io_write->writex.in.remaining = 0;
|
||||
io_write->writex.in.count = MIN(max_xmit - 100, io->in.size);
|
||||
io_write->writex.in.data = io->in.data;
|
||||
state->io_write = io_write;
|
||||
|
||||
req = smb_raw_write_send(tree, io_write);
|
||||
NT_STATUS_HAVE_NO_MEMORY(req);
|
||||
@ -107,9 +110,8 @@ static NTSTATUS savefile_open(struct smbcli_composite *c,
|
||||
c->stage = SAVEFILE_WRITE;
|
||||
req->async.fn = savefile_handler;
|
||||
req->async.private = c;
|
||||
c->req_parms = io_write;
|
||||
c->req = req;
|
||||
talloc_free(io_open);
|
||||
talloc_free(state->io_open);
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
@ -122,30 +124,30 @@ static NTSTATUS savefile_open(struct smbcli_composite *c,
|
||||
static NTSTATUS savefile_write(struct smbcli_composite *c,
|
||||
struct smb_composite_savefile *io)
|
||||
{
|
||||
union smb_write *io_write = c->req_parms;
|
||||
struct savefile_state *state = c->private;
|
||||
struct smbcli_request *req = c->req;
|
||||
struct smbcli_tree *tree = req->tree;
|
||||
struct savefile_state *state = c->private;
|
||||
NTSTATUS status;
|
||||
uint32_t max_xmit = tree->session->transport->negotiate.max_xmit;
|
||||
|
||||
status = smb_raw_write_recv(c->req, io_write);
|
||||
status = smb_raw_write_recv(c->req, state->io_write);
|
||||
NT_STATUS_NOT_OK_RETURN(status);
|
||||
|
||||
state->total_written += io_write->writex.out.nwritten;
|
||||
state->total_written += state->io_write->writex.out.nwritten;
|
||||
|
||||
/* we might be done */
|
||||
if (io_write->writex.out.nwritten != io_write->writex.in.count ||
|
||||
if (state->io_write->writex.out.nwritten != state->io_write->writex.in.count ||
|
||||
state->total_written == io->in.size) {
|
||||
return setup_close(c, tree, io_write->writex.in.fnum);
|
||||
return setup_close(c, tree, state->io_write->writex.in.fnum);
|
||||
}
|
||||
|
||||
/* setup for the next write */
|
||||
io_write->writex.in.offset = state->total_written;
|
||||
io_write->writex.in.count = MIN(max_xmit - 100, io->in.size - state->total_written);
|
||||
io_write->writex.in.data = io->in.data + state->total_written;
|
||||
state->io_write->writex.in.offset = state->total_written;
|
||||
state->io_write->writex.in.count = MIN(max_xmit - 100,
|
||||
io->in.size - state->total_written);
|
||||
state->io_write->writex.in.data = io->in.data + state->total_written;
|
||||
|
||||
req = smb_raw_write_send(tree, io_write);
|
||||
req = smb_raw_write_send(tree, state->io_write);
|
||||
NT_STATUS_HAVE_NO_MEMORY(req);
|
||||
|
||||
/* call the handler again when the write is done */
|
||||
@ -162,8 +164,8 @@ static NTSTATUS savefile_write(struct smbcli_composite *c,
|
||||
static NTSTATUS savefile_close(struct smbcli_composite *c,
|
||||
struct smb_composite_savefile *io)
|
||||
{
|
||||
NTSTATUS status;
|
||||
struct savefile_state *state = c->private;
|
||||
NTSTATUS status;
|
||||
|
||||
status = smbcli_request_simple_recv(c->req);
|
||||
NT_STATUS_NOT_OK_RETURN(status);
|
||||
@ -187,21 +189,21 @@ static NTSTATUS savefile_close(struct smbcli_composite *c,
|
||||
static void savefile_handler(struct smbcli_request *req)
|
||||
{
|
||||
struct smbcli_composite *c = req->async.private;
|
||||
struct smb_composite_savefile *io = c->composite_parms;
|
||||
struct savefile_state *state = c->private;
|
||||
|
||||
/* when this handler is called, the stage indicates what
|
||||
call has just finished */
|
||||
switch (c->stage) {
|
||||
case SAVEFILE_OPEN:
|
||||
c->status = savefile_open(c, io);
|
||||
c->status = savefile_open(c, state->io);
|
||||
break;
|
||||
|
||||
case SAVEFILE_WRITE:
|
||||
c->status = savefile_write(c, io);
|
||||
c->status = savefile_write(c, state->io);
|
||||
break;
|
||||
|
||||
case SAVEFILE_CLOSE:
|
||||
c->status = savefile_close(c, io);
|
||||
c->status = savefile_close(c, state->io);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -221,22 +223,22 @@ struct smbcli_composite *smb_composite_savefile_send(struct smbcli_tree *tree,
|
||||
struct smb_composite_savefile *io)
|
||||
{
|
||||
struct smbcli_composite *c;
|
||||
union smb_open *io_open;
|
||||
struct savefile_state *state;
|
||||
struct smbcli_request *req;
|
||||
union smb_open *io_open;
|
||||
|
||||
c = talloc_zero(tree, struct smbcli_composite);
|
||||
if (c == NULL) goto failed;
|
||||
|
||||
c->state = SMBCLI_REQUEST_SEND;
|
||||
c->stage = SAVEFILE_OPEN;
|
||||
c->composite_parms = io;
|
||||
c->event_ctx = tree->session->transport->socket->event.ctx;
|
||||
|
||||
state = talloc(c, struct savefile_state);
|
||||
if (state == NULL) goto failed;
|
||||
|
||||
state->total_written = 0;
|
||||
state->io = io;
|
||||
|
||||
/* setup for the open */
|
||||
io_open = talloc_zero(c, union smb_open);
|
||||
@ -250,6 +252,7 @@ struct smbcli_composite *smb_composite_savefile_send(struct smbcli_tree *tree,
|
||||
io_open->ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
|
||||
io_open->ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
|
||||
io_open->ntcreatex.in.fname = io->in.fname;
|
||||
state->io_open = io_open;
|
||||
|
||||
/* send the open on its way */
|
||||
req = smb_raw_open_send(tree, io_open);
|
||||
@ -258,7 +261,6 @@ struct smbcli_composite *smb_composite_savefile_send(struct smbcli_tree *tree,
|
||||
/* setup the callback handler */
|
||||
req->async.fn = savefile_handler;
|
||||
req->async.private = c;
|
||||
c->req_parms = io_open;
|
||||
c->private = state;
|
||||
c->req = req;
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
struct sesssetup_state {
|
||||
union smb_sesssetup setup;
|
||||
NTSTATUS session_key_err;
|
||||
struct smb_composite_sesssetup *io;
|
||||
};
|
||||
|
||||
|
||||
@ -93,7 +94,6 @@ static void request_handler(struct smbcli_request *req)
|
||||
{
|
||||
struct smbcli_composite *c = req->async.private;
|
||||
struct sesssetup_state *state = c->private;
|
||||
struct smb_composite_sesssetup *io = c->composite_parms;
|
||||
struct smbcli_session *session = req->session;
|
||||
DATA_BLOB session_key = data_blob(NULL, 0);
|
||||
DATA_BLOB null_data_blob = data_blob(NULL, 0);
|
||||
@ -102,15 +102,15 @@ static void request_handler(struct smbcli_request *req)
|
||||
|
||||
switch (state->setup.old.level) {
|
||||
case RAW_SESSSETUP_OLD:
|
||||
io->out.vuid = state->setup.old.out.vuid;
|
||||
state->io->out.vuid = state->setup.old.out.vuid;
|
||||
break;
|
||||
|
||||
case RAW_SESSSETUP_NT1:
|
||||
io->out.vuid = state->setup.nt1.out.vuid;
|
||||
state->io->out.vuid = state->setup.nt1.out.vuid;
|
||||
break;
|
||||
|
||||
case RAW_SESSSETUP_SPNEGO:
|
||||
session->vuid = io->out.vuid = state->setup.spnego.out.vuid;
|
||||
session->vuid = state->io->out.vuid = state->setup.spnego.out.vuid;
|
||||
if (!NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED) &&
|
||||
!NT_STATUS_IS_OK(c->status)) {
|
||||
break;
|
||||
@ -142,7 +142,7 @@ static void request_handler(struct smbcli_request *req)
|
||||
}
|
||||
|
||||
/* enforce the local signing required flag */
|
||||
if (NT_STATUS_IS_OK(c->status) && io->in.user && io->in.user[0]) {
|
||||
if (NT_STATUS_IS_OK(c->status) && state->io->in.user && state->io->in.user[0]) {
|
||||
if (!session->transport->negotiate.sign_info.doing_signing
|
||||
&& session->transport->negotiate.sign_info.mandatory_signing) {
|
||||
DEBUG(0, ("SMB signing required, but server does not support it\n"));
|
||||
@ -346,11 +346,11 @@ struct smbcli_composite *smb_composite_sesssetup_send(struct smbcli_session *ses
|
||||
state = talloc(c, struct sesssetup_state);
|
||||
if (state == NULL) goto failed;
|
||||
|
||||
state->io = io;
|
||||
|
||||
c->state = SMBCLI_REQUEST_SEND;
|
||||
c->req_parms = io;
|
||||
c->private = state;
|
||||
c->event_ctx = session->transport->socket->event.ctx;
|
||||
c->composite_parms = io;
|
||||
|
||||
/* no session setup at all in earliest protocol varients */
|
||||
if (session->transport->negotiate.protocol < PROTOCOL_LANMAN1) {
|
||||
|
Loading…
Reference in New Issue
Block a user