From 37d53832a4623653f706e77985a79d84bd7c6694 Mon Sep 17 00:00:00 2001
From: Jelmer Vernooij <jelmer@samba.org>
Date: Fri, 28 Sep 2007 01:17:46 +0000
Subject: r25398: Parse loadparm context to all lp_*() functions. (This used to
 be commit 3fcc960839c6e5ca4de2c3c042f12f369ac5f238)

---
 source4/smb_server/smb/negprot.c | 54 +++++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 26 deletions(-)

(limited to 'source4/smb_server/smb/negprot.c')

diff --git a/source4/smb_server/smb/negprot.c b/source4/smb_server/smb/negprot.c
index f5ae0aa5078..a35f86367b9 100644
--- a/source4/smb_server/smb/negprot.c
+++ b/source4/smb_server/smb/negprot.c
@@ -91,7 +91,7 @@ this any more it probably doesn't matter
 ****************************************************************************/
 static void reply_coreplus(struct smbsrv_request *req, uint16_t choice)
 {
-	uint16_t raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0);
+	uint16_t raw = (lp_readraw(global_loadparm)?1:0) | (lp_writeraw(global_loadparm)?2:0);
 
 	smbsrv_setup_reply(req, 13, 0);
 
@@ -122,13 +122,13 @@ static void reply_coreplus(struct smbsrv_request *req, uint16_t choice)
 ****************************************************************************/
 static void reply_lanman1(struct smbsrv_request *req, uint16_t choice)
 {
-	int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0);
+	int raw = (lp_readraw(global_loadparm)?1:0) | (lp_writeraw(global_loadparm)?2:0);
 	int secword=0;
 	time_t t = req->request_time.tv_sec;
 
-	req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords();
+	req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords(global_loadparm);
 
-	if (lp_security() != SEC_SHARE)
+	if (lp_security(global_loadparm) != SEC_SHARE)
 		secword |= NEGOTIATE_SECURITY_USER_LEVEL;
 
 	if (req->smb_conn->negotiate.encrypted_passwords)
@@ -145,7 +145,7 @@ 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_conn->negotiate.max_recv);
-	SSVAL(req->out.vwv, VWV(3), lp_maxmux());
+	SSVAL(req->out.vwv, VWV(3), lp_maxmux(global_loadparm));
 	SSVAL(req->out.vwv, VWV(4), 1);
 	SSVAL(req->out.vwv, VWV(5), raw); 
 	SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.id);
@@ -180,13 +180,13 @@ static void reply_lanman1(struct smbsrv_request *req, uint16_t choice)
 ****************************************************************************/
 static void reply_lanman2(struct smbsrv_request *req, uint16_t choice)
 {
-	int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0);
+	int raw = (lp_readraw(global_loadparm)?1:0) | (lp_writeraw(global_loadparm)?2:0);
 	int secword=0;
 	time_t t = req->request_time.tv_sec;
 
-	req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords();
+	req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords(global_loadparm);
   
-	if (lp_security() != SEC_SHARE)
+	if (lp_security(global_loadparm) != SEC_SHARE)
 		secword |= NEGOTIATE_SECURITY_USER_LEVEL;
 
 	if (req->smb_conn->negotiate.encrypted_passwords)
@@ -199,7 +199,7 @@ static void reply_lanman2(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_conn->negotiate.max_recv);
-	SSVAL(req->out.vwv, VWV(3), lp_maxmux());
+	SSVAL(req->out.vwv, VWV(3), lp_maxmux(global_loadparm));
 	SSVAL(req->out.vwv, VWV(4), 1);
 	SSVAL(req->out.vwv, VWV(5), raw); 
 	SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.id);
@@ -214,7 +214,7 @@ static void reply_lanman2(struct smbsrv_request *req, uint16_t choice)
 		get_challenge(req->smb_conn, req->out.data);
 	}
 
