summaryrefslogtreecommitdiff
path: root/source4/smb_server
diff options
context:
space:
mode:
Diffstat (limited to 'source4/smb_server')
-rw-r--r--source4/smb_server/smb2/config.mk3
-rw-r--r--source4/smb_server/smb2/fileio.c15
-rw-r--r--source4/smb_server/smb2/negprot.c2
-rw-r--r--source4/smb_server/smb2/receive.c17
-rw-r--r--source4/smb_server/smb2/sesssetup.c57
5 files changed, 82 insertions, 12 deletions
diff --git a/source4/smb_server/smb2/config.mk b/source4/smb_server/smb2/config.mk
index 105b646e31..6117c1e43a 100644
--- a/source4/smb_server/smb2/config.mk
+++ b/source4/smb_server/smb2/config.mk
@@ -7,7 +7,8 @@ ADD_OBJ_FILES = \
negprot.o \
sesssetup.o \
tcon.o \
- fileio.o
+ fileio.o \
+ keepalive.o
REQUIRED_SUBSYSTEMS = \
NTVFS LIBPACKET LIBCLI_SMB2
# End SUBSYSTEM SMB2_PROTOCOL
diff --git a/source4/smb_server/smb2/fileio.c b/source4/smb_server/smb2/fileio.c
index 63b02de2c6..ea09c3ce9b 100644
--- a/source4/smb_server/smb2/fileio.c
+++ b/source4/smb_server/smb2/fileio.c
@@ -33,6 +33,11 @@ void smb2srv_close_recv(struct smb2srv_request *req)
smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED);
}
+void smb2srv_flush_recv(struct smb2srv_request *req)
+{
+ smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED);
+}
+
void smb2srv_read_recv(struct smb2srv_request *req)
{
smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED);
@@ -43,6 +48,16 @@ void smb2srv_write_recv(struct smb2srv_request *req)
smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED);
}
+void smb2srv_lock_recv(struct smb2srv_request *req)
+{
+ smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED);
+}
+
+void smb2srv_ioctl_recv(struct smb2srv_request *req)
+{
+ smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED);
+}
+
void smb2srv_cancel_recv(struct smb2srv_request *req)
{
smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED);
diff --git a/source4/smb_server/smb2/negprot.c b/source4/smb_server/smb2/negprot.c
index 630f38b159..71e86ad805 100644
--- a/source4/smb_server/smb2/negprot.c
+++ b/source4/smb_server/smb2/negprot.c
@@ -123,8 +123,6 @@ static void smb2srv_negprot_send(struct smb2srv_request *req, struct smb2_negpro
return;
}
- SIVAL(req->out.hdr, SMB2_HDR_STATUS, NT_STATUS_V(req->status));
-
SSVAL(req->out.body, 0x02, io->out._pad);
SIVAL(req->out.body, 0x04, io->out.unknown2);
memcpy(req->out.body+0x08, io->out.sessid, 16);
diff --git a/source4/smb_server/smb2/receive.c b/source4/smb_server/smb2/receive.c
index 9afa10463f..7544e0be3e 100644
--- a/source4/smb_server/smb2/receive.c
+++ b/source4/smb_server/smb2/receive.c
@@ -56,7 +56,7 @@ NTSTATUS smb2srv_setup_reply(struct smb2srv_request *req, uint_t body_fixed_size
SIVAL(req->out.hdr, 0, SMB2_MAGIC);
SSVAL(req->out.hdr, SMB2_HDR_LENGTH, SMB2_HDR_BODY);
SSVAL(req->out.hdr, SMB2_HDR_PAD1, 0);
- SIVAL(req->out.hdr, SMB2_HDR_STATUS, 0);
+ SIVAL(req->out.hdr, SMB2_HDR_STATUS, NT_STATUS_V(req->status));
SSVAL(req->out.hdr, SMB2_HDR_OPCODE, SVAL(req->in.hdr, SMB2_HDR_OPCODE));
SSVAL(req->out.hdr, SMB2_HDR_PAD2, 0);
SIVAL(req->out.hdr, SMB2_HDR_FLAGS, 0x00000001);
@@ -133,6 +133,9 @@ static NTSTATUS smb2srv_reply(struct smb2srv_request *req)
case SMB2_OP_SESSSETUP:
smb2srv_sesssetup_recv(req);
return NT_STATUS_OK;
+ case SMB2_OP_LOGOFF:
+ smb2srv_logoff_recv(req);
+ return NT_STATUS_OK;
case SMB2_OP_TCON:
smb2srv_tcon_recv(req);
return NT_STATUS_OK;
@@ -145,15 +148,27 @@ static NTSTATUS smb2srv_reply(struct smb2srv_request *req)
case SMB2_OP_CLOSE:
smb2srv_close_recv(req);
return NT_STATUS_OK;
+ case SMB2_OP_FLUSH:
+ smb2srv_flush_recv(req);
+ return NT_STATUS_OK;
case SMB2_OP_READ:
smb2srv_read_recv(req);
return NT_STATUS_OK;
case SMB2_OP_WRITE:
smb2srv_write_recv(req);
return NT_STATUS_OK;
+ case SMB2_OP_LOCK:
+ smb2srv_lock_recv(req);
+ return NT_STATUS_OK;
+ case SMB2_OP_IOCTL:
+ smb2srv_ioctl_recv(req);
+ return NT_STATUS_OK;
case SMB2_OP_CANCEL:
smb2srv_cancel_recv(req);
return NT_STATUS_OK;
+ case SMB2_OP_KEEPALIVE:
+ smb2srv_keepalive_recv(req);
+ return NT_STATUS_OK;
case SMB2_OP_FIND:
smb2srv_find_recv(req);
return NT_STATUS_OK;
diff --git a/source4/smb_server/smb2/sesssetup.c b/source4/smb_server/smb2/sesssetup.c
index af0c074dac..7915590464 100644
--- a/source4/smb_server/smb2/sesssetup.c
+++ b/source4/smb_server/smb2/sesssetup.c
@@ -27,13 +27,6 @@
#include "smb_server/smb2/smb2_server.h"
#include "smbd/service_stream.h"
-struct smb2srv_session {
- struct smb2srv_session *prev,*next;
- uint64_t uid;
- struct gensec_security *gensec_ctx;
- struct auth_session_info *session_info;
-};
-
static NTSTATUS smb2srv_sesssetup_backend(struct smb2srv_request *req, struct smb2_session_setup *io)
{
NTSTATUS status = NT_STATUS_ACCESS_DENIED;
@@ -134,7 +127,6 @@ static void smb2srv_sesssetup_send(struct smb2srv_request *req, struct smb2_sess
return;
}
- SIVAL(req->out.hdr, SMB2_HDR_STATUS, NT_STATUS_V(req->status));
SBVAL(req->out.hdr, SMB2_HDR_UID, io->out.uid);
SSVAL(req->out.body, 0x02, io->out._pad);
@@ -183,3 +175,52 @@ void smb2srv_sesssetup_recv(struct smb2srv_request *req)
}
smb2srv_sesssetup_send(req, io);
}
+
+static NTSTATUS smb2srv_logoff_backend(struct smb2srv_request *req)
+{
+ /* TODO: call ntvfs backends to close file of this session */
+ talloc_free(req->session);
+ req->session = NULL;
+ return NT_STATUS_OK;
+}
+
+static void smb2srv_logoff_send(struct smb2srv_request *req)
+{
+ NTSTATUS status;
+
+ if (NT_STATUS_IS_ERR(req->status)) {
+ smb2srv_send_error(req, req->status);
+ return;
+ }
+
+ status = smb2srv_setup_reply(req, 0x04, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
+ talloc_free(req);
+ return;
+ }
+
+ SSVAL(req->out.body, 0x02, 0);
+
+ smb2srv_send_reply(req);
+}
+
+void smb2srv_logoff_recv(struct smb2srv_request *req)
+{
+ uint16_t _pad;
+
+ if (req->in.body_size < 0x04) {
+ smb2srv_send_error(req, NT_STATUS_FOOBAR);
+ return;
+ }
+
+ _pad = SVAL(req->in.body, 0x02);
+
+ req->status = smb2srv_logoff_backend(req);
+
+ if (req->control_flags & SMB2SRV_REQ_CTRL_FLAG_NOT_REPLY) {
+ talloc_free(req);
+ return;
+ }
+ smb2srv_logoff_send(req);
+}