1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

r12092: - add dummy functions for the missing SMB2 opcodes

- implement keepalive and logoff

metze
This commit is contained in:
Stefan Metzmacher 2005-12-06 13:26:24 +00:00 committed by Gerald (Jerry) Carter
parent 436c5127ef
commit 859ab627f4
5 changed files with 82 additions and 12 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);
}