diff options
Diffstat (limited to 'source4/smb_server')
-rw-r--r-- | source4/smb_server/conn.c | 42 | ||||
-rw-r--r-- | source4/smb_server/connection.c | 2 | ||||
-rw-r--r-- | source4/smb_server/negprot.c | 106 | ||||
-rw-r--r-- | source4/smb_server/password.c | 8 | ||||
-rw-r--r-- | source4/smb_server/reply.c | 42 | ||||
-rw-r--r-- | source4/smb_server/request.c | 18 | ||||
-rw-r--r-- | source4/smb_server/search.c | 2 | ||||
-rw-r--r-- | source4/smb_server/service.c | 16 | ||||
-rw-r--r-- | source4/smb_server/session.c | 2 | ||||
-rw-r--r-- | source4/smb_server/sesssetup.c | 22 | ||||
-rw-r--r-- | source4/smb_server/signing.c | 24 | ||||
-rw-r--r-- | source4/smb_server/smb_server.c | 88 | ||||
-rw-r--r-- | source4/smb_server/srvtime.c | 12 | ||||
-rw-r--r-- | source4/smb_server/trans2.c | 30 |
14 files changed, 207 insertions, 207 deletions
diff --git a/source4/smb_server/conn.c b/source4/smb_server/conn.c index 490dde979c..4a5a6a6ed0 100644 --- a/source4/smb_server/conn.c +++ b/source4/smb_server/conn.c @@ -30,18 +30,18 @@ /**************************************************************************** init the conn structures ****************************************************************************/ -void conn_init(struct server_context *smb) +void conn_init(struct smbsrv_context *smb_ctx) { - smb->tree.bmap = bitmap_allocate(MAX_CONNECTIONS); + smb_ctx->tree.bmap = bitmap_allocate(MAX_CONNECTIONS); } /**************************************************************************** check if a snum is in use ****************************************************************************/ -BOOL conn_snum_used(struct server_context *smb, int snum) +BOOL conn_snum_used(struct smbsrv_context *smb_ctx, int snum) { struct tcon_context *conn; - for (conn=smb->tree.connections;conn;conn=conn->next) { + for (conn=smb_ctx->tree.connections;conn;conn=conn->next) { if (conn->service == snum) { return(True); } @@ -53,15 +53,15 @@ BOOL conn_snum_used(struct server_context *smb, int snum) /**************************************************************************** find a conn given a cnum ****************************************************************************/ -struct tcon_context *conn_find(struct server_context *smb, uint_t cnum) +struct tcon_context *conn_find(struct smbsrv_context *smb_ctx, uint_t cnum) { int count=0; struct tcon_context *conn; - for (conn=smb->tree.connections;conn;conn=conn->next,count++) { + for (conn=smb_ctx->tree.connections;conn;conn=conn->next,count++) { if (conn->cnum == cnum) { if (count > 10) { - DLIST_PROMOTE(smb->tree.connections, conn); + DLIST_PROMOTE(smb_ctx->tree.connections, conn); } return conn; } @@ -76,13 +76,13 @@ struct tcon_context *conn_find(struct server_context *smb, uint_t cnum) The randomisation stops problems with the server dieing and clients thinking the server is still available. ****************************************************************************/ -struct tcon_context *conn_new(struct server_context *smb) +struct tcon_context *conn_new(struct smbsrv_context *smb_ctx) { TALLOC_CTX *mem_ctx; struct tcon_context *conn; int i; - i = bitmap_find(smb->tree.bmap, 1); + i = bitmap_find(smb_ctx->tree.bmap, 1); if (i == -1) { DEBUG(1,("ERROR! Out of connection structures\n")); @@ -98,13 +98,13 @@ struct tcon_context *conn_new(struct server_context *smb) conn->mem_ctx = mem_ctx; conn->cnum = i; - conn->smb = smb; + conn->smb_ctx = smb_ctx; - bitmap_set(smb->tree.bmap, i); + bitmap_set(smb_ctx->tree.bmap, i); - smb->tree.num_open++; + smb_ctx->tree.num_open++; - DLIST_ADD(smb->tree.connections, conn); + DLIST_ADD(smb_ctx->tree.connections, conn); return conn; } @@ -112,10 +112,10 @@ struct tcon_context *conn_new(struct server_context *smb) /**************************************************************************** close all conn structures ****************************************************************************/ -void conn_close_all(struct server_context *smb) +void conn_close_all(struct smbsrv_context *smb_ctx) { struct tcon_context *conn, *next; - for (conn=smb->tree.connections;conn;conn=next) { + for (conn=smb_ctx->tree.connections;conn;conn=next) { next=conn->next; close_cnum(conn); } @@ -126,12 +126,12 @@ void conn_close_all(struct server_context *smb) /**************************************************************************** clear a vuid out of the validity cache, and as the 'owner' of a connection. ****************************************************************************/ -void conn_clear_vuid_cache(struct server_context *smb, uint16_t vuid) +void conn_clear_vuid_cache(struct smbsrv_context *smb_ctx, uint16_t vuid) { struct tcon_context *conn; uint_t i; - for (conn=smb->tree.connections;conn;conn=conn->next) { + for (conn=smb_ctx->tree.connections;conn;conn=conn->next) { for (i=0;i<conn->vuid_cache.entries && i< VUID_CACHE_SIZE;i++) { if (conn->vuid_cache.list[i] == vuid) { conn->vuid_cache.list[i] = UID_FIELD_INVALID; @@ -145,12 +145,12 @@ void conn_clear_vuid_cache(struct server_context *smb, uint16_t vuid) Free a conn structure. ****************************************************************************/ -void conn_free(struct server_context *smb, struct tcon_context *conn) +void conn_free(struct smbsrv_context *smb_ctx, struct tcon_context *conn) { - DLIST_REMOVE(smb->tree.connections, conn); + DLIST_REMOVE(smb_ctx->tree.connections, conn); - bitmap_clear(smb->tree.bmap, conn->cnum); - smb->tree.num_open--; + bitmap_clear(smb_ctx->tree.bmap, conn->cnum); + smb_ctx->tree.num_open--; talloc_destroy(conn->mem_ctx); } diff --git a/source4/smb_server/connection.c b/source4/smb_server/connection.c index 389cf3c6dc..8b984754ba 100644 --- a/source4/smb_server/connection.c +++ b/source4/smb_server/connection.c @@ -166,7 +166,7 @@ BOOL claim_connection(struct tcon_context *conn, const char *name,int max_connec crec.bcast_msg_flags = msg_flags; StrnCpy(crec.machine,sub_get_remote_machine(),sizeof(crec.machine)-1); - StrnCpy(crec.addr,conn?conn->smb->socket.client_addr:"NONE",sizeof(crec.addr)-1); + StrnCpy(crec.addr,conn?conn->smb_ctx->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 9c9517e43b..dfeb9ef457 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 server_context *smb, char buff[8]) +static void get_challenge(struct smbsrv_context *smb_ctx, char buff[8]) { NTSTATUS nt_status; const uint8_t *cryptkey; /* muliple negprots are not premitted */ - if (smb->negotiate.auth_context) { + if (smb_ctx->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->negotiate.auth_context); + nt_status = make_auth_context_subsystem(&smb_ctx->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 server_context *smb, char buff[8]) } DEBUG(10, ("get challenge: getting challenge\n")); - cryptkey = smb->negotiate.auth_context->get_ntlm_challenge(smb->negotiate.auth_context); + cryptkey = smb_ctx->negotiate.auth_context->get_ntlm_challenge(smb_ctx->negotiate.auth_context); memcpy(buff, cryptkey, 8); } @@ -55,7 +55,7 @@ static void reply_corep(struct request_context *req, uint16_t choice) SSVAL(req->out.vwv, VWV(0), choice); - req->smb->negotiate.protocol = PROTOCOL_CORE; + req->smb_ctx->negotiate.protocol = PROTOCOL_CORE; req_send_reply(req); } @@ -82,7 +82,7 @@ static void reply_coreplus(struct request_context *req, uint16_t choice) readbraw and writebraw (possibly) */ SSVAL(req->out.vwv, VWV(5), raw); - req->smb->negotiate.protocol = PROTOCOL_COREPLUS; + req->smb_ctx->negotiate.protocol = PROTOCOL_COREPLUS; req_send_reply(req); } @@ -96,17 +96,17 @@ static void reply_lanman1(struct request_context *req, uint16_t choice) int secword=0; time_t t = req->request_time.tv_sec; - req->smb->negotiate.encrypted_passwords = lp_encrypted_passwords(); + req->smb_ctx->negotiate.encrypted_passwords = lp_encrypted_passwords(); if (lp_security() != SEC_SHARE) secword |= NEGOTIATE_SECURITY_USER_LEVEL; - if (req->smb->negotiate.encrypted_passwords) + if (req->smb_ctx->negotiate.encrypted_passwords) secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE; - req->smb->negotiate.protocol = PROTOCOL_LANMAN1; + req->smb_ctx->negotiate.protocol = PROTOCOL_LANMAN1; - req_setup_reply(req, 13, req->smb->negotiate.encrypted_passwords ? 8 : 0); + req_setup_reply(req, 13, req->smb_ctx->negotiate.encrypted_passwords ? 8 : 0); /* SMBlockread, SMBwritelock supported. */ SCVAL(req->out.hdr,HDR_FLG, @@ -114,18 +114,18 @@ static void reply_lanman1(struct request_context *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->negotiate.max_recv); + SSVAL(req->out.vwv, VWV(2), req->smb_ctx->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->pid); - srv_push_dos_date(req->smb, req->out.vwv, VWV(8), t); - SSVAL(req->out.vwv, VWV(10), req->smb->negotiate.zone_offset/60); + 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); /* Create a token value and add it to the outgoing packet. */ - if (req->smb->negotiate.encrypted_passwords) { + if (req->smb_ctx->negotiate.encrypted_passwords) { SSVAL(req->out.vwv, VWV(11), 8); - get_challenge(req->smb, req->out.data); + get_challenge(req->smb_ctx, req->out.data); } req_send_reply(req); @@ -140,33 +140,33 @@ static void reply_lanman2(struct request_context *req, uint16_t choice) int secword=0; time_t t = req->request_time.tv_sec; - req->smb->negotiate.encrypted_passwords = lp_encrypted_passwords(); + req->smb_ctx->negotiate.encrypted_passwords = lp_encrypted_passwords(); if (lp_security() != SEC_SHARE) secword |= NEGOTIATE_SECURITY_USER_LEVEL; - if (req->smb->negotiate.encrypted_passwords) + if (req->smb_ctx->negotiate.encrypted_passwords) secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE; - req->smb->negotiate.protocol = PROTOCOL_LANMAN2; + req->smb_ctx->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->negotiate.max_recv); + SSVAL(req->out.vwv, VWV(2), req->smb_ctx->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->pid); - srv_push_dos_date(req->smb, req->out.vwv, VWV(8), t); - SSVAL(req->out.vwv, VWV(10), req->smb->negotiate.zone_offset/60); + 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); /* Create a token value and add it to the outgoing packet. */ - if (req->smb->negotiate.encrypted_passwords) { + if (req->smb_ctx->negotiate.encrypted_passwords) { SSVAL(req->out.vwv, VWV(11), 8); req_grow_data(req, 8); - get_challenge(req->smb, req->out.data); + get_challenge(req->smb_ctx, req->out.data); } req_push_str(req, NULL, lp_workgroup(), -1, STR_TERMINATE); @@ -179,7 +179,7 @@ static void reply_lanman2(struct request_context *req, uint16_t choice) /**************************************************************************** Generate the spnego negprot reply blob. Return the number of bytes used. ****************************************************************************/ -static DATA_BLOB negprot_spnego(struct server_context *smb) +static DATA_BLOB negprot_spnego(struct smbsrv_context *smb_ctx) { DATA_BLOB blob; uint8_t guid[16]; @@ -190,7 +190,7 @@ static DATA_BLOB negprot_spnego(struct server_context *smb) const char *OIDs_plain[] = {OID_NTLMSSP, NULL}; char *principal; - smb->negotiate.spnego_negotiated = True; + smb_ctx->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 request_context *req, uint16_t choice) CAP_NT_FIND | CAP_LOCK_AND_READ | CAP_LEVEL_II_OPLOCKS | CAP_NT_SMBS | CAP_RPC_REMOTE_APIS; - req->smb->negotiate.encrypted_passwords = lp_encrypted_passwords(); + req->smb_ctx->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->negotiate.encrypted_passwords && + if (req->smb_ctx->negotiate.encrypted_passwords && (lp_security() != SEC_SHARE) && lp_use_spnego() && (req->flags2 & FLAGS2_EXTENDED_SECURITY)) { @@ -283,13 +283,13 @@ static void reply_nt1(struct request_context *req, uint16_t choice) secword |= NEGOTIATE_SECURITY_USER_LEVEL; } - if (req->smb->negotiate.encrypted_passwords) { + if (req->smb_ctx->negotiate.encrypted_passwords) { secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE; } - req->smb->signing.signing_state = lp_server_signing(); + req->smb_ctx->signing.signing_state = lp_server_signing(); - switch (req->smb->signing.signing_state) { + switch (req->smb_ctx->signing.signing_state) { case SMB_SIGNING_OFF: break; case SMB_SIGNING_SUPPORTED: @@ -301,7 +301,7 @@ static void reply_nt1(struct request_context *req, uint16_t choice) break; } - req->smb->negotiate.protocol = PROTOCOL_NT1; + req->smb_ctx->negotiate.protocol = PROTOCOL_NT1; req_setup_reply(req, 17, 0); @@ -314,20 +314,20 @@ static void reply_nt1(struct request_context *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->negotiate.max_recv); + SIVAL(req->out.vwv+1, VWV(3), req->smb_ctx->negotiate.max_recv); SIVAL(req->out.vwv+1, VWV(5), 0x10000); /* raw size. full 64k */ - SIVAL(req->out.vwv+1, VWV(7), req->smb->pid); /* session key */ + SIVAL(req->out.vwv+1, VWV(7), req->smb_ctx->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->negotiate.zone_offset/60); + SSVALS(req->out.vwv+1,VWV(15), req->smb_ctx->negotiate.zone_offset/60); if (!negotiate_spnego) { /* Create a token value and add it to the outgoing packet. */ - if (req->smb->negotiate.encrypted_passwords) { + if (req->smb_ctx->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, req->out.ptr); + get_challenge(req->smb_ctx, req->out.ptr); req->out.ptr += 8; SCVAL(req->out.vwv+1, VWV(16), 8); } @@ -336,13 +336,13 @@ static void reply_nt1(struct request_context *req, uint16_t choice) DEBUG(3,("not using SPNEGO\n")); } else { #if 0 - DATA_BLOB blob = negprot_spnego(req->smb); + DATA_BLOB blob = negprot_spnego(req->smb_ctx); req_grow_data(req, blob.length); memcpy(req->out.ptr, blob.data, blob.length); DEBUG(3,("using SPNEGO\n")); #else - exit_server(req->smb, "no SPNEGO please"); + exit_server(req->smb_ctx, "no SPNEGO please"); #endif } @@ -449,10 +449,10 @@ void reply_negprot(struct request_context *req) char *p; int arch = ARCH_ALL; - if (req->smb->negotiate.done_negprot) { - exit_server(req->smb, "multiple negprot's are not permitted"); + if (req->smb_ctx->negotiate.done_negprot) { + exit_server(req->smb_ctx, "multiple negprot's are not permitted"); } - req->smb->negotiate.done_negprot = True; + req->smb_ctx->negotiate.done_negprot = True; p = req->in.data + 1; @@ -485,33 +485,33 @@ void reply_negprot(struct request_context *req) switch (arch) { case ARCH_SAMBA: - set_remote_arch(req->smb, RA_SAMBA); + set_remote_arch(req->smb_ctx, RA_SAMBA); break; case ARCH_WFWG: - set_remote_arch(req->smb, RA_WFWG); + set_remote_arch(req->smb_ctx, RA_WFWG); break; case ARCH_WIN95: - set_remote_arch(req->smb, RA_WIN95); + set_remote_arch(req->smb_ctx, RA_WIN95); break; case ARCH_WINNT: if (req->flags2==FLAGS2_WIN2K_SIGNATURE) - set_remote_arch(req->smb, RA_WIN2K); + set_remote_arch(req->smb_ctx, RA_WIN2K); else - set_remote_arch(req->smb, RA_WINNT); + set_remote_arch(req->smb_ctx, RA_WINNT); break; case ARCH_WIN2K: - set_remote_arch(req->smb, RA_WIN2K); + set_remote_arch(req->smb_ctx, RA_WIN2K); break; case ARCH_OS2: - set_remote_arch(req->smb, RA_OS2); + set_remote_arch(req->smb_ctx, RA_OS2); break; default: - set_remote_arch(req->smb, RA_UNKNOWN); + set_remote_arch(req->smb_ctx, RA_UNKNOWN); break; } /* possibly reload - change of architecture */ - reload_services(req->smb, True); + reload_services(req->smb_ctx, True); /* Check for protocols, most desirable first */ for (protocol = 0; supported_protocols[protocol].proto_name; protocol++) { @@ -531,7 +531,7 @@ void reply_negprot(struct request_context *req) if(choice != -1) { sub_set_remote_proto(supported_protocols[protocol].short_name); - reload_services(req->smb, True); + reload_services(req->smb_ctx, 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 075638852c..bfd3ebd82b 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 server_context *smb, uint16_t vuid) +struct user_struct *get_valid_user_struct(struct smbsrv_context *smb, uint16_t vuid) { user_struct *usp; int count=0; @@ -49,7 +49,7 @@ struct user_struct *get_valid_user_struct(struct server_context *smb, uint16_t v /**************************************************************************** invalidate a uid ****************************************************************************/ -void invalidate_vuid(struct server_context *smb, uint16_t vuid) +void invalidate_vuid(struct smbsrv_context *smb, uint16_t vuid) { user_struct *vuser = get_valid_user_struct(smb, vuid); @@ -73,7 +73,7 @@ void invalidate_vuid(struct server_context *smb, uint16_t vuid) /**************************************************************************** invalidate all vuid entries for this process ****************************************************************************/ -void invalidate_all_vuids(struct server_context *smb) +void invalidate_all_vuids(struct smbsrv_context *smb) { user_struct *usp, *next=NULL; @@ -98,7 +98,7 @@ void invalidate_all_vuids(struct server_context *smb) * */ -int register_vuid(struct server_context *smb, +int register_vuid(struct smbsrv_context *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 984d1be705..7ff8929a65 100644 --- a/source4/smb_server/reply.c +++ b/source4/smb_server/reply.c @@ -160,7 +160,7 @@ void reply_tcon_and_X(struct request_context *req) } /* construct reply - two variants */ - if (req->smb->negotiate.protocol < PROTOCOL_NT1) { + if (req->smb_ctx->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 request_context *req) req_setup_reply(req, 10, 0); SSVAL(req->out.vwv, VWV(0), st->getattr.out.attrib); - srv_push_dos_date3(req->smb, req->out.vwv, VWV(1), st->getattr.out.write_time); + srv_push_dos_date3(req->smb_ctx, 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 request_context *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, req->in.vwv + VWV(1)); + st->setattr.in.write_time = srv_pull_dos_date3(req->smb_ctx, 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 request_context *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, req->out.vwv, VWV(2), oi->open.out.write_time); + srv_push_dos_date3(req->smb_ctx, 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 request_context *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, req->out.vwv, VWV(4), oi->openx.out.write_time); + srv_push_dos_date3(req->smb_ctx, 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 request_context *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, req->in.vwv + VWV(6)); + oi->openx.in.write_time = srv_pull_dos_date3(req->smb_ctx, 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 request_context *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, req->in.vwv + VWV(1)); + oi->mknew.in.write_time = srv_pull_dos_date3(req->smb_ctx, 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 request_context *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, req->in.vwv + VWV(1)); + oi->ctemp.in.write_time = srv_pull_dos_date3(req->smb_ctx, 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 request_context *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, req->in.vwv + VWV(1)); + io->close.in.write_time = srv_pull_dos_date3(req->smb_ctx, req->in.vwv + VWV(1)); req->async.send_fn = reply_simple_send; @@ -1231,7 +1231,7 @@ void reply_writeclose(struct request_context *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, req->in.vwv + VWV(4)); + io->writeclose.in.mtime = srv_pull_dos_date3(req->smb_ctx, 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 request_context *req) req->out.ptr = req->out.data + 3; for (i=0;i<lpq->retq.out.count;i++) { - srv_push_dos_date2(req->smb, req->out.ptr, 0 , lpq->retq.out.queue[i].time); + srv_push_dos_date2(req->smb_ctx, 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 request_context *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, req->in.vwv + VWV(1)); - info->setattre.in.access_time = srv_pull_dos_date2(req->smb, req->in.vwv + VWV(3)); - info->setattre.in.write_time = srv_pull_dos_date2(req->smb, req->in.vwv + VWV(5)); + 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)); req->async.send_fn = reply_simple_send; @@ -1852,9 +1852,9 @@ static void reply_getattrE_send(struct request_context *req) /* setup reply */ req_setup_reply(req, 11, 0); - srv_push_dos_date2(req->smb, req->out.vwv, VWV(0), info->getattre.out.create_time); - srv_push_dos_date2(req->smb, req->out.vwv, VWV(2), info->getattre.out.access_time); - srv_push_dos_date2(req->smb, req->out.vwv, VWV(4), info->getattre.out.write_time); + 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); 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 request_context *req) DEBUG(0,("REWRITE: not closing user files\n")); } - invalidate_vuid(req->smb, vuid); + invalidate_vuid(req->smb_ctx, vuid); req_setup_reply(req, 2, 0); @@ -2298,8 +2298,8 @@ void reply_special(struct request_context *req) switch (msg_type) { case 0x81: /* session request */ - if (req->smb->negotiate.done_nbt_session) { - exit_server(req->smb, "multiple session request not permitted"); + if (req->smb_ctx->negotiate.done_nbt_session) { + exit_server(req->smb_ctx, "multiple session request not permitted"); } SCVAL(buf,0,0x82); @@ -2307,7 +2307,7 @@ void reply_special(struct request_context *req) DEBUG(0,("REWRITE: not parsing netbios names in NBT session request!\n")); - req->smb->negotiate.done_nbt_session = True; + req->smb_ctx->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 8f545e8f59..6361325f22 100644 --- a/source4/smb_server/request.c +++ b/source4/smb_server/request.c @@ -45,7 +45,7 @@ void req_destroy(struct request_context *req) construct a basic request packet, mostly used to construct async packets such as change notify and oplock break requests ****************************************************************************/ -struct request_context *init_smb_request(struct server_context *smb) +struct request_context *init_smb_request(struct smbsrv_context *smb_ctx) { struct request_context *req; TALLOC_CTX *mem_ctx; @@ -54,12 +54,12 @@ struct request_context *init_smb_request(struct server_context *smb) 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->socket.pkt_count); + mem_ctx = talloc_init("request_context[%d]", smb_ctx->socket.pkt_count); if (!mem_ctx) { return NULL; } - smb->socket.pkt_count++; + smb_ctx->socket.pkt_count++; req = talloc(mem_ctx, sizeof(*req)); if (!req) { @@ -69,7 +69,7 @@ struct request_context *init_smb_request(struct server_context *smb) ZERO_STRUCTP(req); /* setup the request context */ - req->smb = smb; + req->smb_ctx = smb_ctx; req->mem_ctx = mem_ctx; return req; @@ -91,7 +91,7 @@ static void req_setup_chain_reply(struct request_context *req, uint_t wct, uint_ req->out.buffer = talloc_realloc(req->mem_ctx, req->out.buffer, req->out.allocated); if (!req->out.buffer) { - exit_server(req->smb, "allocation failed"); + exit_server(req->smb_ctx, "allocation failed"); } req->out.hdr = req->out.buffer + NBT_HDR_SIZE; @@ -125,7 +125,7 @@ void req_setup_reply(struct request_context *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, "allocation failed"); + exit_server(req->smb_ctx, "allocation failed"); } req->out.hdr = req->out.buffer + NBT_HDR_SIZE; @@ -175,7 +175,7 @@ void req_setup_reply(struct request_context *req, uint_t wct, uint_t buflen) int req_max_data(struct request_context *req) { int ret; - ret = req->smb->negotiate.max_send; + ret = req->smb_ctx->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 request_context *req) _smb_setlen(req->out.buffer, req->out.size - NBT_HDR_SIZE); } - if (write_data(req->smb->socket.fd, req->out.buffer, req->out.size) != req->out.size) { + if (write_data(req->smb_ctx->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 request_context *req, uint8_t eclass, uint16_t e */ void req_setup_error(struct request_context *req, NTSTATUS status) { - if (!lp_nt_status_support() || !(req->smb->negotiate.client_caps & CAP_STATUS32)) { + if (!lp_nt_status_support() || !(req->smb_ctx->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 8a4b48387e..63ae521783 100644 --- a/source4/smb_server/search.c +++ b/source4/smb_server/search.c @@ -78,7 +78,7 @@ static void find_fill_info(struct request_context *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, (uint8_t *)&dos_date, 0, file->search.write_time); + srv_push_dos_date3(req->smb_ctx, (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 5d4cb3f0fd..a7b1c33395 100644 --- a/source4/smb_server/service.c +++ b/source4/smb_server/service.c @@ -143,7 +143,7 @@ static NTSTATUS make_connection_snum(struct request_context *req, struct tcon_context *conn; NTSTATUS status; - conn = conn_new(req->smb); + conn = conn_new(req->smb_ctx); if (!conn) { DEBUG(0,("Couldn't find free connection.\n")); return NT_STATUS_INSUFFICIENT_RESOURCES; @@ -165,7 +165,7 @@ static NTSTATUS make_connection_snum(struct request_context *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, conn); + conn_free(req->smb_ctx, conn); return NT_STATUS_ACCESS_DENIED; } else { conn->read_only = True; @@ -178,7 +178,7 @@ static NTSTATUS make_connection_snum(struct request_context *req, lp_max_connections(SNUM(conn)), False,0)) { DEBUG(1,("too many connections - rejected\n")); - conn_free(req->smb, conn); + conn_free(req->smb_ctx, conn); return NT_STATUS_INSUFFICIENT_RESOURCES; } @@ -186,7 +186,7 @@ static NTSTATUS make_connection_snum(struct request_context *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(conn)))); - conn_free(req->smb, conn); + conn_free(req->smb_ctx, conn); return status; } @@ -195,7 +195,7 @@ static NTSTATUS make_connection_snum(struct request_context *req, status = conn->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, conn); + conn_free(req->smb_ctx, conn); return status; } } @@ -259,14 +259,14 @@ close a cnum void close_cnum(struct tcon_context *conn) { DEBUG(3,("%s closed connection to service %s\n", - conn->smb->socket.client_addr, lp_servicename(SNUM(conn)))); + conn->smb_ctx->socket.client_addr, lp_servicename(SNUM(conn)))); yield_connection(conn, lp_servicename(SNUM(conn))); /* tell the ntvfs backend that we are disconnecting */ conn->ntvfs_ops->disconnect(conn); - conn_free(conn->smb, conn); + conn_free(conn->smb_ctx, conn); } @@ -293,7 +293,7 @@ NTSTATUS tcon_backend(struct request_context *req, union smb_tcon *con) return status; } - con->tcon.out.max_xmit = req->smb->negotiate.max_recv; + con->tcon.out.max_xmit = req->smb_ctx->negotiate.max_recv; con->tcon.out.cnum = req->conn->cnum; return status; diff --git a/source4/smb_server/session.c b/source4/smb_server/session.c index 7f85fca2ac..dc131b366c 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 server_context *smb, user_struct *vuser) +BOOL session_claim(struct smbsrv_context *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 dcaf25bb84..f438f84712 100644 --- a/source4/smb_server/sesssetup.c +++ b/source4/smb_server/sesssetup.c @@ -46,8 +46,8 @@ static NTSTATUS sesssetup_old(struct request_context *req, union smb_sesssetup * struct auth_session_info *session_info; DATA_BLOB null_blob; - if (!req->smb->negotiate.done_sesssetup) { - req->smb->negotiate.max_send = sess->old.in.bufsize; + if (!req->smb_ctx->negotiate.done_sesssetup) { + req->smb_ctx->negotiate.max_send = sess->old.in.bufsize; } null_blob.length = 0; @@ -60,7 +60,7 @@ static NTSTATUS sesssetup_old(struct request_context *req, union smb_sesssetup * return NT_STATUS_ACCESS_DENIED; } - status = req->smb->negotiate.auth_context->check_ntlm_password(req->smb->negotiate.auth_context, + status = req->smb_ctx->negotiate.auth_context->check_ntlm_password(req->smb_ctx->negotiate.auth_context, user_info, &server_info); if (!NT_STATUS_IS_OK(status)) { @@ -73,7 +73,7 @@ static NTSTATUS sesssetup_old(struct request_context *req, union smb_sesssetup * } sess->old.out.action = 0; - sess->old.out.vuid = register_vuid(req->smb, session_info, sess->old.in.user); + sess->old.out.vuid = register_vuid(req->smb_ctx, 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 request_context *req, union smb_sesssetup * struct auth_serversupplied_info *server_info = NULL; struct auth_session_info *session_info; - if (!req->smb->negotiate.done_sesssetup) { - req->smb->negotiate.max_send = sess->nt1.in.bufsize; - req->smb->negotiate.client_caps = sess->nt1.in.capabilities; + 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; } status = make_user_info_for_reply_enc(&user_info, @@ -106,7 +106,7 @@ static NTSTATUS sesssetup_nt1(struct request_context *req, union smb_sesssetup * return NT_STATUS_ACCESS_DENIED; } - status = req->smb->negotiate.auth_context->check_ntlm_password(req->smb->negotiate.auth_context, + status = req->smb_ctx->negotiate.auth_context->check_ntlm_password(req->smb_ctx->negotiate.auth_context, user_info, &server_info); if (!NT_STATUS_IS_OK(status)) { @@ -119,7 +119,7 @@ static NTSTATUS sesssetup_nt1(struct request_context *req, union smb_sesssetup * } sess->nt1.out.action = 0; - sess->nt1.out.vuid = register_vuid(req->smb, session_info, sess->old.in.user); + sess->nt1.out.vuid = register_vuid(req->smb_ctx, 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 request_context *req, union smb_sesssetup * &sess->nt1.out.lanman, &sess->nt1.out.domain); - srv_setup_signing(req->smb, &session_info->session_key, &sess->nt1.in.password2); + srv_setup_signing(req->smb_ctx, &session_info->session_key, &sess->nt1.in.password2); return NT_STATUS_OK; } @@ -157,7 +157,7 @@ NTSTATUS sesssetup_backend(struct request_context *req, return sesssetup_spnego(req, sess); } - req->smb->negotiate.done_sesssetup = True; + req->smb_ctx->negotiate.done_sesssetup = True; return NT_STATUS_INVALID_LEVEL; } diff --git a/source4/smb_server/signing.c b/source4/smb_server/signing.c index 0ac271a255..9fcd875e39 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 request_context *req) { /* check if we are doing signing on this connection */ - if (req->smb->signing.signing_state != SMB_SIGNING_REQUIRED) { + if (req->smb_ctx->signing.signing_state != SMB_SIGNING_REQUIRED) { return; } @@ -63,7 +63,7 @@ void req_sign_packet(struct request_context *req) mark_packet_signed(req); calc_signature(req->out.hdr, req->out.size - NBT_HDR_SIZE, - &req->smb->signing.mac_key, + &req->smb_ctx->signing.mac_key, &req->out.hdr[HDR_SS_FIELD]); } @@ -72,15 +72,15 @@ void req_sign_packet(struct request_context *req) setup the signing key for a connection. Called after authentication succeeds in a session setup */ -void srv_setup_signing(struct server_context *smb, +void srv_setup_signing(struct smbsrv_context *smb_ctx, DATA_BLOB *session_key, DATA_BLOB *session_response) { - smb->signing.mac_key = data_blob(NULL, + smb_ctx->signing.mac_key = data_blob(NULL, session_key->length + session_response->length); - memcpy(smb->signing.mac_key.data, session_key->data, session_key->length); + memcpy(smb_ctx->signing.mac_key.data, session_key->data, session_key->length); if (session_response->length != 0) { - memcpy(&smb->signing.mac_key.data[session_key->length], + memcpy(&smb_ctx->signing.mac_key.data[session_key->length], session_response->data, session_response->length); } @@ -92,12 +92,12 @@ void srv_setup_signing(struct server_context *smb, */ static void req_signing_alloc_seq_num(struct request_context *req) { - req->seq_num = req->smb->signing.next_seq_num; + req->seq_num = req->smb_ctx->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->signing.signing_state != SMB_SIGNING_OFF) { - req->smb->signing.next_seq_num += 2; + if (req->smb_ctx->signing.signing_state != SMB_SIGNING_OFF) { + req->smb_ctx->signing.next_seq_num += 2; } } @@ -108,12 +108,12 @@ BOOL req_signing_check_incoming(struct request_context *req) { uint8_t client_md5_mac[8], signature[8]; - switch (req->smb->signing.signing_state) { + switch (req->smb_ctx->signing.signing_state) { case SMB_SIGNING_OFF: return True; case SMB_SIGNING_SUPPORTED: if (req->flags2 & FLAGS2_SMB_SECURITY_SIGNATURES) { - req->smb->signing.signing_state = SMB_SIGNING_REQUIRED; + req->smb_ctx->signing.signing_state = SMB_SIGNING_REQUIRED; } return True; case SMB_SIGNING_REQUIRED: @@ -137,7 +137,7 @@ BOOL req_signing_check_incoming(struct request_context *req) SBVAL(req->in.hdr, HDR_SS_FIELD, req->seq_num); calc_signature(req->in.hdr, req->in.size - NBT_HDR_SIZE, - &req->smb->signing.mac_key, + &req->smb_ctx->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 e2ce4182a1..a89007d68d 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 tcon_context *conn, uint16_t fnum, uint8_t lev { struct request_context *req; - req = init_smb_request(conn->smb); + req = init_smb_request(conn->smb_ctx); req_setup_reply(req, 8, 0); @@ -57,20 +57,20 @@ BOOL req_send_oplock_break(struct tcon_context *conn, uint16_t fnum, uint8_t lev /**************************************************************************** receive a SMB request from the wire, forming a request_context from the result ****************************************************************************/ -static struct request_context *receive_smb_request(struct server_context *smb) +static struct request_context *receive_smb_request(struct smbsrv_context *smb_ctx) { ssize_t len, len2; char header[4]; struct request_context *req; - len = read_data(smb->socket.fd, header, 4); + len = read_data(smb_ctx->socket.fd, header, 4); if (len != 4) { return NULL; } len = smb_len(header); - req = init_smb_request(smb); + req = init_smb_request(smb_ctx); GetTimeOfDay(&req->request_time); req->chained_fnum = -1; @@ -81,7 +81,7 @@ static struct request_context *receive_smb_request(struct server_context *smb) /* fill in the already received header */ memcpy(req->in.buffer, header, 4); - len2 = read_data(smb->socket.fd, req->in.buffer + NBT_HDR_SIZE, len); + len2 = read_data(smb_ctx->socket.fd, req->in.buffer + NBT_HDR_SIZE, len); if (len2 != len) { return NULL; } @@ -122,7 +122,7 @@ static void setup_user_context(struct request_context *req) ctx = talloc(req->mem_ctx, sizeof(*ctx)); ctx->vuid = SVAL(req->in.hdr, HDR_UID); - ctx->vuser = get_valid_user_struct(req->smb, ctx->vuid); + ctx->vuser = get_valid_user_struct(req->smb_ctx, ctx->vuid); req->user_ctx = ctx; } @@ -437,7 +437,7 @@ static void switch_message(int type, struct request_context *req) { int flags; uint16_t session_tag; - struct server_context *smb = req->smb; + struct smbsrv_context *smb_ctx = req->smb_ctx; type &= 0xff; @@ -456,7 +456,7 @@ static void switch_message(int type, struct request_context *req) UID_FIELD_INVALID : SVAL(req->in.hdr,HDR_UID); - req->conn = conn_find(req->smb, SVAL(req->in.hdr,HDR_TID)); + req->conn = conn_find(smb_ctx, 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 request_context *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->model_ops->get_id(req))); + DEBUG(3,("switch message %s (task_id %d)\n",smb_fn_name(type), smb_ctx->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 request_context *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, "Non-SMB packet"); + exit_server(req->smb_ctx, "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, "Invalid SMB packet"); + exit_server(req->smb_ctx, "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, "Invalid SMB packet"); + exit_server(req->smb_ctx, "Invalid SMB packet"); return; } @@ -667,22 +667,22 @@ error: /* close the socket and shutdown a server_context */ -void server_terminate(struct server_context *smb) +void server_terminate(struct smbsrv_context *smb_ctx) { - close(smb->socket.fd); - event_remove_fd_all(smb->events, smb->socket.fd); + close(smb_ctx->socket.fd); + event_remove_fd_all(smb_ctx->events, smb_ctx->socket.fd); - conn_close_all(smb); + conn_close_all(smb_ctx); - talloc_destroy(smb->mem_ctx); + talloc_destroy(smb_ctx->mem_ctx); } /* called on a fatal error that should cause this server to terminate */ -void exit_server(struct server_context *smb, const char *reason) +void exit_server(struct smbsrv_context *smb_ctx, const char *reason) { - smb->model_ops->terminate_connection(smb, reason); + smb_ctx->model_ops->terminate_connection(smb_ctx, reason); } /* @@ -783,11 +783,11 @@ void smbd_read_handler(struct event_context *ev, struct fd_event *fde, time_t t, uint16_t flags) { struct request_context *req; - struct server_context *smb = fde->private; + struct smbsrv_context *smb_ctx = fde->private; - req = receive_smb_request(smb); + req = receive_smb_request(smb_ctx); if (!req) { - smb->model_ops->terminate_connection(smb, "receive error"); + smb_ctx->model_ops->terminate_connection(smb_ctx, "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 server_context *smb) +void smbd_process_async(struct smbsrv_context *smb_ctx) { struct request_context *req; - req = receive_smb_request(smb); + req = receive_smb_request(smb_ctx); if (!req) { - smb->model_ops->terminate_connection(smb, "receive error"); + smb_ctx->model_ops->terminate_connection(smb_ctx, "receive error"); return; } @@ -825,7 +825,7 @@ void smbd_process_async(struct server_context *smb) 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 server_context *smb; + struct smbsrv_context *smb_ctx; 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 = talloc_p(mem_ctx, struct server_context); - if (!smb) return; + smb_ctx = talloc_p(mem_ctx, struct smbsrv_context); + if (!smb_ctx) return; - ZERO_STRUCTP(smb); + ZERO_STRUCTP(smb_ctx); - smb->mem_ctx = mem_ctx; - smb->socket.fd = fd; - smb->pid = getpid(); + smb_ctx->mem_ctx = mem_ctx; + smb_ctx->socket.fd = fd; + smb_ctx->pid = getpid(); - sub_set_context(&smb->substitute); + sub_set_context(&smb_ctx->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->mem_ctx, fd); + socket_addr = get_socket_addr(smb_ctx->mem_ctx, fd); sub_set_remote_machine(socket_addr); - smb->socket.client_addr = socket_addr; + smb_ctx->socket.client_addr = socket_addr; /* now initialise a few default values associated with this smb socket */ - smb->negotiate.max_send = 0xFFFF; + smb_ctx->negotiate.max_send = 0xFFFF; /* this is the size that w2k uses, and it appears to be important for good performance */ - smb->negotiate.max_recv = lp_max_xmit(); + smb_ctx->negotiate.max_recv = lp_max_xmit(); - smb->negotiate.zone_offset = get_time_zone(time(NULL)); + smb_ctx->negotiate.zone_offset = get_time_zone(time(NULL)); - smb->users.next_vuid = VUID_OFFSET; + smb_ctx->users.next_vuid = VUID_OFFSET; - smb->events = ev; - smb->model_ops = model_ops; + smb_ctx->events = ev; + smb_ctx->model_ops = model_ops; - conn_init(smb); + conn_init(smb_ctx); /* 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; + fde.private = smb_ctx; fde.flags = EVENT_FD_READ; event_add_fd(ev, &fde); /* setup the DCERPC server subsystem */ - dcesrv_init_context(&smb->dcesrv); + dcesrv_init_context(&smb_ctx->dcesrv); } diff --git a/source4/smb_server/srvtime.c b/source4/smb_server/srvtime.c index 7eeb1fcff9..04b758bc79 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 server_context *smb_server, +void srv_push_dos_date(struct smbsrv_context *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 server_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 server_context *smb_server, +void srv_push_dos_date2(struct smbsrv_context *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 server_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 server_context *smb_server, +void srv_push_dos_date3(struct smbsrv_context *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 server_context *smb_server, /******************************************************************* convert a dos date ********************************************************************/ -time_t srv_pull_dos_date(struct server_context *smb_server, +time_t srv_pull_dos_date(struct smbsrv_context *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 server_context *smb_server, /******************************************************************* like srv_pull_dos_date() but the words are reversed ********************************************************************/ -time_t srv_pull_dos_date2(struct server_context *smb_server, +time_t srv_pull_dos_date2(struct smbsrv_context *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 server_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 server_context *smb_server, +time_t srv_pull_dos_date3(struct smbsrv_context *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 6985e0a4d1..922d225a8b 100644 --- a/source4/smb_server/trans2.c +++ b/source4/smb_server/trans2.c @@ -420,9 +420,9 @@ static NTSTATUS trans2_fileinfo_fill(struct request_context *req, struct smb_tra trans2_setup_reply(req, trans, 2, 22, 0); SSVAL(trans->out.params.data, 0, 0); - srv_push_dos_date2(req->smb, trans->out.data.data, 0, st->standard.out.create_time); - srv_push_dos_date2(req->smb, trans->out.data.data, 4, st->standard.out.access_time); - srv_push_dos_date2(req->smb, trans->out.data.data, 8, st->standard.out.write_time); + 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); 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 request_context *req, struct smb_tra trans2_setup_reply(req, trans, 2, 26, 0); SSVAL(trans->out.params.data, 0, 0); - srv_push_dos_date2(req->smb, trans->out.data.data, 0, st->ea_size.out.create_time); - srv_push_dos_date2(req->smb, trans->out.data.data, 4, st->ea_size.out.access_time); - srv_push_dos_date2(req->smb, trans->out.data.data, 8, st->ea_size.out.write_time); + 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); 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 request_context *req, case RAW_SFILEINFO_STANDARD: CHECK_MIN_BLOB_SIZE(blob, 12); - st->standard.in.create_time = srv_pull_dos_date2(req->smb, blob->data + 0); - st->standard.in.access_time = srv_pull_dos_date2(req->smb, blob->data + 4); - st->standard.in.write_time = srv_pull_dos_date2(req->smb, blob->data + 8); + 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); return NT_STATUS_OK; case RAW_SFILEINFO_EA_SET: @@ -896,9 +896,9 @@ static void find_fill_info(struct request_context *req, trans2_grow_data(req, trans, ofs + 23); } data = trans->out.data.data + ofs; - srv_push_dos_date2(req->smb, data, 0, file->standard.create_time); - srv_push_dos_date2(req->smb, data, 4, file->standard.access_time); - srv_push_dos_date2(req->smb, data, 8, file->standard.write_time); + 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); 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 request_context *req, trans2_grow_data(req, trans, ofs + 27); } data = trans->out.data.data + ofs; - srv_push_dos_date2(req->smb, data, 0, file->ea_size.create_time); - srv_push_dos_date2(req->smb, data, 4, file->ea_size.access_time); - srv_push_dos_date2(req->smb, data, 8, file->ea_size.write_time); + 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); SIVAL(data, 12, file->ea_size.size); SIVAL(data, 16, file->ea_size.alloc_size); SSVAL(data, 20, file->ea_size.attrib); |