summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/lib/util.c2
-rw-r--r--source4/ntvfs/cifs/vfs_cifs.c8
-rw-r--r--source4/ntvfs/ipc/vfs_ipc.c2
-rw-r--r--source4/ntvfs/ntvfs_generic.c2
-rw-r--r--source4/param/loadparm.c2
-rw-r--r--source4/smb_server/conn.c42
-rw-r--r--source4/smb_server/connection.c2
-rw-r--r--source4/smb_server/negprot.c106
-rw-r--r--source4/smb_server/password.c8
-rw-r--r--source4/smb_server/reply.c42
-rw-r--r--source4/smb_server/request.c18
-rw-r--r--source4/smb_server/search.c2
-rw-r--r--source4/smb_server/service.c16
-rw-r--r--source4/smb_server/session.c2
-rw-r--r--source4/smb_server/sesssetup.c22
-rw-r--r--source4/smb_server/signing.c24
-rw-r--r--source4/smb_server/smb_server.c88
-rw-r--r--source4/smb_server/smb_server.h308
-rw-r--r--source4/smb_server/srvtime.c12
-rw-r--r--source4/smb_server/trans2.c30
-rw-r--r--source4/smbd/process_model.c2
-rw-r--r--source4/smbd/process_model.h4
-rw-r--r--source4/smbd/process_single.c6
-rw-r--r--source4/smbd/process_standard.c6
-rw-r--r--source4/smbd/process_thread.c4
-rw-r--r--source4/smbd/rewrite.c2
26 files changed, 369 insertions, 393 deletions
diff --git a/source4/lib/util.c b/source4/lib/util.c
index 7fb51710a0..ee637aeaad 100644
--- a/source4/lib/util.c
+++ b/source4/lib/util.c
@@ -640,7 +640,7 @@ BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
Set the remote_arch string based on an enum. This is used in places
where we desperately need to distinguish client type.
********************************************************************/
-void set_remote_arch(struct smbsrv_context *smb, enum remote_arch_types type)
+void set_remote_arch(struct smbsrv_connection *smb, enum remote_arch_types type)
{
const char *arch;
diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c
index b0389b9e59..93b9f2630e 100644
--- a/source4/ntvfs/cifs/vfs_cifs.c
+++ b/source4/ntvfs/cifs/vfs_cifs.c
@@ -51,8 +51,8 @@ struct async_info {
static void idle_func(struct cli_transport *transport, void *p_private)
{
struct cvfs_private *private = p_private;
- if (socket_pending(private->tcon->smb_ctx->socket.fd)) {
- smbd_process_async(private->tcon->smb_ctx);
+ if (socket_pending(private->tcon->smb_conn->socket.fd)) {
+ smbd_process_async(private->tcon->smb_conn);
}
}
@@ -164,7 +164,7 @@ static NTSTATUS cvfs_connect(struct smbsrv_request *req, const char *sharename)
fde.private = private;
fde.handler = cifs_socket_handler;
- event_add_fd(tcon->smb_ctx->events, &fde);
+ event_add_fd(tcon->smb_conn->events, &fde);
/* we need to receive oplock break requests from the server */
cli_oplock_handler(private->transport, oplock_handler, private);
@@ -180,7 +180,7 @@ static NTSTATUS cvfs_disconnect(struct smbsrv_tcon *tcon)
{
struct cvfs_private *private = tcon->ntvfs_private;
- event_remove_fd_all(tcon->smb_ctx->events, private->transport->socket->fd);
+ event_remove_fd_all(tcon->smb_conn->events, private->transport->socket->fd);
smb_tree_disconnect(private->tree);
cli_tree_close(private->tree);
diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c
index 8d3eaa2bb4..cf8b49ebb8 100644
--- a/source4/ntvfs/ipc/vfs_ipc.c
+++ b/source4/ntvfs/ipc/vfs_ipc.c
@@ -249,7 +249,7 @@ static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname,
session_info = req->user_ctx->vuser->session_info;
}
- status = dcesrv_endpoint_search_connect(&req->smb_ctx->dcesrv,
+ status = dcesrv_endpoint_search_connect(&req->smb_conn->dcesrv,
&ep_description,
session_info,
&p->dce_conn);
diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c
index ba2ec344f4..36cbcabbd5 100644
--- a/source4/ntvfs/ntvfs_generic.c
+++ b/source4/ntvfs/ntvfs_generic.c
@@ -290,7 +290,7 @@ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs)
(fs2.generic.out.blocks_free * (double)fs2.generic.out.block_size) / (bpunit * 512);
/* we must return a maximum of 2G to old DOS systems, or they get very confused */
- if (bpunit > 64 && req->smb_ctx->negotiate.protocol <= PROTOCOL_LANMAN2) {
+ if (bpunit > 64 && req->smb_conn->negotiate.protocol <= PROTOCOL_LANMAN2) {
fs->dskattr.out.blocks_per_unit = 64;
fs->dskattr.out.units_total = 0xFFFF;
fs->dskattr.out.units_free = 0xFFFF;
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index c3d4c6c8dd..68a16501d2 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -3039,7 +3039,7 @@ BOOL lp_loaded(void)
Unload unused services.
***************************************************************************/
-void lp_killunused(struct smbsrv_context *smb, BOOL (*snumused) (struct smbsrv_context *, int))
+void lp_killunused(struct smbsrv_connection *smb, BOOL (*snumused) (struct smbsrv_connection *, int))
{
int i;
for (i = 0; i < iNumServices; i++) {
diff --git a/source4/smb_server/conn.c b/source4/smb_server/conn.c
index e275854325..197d925f34 100644
--- a/source4/smb_server/conn.c
+++ b/source4/smb_server/conn.c
@@ -30,18 +30,18 @@
/****************************************************************************
init the tcon structures
****************************************************************************/
-void conn_init(struct smbsrv_context *smb_ctx)
+void conn_init(struct smbsrv_connection *smb_conn)
{
- smb_ctx->tree.bmap = bitmap_allocate(MAX_CONNECTIONS);
+ smb_conn->tree.bmap = bitmap_allocate(MAX_CONNECTIONS);
}
/****************************************************************************
check if a snum is in use
****************************************************************************/
-BOOL conn_snum_used(struct smbsrv_context *smb_ctx, int snum)
+BOOL conn_snum_used(struct smbsrv_connection *smb_conn, int snum)
{
struct smbsrv_tcon *tcon;
- for (tcon=smb_ctx->tree.tcons;tcon;tcon=tcon->next) {
+ for (tcon=smb_conn->tree.tcons;tcon;tcon=tcon->next) {
if (tcon->service == snum) {
return(True);
}
@@ -53,15 +53,15 @@ BOOL conn_snum_used(struct smbsrv_context *smb_ctx, int snum)
/****************************************************************************
find a tcon given a cnum
****************************************************************************/
-struct smbsrv_tcon *conn_find(struct smbsrv_context *smb_ctx, uint_t cnum)
+struct smbsrv_tcon *conn_find(struct smbsrv_connection *smb_conn, uint_t cnum)
{
int count=0;
struct smbsrv_tcon *tcon;
- for (tcon=smb_ctx->tree.tcons;tcon;tcon=tcon->next,count++) {
+ for (tcon=smb_conn->tree.tcons;tcon;tcon=tcon->next,count++) {
if (tcon->cnum == cnum) {
if (count > 10) {
- DLIST_PROMOTE(smb_ctx->tree.tcons, tcon);
+ DLIST_PROMOTE(smb_conn->tree.tcons, tcon);
}
return tcon;
}
@@ -76,13 +76,13 @@ struct smbsrv_tcon *conn_find(struct smbsrv_context *smb_ctx, uint_t cnum)
The randomisation stops problems with the server dieing and clients
thinking the server is still available.
****************************************************************************/
-struct smbsrv_tcon *conn_new(struct smbsrv_context *smb_ctx)
+struct smbsrv_tcon *conn_new(struct smbsrv_connection *smb_conn)
{
TALLOC_CTX *mem_ctx;
struct smbsrv_tcon *tcon;
int i;
- i = bitmap_find(smb_ctx->tree.bmap, 1);
+ i = bitmap_find(smb_conn->tree.bmap, 1);
if (i == -1) {
DEBUG(1,("ERROR! Out of connection structures\n"));
@@ -98,13 +98,13 @@ struct smbsrv_tcon *conn_new(struct smbsrv_context *smb_ctx)
tcon->mem_ctx = mem_ctx;
tcon->cnum = i;
- tcon->smb_ctx = smb_ctx;
+ tcon->smb_conn = smb_conn;
- bitmap_set(smb_ctx->tree.bmap, i);
+ bitmap_set(smb_conn->tree.bmap, i);
- smb_ctx->tree.num_open++;
+ smb_conn->tree.num_open++;
- DLIST_ADD(smb_ctx->tree.tcons, tcon);
+ DLIST_ADD(smb_conn->tree.tcons, tcon);
return tcon;
}
@@ -112,10 +112,10 @@ struct smbsrv_tcon *conn_new(struct smbsrv_context *smb_ctx)
/****************************************************************************
close all tcon structures
****************************************************************************/
-void conn_close_all(struct smbsrv_context *smb_ctx)
+void conn_close_all(struct smbsrv_connection *smb_conn)
{
struct smbsrv_tcon *tcon, *next;
- for (tcon=smb_ctx->tree.tcons;tcon;tcon=next) {
+ for (tcon=smb_conn->tree.tcons;tcon;tcon=next) {
next=tcon->next;
close_cnum(tcon);
}
@@ -126,12 +126,12 @@ void conn_close_all(struct smbsrv_context *smb_ctx)
/****************************************************************************
clear a vuid out of the validity cache, and as the 'owner' of a connection.
****************************************************************************/
-void conn_clear_vuid_cache(struct smbsrv_context *smb_ctx, uint16_t vuid)
+void conn_clear_vuid_cache(struct smbsrv_connection *smb_conn, uint16_t vuid)
{
struct smbsrv_tcon *tcon;
uint_t i;
- for (tcon=smb_ctx->tree.tcons;tcon;tcon=tcon->next) {
+ for (tcon=smb_conn->tree.tcons;tcon;tcon=tcon->next) {
for (i=0;i<tcon->vuid_cache.entries && i< VUID_CACHE_SIZE;i++) {
if (tcon->vuid_cache.list[i] == vuid) {
tcon->vuid_cache.list[i] = UID_FIELD_INVALID;
@@ -145,12 +145,12 @@ void conn_clear_vuid_cache(struct smbsrv_context *smb_ctx, uint16_t vuid)
Free a tcon structure.
****************************************************************************/
-void conn_free(struct smbsrv_context *smb_ctx, struct smbsrv_tcon *tcon)
+void conn_free(struct smbsrv_connection *smb_conn, struct smbsrv_tcon *tcon)
{
- DLIST_REMOVE(smb_ctx->tree.tcons, tcon);
+ DLIST_REMOVE(smb_conn->tree.tcons, tcon);
- bitmap_clear(smb_ctx->tree.bmap, tcon->cnum);
- smb_ctx->tree.num_open--;
+ bitmap_clear(smb_conn->tree.bmap, tcon->cnum);
+ smb_conn->tree.num_open--;
talloc_destroy(tcon->mem_ctx);
}
diff --git a/source4/smb_server/connection.c b/source4/smb_server/connection.c
index 7757ffe6d6..77f2395d9e 100644
--- a/source4/smb_server/connection.c
+++ b/source4/smb_server/connection.c
@@ -166,7 +166,7 @@ BOOL claim_connection(struct smbsrv_tcon *tcon, const char *name,int max_connect
crec.bcast_msg_flags = msg_flags;
StrnCpy(crec.machine,sub_get_remote_machine(),sizeof(crec.machine)-1);
- StrnCpy(crec.addr,tcon?tcon->smb_ctx->socket.client_addr:"NONE",sizeof(crec.addr)-1);
+ StrnCpy(crec.addr,tcon?tcon->smb_conn->socket.client_addr:"NONE",sizeof(crec.addr)-1);
dbuf.dptr = (char *)&crec;
dbuf.dsize = sizeof(crec);
diff --git a/source4/smb_server/negprot.c b/source4/smb_server/negprot.c
index 83b3cd75e9..f239e6ae81 100644
--- a/source4/smb_server/negprot.c
+++ b/source4/smb_server/negprot.c
@@ -21,20 +21,20 @@
#include "includes.h"
/* initialise the auth_context for this server and return the cryptkey */
-static void get_challenge(struct smbsrv_context *smb_ctx, char buff[8])
+static void get_challenge(struct smbsrv_connection *smb_conn, char buff[8])
{
NTSTATUS nt_status;
const uint8_t *cryptkey;
/* muliple negprots are not premitted */
- if (smb_ctx->negotiate.auth_context) {
+ if (smb_conn->negotiate.auth_context) {
DEBUG(3,("get challenge: is this a secondary negprot? auth_context is non-NULL!\n"));
smb_panic("secondary negprot");
}
DEBUG(10, ("get challenge: creating negprot_global_auth_context\n"));
- nt_status = make_auth_context_subsystem(&smb_ctx->negotiate.auth_context);
+ nt_status = make_auth_context_subsystem(&smb_conn->negotiate.auth_context);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("make_auth_context_subsystem returned %s", nt_errstr(nt_status)));
@@ -42,7 +42,7 @@ static void get_challenge(struct smbsrv_context *smb_ctx, char buff[8])
}
DEBUG(10, ("get challenge: getting challenge\n"));
- cryptkey = smb_ctx->negotiate.auth_context->get_ntlm_challenge(smb_ctx->negotiate.auth_context);
+ cryptkey = smb_conn->negotiate.auth_context->get_ntlm_challenge(smb_conn->negotiate.auth_context);
memcpy(buff, cryptkey, 8);
}
@@ -55,7 +55,7 @@ static void reply_corep(struct smbsrv_request *req, uint16_t choice)
SSVAL(req->out.vwv, VWV(0), choice);
- req->smb_ctx->negotiate.protocol = PROTOCOL_CORE;
+ req->smb_conn->negotiate.protocol = PROTOCOL_CORE;
req_send_reply(req);
}
@@ -82,7 +82,7 @@ static void reply_coreplus(struct smbsrv_request *req, uint16_t choice)
readbraw and writebraw (possibly) */
SSVAL(req->out.vwv, VWV(5), raw);
- req->smb_ctx->negotiate.protocol = PROTOCOL_COREPLUS;
+ req->smb_conn->negotiate.protocol = PROTOCOL_COREPLUS;
req_send_reply(req);
}
@@ -96,17 +96,17 @@ static void reply_lanman1(struct smbsrv_request *req, uint16_t choice)
int secword=0;
time_t t = req->request_time.tv_sec;
- req->smb_ctx->negotiate.encrypted_passwords = lp_encrypted_passwords();
+ req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords();
if (lp_security() != SEC_SHARE)
secword |= NEGOTIATE_SECURITY_USER_LEVEL;
- if (req->smb_ctx->negotiate.encrypted_passwords)
+ if (req->smb_conn->negotiate.encrypted_passwords)
secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE;
- req->smb_ctx->negotiate.protocol = PROTOCOL_LANMAN1;
+ req->smb_conn->negotiate.protocol = PROTOCOL_LANMAN1;
- req_setup_reply(req, 13, req->smb_ctx->negotiate.encrypted_passwords ? 8 : 0);
+ req_setup_reply(req, 13, req->smb_conn->negotiate.encrypted_passwords ? 8 : 0);
/* SMBlockread, SMBwritelock supported. */
SCVAL(req->out.hdr,HDR_FLG,
@@ -114,18 +114,18 @@ static void reply_lanman1(struct smbsrv_request *req, uint16_t choice)
SSVAL(req->out.vwv, VWV(0), choice);
SSVAL(req->out.vwv, VWV(1), secword);
- SSVAL(req->out.vwv, VWV(2), req->smb_ctx->negotiate.max_recv);
+ SSVAL(req->out.vwv, VWV(2), req->smb_conn->negotiate.max_recv);
SSVAL(req->out.vwv, VWV(3), lp_maxmux());
SSVAL(req->out.vwv, VWV(4), 1);
SSVAL(req->out.vwv, VWV(5), raw);
- SIVAL(req->out.vwv, VWV(6), req->smb_ctx->pid);
- srv_push_dos_date(req->smb_ctx, req->out.vwv, VWV(8), t);
- SSVAL(req->out.vwv, VWV(10), req->smb_ctx->negotiate.zone_offset/60);
+ SIVAL(req->out.vwv, VWV(6), req->smb_conn->pid);
+ srv_push_dos_date(req->smb_conn, req->out.vwv, VWV(8), t);
+ SSVAL(req->out.vwv, VWV(10), req->smb_conn->negotiate.zone_offset/60);
/* Create a token value and add it to the outgoing packet. */
- if (req->smb_ctx->negotiate.encrypted_passwords) {
+ if (req->smb_conn->negotiate.encrypted_passwords) {
SSVAL(req->out.vwv, VWV(11), 8);
- get_challenge(req->smb_ctx, req->out.data);
+ get_challenge(req->smb_conn, req->out.data);
}
req_send_reply(req);
@@ -140,33 +140,33 @@ static void reply_lanman2(struct smbsrv_request *req, uint16_t choice)
int secword=0;
time_t t = req->request_time.tv_sec;
- req->smb_ctx->negotiate.encrypted_passwords = lp_encrypted_passwords();
+ req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords();
if (lp_security() != SEC_SHARE)
secword |= NEGOTIATE_SECURITY_USER_LEVEL;
- if (req->smb_ctx->negotiate.encrypted_passwords)
+ if (req->smb_conn->negotiate.encrypted_passwords)
secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE;
- req->smb_ctx->negotiate.protocol = PROTOCOL_LANMAN2;
+ req->smb_conn->negotiate.protocol = PROTOCOL_LANMAN2;
req_setup_reply(req, 13, 0);
SSVAL(req->out.vwv, VWV(0), choice);
SSVAL(req->out.vwv, VWV(1), secword);
- SSVAL(req->out.vwv, VWV(2), req->smb_ctx->negotiate.max_recv);
+ SSVAL(req->out.vwv, VWV(2), req->smb_conn->negotiate.max_recv);
SSVAL(req->out.vwv, VWV(3), lp_maxmux());
SSVAL(req->out.vwv, VWV(4), 1);
SSVAL(req->out.vwv, VWV(5), raw);
- SIVAL(req->out.vwv, VWV(6), req->smb_ctx->pid);
- srv_push_dos_date(req->smb_ctx, req->out.vwv, VWV(8), t);
- SSVAL(req->out.vwv, VWV(10), req->smb_ctx->negotiate.zone_offset/60);
+ SIVAL(req->out.vwv, VWV(6), req->smb_conn->pid);
+ srv_push_dos_date(req->smb_conn, req->out.vwv, VWV(8), t);
+ SSVAL(req->out.vwv, VWV(10), req->smb_conn->negotiate.zone_offset/60);
/* Create a token value and add it to the outgoing packet. */
- if (req->smb_ctx->negotiate.encrypted_passwords) {
+ if (req->smb_conn->negotiate.encrypted_passwords) {
SSVAL(req->out.vwv, VWV(11), 8);
req_grow_data(req, 8);
- get_challenge(req->smb_ctx, req->out.data);
+ get_challenge(req->smb_conn, req->out.data);
}
req_push_str(req, NULL, lp_workgroup(), -1, STR_TERMINATE);
@@ -179,7 +179,7 @@ static void reply_lanman2(struct smbsrv_request *req, uint16_t choice)
/****************************************************************************
Generate the spnego negprot reply blob. Return the number of bytes used.
****************************************************************************/
-static DATA_BLOB negprot_spnego(struct smbsrv_context *smb_ctx)
+static DATA_BLOB negprot_spnego(struct smbsrv_connection *smb_conn)
{
DATA_BLOB blob;
uint8_t guid[16];
@@ -190,7 +190,7 @@ static DATA_BLOB negprot_spnego(struct smbsrv_context *smb_ctx)
const char *OIDs_plain[] = {OID_NTLMSSP, NULL};
char *principal;
- smb_ctx->negotiate.spnego_negotiated = True;
+ smb_conn->negotiate.spnego_negotiated = True;
memset(guid, 0, 16);
safe_strcpy((char *)guid, lp_netbios_name(), 16);
@@ -238,12 +238,12 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
CAP_NT_FIND | CAP_LOCK_AND_READ |
CAP_LEVEL_II_OPLOCKS | CAP_NT_SMBS | CAP_RPC_REMOTE_APIS;
- req->smb_ctx->negotiate.encrypted_passwords = lp_encrypted_passwords();
+ req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords();
/* do spnego in user level security if the client
supports it and we can do encrypted passwords */
- if (req->smb_ctx->negotiate.encrypted_passwords &&
+ if (req->smb_conn->negotiate.encrypted_passwords &&
(lp_security() != SEC_SHARE) &&
lp_use_spnego() &&
(req->flags2 & FLAGS2_EXTENDED_SECURITY)) {
@@ -283,13 +283,13 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
secword |= NEGOTIATE_SECURITY_USER_LEVEL;
}
- if (req->smb_ctx->negotiate.encrypted_passwords) {
+ if (req->smb_conn->negotiate.encrypted_passwords) {
secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE;
}
- req->smb_ctx->signing.signing_state = lp_server_signing();
+ req->smb_conn->signing.signing_state = lp_server_signing();
- switch (req->smb_ctx->signing.signing_state) {
+ switch (req->smb_conn->signing.signing_state) {
case SMB_SIGNING_OFF:
break;
case SMB_SIGNING_SUPPORTED:
@@ -301,7 +301,7 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
break;
}
- req->smb_ctx->negotiate.protocol = PROTOCOL_NT1;
+ req->smb_conn->negotiate.protocol = PROTOCOL_NT1;
req_setup_reply(req, 17, 0);
@@ -314,20 +314,20 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
are offset by 1 byte */
SSVAL(req->out.vwv+1, VWV(1), lp_maxmux());
SSVAL(req->out.vwv+1, VWV(2), 1); /* num vcs */
- SIVAL(req->out.vwv+1, VWV(3), req->smb_ctx->negotiate.max_recv);
+ SIVAL(req->out.vwv+1, VWV(3), req->smb_conn->negotiate.max_recv);
SIVAL(req->out.vwv+1, VWV(5), 0x10000); /* raw size. full 64k */
- SIVAL(req->out.vwv+1, VWV(7), req->smb_ctx->pid); /* session key */
+ SIVAL(req->out.vwv+1, VWV(7), req->smb_conn->pid); /* session key */
SIVAL(req->out.vwv+1, VWV(9), capabilities);
push_nttime(req->out.vwv+1, VWV(11), nttime);
- SSVALS(req->out.vwv+1,VWV(15), req->smb_ctx->negotiate.zone_offset/60);
+ SSVALS(req->out.vwv+1,VWV(15), req->smb_conn->negotiate.zone_offset/60);
if (!negotiate_spnego) {
/* Create a token value and add it to the outgoing packet. */
- if (req->smb_ctx->negotiate.encrypted_passwords) {
+ if (req->smb_conn->negotiate.encrypted_passwords) {
req_grow_data(req, 8);
/* note that we do not send a challenge at all if
we are using plaintext */
- get_challenge(req->smb_ctx, req->out.ptr);
+ get_challenge(req->smb_conn, req->out.ptr);
req->out.ptr += 8;
SCVAL(req->out.vwv+1, VWV(16), 8);
}
@@ -336,13 +336,13 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
DEBUG(3,("not using SPNEGO\n"));
} else {
#if 0
- DATA_BLOB blob = negprot_spnego(req->smb_ctx);
+ DATA_BLOB blob = negprot_spnego(req->smb_conn);
req_grow_data(req, blob.length);
memcpy(req->out.ptr, blob.data, blob.length);
DEBUG(3,("using SPNEGO\n"));
#else
- exit_server(req->smb_ctx, "no SPNEGO please");
+ exit_server(req->smb_conn, "no SPNEGO please");
#endif
}
@@ -449,10 +449,10 @@ void reply_negprot(struct smbsrv_request *req)
char *p;
int arch = ARCH_ALL;
- if (req->smb_ctx->negotiate.done_negprot) {
- exit_server(req->smb_ctx, "multiple negprot's are not permitted");
+ if (req->smb_conn->negotiate.done_negprot) {
+ exit_server(req->smb_conn, "multiple negprot's are not permitted");
}
- req->smb_ctx->negotiate.done_negprot = True;
+ req->smb_conn->negotiate.done_negprot = True;
p = req->in.data + 1;
@@ -485,33 +485,33 @@ void reply_negprot(struct smbsrv_request *req)
switch (arch) {
case ARCH_SAMBA:
- set_remote_arch(req->smb_ctx, RA_SAMBA);
+ set_remote_arch(req->smb_conn, RA_SAMBA);
break;
case ARCH_WFWG:
- set_remote_arch(req->smb_ctx, RA_WFWG);
+ set_remote_arch(req->smb_conn, RA_WFWG);
break;
case ARCH_WIN95:
- set_remote_arch(req->smb_ctx, RA_WIN95);
+ set_remote_arch(req->smb_conn, RA_WIN95);
break;
case ARCH_WINNT:
if (req->flags2==FLAGS2_WIN2K_SIGNATURE)
- set_remote_arch(req->smb_ctx, RA_WIN2K);
+ set_remote_arch(req->smb_conn, RA_WIN2K);
else
- set_remote_arch(req->smb_ctx, RA_WINNT);
+ set_remote_arch(req->smb_conn, RA_WINNT);
break;
case ARCH_WIN2K:
- set_remote_arch(req->smb_ctx, RA_WIN2K);
+ set_remote_arch(req->smb_conn, RA_WIN2K);
break;
case ARCH_OS2:
- set_remote_arch(req->smb_ctx, RA_OS2);
+ set_remote_arch(req->smb_conn, RA_OS2);
break;
default:
- set_remote_arch(req->smb_ctx, RA_UNKNOWN);
+ set_remote_arch(req->smb_conn, RA_UNKNOWN);
break;
}
/* possibly reload - change of architecture */
- reload_services(req->smb_ctx, True);
+ reload_services(req->smb_conn, True);
/* Check for protocols, most desirable first */
for (protocol = 0; supported_protocols[protocol].proto_name; protocol++) {
@@ -531,7 +531,7 @@ void reply_negprot(struct smbsrv_request *req)
if(choice != -1) {
sub_set_remote_proto(supported_protocols[protocol].short_name);
- reload_services(req->smb_ctx, True);
+ reload_services(req->smb_conn, True);
supported_protocols[protocol].proto_reply_fn(req, choice);
DEBUG(3,("Selected protocol %s\n",supported_protocols[protocol].proto_name));
} else {
diff --git a/source4/smb_server/password.c b/source4/smb_server/password.c
index bfd3ebd82b..499023374f 100644
--- a/source4/smb_server/password.c
+++ b/source4/smb_server/password.c
@@ -26,7 +26,7 @@ check if a uid has been validated, and return an pointer to the user_struct
if it has. NULL if not. vuid is biased by an offset. This allows us to
tell random client vuid's (normally zero) from valid vuids.
****************************************************************************/
-struct user_struct *get_valid_user_struct(struct smbsrv_context *smb, uint16_t vuid)
+struct user_struct *get_valid_user_struct(struct smbsrv_connection *smb, uint16_t vuid)
{
user_struct *usp;
int count=0;
@@ -49,7 +49,7 @@ struct user_struct *get_valid_user_struct(struct smbsrv_context *smb, uint16_t v
/****************************************************************************
invalidate a uid
****************************************************************************/
-void invalidate_vuid(struct smbsrv_context *smb, uint16_t vuid)
+void invalidate_vuid(struct smbsrv_connection *smb, uint16_t vuid)
{
user_struct *vuser = get_valid_user_struct(smb, vuid);
@@ -73,7 +73,7 @@ void invalidate_vuid(struct smbsrv_context *smb, uint16_t vuid)
/****************************************************************************
invalidate all vuid entries for this process
****************************************************************************/
-void invalidate_all_vuids(struct smbsrv_context *smb)
+void invalidate_all_vuids(struct smbsrv_connection *smb)
{
user_struct *usp, *next=NULL;
@@ -98,7 +98,7 @@ void invalidate_all_vuids(struct smbsrv_context *smb)
*
*/
-int register_vuid(struct smbsrv_context *smb,
+int register_vuid(struct smbsrv_connection *smb,
struct auth_session_info *session_info,
const char *smb_name)
{
diff --git a/source4/smb_server/reply.c b/source4/smb_server/reply.c
index 0715dc4075..30f1d12352 100644
--- a/source4/smb_server/reply.c
+++ b/source4/smb_server/reply.c
@@ -160,7 +160,7 @@ void reply_tcon_and_X(struct smbsrv_request *req)
}
/* construct reply - two variants */
- if (req->smb_ctx->negotiate.protocol < PROTOCOL_NT1) {
+ if (req->smb_conn->negotiate.protocol < PROTOCOL_NT1) {
req_setup_reply(req, 2, 0);
SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
@@ -277,7 +277,7 @@ static void reply_getatr_send(struct smbsrv_request *req)
req_setup_reply(req, 10, 0);
SSVAL(req->out.vwv, VWV(0), st->getattr.out.attrib);
- srv_push_dos_date3(req->smb_ctx, req->out.vwv, VWV(1), st->getattr.out.write_time);
+ srv_push_dos_date3(req->smb_conn, req->out.vwv, VWV(1), st->getattr.out.write_time);
SIVAL(req->out.vwv, VWV(3), st->getattr.out.size);
REQ_VWV_RESERVED(5, 5);
@@ -327,7 +327,7 @@ void reply_setatr(struct smbsrv_request *req)
st->setattr.level = RAW_SFILEINFO_SETATTR;
st->setattr.in.attrib = SVAL(req->in.vwv, VWV(0));
- st->setattr.in.write_time = srv_pull_dos_date3(req->smb_ctx, req->in.vwv + VWV(1));
+ st->setattr.in.write_time = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(1));
req_pull_ascii4(req, &st->setattr.file.fname, req->in.data, STR_TERMINATE);
@@ -404,7 +404,7 @@ static void reply_open_send(struct smbsrv_request *req)
SSVAL(req->out.vwv, VWV(0), oi->open.out.fnum);
SSVAL(req->out.vwv, VWV(1), oi->open.out.attrib);
- srv_push_dos_date3(req->smb_ctx, req->out.vwv, VWV(2), oi->open.out.write_time);
+ srv_push_dos_date3(req->smb_conn, req->out.vwv, VWV(2), oi->open.out.write_time);
SIVAL(req->out.vwv, VWV(4), oi->open.out.size);
SSVAL(req->out.vwv, VWV(6), oi->open.out.rmode);
@@ -463,7 +463,7 @@ static void reply_open_and_X_send(struct smbsrv_request *req)
SSVAL(req->out.vwv, VWV(1), 0);
SSVAL(req->out.vwv, VWV(2), oi->openx.out.fnum);
SSVAL(req->out.vwv, VWV(3), oi->openx.out.attrib);
- srv_push_dos_date3(req->smb_ctx, req->out.vwv, VWV(4), oi->openx.out.write_time);
+ srv_push_dos_date3(req->smb_conn, req->out.vwv, VWV(4), oi->openx.out.write_time);
SIVAL(req->out.vwv, VWV(6), oi->openx.out.size);
SSVAL(req->out.vwv, VWV(8), oi->openx.out.access);
SSVAL(req->out.vwv, VWV(9), oi->openx.out.ftype);
@@ -496,7 +496,7 @@ void reply_open_and_X(struct smbsrv_request *req)
oi->openx.in.open_mode = SVAL(req->in.vwv, VWV(3));
oi->openx.in.search_attrs = SVAL(req->in.vwv, VWV(4));
oi->openx.in.file_attrs = SVAL(req->in.vwv, VWV(5));
- oi->openx.in.write_time = srv_pull_dos_date3(req->smb_ctx, req->in.vwv + VWV(6));
+ oi->openx.in.write_time = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(6));
oi->openx.in.open_func = SVAL(req->in.vwv, VWV(8));
oi->openx.in.size = IVAL(req->in.vwv, VWV(9));
oi->openx.in.timeout = IVAL(req->in.vwv, VWV(11));
@@ -549,7 +549,7 @@ void reply_mknew(struct smbsrv_request *req)
oi->mknew.level = RAW_OPEN_MKNEW;
oi->mknew.in.attrib = SVAL(req->in.vwv, VWV(0));
- oi->mknew.in.write_time = srv_pull_dos_date3(req->smb_ctx, req->in.vwv + VWV(1));
+ oi->mknew.in.write_time = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(1));
req_pull_ascii4(req, &oi->mknew.in.fname, req->in.data, STR_TERMINATE);
@@ -600,7 +600,7 @@ void reply_ctemp(struct smbsrv_request *req)
oi->ctemp.level = RAW_OPEN_CTEMP;
oi->ctemp.in.attrib = SVAL(req->in.vwv, VWV(0));
- oi->ctemp.in.write_time = srv_pull_dos_date3(req->smb_ctx, req->in.vwv + VWV(1));
+ oi->ctemp.in.write_time = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(1));
/* the filename is actually a directory name, the server provides a filename
in that directory */
@@ -1184,7 +1184,7 @@ void reply_close(struct smbsrv_request *req)
io->close.level = RAW_CLOSE_CLOSE;
io->close.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
- io->close.in.write_time = srv_pull_dos_date3(req->smb_ctx, req->in.vwv + VWV(1));
+ io->close.in.write_time = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(1));
req->async.send_fn = reply_simple_send;
@@ -1231,7 +1231,7 @@ void reply_writeclose(struct smbsrv_request *req)
io->writeclose.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
io->writeclose.in.count = SVAL(req->in.vwv, VWV(1));
io->writeclose.in.offset = IVAL(req->in.vwv, VWV(2));
- io->writeclose.in.mtime = srv_pull_dos_date3(req->smb_ctx, req->in.vwv + VWV(4));
+ io->writeclose.in.mtime = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(4));
io->writeclose.in.data = req->in.data + 1;
/* make sure they gave us the data they promised */
@@ -1446,7 +1446,7 @@ void reply_printqueue_send(struct smbsrv_request *req)
req->out.ptr = req->out.data + 3;
for (i=0;i<lpq->retq.out.count;i++) {
- srv_push_dos_date2(req->smb_ctx, req->out.ptr, 0 , lpq->retq.out.queue[i].time);
+ srv_push_dos_date2(req->smb_conn, req->out.ptr, 0 , lpq->retq.out.queue[i].time);
SCVAL(req->out.ptr, 4, lpq->retq.out.queue[i].status);
SSVAL(req->out.ptr, 5, lpq->retq.out.queue[i].job);
SIVAL(req->out.ptr, 7, lpq->retq.out.queue[i].size);
@@ -1806,9 +1806,9 @@ void reply_setattrE(struct smbsrv_request *req)
info->setattre.level = RAW_SFILEINFO_SETATTRE;
info->setattre.file.fnum = req_fnum(req, req->in.vwv, VWV(0));
- info->setattre.in.create_time = srv_pull_dos_date2(req->smb_ctx, req->in.vwv + VWV(1));
- info->setattre.in.access_time = srv_pull_dos_date2(req->smb_ctx, req->in.vwv + VWV(3));
- info->setattre.in.write_time = srv_pull_dos_date2(req->smb_ctx, req->in.vwv + VWV(5));
+ info->setattre.in.create_time = srv_pull_dos_date2(req->smb_conn, req->in.vwv + VWV(1));
+ info->setattre.in.access_time = srv_pull_dos_date2(req->smb_conn, req->in.vwv + VWV(3));
+ info->setattre.in.write_time = srv_pull_dos_date2(req->smb_conn, req->in.vwv + VWV(5));
req->async.send_fn = reply_simple_send;
@@ -1852,9 +1852,9 @@ static void reply_getattrE_send(struct smbsrv_request *req)
/* setup reply */
req_setup_reply(req, 11, 0);
- srv_push_dos_date2(req->smb_ctx, req->out.vwv, VWV(0), info->getattre.out.create_time);
- srv_push_dos_date2(req->smb_ctx, req->out.vwv, VWV(2), info->getattre.out.access_time);
- srv_push_dos_date2(req->smb_ctx, req->out.vwv, VWV(4), info->getattre.out.write_time);
+ srv_push_dos_date2(req->smb_conn, req->out.vwv, VWV(0), info->getattre.out.create_time);
+ srv_push_dos_date2(req->smb_conn, req->out.vwv, VWV(2), info->getattre.out.access_time);
+ srv_push_dos_date2(req->smb_conn, req->out.vwv, VWV(4), info->getattre.out.write_time);
SIVAL(req->out.vwv, VWV(6), info->getattre.out.size);
SIVAL(req->out.vwv, VWV(8), info->getattre.out.alloc_size);
SSVAL(req->out.vwv, VWV(10), info->getattre.out.attrib);
@@ -2111,7 +2111,7 @@ void reply_ulogoffX(struct smbsrv_request *req)
DEBUG(0,("REWRITE: not closing user files\n"));
}
- invalidate_vuid(req->smb_ctx, vuid);
+ invalidate_vuid(req->smb_conn, vuid);
req_setup_reply(req, 2, 0);
@@ -2298,8 +2298,8 @@ void reply_special(struct smbsrv_request *req)
switch (msg_type) {
case 0x81: /* session request */
- if (req->smb_ctx->negotiate.done_nbt_session) {
- exit_server(req->smb_ctx, "multiple session request not permitted");
+ if (req->smb_conn->negotiate.done_nbt_session) {
+ exit_server(req->smb_conn, "multiple session request not permitted");
}
SCVAL(buf,0,0x82);
@@ -2307,7 +2307,7 @@ void reply_special(struct smbsrv_request *req)
DEBUG(0,("REWRITE: not parsing netbios names in NBT session request!\n"));
- req->smb_ctx->negotiate.done_nbt_session = True;
+ req->smb_conn->negotiate.done_nbt_session = True;
req->out.buffer = buf;
req->out.size = 4;
diff --git a/source4/smb_server/request.c b/source4/smb_server/request.c
index d845a78c0d..3bfe6a4e73 100644
--- a/source4/smb_server/request.c
+++ b/source4/smb_server/request.c
@@ -45,7 +45,7 @@ void req_destroy(struct smbsrv_request *req)
construct a basic request packet, mostly used to construct async packets
such as change notify and oplock break requests
****************************************************************************/
-struct smbsrv_request *init_smb_request(struct smbsrv_context *smb_ctx)
+struct smbsrv_request *init_smb_request(struct smbsrv_connection *smb_conn)
{
struct smbsrv_request *req;
TALLOC_CTX *mem_ctx;
@@ -54,12 +54,12 @@ struct smbsrv_request *init_smb_request(struct smbsrv_context *smb_ctx)
structure itself is also allocated inside this context, so
we need to allocate it before we construct the request
*/
- mem_ctx = talloc_init("request_context[%d]", smb_ctx->socket.pkt_count);
+ mem_ctx = talloc_init("request_context[%d]", smb_conn->socket.pkt_count);
if (!mem_ctx) {
return NULL;
}
- smb_ctx->socket.pkt_count++;
+ smb_conn->socket.pkt_count++;
req = talloc(mem_ctx, sizeof(*req));
if (!req) {
@@ -69,7 +69,7 @@ struct smbsrv_request *init_smb_request(struct smbsrv_context *smb_ctx)
ZERO_STRUCTP(req);
/* setup the request context */
- req->smb_ctx = smb_ctx;
+ req->smb_conn = smb_conn;
req->mem_ctx = mem_ctx;
return req;
@@ -91,7 +91,7 @@ static void req_setup_chain_reply(struct smbsrv_request *req, uint_t wct, uint_t
req->out.buffer = talloc_realloc(req->mem_ctx, req->out.buffer, req->out.allocated);
if (!req->out.buffer) {
- exit_server(req->smb_ctx, "allocation failed");
+ exit_server(req->smb_conn, "allocation failed");
}
req->out.hdr = req->out.buffer + NBT_HDR_SIZE;
@@ -125,7 +125,7 @@ void req_setup_reply(struct smbsrv_request *req, uint_t wct, uint_t buflen)
req->out.buffer = talloc(req->mem_ctx, req->out.allocated);
if (!req->out.buffer) {
- exit_server(req->smb_ctx, "allocation failed");
+ exit_server(req->smb_conn, "allocation failed");
}
req->out.hdr = req->out.buffer + NBT_HDR_SIZE;
@@ -175,7 +175,7 @@ void req_setup_reply(struct smbsrv_request *req, uint_t wct, uint_t buflen)
int req_max_data(struct smbsrv_request *req)
{
int ret;
- ret = req->smb_ctx->negotiate.max_send;
+ ret = req->smb_conn->negotiate.max_send;
ret -= PTR_DIFF(req->out.data, req->out.hdr);
if (ret < 0) ret = 0;
return ret;
@@ -262,7 +262,7 @@ void req_send_reply_nosign(struct smbsrv_request *req)
_smb_setlen(req->out.buffer, req->out.size - NBT_HDR_SIZE);
}
- if (write_data(req->smb_ctx->socket.fd, req->out.buffer, req->out.size) != req->out.size) {
+ if (write_data(req->smb_conn->socket.fd, req->out.buffer, req->out.size) != req->out.size) {
smb_panic("failed to send reply\n");
}
@@ -306,7 +306,7 @@ void req_reply_dos_error(struct smbsrv_request *req, uint8_t eclass, uint16_t ec
*/
void req_setup_error(struct smbsrv_request *req, NTSTATUS status)
{
- if (!lp_nt_status_support() || !(req->smb_ctx->negotiate.client_caps & CAP_STATUS32)) {
+ if (!lp_nt_status_support() || !(req->smb_conn->negotiate.client_caps & CAP_STATUS32)) {
/* convert to DOS error codes */
uint8_t eclass;
uint32_t ecode;
diff --git a/source4/smb_server/search.c b/source4/smb_server/search.c
index 282f4bd1a3..28aec1605e 100644
--- a/source4/smb_server/search.c
+++ b/source4/smb_server/search.c
@@ -78,7 +78,7 @@ static void find_fill_info(struct smbsrv_request *req,
p += req_append_bytes(req, file->search.search_id.data, 21);
p += req_append_bytes(req, (char*)&file->search.attrib, 1);
- srv_push_dos_date3(req->smb_ctx, (uint8_t *)&dos_date, 0, file->search.write_time);
+ srv_push_dos_date3(req->smb_conn, (uint8_t *)&dos_date, 0, file->search.write_time);
p += req_append_bytes(req, (char*)&dos_date, 4);
p += req_append_bytes(req, (char*)&file->search.size, 4);
memset(&search_name[0], ' ', 13);
diff --git a/source4/smb_server/service.c b/source4/smb_server/service.c
index 082a7d02da..44aae340b2 100644
--- a/source4/smb_server/service.c
+++ b/source4/smb_server/service.c
@@ -143,7 +143,7 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req,
struct smbsrv_tcon *tcon;
NTSTATUS status;
- tcon = conn_new(req->smb_ctx);
+ tcon = conn_new(req->smb_conn);
if (!tcon) {
DEBUG(0,("Couldn't find free connection.\n"));
return NT_STATUS_INSUFFICIENT_RESOURCES;
@@ -165,7 +165,7 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req,
/* No access, read or write. */
DEBUG(0,( "make_connection: connection to %s denied due to security descriptor.\n",
lp_servicename(snum)));
- conn_free(req->smb_ctx, tcon);
+ conn_free(req->smb_conn, tcon);
return NT_STATUS_ACCESS_DENIED;
} else {
tcon->read_only = True;
@@ -178,7 +178,7 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req,
lp_max_connections(SNUM(tcon)),
False,0)) {
DEBUG(1,("too many connections - rejected\n"));
- conn_free(req->smb_ctx, tcon);
+ conn_free(req->smb_conn, tcon);
return NT_STATUS_INSUFFICIENT_RESOURCES;
}
@@ -186,7 +186,7 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req,
status = ntvfs_init_connection(req);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("ntvfs_init_connection failed for service %s\n", lp_servicename(SNUM(tcon))));
- conn_free(req->smb_ctx, tcon);
+ conn_free(req->smb_conn, tcon);
return status;
}
@@ -195,7 +195,7 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req,
status = tcon->ntvfs_ops->connect(req, lp_servicename(snum));
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("make_connection: NTVFS make connection failed!\n"));
- conn_free(req->smb_ctx, tcon);
+ conn_free(req->smb_conn, tcon);
return status;
}
}
@@ -259,14 +259,14 @@ close a cnum
void close_cnum(struct smbsrv_tcon *tcon)
{
DEBUG(3,("%s closed connection to service %s\n",
- tcon->smb_ctx->socket.client_addr, lp_servicename(SNUM(tcon))));
+ tcon->smb_conn->socket.client_addr, lp_servicename(SNUM(tcon))));
yield_connection(tcon, lp_servicename(SNUM(tcon)));
/* tell the ntvfs backend that we are disconnecting */
tcon->ntvfs_ops->disconnect(tcon);
- conn_free(tcon->smb_ctx, tcon);
+ conn_free(tcon->smb_conn, tcon);
}
@@ -293,7 +293,7 @@ NTSTATUS tcon_backend(struct smbsrv_request *req, union smb_tcon *con)
return status;
}
- con->tcon.out.max_xmit = req->smb_ctx->negotiate.max_recv;
+ con->tcon.out.max_xmit = req->smb_conn->negotiate.max_recv;
con->tcon.out.cnum = req->tcon->cnum;
return status;
diff --git a/source4/smb_server/session.c b/source4/smb_server/session.c
index dc131b366c..8df12faff9 100644
--- a/source4/smb_server/session.c
+++ b/source4/smb_server/session.c
@@ -28,7 +28,7 @@
#include "includes.h"
/* called when a session is created */
-BOOL session_claim(struct smbsrv_context *smb_ctx, user_struct *vuser)
+BOOL session_claim(struct smbsrv_connection *smb_ctx, user_struct *vuser)
{
DEBUG(0,("rewrite: Not doing session claim\n"));
return True;
diff --git a/source4/smb_server/sesssetup.c b/source4/smb_server/sesssetup.c
index f766d9bd0f..9a3a96d9a5 100644
--- a/source4/smb_server/sesssetup.c
+++ b/source4/smb_server/sesssetup.c
@@ -46,8 +46,8 @@ static NTSTATUS sesssetup_old(struct smbsrv_request *req, union smb_sesssetup *s
struct auth_session_info *session_info;
DATA_BLOB null_blob;
- if (!req->smb_ctx->negotiate.done_sesssetup) {
- req->smb_ctx->negotiate.max_send = sess->old.in.bufsize;
+ if (!req->smb_conn->negotiate.done_sesssetup) {
+ req->smb_conn->negotiate.max_send = sess->old.in.bufsize;
}
null_blob.length = 0;
@@ -60,7 +60,7 @@ static NTSTATUS sesssetup_old(struct smbsrv_request *req, union smb_sesssetup *s
return NT_STATUS_ACCESS_DENIED;
}
- status = req->smb_ctx->negotiate.auth_context->check_ntlm_password(req->smb_ctx->negotiate.auth_context,
+ status = req->smb_conn->negotiate.auth_context->check_ntlm_password(req->smb_conn->negotiate.auth_context,
user_info,
&server_info);
if (!NT_STATUS_IS_OK(status)) {
@@ -73,7 +73,7 @@ static NTSTATUS sesssetup_old(struct smbsrv_request *req, union smb_sesssetup *s
}
sess->old.out.action = 0;
- sess->old.out.vuid = register_vuid(req->smb_ctx, session_info, sess->old.in.user);
+ sess->old.out.vuid = register_vuid(req->smb_conn, session_info, sess->old.in.user);
sesssetup_common_strings(req,
&sess->old.out.os,
&sess->old.out.lanman,
@@ -93,9 +93,9 @@ static NTSTATUS sesssetup_nt1(struct smbsrv_request *req, union smb_sesssetup *s
struct auth_serversupplied_info *server_info = NULL;
struct auth_session_info *session_info;
- if (!req->smb_ctx->negotiate.done_sesssetup) {
- req->smb_ctx->negotiate.max_send = sess->nt1.in.bufsize;
- req->smb_ctx->negotiate.client_caps = sess->nt1.in.capabilities;
+ if (!req->smb_conn->negotiate.done_sesssetup) {
+ req->smb_conn->negotiate.max_send = sess->nt1.in.bufsize;
+ req->smb_conn->negotiate.client_caps = sess->nt1.in.capabilities;
}
status = make_user_info_for_reply_enc(&user_info,
@@ -106,7 +106,7 @@ static NTSTATUS sesssetup_nt1(struct smbsrv_request *req, union smb_sesssetup *s
return NT_STATUS_ACCESS_DENIED;
}
- status = req->smb_ctx->negotiate.auth_context->check_ntlm_password(req->smb_ctx->negotiate.auth_context,
+ status = req->smb_conn->negotiate.auth_context->check_ntlm_password(req->smb_conn->negotiate.auth_context,
user_info,
&server_info);
if (!NT_STATUS_IS_OK(status)) {
@@ -119,7 +119,7 @@ static NTSTATUS sesssetup_nt1(struct smbsrv_request *req, union smb_sesssetup *s
}
sess->nt1.out.action = 0;
- sess->nt1.out.vuid = register_vuid(req->smb_ctx, session_info, sess->old.in.user);
+ sess->nt1.out.vuid = register_vuid(req->smb_conn, session_info, sess->old.in.user);
if (sess->nt1.out.vuid == UID_FIELD_INVALID) {
return NT_STATUS_ACCESS_DENIED;
}
@@ -128,7 +128,7 @@ static NTSTATUS sesssetup_nt1(struct smbsrv_request *req, union smb_sesssetup *s
&sess->nt1.out.lanman,
&sess->nt1.out.domain);
- srv_setup_signing(req->smb_ctx, &session_info->session_key, &sess->nt1.in.password2);
+ srv_setup_signing(req->smb_conn, &session_info->session_key, &sess->nt1.in.password2);
return NT_STATUS_OK;
}
@@ -157,7 +157,7 @@ NTSTATUS sesssetup_backend(struct smbsrv_request *req,
return sesssetup_spnego(req, sess);
}
- req->smb_ctx->negotiate.done_sesssetup = True;
+ req->smb_conn->negotiate.done_sesssetup = True;
return NT_STATUS_INVALID_LEVEL;
}
diff --git a/source4/smb_server/signing.c b/source4/smb_server/signing.c
index 4765d9d6c3..edc177174e 100644
--- a/source4/smb_server/signing.c
+++ b/source4/smb_server/signing.c
@@ -54,7 +54,7 @@ static void calc_signature(uint8_t *buffer, size_t length,
void req_sign_packet(struct smbsrv_request *req)
{
/* check if we are doing signing on this connection */
- if (req->smb_ctx->signing.signing_state != SMB_SIGNING_REQUIRED) {
+ if (req->smb_conn->signing.signing_state != SMB_SIGNING_REQUIRED) {
return;
}
@@ -63,7 +63,7 @@ void req_sign_packet(struct smbsrv_request *req)
mark_packet_signed(req);
calc_signature(req->out.hdr, req->out.size - NBT_HDR_SIZE,
- &req->smb_ctx->signing.mac_key,
+ &req->smb_conn->signing.mac_key,
&req->out.hdr[HDR_SS_FIELD]);
}
@@ -72,15 +72,15 @@ void req_sign_packet(struct smbsrv_request *req)
setup the signing key for a connection. Called after authentication succeeds
in a session setup
*/
-void srv_setup_signing(struct smbsrv_context *smb_ctx,
+void srv_setup_signing(struct smbsrv_connection *smb_conn,
DATA_BLOB *session_key,
DATA_BLOB *session_response)
{
- smb_ctx->signing.mac_key = data_blob(NULL,
+ smb_conn->signing.mac_key = data_blob(NULL,
session_key->length + session_response->length);
- memcpy(smb_ctx->signing.mac_key.data, session_key->data, session_key->length);
+ memcpy(smb_conn->signing.mac_key.data, session_key->data, session_key->length);
if (session_response->length != 0) {
- memcpy(&smb_ctx->signing.mac_key.data[session_key->length],
+ memcpy(&smb_conn->signing.mac_key.data[session_key->length],
session_response->data,
session_response->length);
}
@@ -92,12 +92,12 @@ void srv_setup_signing(struct smbsrv_context *smb_ctx,
*/
static void req_signing_alloc_seq_num(struct smbsrv_request *req)
{
- req->seq_num = req->smb_ctx->signing.next_seq_num;
+ req->seq_num = req->smb_conn->signing.next_seq_num;
/* TODO: we need to handle one-way requests like NTcancel, which
only increment the sequence number by 1 */
- if (req->smb_ctx->signing.signing_state != SMB_SIGNING_OFF) {
- req->smb_ctx->signing.next_seq_num += 2;
+ if (req->smb_conn->signing.signing_state != SMB_SIGNING_OFF) {
+ req->smb_conn->signing.next_seq_num += 2;
}
}
@@ -108,12 +108,12 @@ BOOL req_signing_check_incoming(struct smbsrv_request *req)
{
uint8_t client_md5_mac[8], signature[8];
- switch (req->smb_ctx->signing.signing_state) {
+ switch (req->smb_conn->signing.signing_state) {
case SMB_SIGNING_OFF:
return True;
case SMB_SIGNING_SUPPORTED:
if (req->flags2 & FLAGS2_SMB_SECURITY_SIGNATURES) {
- req->smb_ctx->signing.signing_state = SMB_SIGNING_REQUIRED;
+ req->smb_conn->signing.signing_state = SMB_SIGNING_REQUIRED;
}
return True;
case SMB_SIGNING_REQUIRED:
@@ -137,7 +137,7 @@ BOOL req_signing_check_incoming(struct smbsrv_request *req)
SBVAL(req->in.hdr, HDR_SS_FIELD, req->seq_num);
calc_signature(req->in.hdr, req->in.size - NBT_HDR_SIZE,
- &req->smb_ctx->signing.mac_key,
+ &req->smb_conn->signing.mac_key,
signature);
if (memcmp(client_md5_mac, signature, 8) != 0) {
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index b32cf5b7af..16d1d774c0 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -29,7 +29,7 @@ BOOL req_send_oplock_break(struct smbsrv_tcon *tcon, uint16_t fnum, uint8_t leve
{
struct smbsrv_request *req;
- req = init_smb_request(tcon->smb_ctx);
+ req = init_smb_request(tcon->smb_conn);
req_setup_reply(req, 8, 0);
@@ -57,20 +57,20 @@ BOOL req_send_oplock_break(struct smbsrv_tcon *tcon, uint16_t fnum, uint8_t leve
/****************************************************************************
receive a SMB request from the wire, forming a request_context from the result
****************************************************************************/
-static struct smbsrv_request *receive_smb_request(struct smbsrv_context *smb_ctx)
+static struct smbsrv_request *receive_smb_request(struct smbsrv_connection *smb_conn)
{
ssize_t len, len2;
char header[4];
struct smbsrv_request *req;
- len = read_data(smb_ctx->socket.fd, header, 4);
+ len = read_data(smb_conn->socket.fd, header, 4);
if (len != 4) {
return NULL;
}
len = smb_len(header);
- req = init_smb_request(smb_ctx);
+ req = init_smb_request(smb_conn);
GetTimeOfDay(&req->request_time);
req->chained_fnum = -1;
@@ -81,7 +81,7 @@ static struct smbsrv_request *receive_smb_request(struct smbsrv_context *smb_ctx
/* fill in the already received header */
memcpy(req->in.buffer, header, 4);
- len2 = read_data(smb_ctx->socket.fd, req->in.buffer + NBT_HDR_SIZE, len);
+ len2 = read_data(smb_conn->socket.fd, req->in.buffer + NBT_HDR_SIZE, len);
if (len2 != len) {
return NULL;
}
@@ -122,7 +122,7 @@ static void setup_user_context(struct smbsrv_request *req)
user_ctx = talloc(req->mem_ctx, sizeof(*user_ctx));
user_ctx->vuid = SVAL(req->in.hdr, HDR_UID);
- user_ctx->vuser = get_valid_user_struct(req->smb_ctx, user_ctx->vuid);
+ user_ctx->vuser = get_valid_user_struct(req->smb_conn, user_ctx->vuid);
req->user_ctx = user_ctx;
}
@@ -437,7 +437,7 @@ static void switch_message(int type, struct smbsrv_request *req)
{
int flags;
uint16_t session_tag;
- struct smbsrv_context *smb_ctx = req->smb_ctx;
+ struct smbsrv_connection *smb_conn = req->smb_conn;
type &= 0xff;
@@ -456,7 +456,7 @@ static void switch_message(int type, struct smbsrv_request *req)
UID_FIELD_INVALID :
SVAL(req->in.hdr,HDR_UID);
- req->tcon = conn_find(smb_ctx, SVAL(req->in.hdr,HDR_TID));
+ req->tcon = conn_find(smb_conn, SVAL(req->in.hdr,HDR_TID));
/* setup the user context for this request */
setup_user_context(req);
@@ -467,7 +467,7 @@ static void switch_message(int type, struct smbsrv_request *req)
if (req->user_ctx) {
req->user_ctx->vuid = session_tag;
}
- DEBUG(3,("switch message %s (task_id %d)\n",smb_fn_name(type), smb_ctx->model_ops->get_id(req)));
+ DEBUG(3,("switch message %s (task_id %d)\n",smb_fn_name(type), smb_conn->model_ops->get_id(req)));
/* does this protocol need to be run as root? */
if (!(flags & AS_USER)) {
@@ -562,19 +562,19 @@ static void construct_reply(struct smbsrv_request *req)
if (memcmp(req->in.hdr,"\377SMB",4) != 0) {
DEBUG(2,("Non-SMB packet of length %d. Terminating connection\n",
req->in.size));
- exit_server(req->smb_ctx, "Non-SMB packet");
+ exit_server(req->smb_conn, "Non-SMB packet");
return;
}
if (NBT_HDR_SIZE + MIN_SMB_SIZE + 2*req->in.wct > req->in.size) {
DEBUG(2,("Invalid SMB word count %d\n", req->in.wct));
- exit_server(req->smb_ctx, "Invalid SMB packet");
+ exit_server(req->smb_conn, "Invalid SMB packet");
return;
}
if (NBT_HDR_SIZE + MIN_SMB_SIZE + 2*req->in.wct + req->in.data_size > req->in.size) {
DEBUG(2,("Invalid SMB buffer length count %d\n", req->in.data_size));
- exit_server(req->smb_ctx, "Invalid SMB packet");
+ exit_server(req->smb_conn, "Invalid SMB packet");
return;
}
@@ -667,22 +667,22 @@ error:
/*
close the socket and shutdown a server_context
*/
-void server_terminate(struct smbsrv_context *smb_ctx)
+void server_terminate(struct smbsrv_connection *smb_conn)
{
- close(smb_ctx->socket.fd);
- event_remove_fd_all(smb_ctx->events, smb_ctx->socket.fd);
+ close(smb_conn->socket.fd);
+ event_remove_fd_all(smb_conn->events, smb_conn->socket.fd);
- conn_close_all(smb_ctx);
+ conn_close_all(smb_conn);
- talloc_destroy(smb_ctx->mem_ctx);
+ talloc_destroy(smb_conn->mem_ctx);
}
/*
called on a fatal error that should cause this server to terminate
*/
-void exit_server(struct smbsrv_context *smb_ctx, const char *reason)
+void exit_server(struct smbsrv_connection *smb_conn, const char *reason)
{
- smb_ctx->model_ops->terminate_connection(smb_ctx, reason);
+ smb_conn->model_ops->terminate_connection(smb_conn, reason);
}
/*
@@ -783,11 +783,11 @@ void smbd_read_handler(struct event_context *ev, struct fd_event *fde,
time_t t, uint16_t flags)
{
struct smbsrv_request *req;
- struct smbsrv_context *smb_ctx = fde->private;
+ struct smbsrv_connection *smb_conn = fde->private;
- req = receive_smb_request(smb_ctx);
+ req = receive_smb_request(smb_conn);
if (!req) {
- smb_ctx->model_ops->terminate_connection(smb_ctx, "receive error");
+ smb_conn->model_ops->terminate_connection(smb_conn, "receive error");
return;
}
@@ -804,13 +804,13 @@ void smbd_read_handler(struct event_context *ev, struct fd_event *fde,
new messages from clients are still processed while they are
performing long operations
*/
-void smbd_process_async(struct smbsrv_context *smb_ctx)
+void smbd_process_async(struct smbsrv_connection *smb_conn)
{
struct smbsrv_request *req;
- req = receive_smb_request(smb_ctx);
+ req = receive_smb_request(smb_conn);
if (!req) {
- smb_ctx->model_ops->terminate_connection(smb_ctx, "receive error");
+ smb_conn->model_ops->terminate_connection(smb_conn, "receive error");
return;
}
@@ -825,7 +825,7 @@ void smbd_process_async(struct smbsrv_context *smb_ctx)
void init_smbsession(struct event_context *ev, struct model_ops *model_ops, int fd,
void (*read_handler)(struct event_context *, struct fd_event *, time_t, uint16_t))
{
- struct smbsrv_context *smb_ctx;
+ struct smbsrv_connection *smb_conn;
TALLOC_CTX *mem_ctx;
struct fd_event fde;
char *socket_addr;
@@ -835,48 +835,48 @@ void init_smbsession(struct event_context *ev, struct model_ops *model_ops, int
mem_ctx = talloc_init("server_context");
- smb_ctx = talloc_p(mem_ctx, struct smbsrv_context);
- if (!smb_ctx) return;
+ smb_conn = talloc_p(mem_ctx, struct smbsrv_connection);
+ if (!smb_conn) return;
- ZERO_STRUCTP(smb_ctx);
+ ZERO_STRUCTP(smb_conn);
- smb_ctx->mem_ctx = mem_ctx;
- smb_ctx->socket.fd = fd;
- smb_ctx->pid = getpid();
+ smb_conn->mem_ctx = mem_ctx;
+ smb_conn->socket.fd = fd;
+ smb_conn->pid = getpid();
- sub_set_context(&smb_ctx->substitute);
+ sub_set_context(&smb_conn->substitute);
/* set an initial client name based on its IP address. This will be replaced with
the netbios name later if it gives us one */
- socket_addr = get_socket_addr(smb_ctx->mem_ctx, fd);
+ socket_addr = get_socket_addr(smb_conn->mem_ctx, fd);
sub_set_remote_machine(socket_addr);
- smb_ctx->socket.client_addr = socket_addr;
+ smb_conn->socket.client_addr = socket_addr;
/* now initialise a few default values associated with this smb socket */
- smb_ctx->negotiate.max_send = 0xFFFF;
+ smb_conn->negotiate.max_send = 0xFFFF;
/* this is the size that w2k uses, and it appears to be important for
good performance */
- smb_ctx->negotiate.max_recv = lp_max_xmit();
+ smb_conn->negotiate.max_recv = lp_max_xmit();
- smb_ctx->negotiate.zone_offset = get_time_zone(time(NULL));
+ smb_conn->negotiate.zone_offset = get_time_zone(time(NULL));
- smb_ctx->users.next_vuid = VUID_OFFSET;
+ smb_conn->users.next_vuid = VUID_OFFSET;
- smb_ctx->events = ev;
- smb_ctx->model_ops = model_ops;
+ smb_conn->events = ev;
+ smb_conn->model_ops = model_ops;
- conn_init(smb_ctx);
+ conn_init(smb_conn);
/* setup a event handler for this socket. We are initially
only interested in reading from the socket */
fde.fd = fd;
fde.handler = read_handler;
- fde.private = smb_ctx;
+ fde.private = smb_conn;
fde.flags = EVENT_FD_READ;
event_add_fd(ev, &fde);
/* setup the DCERPC server subsystem */
- dcesrv_init_context(&smb_ctx->dcesrv);
+ dcesrv_init_context(&smb_conn->dcesrv);
}
diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h
index 93f8552d86..6dc40aee08 100644
--- a/source4/smb_server/smb_server.h
+++ b/source4/smb_server/smb_server.h
@@ -53,7 +53,7 @@ struct smbsrv_tcon {
struct smbsrv_tcon *next, *prev;
/* the server context that this was created on */
- struct smbsrv_context *smb_ctx;
+ struct smbsrv_connection *smb_conn;
/* a talloc context for all data in this structure */
TALLOC_CTX *mem_ctx;
@@ -80,8 +80,11 @@ struct smbsrv_tcon {
/* the context for a single SMB request. This is passed to any request-context
functions */
struct smbsrv_request {
+ /* a talloc context for the lifetime of this request */
+ TALLOC_CTX *mem_ctx;
+
/* the server_context contains all context specific to this SMB socket */
- struct smbsrv_context *smb_ctx;
+ struct smbsrv_connection *smb_conn;
/* conn is only set for operations that have a valid TID */
struct smbsrv_tcon *tcon;
@@ -89,9 +92,6 @@ struct smbsrv_request {
/* the user context is derived from the vuid plus smb.conf options */
struct smbsrv_user *user_ctx;
- /* a talloc context for the lifetime of this request */
- TALLOC_CTX *mem_ctx;
-
/* a set of flags to control usage of the request. See REQ_CONTROL_* */
unsigned control_flags;
@@ -168,48 +168,6 @@ struct smbsrv_request {
} in, out;
};
-
-
-/* the context associated with open files on an smb socket */
-struct files_context {
- struct files_struct *files; /* open files */
- struct bitmap *file_bmap; /* bitmap used to allocate file handles */
-
- /* a fsp to use when chaining */
- struct files_struct *chain_fsp;
-
- /* a fsp to use to save when breaking an oplock. */
- struct files_struct *oplock_save_chain_fsp;
-
- /* how many files are open */
- int files_used;
-
- /* limit for maximum open files */
- int real_max_open_files;
-};
-
-
-/* the context associated with open tree connects on a smb socket */
-struct tree_context {
- struct smbsrv_tcon *tcons;
-
- /* number of open connections */
- struct bitmap *bmap;
- int num_open;
-};
-
-/* context associated with currently valid session setups */
-struct users_context {
- /* users from session setup */
- char *session_users; /* was a pstring */
-
- /* this holds info on user ids that are already validated for this VC */
- struct user_struct *validated_users;
- int next_vuid; /* initialise to VUID_OFFSET */
- int num_validated_vuids;
-};
-
-
/* this contains variables that should be used in % substitutions for
* smb.conf parameters */
struct substitute_context {
@@ -232,144 +190,162 @@ struct substitute_context {
char *user_name;
};
-/* context that has been negotiated between the client and server */
-struct negotiate_context {
- /* have we already done the NBT session establishment? */
- BOOL done_nbt_session;
+#include "smbd/process_model.h"
- /* only one negprot per connection is allowed */
- BOOL done_negprot;
+/* smb server context structure. This should contain all the state
+ * information associated with a SMB server connection
+ */
+struct smbsrv_connection {
+ /* a talloc context for all data in this structure */
+ TALLOC_CTX *mem_ctx;
- /* multiple session setups are allowed, but some parameters are
- ignored in any but the first */
- BOOL done_sesssetup;
+ /* this is the context for a SMB socket associated with the socket itself */
+ struct {
+ /* the open file descriptor */
+ int fd;
- /*
- * Size of data we can send to client. Set
- * by the client for all protocols above CORE.
- * Set by us for CORE protocol.
- */
- unsigned max_send; /* init to BUFFER_SIZE */
-
- /*
- * Size of the data we can receive. Set by us.
- * Can be modified by the max xmit parameter.
- */
- unsigned max_recv; /* init to BUFFER_SIZE */
-
- /* a guess at the remote architecture. Try not to rely on this - in almost
- all cases using these values is the wrong thing to do */
- enum remote_arch_types ra_type;
-
- /* the negotiatiated protocol */
- enum protocol_types protocol;
-
- /* authentication context for multi-part negprot */
- struct auth_context *auth_context;
-
- /* state of NTLMSSP auth */
- struct auth_ntlmssp_state *ntlmssp_state;
-
- /* did we tell the client we support encrypted passwords? */
- BOOL encrypted_passwords;
-
- /* did we send an extended security negprot reply? */
- BOOL spnego_negotiated;
-
- /* client capabilities */
- uint32_t client_caps;
-
- /* the timezone we sent to the client */
- int zone_offset;
-};
+ /* the last read error on the socket, if any (replaces smb_read_error global) */
+ int read_error;
-/* this is the context for a SMB socket associated with the socket itself */
-struct socket_context {
- /* the open file descriptor */
- int fd;
-
- /* the last read error on the socket, if any (replaces smb_read_error global) */
- int read_error;
-
- /* a count of the number of packets we have received. We
- * actually only care about zero/non-zero at this stage */
- unsigned pkt_count;
-
- /* the network address of the client */
- char *client_addr;
-};
-
-
-/* this holds long term state specific to the printing subsystem */
-struct printing_context {
- struct notify_queue *notify_queue_head;
-};
-
+ /* a count of the number of packets we have received. We
+ * actually only care about zero/non-zero at this stage */
+ unsigned pkt_count;
+
+ /* the network address of the client */
+ char *client_addr;
+ } socket;
-/* the server_context holds a linked list of pending requests,
- * this is used for blocking locks and requests blocked due to oplock
- * break requests */
-struct pending_request {
- struct pending_request *next, *prev;
+ /* context that has been negotiated between the client and server */
+ struct {
+ /* have we already done the NBT session establishment? */
+ BOOL done_nbt_session;
+
+ /* only one negprot per connection is allowed */
+ BOOL done_negprot;
+
+ /* multiple session setups are allowed, but some parameters are
+ ignored in any but the first */
+ BOOL done_sesssetup;
+
+ /*
+ * Size of data we can send to client. Set
+ * by the client for all protocols above CORE.
+ * Set by us for CORE protocol.
+ */
+ unsigned max_send; /* init to BUFFER_SIZE */
+
+ /*
+ * Size of the data we can receive. Set by us.
+ * Can be modified by the max xmit parameter.
+ */
+ unsigned max_recv; /* init to BUFFER_SIZE */
+
+ /* a guess at the remote architecture. Try not to rely on this - in almost
+ all cases using these values is the wrong thing to do */
+ enum remote_arch_types ra_type;
+
+ /* the negotiatiated protocol */
+ enum protocol_types protocol;
+
+ /* authentication context for multi-part negprot */
+ struct auth_context *auth_context;
+
+ /* state of NTLMSSP auth */
+ struct auth_ntlmssp_state *ntlmssp_state;
+
+ /* did we tell the client we support encrypted passwords? */
+ BOOL encrypted_passwords;
+
+ /* did we send an extended security negprot reply? */
+ BOOL spnego_negotiated;
+
+ /* client capabilities */
+ uint32_t client_caps;
+
+ /* the timezone we sent to the client */
+ int zone_offset;
+ } negotiate;
- /* the request itself - needs to be freed */
- struct smbsrv_request *request;
-};
+ /* the context associated with open tree connects on a smb socket */
+ struct {
+ struct smbsrv_tcon *tcons;
-/* the timers context contains info on when we last did various
- * functions */
-struct timers_context {
- /* when did we last do timeout processing? */
- time_t last_timeout_processing;
+ /* number of open connections */
+ struct bitmap *bmap;
+ int num_open;
+ } tree;
- /* when did we last sent a keepalive */
- time_t last_keepalive_sent;
+ /* the context associated with open files on an smb socket */
+ struct {
+ struct files_struct *files; /* open files */
+ struct bitmap *file_bmap; /* bitmap used to allocate file handles */
- /* when we last checked the smb.conf for auto-reload */
- time_t last_smb_conf_reload;
-};
-
+ /* a fsp to use when chaining */
+ struct files_struct *chain_fsp;
+
+ /* a fsp to use to save when breaking an oplock. */
+ struct files_struct *oplock_save_chain_fsp;
+
+ /* how many files are open */
+ int files_used;
+
+ /* limit for maximum open files */
+ int real_max_open_files;
+ } file;
-struct signing_context {
- DATA_BLOB mac_key;
- uint64_t next_seq_num;
- enum smb_signing_state signing_state;
-};
+ /* context associated with currently valid session setups */
+ struct {
+ /* users from session setup */
+ char *session_users; /* was a pstring */
+
+ /* this holds info on user ids that are already validated for this VC */
+ struct user_struct *validated_users;
+ int next_vuid; /* initialise to VUID_OFFSET */
+ int num_validated_vuids;
+ } users;
-#include "smbd/process_model.h"
+ /* this holds long term state specific to the printing subsystem */
+ struct {
+ struct notify_queue *notify_queue_head;
+ } print;
+
+ /* the server_context holds a linked list of pending requests,
+ * this is used for blocking locks and requests blocked due to oplock
+ * break requests */
+ struct _smbsrv_pending_request {
+ struct _smbsrv_pending_request *next, *prev;
+
+ /* the request itself - needs to be freed */
+ struct smbsrv_request *request;
+ } *requests;
-/* smb server context structure. This should contain all the state
- * information associated with a SMB server */
-struct smbsrv_context {
- /* a talloc context for all data in this structure */
- TALLOC_CTX *mem_ctx;
+ /* the timers context contains info on when we last did various
+ * functions */
+ struct {
+ /* when did we last do timeout processing? */
+ time_t last_timeout_processing;
+
+ /* when did we last sent a keepalive */
+ time_t last_keepalive_sent;
+
+ /* when we last checked the smb.conf for auto-reload */
+ time_t last_smb_conf_reload;
+ } timers;
- struct negotiate_context negotiate;
+ struct {
+ DATA_BLOB mac_key;
+ uint64_t next_seq_num;
+ enum smb_signing_state signing_state;
+ } signing;
struct substitute_context substitute;
- struct socket_context socket;
-
- struct files_context file;
-
- struct tree_context tree;
-
- struct users_context users;
-
- struct printing_context print;
-
- struct timers_context timers;
-
struct dcesrv_context dcesrv;
- struct signing_context signing;
+ const struct model_ops *model_ops;
- /* the pid of the process handling this session */
- pid_t pid;
-
- /* pointer to list of events that we are waiting on */
struct event_context *events;
- /* process model specific operations */
- const struct model_ops *model_ops;
+ /* the pid of the process handling this session */
+ pid_t pid;
};
diff --git a/source4/smb_server/srvtime.c b/source4/smb_server/srvtime.c
index 04b758bc79..c39267521c 100644
--- a/source4/smb_server/srvtime.c
+++ b/source4/smb_server/srvtime.c
@@ -26,7 +26,7 @@
put a dos date into a buffer (time/date format)
This takes GMT time and puts local time for zone_offset in the buffer
********************************************************************/
-void srv_push_dos_date(struct smbsrv_context *smb_server,
+void srv_push_dos_date(struct smbsrv_connection *smb_server,
uint8_t *buf, int offset, time_t unixdate)
{
push_dos_date(buf, offset, unixdate, smb_server->negotiate.zone_offset);
@@ -36,7 +36,7 @@ void srv_push_dos_date(struct smbsrv_context *smb_server,
put a dos date into a buffer (date/time format)
This takes GMT time and puts local time in the buffer
********************************************************************/
-void srv_push_dos_date2(struct smbsrv_context *smb_server,
+void srv_push_dos_date2(struct smbsrv_connection *smb_server,
char *buf, int offset, time_t unixdate)
{
push_dos_date2(buf, offset, unixdate, smb_server->negotiate.zone_offset);
@@ -46,7 +46,7 @@ void srv_push_dos_date2(struct smbsrv_context *smb_server,
put a dos 32 bit "unix like" date into a buffer. This routine takes
GMT and converts it to LOCAL time in zone_offset before putting it
********************************************************************/
-void srv_push_dos_date3(struct smbsrv_context *smb_server,
+void srv_push_dos_date3(struct smbsrv_connection *smb_server,
char *buf, int offset, time_t unixdate)
{
push_dos_date3(buf, offset, unixdate, smb_server->negotiate.zone_offset);
@@ -55,7 +55,7 @@ void srv_push_dos_date3(struct smbsrv_context *smb_server,
/*******************************************************************
convert a dos date
********************************************************************/
-time_t srv_pull_dos_date(struct smbsrv_context *smb_server,
+time_t srv_pull_dos_date(struct smbsrv_connection *smb_server,
const uint8_t *date_ptr)
{
return pull_dos_date(date_ptr, smb_server->negotiate.zone_offset);
@@ -64,7 +64,7 @@ time_t srv_pull_dos_date(struct smbsrv_context *smb_server,
/*******************************************************************
like srv_pull_dos_date() but the words are reversed
********************************************************************/
-time_t srv_pull_dos_date2(struct smbsrv_context *smb_server,
+time_t srv_pull_dos_date2(struct smbsrv_connection *smb_server,
const uint8_t *date_ptr)
{
return pull_dos_date2(date_ptr, smb_server->negotiate.zone_offset);
@@ -74,7 +74,7 @@ time_t srv_pull_dos_date2(struct smbsrv_context *smb_server,
create a unix GMT date from a dos date in 32 bit "unix like" format
these arrive in server zone, with corresponding DST
******************************************************************/
-time_t srv_pull_dos_date3(struct smbsrv_context *smb_server,
+time_t srv_pull_dos_date3(struct smbsrv_connection *smb_server,
const uint8_t *date_ptr)
{
return pull_dos_date3(date_ptr, smb_server->negotiate.zone_offset);
diff --git a/source4/smb_server/trans2.c b/source4/smb_server/trans2.c
index 0ab1ca0b7c..301a0221d0 100644
--- a/source4/smb_server/trans2.c
+++ b/source4/smb_server/trans2.c
@@ -420,9 +420,9 @@ static NTSTATUS trans2_fileinfo_fill(struct smbsrv_request *req, struct smb_tran
trans2_setup_reply(req, trans, 2, 22, 0);
SSVAL(trans->out.params.data, 0, 0);
- srv_push_dos_date2(req->smb_ctx, trans->out.data.data, 0, st->standard.out.create_time);
- srv_push_dos_date2(req->smb_ctx, trans->out.data.data, 4, st->standard.out.access_time);
- srv_push_dos_date2(req->smb_ctx, trans->out.data.data, 8, st->standard.out.write_time);
+ srv_push_dos_date2(req->smb_conn, trans->out.data.data, 0, st->standard.out.create_time);
+ srv_push_dos_date2(req->smb_conn, trans->out.data.data, 4, st->standard.out.access_time);
+ srv_push_dos_date2(req->smb_conn, trans->out.data.data, 8, st->standard.out.write_time);
SIVAL(trans->out.data.data, 12, st->standard.out.size);
SIVAL(trans->out.data.data, 16, st->standard.out.alloc_size);
SSVAL(trans->out.data.data, 20, st->standard.out.attrib);
@@ -432,9 +432,9 @@ static NTSTATUS trans2_fileinfo_fill(struct smbsrv_request *req, struct smb_tran
trans2_setup_reply(req, trans, 2, 26, 0);
SSVAL(trans->out.params.data, 0, 0);
- srv_push_dos_date2(req->smb_ctx, trans->out.data.data, 0, st->ea_size.out.create_time);
- srv_push_dos_date2(req->smb_ctx, trans->out.data.data, 4, st->ea_size.out.access_time);
- srv_push_dos_date2(req->smb_ctx, trans->out.data.data, 8, st->ea_size.out.write_time);
+ srv_push_dos_date2(req->smb_conn, trans->out.data.data, 0, st->ea_size.out.create_time);
+ srv_push_dos_date2(req->smb_conn, trans->out.data.data, 4, st->ea_size.out.access_time);
+ srv_push_dos_date2(req->smb_conn, trans->out.data.data, 8, st->ea_size.out.write_time);
SIVAL(trans->out.data.data, 12, st->ea_size.out.size);
SIVAL(trans->out.data.data, 16, st->ea_size.out.alloc_size);
SSVAL(trans->out.data.data, 20, st->ea_size.out.attrib);
@@ -705,9 +705,9 @@ static NTSTATUS trans2_parse_sfileinfo(struct smbsrv_request *req,
case RAW_SFILEINFO_STANDARD:
CHECK_MIN_BLOB_SIZE(blob, 12);
- st->standard.in.create_time = srv_pull_dos_date2(req->smb_ctx, blob->data + 0);
- st->standard.in.access_time = srv_pull_dos_date2(req->smb_ctx, blob->data + 4);
- st->standard.in.write_time = srv_pull_dos_date2(req->smb_ctx, blob->data + 8);
+ st->standard.in.create_time = srv_pull_dos_date2(req->smb_conn, blob->data + 0);
+ st->standard.in.access_time = srv_pull_dos_date2(req->smb_conn, blob->data + 4);
+ st->standard.in.write_time = srv_pull_dos_date2(req->smb_conn, blob->data + 8);
return NT_STATUS_OK;
case RAW_SFILEINFO_EA_SET:
@@ -896,9 +896,9 @@ static void find_fill_info(struct smbsrv_request *req,
trans2_grow_data(req, trans, ofs + 23);
}
data = trans->out.data.data + ofs;
- srv_push_dos_date2(req->smb_ctx, data, 0, file->standard.create_time);
- srv_push_dos_date2(req->smb_ctx, data, 4, file->standard.access_time);
- srv_push_dos_date2(req->smb_ctx, data, 8, file->standard.write_time);
+ srv_push_dos_date2(req->smb_conn, data, 0, file->standard.create_time);
+ srv_push_dos_date2(req->smb_conn, data, 4, file->standard.access_time);
+ srv_push_dos_date2(req->smb_conn, data, 8, file->standard.write_time);
SIVAL(data, 12, file->standard.size);
SIVAL(data, 16, file->standard.alloc_size);
SSVAL(data, 20, file->standard.attrib);
@@ -915,9 +915,9 @@ static void find_fill_info(struct smbsrv_request *req,
trans2_grow_data(req, trans, ofs + 27);
}
data = trans->out.data.data + ofs;
- srv_push_dos_date2(req->smb_ctx, data, 0, file->ea_size.create_time);
- srv_push_dos_date2(req->smb_ctx, data, 4, file->ea_size.access_time);
- srv_push_dos_date2(req->smb_ctx, data, 8, file->ea_size.write_time);
+ srv_push_dos_date2(req->smb_conn, data, 0, file->ea_size.create_time);
+ srv_push_dos_date2(req->smb_conn, data, 4, file->ea_size.access_time);
+ srv_push_dos_date2(req->smb_conn, data, 8, file->ea_size.write_time);
SIVAL(data, 12, file->ea_size.size);
SIVAL(data, 16, file->ea_size.alloc_size);
SSVAL(data, 20, file->ea_size.attrib);
diff --git a/source4/smbd/process_model.c b/source4/smbd/process_model.c
index b098e740ca..16bce3913d 100644
--- a/source4/smbd/process_model.c
+++ b/source4/smbd/process_model.c
@@ -110,7 +110,7 @@ const struct process_model_critical_sizes *process_model_version(void)
static const struct process_model_critical_sizes critical_sizes = {
PROCESS_MODEL_VERSION,
sizeof(struct model_ops),
- sizeof(struct smbsrv_context),
+ sizeof(struct smbsrv_connection),
sizeof(struct event_context),
sizeof(struct fd_event)
};
diff --git a/source4/smbd/process_model.h b/source4/smbd/process_model.h
index 8d6635205c..c4c3aa68df 100644
--- a/source4/smbd/process_model.h
+++ b/source4/smbd/process_model.h
@@ -45,13 +45,13 @@ struct model_ops {
void (*accept_rpc_connection)(struct event_context *, struct fd_event *, time_t, uint16_t);
/* function to terminate a connection */
- void (*terminate_connection)(struct smbsrv_context *smb, const char *reason);
+ void (*terminate_connection)(struct smbsrv_connection *smb, const char *reason);
/* function to terminate a connection */
void (*terminate_rpc_connection)(void *r, const char *reason);
/* function to exit server */
- void (*exit_server)(struct smbsrv_context *smb, const char *reason);
+ void (*exit_server)(struct smbsrv_connection *smb, const char *reason);
/* returns process or thread id */
int (*get_id)(struct smbsrv_request *req);
diff --git a/source4/smbd/process_single.c b/source4/smbd/process_single.c
index ba4c7225e7..9c92d8569a 100644
--- a/source4/smbd/process_single.c
+++ b/source4/smbd/process_single.c
@@ -76,7 +76,7 @@ static void accept_rpc_connection(struct event_context *ev, struct fd_event *fde
}
/* called when a SMB connection goes down */
-static void terminate_connection(struct smbsrv_context *server, const char *reason)
+static void terminate_connection(struct smbsrv_connection *server, const char *reason)
{
server_terminate(server);
}
@@ -89,10 +89,10 @@ static void terminate_rpc_connection(void *r, const char *reason)
static int get_id(struct smbsrv_request *req)
{
- return (int)req->smb_ctx->pid;
+ return (int)req->smb_conn->pid;
}
-static void single_exit_server(struct smbsrv_context *smb, const char *reason)
+static void single_exit_server(struct smbsrv_connection *smb, const char *reason)
{
DEBUG(1,("single_exit_server: reason[%s]\n",reason));
}
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index 84166196d5..2ee486e1d2 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -115,7 +115,7 @@ static void accept_rpc_connection(struct event_context *ev, struct fd_event *fde
}
/* called when a SMB connection goes down */
-static void terminate_connection(struct smbsrv_context *server, const char *reason)
+static void terminate_connection(struct smbsrv_connection *server, const char *reason)
{
server_terminate(server);
/* terminate this process */
@@ -132,10 +132,10 @@ static void terminate_rpc_connection(void *r, const char *reason)
static int get_id(struct smbsrv_request *req)
{
- return (int)req->smb_ctx->pid;
+ return (int)req->smb_conn->pid;
}
-static void standard_exit_server(struct smbsrv_context *smb, const char *reason)
+static void standard_exit_server(struct smbsrv_connection *smb, const char *reason)
{
DEBUG(1,("standard_exit_server: reason[%s]\n",reason));
}
diff --git a/source4/smbd/process_thread.c b/source4/smbd/process_thread.c
index bccf132fe4..f79f34e389 100644
--- a/source4/smbd/process_thread.c
+++ b/source4/smbd/process_thread.c
@@ -126,7 +126,7 @@ static void accept_rpc_connection(struct event_context *ev, struct fd_event *fde
}
/* called when a SMB connection goes down */
-static void terminate_connection(struct smbsrv_context *server, const char *reason)
+static void terminate_connection(struct smbsrv_connection *server, const char *reason)
{
server_terminate(server);
@@ -465,7 +465,7 @@ static void model_startup(void)
register_debug_handlers("thread", &d_ops);
}
-static void thread_exit_server(struct smbsrv_context *smb, const char *reason)
+static void thread_exit_server(struct smbsrv_connection *smb, const char *reason)
{
DEBUG(1,("thread_exit_server: reason[%s]\n",reason));
}
diff --git a/source4/smbd/rewrite.c b/source4/smbd/rewrite.c
index b0ef693497..5bc826bf71 100644
--- a/source4/smbd/rewrite.c
+++ b/source4/smbd/rewrite.c
@@ -96,7 +96,7 @@ void init_subsystems(void)
/****************************************************************************
Reload the services file.
**************************************************************************/
-BOOL reload_services(struct smbsrv_context *smb, BOOL test)
+BOOL reload_services(struct smbsrv_connection *smb, BOOL test)
{
BOOL ret;