#include "libcli/composite/composite.h"
#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
-#include "libcli/raw/ioctl.h"
+#include "../libcli/smb/smb_constants.h"
#include "librpc/rpc/dcerpc.h"
#include "librpc/rpc/dcerpc_proto.h"
+#include "librpc/rpc/rpc_common.h"
/* transport private information used by SMB2 pipe transport */
struct smb2_private {
/*
tell the dcerpc layer that the transport is dead
*/
-static void pipe_dead(struct dcerpc_connection *c, NTSTATUS status)
+static void pipe_dead(struct dcecli_connection *c, NTSTATUS status)
{
struct smb2_private *smb = (struct smb2_private *)c->transport.private_data;
this holds the state of an in-flight call
*/
struct smb2_read_state {
- struct dcerpc_connection *c;
+ struct dcecli_connection *c;
DATA_BLOB data;
};
*/
static void smb2_read_callback(struct smb2_request *req)
{
+ struct dcecli_connection *c;
struct smb2_private *smb;
struct smb2_read_state *state;
struct smb2_read io;
state = talloc_get_type(req->async.private_data, struct smb2_read_state);
smb = talloc_get_type(state->c->transport.private_data, struct smb2_private);
+ c = state->c;
status = smb2_read_recv(req, state, &io);
if (NT_STATUS_IS_ERR(status)) {
- pipe_dead(state->c, status);
talloc_free(state);
+ pipe_dead(c, status);
return;
}
if (!data_blob_append(state, &state->data,
io.out.data.data, io.out.data.length)) {
- pipe_dead(state->c, NT_STATUS_NO_MEMORY);
talloc_free(state);
+ pipe_dead(c, NT_STATUS_NO_MEMORY);
return;
}
if (state->data.length < 16) {
DEBUG(0,("dcerpc_smb2: short packet (length %d) in read callback!\n",
(int)state->data.length));
- pipe_dead(state->c, NT_STATUS_INFO_LENGTH_MISMATCH);
talloc_free(state);
+ pipe_dead(c, NT_STATUS_INFO_LENGTH_MISMATCH);
return;
}
if (frag_length <= state->data.length) {
DATA_BLOB data = state->data;
- struct dcerpc_connection *c = state->c;
talloc_steal(c, data.data);
talloc_free(state);
c->transport.recv_data(c, &data, NT_STATUS_OK);
req = smb2_read_send(smb->tree, &io);
if (req == NULL) {
- pipe_dead(state->c, NT_STATUS_NO_MEMORY);
talloc_free(state);
+ pipe_dead(c, NT_STATUS_NO_MEMORY);
return;
}
trigger a read request from the server, possibly with some initial
data in the read buffer
*/
-static NTSTATUS send_read_request_continue(struct dcerpc_connection *c, DATA_BLOB *blob)
+static NTSTATUS send_read_request_continue(struct dcecli_connection *c, DATA_BLOB *blob)
{
struct smb2_private *smb = (struct smb2_private *)c->transport.private_data;
struct smb2_read io;
struct smb2_read_state *state;
struct smb2_request *req;
- state = talloc(smb, struct smb2_read_state);
+ state = talloc(c, struct smb2_read_state);
if (state == NULL) {
return NT_STATUS_NO_MEMORY;
}
/*
trigger a read request from the server
*/
-static NTSTATUS send_read_request(struct dcerpc_connection *c)
+static NTSTATUS send_read_request(struct dcecli_connection *c)
{
struct smb2_private *smb = (struct smb2_private *)c->transport.private_data;
this holds the state of an in-flight trans call
*/
struct smb2_trans_state {
- struct dcerpc_connection *c;
+ struct dcecli_connection *c;
};
/*
{
struct smb2_trans_state *state = talloc_get_type(req->async.private_data,
struct smb2_trans_state);
- struct dcerpc_connection *c = state->c;
+ struct dcecli_connection *c = state->c;
NTSTATUS status;
struct smb2_ioctl io;
/*
send a SMBtrans style request, using a named pipe read_write fsctl
*/
-static NTSTATUS smb2_send_trans_request(struct dcerpc_connection *c, DATA_BLOB *blob)
+static NTSTATUS smb2_send_trans_request(struct dcecli_connection *c, DATA_BLOB *blob)
{
struct smb2_private *smb = talloc_get_type(c->transport.private_data,
struct smb2_private);
ZERO_STRUCT(io);
io.in.file.handle = smb->handle;
io.in.function = FSCTL_NAMED_PIPE_READ_WRITE;
- io.in.max_response_size = 0x1000;
+ io.in.max_response_size = 0x2000;
io.in.flags = 1;
io.in.out = *blob;
*/
static void smb2_write_callback(struct smb2_request *req)
{
- struct dcerpc_connection *c = (struct dcerpc_connection *)req->async.private_data;
+ struct dcecli_connection *c = (struct dcecli_connection *)req->async.private_data;
if (!NT_STATUS_IS_OK(req->status)) {
DEBUG(0,("dcerpc_smb2: write callback error\n"));
/*
send a packet to the server
*/
-static NTSTATUS smb2_send_request(struct dcerpc_connection *c, DATA_BLOB *blob,
+static NTSTATUS smb2_send_request(struct dcecli_connection *c, DATA_BLOB *blob,
bool trigger_read)
{
struct smb2_private *smb = (struct smb2_private *)c->transport.private_data;
return NT_STATUS_OK;
}
+static void free_request(struct smb2_request *req)
+{
+ talloc_free(req);
+}
+
/*
shutdown SMB pipe connection
*/
-static NTSTATUS smb2_shutdown_pipe(struct dcerpc_connection *c, NTSTATUS status)
+static NTSTATUS smb2_shutdown_pipe(struct dcecli_connection *c, NTSTATUS status)
{
struct smb2_private *smb = (struct smb2_private *)c->transport.private_data;
struct smb2_close io;
req = smb2_close_send(smb->tree, &io);
if (req != NULL) {
/* we don't care if this fails, so just free it if it succeeds */
- req->async.fn = (void (*)(struct smb2_request *))talloc_free;
+ req->async.fn = free_request;
}
talloc_free(smb);
/*
return SMB server name
*/
-static const char *smb2_peer_name(struct dcerpc_connection *c)
+static const char *smb2_peer_name(struct dcecli_connection *c)
{
struct smb2_private *smb = talloc_get_type(c->transport.private_data,
struct smb2_private);
/*
return remote name we make the actual connection (good for kerberos)
*/
-static const char *smb2_target_hostname(struct dcerpc_connection *c)
+static const char *smb2_target_hostname(struct dcecli_connection *c)
{
struct smb2_private *smb = talloc_get_type(c->transport.private_data,
struct smb2_private);
/*
fetch the user session key
*/
-static NTSTATUS smb2_session_key(struct dcerpc_connection *c, DATA_BLOB *session_key)
+static NTSTATUS smb2_session_key(struct dcecli_connection *c, DATA_BLOB *session_key)
{
struct smb2_private *smb = talloc_get_type(c->transport.private_data,
struct smb2_private);
}
struct pipe_open_smb2_state {
- struct dcerpc_connection *c;
+ struct dcecli_connection *c;
struct composite_context *ctx;
};
struct pipe_open_smb2_state *state;
struct smb2_create io;
struct smb2_request *req;
- struct dcerpc_connection *c = p->conn;
+ struct dcecli_connection *c = p->conn;
ctx = composite_create(c, c->event_ctx);
if (ctx == NULL) return NULL;
io.in.create_disposition = NTCREATEX_DISP_OPEN;
io.in.create_options =
NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
- NTCREATEX_OPTIONS_UNKNOWN_400000;
+ NTCREATEX_OPTIONS_NO_RECALL;
io.in.impersonation_level = NTCREATEX_IMPERSONATION_IMPERSONATION;
if ((strncasecmp(pipe_name, "/pipe/", 6) == 0) ||
talloc_get_type(req->async.private_data,
struct pipe_open_smb2_state);
struct composite_context *ctx = state->ctx;
- struct dcerpc_connection *c = state->c;
+ struct dcecli_connection *c = state->c;
struct smb2_tree *tree = req->tree;
struct smb2_private *smb;
struct smb2_create io;
/*
return the SMB2 tree used for a dcerpc over SMB2 pipe
*/
-struct smb2_tree *dcerpc_smb2_tree(struct dcerpc_connection *c)
+struct smb2_tree *dcerpc_smb2_tree(struct dcecli_connection *c)
{
struct smb2_private *smb = talloc_get_type(c->transport.private_data,
struct smb2_private);