-	req_push_str(req, NULL, lp_workgroup(), -1, STR_TERMINATE);
+	req_push_str(req, NULL, lp_workgroup(global_loadparm), -1, STR_TERMINATE);
 
 	if (req->smb_conn->signing.mandatory_signing) {
 		smbsrv_terminate_connection(req->smb_conn, 
@@ -236,8 +236,8 @@ static void reply_nt1_orig(struct smbsrv_request *req)
 		req->out.ptr += 8;
 		SCVAL(req->out.vwv+1, VWV(16), 8);
 	}
-	req_push_str(req, NULL, lp_workgroup(), -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
-	req_push_str(req, NULL, lp_netbios_name(), -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
+	req_push_str(req, NULL, lp_workgroup(global_loadparm), -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
+	req_push_str(req, NULL, lp_netbios_name(global_loadparm), -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
 	DEBUG(3,("not using extended security (SPNEGO or NTLMSSP)\n"));
 }
 
@@ -260,24 +260,24 @@ 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_conn->negotiate.encrypted_passwords = lp_encrypted_passwords();
+	req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords(global_loadparm);
 
 	/* do spnego in user level security if the client
 	   supports it and we can do encrypted passwords */
 	
 	if (req->smb_conn->negotiate.encrypted_passwords && 
-	    (lp_security() != SEC_SHARE) &&
-	    lp_use_spnego() &&
+	    (lp_security(global_loadparm) != SEC_SHARE) &&
+	    lp_use_spnego(global_loadparm) &&
 	    (req->flags2 & FLAGS2_EXTENDED_SECURITY)) {
 		negotiate_spnego = True; 
 		capabilities |= CAP_EXTENDED_SECURITY;
 	}
 	
-	if (lp_unix_extensions()) {
+	if (lp_unix_extensions(global_loadparm)) {
 		capabilities |= CAP_UNIX;
 	}
 	
-	if (lp_large_readwrite()) {
+	if (lp_large_readwrite(global_loadparm)) {
 		capabilities |= CAP_LARGE_READX | CAP_LARGE_WRITEX | CAP_W2K_SMBS;
 	}
 
@@ -286,24 +286,24 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
 		capabilities |= CAP_LARGE_FILES;
 	}
 
-	if (lp_readraw() && lp_writeraw()) {
+	if (lp_readraw(global_loadparm) && lp_writeraw(global_loadparm)) {
 		capabilities |= CAP_RAW_MODE;
 	}
 	
 	/* allow for disabling unicode */
-	if (lp_unicode()) {
+	if (lp_unicode(global_loadparm)) {
 		capabilities |= CAP_UNICODE;
 	}
 
-	if (lp_nt_status_support()) {
+	if (lp_nt_status_support(global_loadparm)) {
 		capabilities |= CAP_STATUS32;
 	}
 	
-	if (lp_host_msdfs()) {
+	if (lp_host_msdfs(global_loadparm)) {
 		capabilities |= CAP_DFS;
 	}
 	
-	if (lp_security() != SEC_SHARE) {
+	if (lp_security(global_loadparm) != SEC_SHARE) {
 		secword |= NEGOTIATE_SECURITY_USER_LEVEL;
 	}
 
@@ -330,7 +330,7 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
 	   this is the one and only SMB packet that is malformed in
 	   the specification - all the command words after the secword
 	   are offset by 1 byte */
-	SSVAL(req->out.vwv+1, VWV(1), lp_maxmux());
+	SSVAL(req->out.vwv+1, VWV(1), lp_maxmux(global_loadparm));
 	SSVAL(req->out.vwv+1, VWV(2), 1); /* num vcs */
 	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 */
@@ -371,7 +371,7 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
 			return;
 		}
 		
-		cli_credentials_set_conf(server_credentials);
+		cli_credentials_set_conf(server_credentials, global_loadparm);
 		nt_status = cli_credentials_set_machine_account(server_credentials);
 		if (!NT_STATUS_IS_OK(nt_status)) {
 			DEBUG(10, ("Failed to obtain server credentials, perhaps a standalone server?: %s\n", nt_errstr(nt_status)));
@@ -517,8 +517,10 @@ void smbsrv_reply_negprot(struct smbsrv_request *req)
 	for (protocol = 0; supported_protocols[protocol].proto_name; protocol++) {
 		int i;
 
-		if (supported_protocols[protocol].protocol_level > lp_srv_maxprotocol()) continue;
-		if (supported_protocols[protocol].protocol_level < lp_srv_minprotocol()) continue;
+		if (supported_protocols[protocol].protocol_level > lp_srv_maxprotocol(global_loadparm)) 
+			continue;
+		if (supported_protocols[protocol].protocol_level < lp_srv_minprotocol(global_loadparm)) 
+			continue;
 
 		for (i = 0; i < protos_count; i++) {
 			if (strcmp(supported_protocols[protocol].proto_name, protos[i]) != 0) continue;
-- 
cgit