Remove "Protocol" as an extern, and add accessor functions.
authorJeremy Allison <jra@samba.org>
Wed, 4 Nov 2009 23:15:50 +0000 (15:15 -0800)
committerJeremy Allison <jra@samba.org>
Wed, 4 Nov 2009 23:15:50 +0000 (15:15 -0800)
Jeremy.

source3/include/proto.h
source3/lib/util.c
source3/param/loadparm.c
source3/smbd/negprot.c
source3/smbd/nttrans.c
source3/smbd/reply.c
source3/smbd/sesssetup.c
source3/smbd/smb2_negprot.c
source3/smbd/trans2.c

index 6c8cb2e3ac8f0a8729cc41c115e484c44b8fd6e9..6a90c87f84ab692a3ffb9699df54a753cbecb4f5 100644 (file)
@@ -1073,6 +1073,8 @@ struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user);
 
 /* The following definitions come from lib/util.c  */
 
+enum protocol_types get_Protocol(void);
+void set_Protocol(enum protocol_types  p);
 bool all_zero(const uint8_t *ptr, size_t size);
 bool set_global_myname(const char *myname);
 const char *global_myname(void);
index b066a0d3464c6da5b3c569b746ee7f6517956fb0..247042d7d97b3e8d6db84640b586baf0ef87f715 100644 (file)
@@ -55,7 +55,17 @@ extern unsigned int global_clobber_region_line;
 #endif /* WITH_NISPLUS_HOME */
 #endif /* HAVE_NETGROUP && WITH_AUTOMOUNT */
 
-enum protocol_types Protocol = PROTOCOL_COREPLUS;
+static enum protocol_types Protocol = PROTOCOL_COREPLUS;
+
+enum protocol_types get_Protocol(void)
+{
+       return Protocol;
+}
+
+void set_Protocol(enum protocol_types  p)
+{
+       Protocol = p;
+}
 
 static enum remote_arch_types ra_type = RA_UNKNOWN;
 
index 93be01783d0f780875cd6403303570e6eaace02f..06fb9625761d94e7e49fea57ed5a81391f33c257 100644 (file)
@@ -64,7 +64,6 @@
 
 bool bLoaded = False;
 
-extern enum protocol_types Protocol;
 extern userdom_struct current_user_info;
 
 #ifndef GLOBAL_NAME
@@ -9720,7 +9719,7 @@ bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
        bool sign_active = false;
 
        /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
-       if (Protocol < PROTOCOL_NT1) {
+       if (get_Protocol() < PROTOCOL_NT1) {
                return false;
        }
        if (signing_state) {
index 372f38eb574884305aefe23cc377e8fbf8207538..81d29d90f97f5a106770dec0b84cd752845beccb 100644 (file)
@@ -23,7 +23,6 @@
 #include "../libcli/auth/spnego.h"
 
 extern fstring remote_proto;
-extern enum protocol_types Protocol;
 
 static void get_challenge(uint8 buff[8])
 {
@@ -61,7 +60,7 @@ static void reply_corep(struct smb_request *req, uint16 choice)
        reply_outbuf(req, 1, 0);
        SSVAL(req->outbuf, smb_vwv0, choice);
 
-       Protocol = PROTOCOL_CORE;
+       set_Protocol(PROTOCOL_CORE);
 }
 
 /****************************************************************************
@@ -81,7 +80,7 @@ static void reply_coreplus(struct smb_request *req, uint16 choice)
        SCVAL(req->outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD);
        SSVAL(req->outbuf,smb_vwv1,0x1); /* user level security, don't
                                          * encrypt */
-       Protocol = PROTOCOL_COREPLUS;
+       set_Protocol(PROTOCOL_COREPLUS);
 }
 
 /****************************************************************************
@@ -114,7 +113,7 @@ static void reply_lanman1(struct smb_request *req, uint16 choice)
                SSVAL(req->outbuf,smb_vwv11, 8);
        }
 
-       Protocol = PROTOCOL_LANMAN1;
+       set_Protocol(PROTOCOL_LANMAN1);
 
        /* Reply, SMBlockread, SMBwritelock supported. */
        SCVAL(req->outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD);
@@ -163,7 +162,7 @@ static void reply_lanman2(struct smb_request *req, uint16 choice)
                SSVAL(req->outbuf,smb_vwv11, 8);
        }
 
