summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/globals.h3
-rw-r--r--source3/smbd/oplock.c87
-rw-r--r--source3/smbd/process.c6
-rw-r--r--source3/smbd/smb2_break.c9
4 files changed, 59 insertions, 46 deletions
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 3b58cb4ef3..f9fd71ed75 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -320,6 +320,9 @@ NTSTATUS smbd_smb2_request_process_getinfo(struct smbd_smb2_request *req);
NTSTATUS smbd_smb2_request_process_setinfo(struct smbd_smb2_request *req);
NTSTATUS smbd_smb2_request_process_break(struct smbd_smb2_request *req);
+void send_smb2_break_message(files_struct *fsp, uint8_t level);
+void schedule_deferred_open_smb2_message(uint16 mid);
+
struct smbd_smb2_request {
struct smbd_smb2_request *prev, *next;
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index f3034bd739..e876e8c286 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -214,7 +214,7 @@ bool should_notify_deferred_opens()
Set up an oplock break message.
****************************************************************************/
-static char *new_break_smb_message(TALLOC_CTX *mem_ctx,
+static char *new_break_smb1_message(TALLOC_CTX *mem_ctx,
files_struct *fsp, uint8 cmd)
{
char *result = TALLOC_ARRAY(mem_ctx, char, smb_size + 8*2 + 0);
@@ -354,9 +354,30 @@ static void add_oplock_timeout_handler(files_struct *fsp)
}
}
+static void send_smb1_break_message(files_struct *fsp, uint8_t level)
+{
+ char *break_msg = new_break_smb1_message(talloc_tos(),
+ fsp,
+ level);
+ if (break_msg == NULL) {
+ exit_server("Could not talloc break_msg\n");
+ }
+
+ show_msg(break_msg);
+ if (!srv_send_smb(smbd_server_fd(),
+ break_msg, false, 0,
+ IS_CONN_ENCRYPTED(fsp->conn),
+ NULL)) {
+ exit_server_cleanly("send_smb1_break_message: "
+ "srv_send_smb failed.");
+ }
+
+ TALLOC_FREE(break_msg);
+}
+
void break_level2_to_none_async(files_struct *fsp)
{
- char *break_msg;
+ struct smbd_server_connection *sconn = smbd_server_conn;
if (fsp->oplock_type == NO_OPLOCK) {
/* We already got a "break to none" message and we've handled
@@ -382,24 +403,14 @@ void break_level2_to_none_async(files_struct *fsp)
fsp_str_dbg(fsp)));
/* Now send a break to none message to our client. */
- break_msg = new_break_smb_message(NULL, fsp, OPLOCKLEVEL_NONE);
- if (break_msg == NULL) {
- exit_server("Could not talloc break_msg\n");
- }
-
- show_msg(break_msg);
- if (!srv_send_smb(smbd_server_fd(),
- break_msg, false, 0,
- IS_CONN_ENCRYPTED(fsp->conn),
- NULL)) {
- exit_server_cleanly("oplock_break: srv_send_smb failed.");
+ if (sconn->allow_smb2) {
+ send_smb2_break_message(fsp, OPLOCKLEVEL_NONE);
+ } else {
+ send_smb1_break_message(fsp, OPLOCKLEVEL_NONE);
}
- TALLOC_FREE(break_msg);
-
/* Async level2 request, don't send a reply, just remove the oplock. */
remove_oplock(fsp);
-
}
/*******************************************************************
@@ -459,9 +470,9 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
struct server_id src,
DATA_BLOB *data)
{
+ struct smbd_server_connection *sconn = smbd_server_conn;
struct share_mode_entry msg;
files_struct *fsp;
- char *break_msg;
bool break_to_level2 = False;
if (data->data == NULL) {
@@ -525,27 +536,20 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
break_to_level2 = True;
}
- break_msg = new_break_smb_message(NULL, fsp, break_to_level2 ?
- OPLOCKLEVEL_II : OPLOCKLEVEL_NONE);
- if (break_msg == NULL) {
- exit_server("Could not talloc break_msg\n");
- }
-
- /* Need to wait before sending a break message if we sent ourselves this message. */
+ /* Need to wait before sending a break
+ message if we sent ourselves this message. */
if (procid_is_me(&src)) {
wait_before_sending_break();
}
- show_msg(break_msg);
- if (!srv_send_smb(smbd_server_fd(),
- break_msg, false, 0,
- IS_CONN_ENCRYPTED(fsp->conn),
- NULL)) {
- exit_server_cleanly("oplock_break: srv_send_smb failed.");
+ if (sconn->allow_smb2) {
+ send_smb2_break_message(fsp, break_to_level2 ?
+ OPLOCKLEVEL_II : OPLOCKLEVEL_NONE);
+ } else {
+ send_smb1_break_message(fsp, break_to_level2 ?
+ OPLOCKLEVEL_II : OPLOCKLEVEL_NONE);
}
- TALLOC_FREE(break_msg);
-
fsp->sent_oplock_break = break_to_level2 ? LEVEL_II_BREAK_SENT:BREAK_TO_NONE_SENT;
msg.pid = src;
@@ -566,10 +570,10 @@ static void process_kernel_oplock_break(struct messaging_context *msg_ctx,
struct server_id src,
DATA_BLOB *data)
{
+ struct smbd_server_connection *sconn = smbd_server_conn;
struct file_id id;
unsigned long file_id;
files_struct *fsp;
- char *break_msg;
if (data->data == NULL) {
DEBUG(0, ("Got NULL buffer\n"));
@@ -604,21 +608,12 @@ static void process_kernel_oplock_break(struct messaging_context *msg_ctx,
return;
}
- break_msg = new_break_smb_message(NULL, fsp, OPLOCKLEVEL_NONE);
- if (break_msg == NULL) {
- exit_server("Could not talloc break_msg\n");
- }
-
- show_msg(break_msg);
- if (!srv_send_smb(smbd_server_fd(),
- break_msg, false, 0,
- IS_CONN_ENCRYPTED(fsp->conn),
- NULL)) {
- exit_server_cleanly("oplock_break: srv_send_smb failed.");
+ if (sconn->allow_smb2) {
+ send_smb2_break_message(fsp, OPLOCKLEVEL_NONE);
+ } else {
+ send_smb1_break_message(fsp, OPLOCKLEVEL_NONE);
}
- TALLOC_FREE(break_msg);
-
fsp->sent_oplock_break = BREAK_TO_NONE_SENT;
add_oplock_timeout_handler(fsp);
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 485439a089..3e5cee83c5 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -623,9 +623,15 @@ void remove_deferred_open_smb_message(uint16 mid)
void schedule_deferred_open_smb_message(uint16 mid)
{
+ struct smbd_server_connection *sconn = smbd_server_conn;
struct pending_message_list *pml;
int i = 0;
+ if (sconn->allow_smb2) {
+ schedule_deferred_open_smb2_message(mid);
+ return;
+ }
+
for (pml = deferred_open_queue; pml; pml = pml->next) {
uint16 msg_mid = SVAL(pml->buf.data,smb_mid);
diff --git a/source3/smbd/smb2_break.c b/source3/smbd/smb2_break.c
index 879d59f89e..5057fc1fc1 100644
--- a/source3/smbd/smb2_break.c
+++ b/source3/smbd/smb2_break.c
@@ -208,3 +208,12 @@ static NTSTATUS smbd_smb2_oplock_break_recv(struct tevent_req *req,
tevent_req_received(req);
return NT_STATUS_OK;
}
+
+void send_smb2_break_message(files_struct *fsp, uint8_t level)
+{
+}
+
+void schedule_deferred_open_smb2_message(uint16 mid)
+{
+ /* FIXME - mid needs to be uint64_t. */
+}