]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Make substitute.c's "remote_proto" static
authorVolker Lendecke <vl@samba.org>
Wed, 30 Nov 2022 15:28:56 +0000 (16:28 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 12 Dec 2022 21:16:33 +0000 (21:16 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/lib/substitute.c
source3/lib/substitute.h
source3/smbd/smb1_negprot.c
source3/smbd/smb2_negprot.c

index a941b89f82a6092502a41888bc0b8dc1b16069ca..24486b86f8e51ae92553fb6bde0faaa77fd4afbf 100644 (file)
@@ -33,7 +33,12 @@ static char local_machine[MACHINE_NAME_SIZE];
 static char remote_machine[MACHINE_NAME_SIZE];
 
 userdom_struct current_user_info;
-fstring remote_proto="UNKNOWN";
+static fstring remote_proto="UNKNOWN";
+
+void set_remote_proto(const char *proto)
+{
+       fstrcpy(remote_proto, proto);
+}
 
 /**
  * Set the 'local' machine name
index 2056d163dd7d4679ae85f1da18e7bcfd17230737..ba903434ecac1133f91f7c1e4cc104d69c513abd 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef SUBSTITUTE_H
 #define SUBSTITUTE_H
 
+void set_remote_proto(const char *proto);
 bool set_local_machine_name(const char *local_name, bool perm);
 const char *get_local_machine_name(void);
 bool set_remote_machine_name(const char *remote_name, bool perm);
index 45d991b0dcd7227582db002e9c53a122bde743b8..db6cf629d9c5c77d60dfdae646eeece31b52a9b0 100644 (file)
@@ -28,6 +28,7 @@
 #include "auth/gensec/gensec.h"
 #include "../libcli/smb/smb_signing.h"
 #include "lib/util/string_wrappers.h"
+#include "source3/lib/substitute.h"
 
 /*
  * MS-CIFS, 2.2.4.52.2 SMB_COM_NEGOTIATE Response:
@@ -36,8 +37,6 @@
  */
 #define NO_PROTOCOL_CHOSEN     0xffff
 
-extern fstring remote_proto;
-
 static void get_challenge(struct smbXsrv_connection *xconn, uint8_t buff[8])
 {
        NTSTATUS nt_status;
@@ -676,7 +675,7 @@ void reply_negprot(struct smb_request *req)
                exit_server_cleanly("no protocol supported\n");
        }
 
-       fstrcpy(remote_proto,supported_protocols[protocol].short_name);
+       set_remote_proto(supported_protocols[protocol].short_name);
        reload_services(sconn, conn_snum_used, true);
        status = supported_protocols[protocol].proto_reply_fn(req, choice);
        if (!NT_STATUS_IS_OK(status)) {
index 2a1212a0ea52bca18e604a74b77fc9ebb332f261..408faf1481d47ddb053d1cf1cab361bb2930e462 100644 (file)
 #include "auth.h"
 #include "auth/gensec/gensec.h"
 #include "lib/util/string_wrappers.h"
+#include "source3/lib/substitute.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_SMB2
 
-extern fstring remote_proto;
-
 /*
  * this is the entry point if SMB2 is selected via
  * the SMB negprot and the given dialect.
@@ -334,11 +333,16 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req)
                break;
        }
 
-       fstr_sprintf(remote_proto, "SMB%X_%02X",
-                    (dialect >> 8) & 0xFF, dialect & 0xFF);
+       {
+               fstring proto;
+               fstr_sprintf(proto,
+                            "SMB%X_%02X",
+                            (dialect >> 8) & 0xFF, dialect & 0xFF);
+               set_remote_proto(proto);
+               DEBUG(3,("Selected protocol %s\n", proto));
+       }
 
        reload_services(req->sconn, conn_snum_used, true);
-       DEBUG(3,("Selected protocol %s\n", remote_proto));
 
        in_preauth = smb2_negotiate_context_find(&in_c,
                                        SMB2_PREAUTH_INTEGRITY_CAPABILITIES);
@@ -1168,7 +1172,7 @@ NTSTATUS smb2_multi_protocol_reply_negprot(struct smb_request *req)
                exit_server_cleanly("no protocol supported\n");
        }
 
-       fstrcpy(remote_proto,supported_protocols[protocol].short_name);
+       set_remote_proto(supported_protocols[protocol].short_name);
        reload_services(sconn, conn_snum_used, true);
        status = supported_protocols[protocol].proto_reply_fn(req, choice);
        if (!NT_STATUS_IS_OK(status)) {