-       Protocol = PROTOCOL_LANMAN2;
+       set_Protocol(PROTOCOL_LANMAN2);
 
        /* Reply, SMBlockread, SMBwritelock supported. */
        SCVAL(req->outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD);
@@ -345,7 +344,7 @@ static void reply_nt1(struct smb_request *req, uint16 choice)
        SSVAL(req->outbuf,smb_vwv0,choice);
        SCVAL(req->outbuf,smb_vwv1,secword);
        
-       Protocol = PROTOCOL_NT1;
+       set_Protocol(PROTOCOL_NT1);
        
        SSVAL(req->outbuf,smb_vwv1+1,lp_maxmux()); /* maxmpx */
        SSVAL(req->outbuf,smb_vwv2+1,1); /* num vcs */
@@ -698,7 +697,7 @@ void reply_negprot(struct smb_request *req)
   
        DEBUG( 5, ( "negprot index=%d\n", choice ) );
 
-       if ((lp_server_signing() == Required) && (Protocol < PROTOCOL_NT1)) {
+       if ((lp_server_signing() == Required) && (get_Protocol() < PROTOCOL_NT1)) {
                exit_server_cleanly("SMB signing is required and "
                        "client negotiated a downlevel protocol");
        }
index 0cc05dbd52ef17ebf19c14f1f8506802aad528ea..66102fa96ccdbf90393d260dc4d6de988d5a28a1 100644 (file)
@@ -21,7 +21,6 @@
 #include "includes.h"
 #include "smbd/globals.h"
 
-extern enum protocol_types Protocol;
 extern const struct generic_mapping file_generic_mapping;
 
 static char *nttrans_realloc(char **ptr, size_t size)
@@ -2538,7 +2537,7 @@ static void handle_nttrans(connection_struct *conn,
                           struct trans_state *state,
                           struct smb_request *req)
 {
-       if (Protocol >= PROTOCOL_NT1) {
+       if (get_Protocol() >= PROTOCOL_NT1) {
                req->flags2 |= 0x40; /* IS_LONG_NAME */
                SSVAL(req->inbuf,smb_flg2,req->flags2);
        }
index 2365ed1da1446daf7f0ff185f6d84ab55760d66e..984cf56c11181d4777efd37905c52e04f7e3625d 100644 (file)
@@ -27,8 +27,6 @@
 #include "includes.h"
 #include "smbd/globals.h"
 
-extern enum protocol_types Protocol;
-
 /****************************************************************************
  Ensure we check the path in *exactly* the same way as W2K for a findfirst/findnext
  path or anything including wildcards.
@@ -787,7 +785,7 @@ void reply_tcon_and_X(struct smb_request *req)
        else
                server_devicetype = "A:";
 
-       if (Protocol < PROTOCOL_NT1) {
+       if (get_Protocol() < PROTOCOL_NT1) {
                reply_outbuf(req, 2, 0);
                if (message_push_string(&req->outbuf, server_devicetype,
                                        STR_TERMINATE|STR_ASCII) == -1) {
@@ -1141,7 +1139,7 @@ void reply_getatr(struct smb_request *req)
        }
        SIVAL(req->outbuf,smb_vwv3,(uint32)size);
 
-       if (Protocol >= PROTOCOL_NT1) {
+       if (get_Protocol() >= PROTOCOL_NT1) {
                SSVAL(req->outbuf, smb_flg2,
                      SVAL(req->outbuf, smb_flg2) | FLAGS2_IS_LONG_NAME);
        }
@@ -1266,7 +1264,7 @@ void reply_dskattr(struct smb_request *req)
 
        reply_outbuf(req, 5, 0);
 
-       if (Protocol <= PROTOCOL_LANMAN2) {
+       if (get_Protocol() <= PROTOCOL_LANMAN2) {
                double total_space, free_space;
                /* we need to scale this to a number that DOS6 can handle. We
                   use floating point so we can handle large drives on systems
@@ -3775,7 +3773,7 @@ void reply_writebraw(struct smb_request *req)
        /* We have to deal with slightly different formats depending
                on whether we are using the core+ or lanman1.0 protocol */
 
-       if(Protocol <= PROTOCOL_COREPLUS) {
+       if(get_Protocol() <= PROTOCOL_COREPLUS) {
                numtowrite = SVAL(smb_buf(req->inbuf),-2);
                data = smb_buf(req->inbuf);
        } else {
@@ -3831,7 +3829,7 @@ void reply_writebraw(struct smb_request *req)
         * it to send more bytes */
 
        memcpy(buf, req->inbuf, smb_size);
-       srv_set_message(buf,Protocol>PROTOCOL_COREPLUS?1:0,0,True);
+       srv_set_message(buf,get_Protocol()>PROTOCOL_COREPLUS?1:0,0,True);
        SCVAL(buf,smb_com,SMBwritebraw);
        SSVALS(buf,smb_vwv0,0xFFFF);
        show_msg(buf);
index 16ea2ebfa911b09a7798cdac0a0880abecbf4bf3..addd386fb4fcc1c9288d17dfc5e8f461c60db8b0 100644 (file)
@@ -26,8 +26,6 @@
 #include "smbd/globals.h"
 #include "../libcli/auth/spnego.h"
 
-extern enum protocol_types Protocol;
-
 /* For split krb5 SPNEGO blobs. */
 struct pending_auth_data {
        struct pending_auth_data *prev, *next;
@@ -1432,7 +1430,7 @@ void reply_sesssetup_and_X(struct smb_request *req)
 
        smb_bufsize = SVAL(req->vwv+2, 0);
 
-       if (Protocol < PROTOCOL_NT1) {
+       if (get_Protocol() < PROTOCOL_NT1) {
                uint16 passlen1 = SVAL(req->vwv+7, 0);
 
                /* Never do NT status codes with protocols before NT1 as we
@@ -1759,7 +1757,7 @@ void reply_sesssetup_and_X(struct smb_request *req)
 
        /* it's ok - setup a reply */
        reply_outbuf(req, 3, 0);
-       if (Protocol >= PROTOCOL_NT1) {
+       if (get_Protocol() >= PROTOCOL_NT1) {
                push_signature(&req->outbuf);
                /* perhaps grab OS version here?? */
        }
index 2c6449dbaa83380320f01dbfac7413b572a0b8ba..5b97c65d79c383b363094d83821dd1485d8f3f95 100644 (file)
@@ -22,8 +22,6 @@
 #include "smbd/globals.h"
 #include "../libcli/smb/smb_common.h"
 
-extern enum protocol_types Protocol;
-
 /*
  * this is the entry point if SMB2 is selected via
  * the SMB negprot
@@ -114,7 +112,7 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req)
                return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
        }
 
-       Protocol = PROTOCOL_SMB2;
+       set_Protocol(PROTOCOL_SMB2);
 
        if (get_remote_arch() != RA_SAMBA) {
                set_remote_arch(RA_VISTA);
index 445817ff11cfae66c7831fa18f70f1fa711e2182..74dd173f4f9c2b9d3094d4a406df42aa0c02ca24 100644 (file)
@@ -28,8 +28,6 @@
 #include "smbd/globals.h"
 #include "../libcli/auth/libcli_auth.h"
 
-extern enum protocol_types Protocol;
-
 #define DIR_ENTRY_SAFETY_MARGIN 4096
 
 static char *store_file_unix_basic(connection_struct *conn,
@@ -2466,7 +2464,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
 
        if(numentries == 0) {
                dptr_close(sconn, &dptr_num);
-               if (Protocol < PROTOCOL_NT1) {
+               if (get_Protocol() < PROTOCOL_NT1) {
                        reply_doserror(req, ERRDOS, ERRnofiles);
                        goto out;
                } else {
@@ -8161,7 +8159,7 @@ void reply_findnclose(struct smb_request *req)
 static void handle_trans2(connection_struct *conn, struct smb_request *req,
                          struct trans_state *state)
 {
-       if (Protocol >= PROTOCOL_NT1) {
+       if (get_Protocol() >= PROTOCOL_NT1) {
                req->flags2 |= 0x40; /* IS_LONG_NAME */
                SSVAL(req->inbuf,smb_flg2,req->flags2);
        }