From: Volker Lendecke Date: Wed, 30 Nov 2022 15:28:56 +0000 (+0100) Subject: lib: Make substitute.c's "remote_proto" static X-Git-Tag: talloc-2.4.0~351 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46ce8a47109f3b92ac32d951e414b2e8c80cb5da;p=thirdparty%2Fsamba.git lib: Make substitute.c's "remote_proto" static Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index a941b89f82a..24486b86f8e 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -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 diff --git a/source3/lib/substitute.h b/source3/lib/substitute.h index 2056d163dd7..ba903434eca 100644 --- a/source3/lib/substitute.h +++ b/source3/lib/substitute.h @@ -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); diff --git a/source3/smbd/smb1_negprot.c b/source3/smbd/smb1_negprot.c index 45d991b0dcd..db6cf629d9c 100644 --- a/source3/smbd/smb1_negprot.c +++ b/source3/smbd/smb1_negprot.c @@ -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)) { diff --git a/source3/smbd/smb2_negprot.c b/source3/smbd/smb2_negprot.c index 2a1212a0ea5..408faf1481d 100644 --- a/source3/smbd/smb2_negprot.c +++ b/source3/smbd/smb2_negprot.c @@ -29,12 +29,11 @@ #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)) {