Eliminate global variable in_client and a plethora of extern declarations.
authorDerrell Lipman <derrell.lipman@unwireduniverse.com>
Thu, 6 Mar 2008 15:41:42 +0000 (10:41 -0500)
committerKarolin Seeger <kseeger@samba.org>
Thu, 27 Mar 2008 07:38:08 +0000 (08:38 +0100)
Derrell
(cherry picked from commit b7f34e7ef2907b498a0645ce68f2773ed7d60cdc)

source/client/client.c
source/client/smbspool.c
source/libsmb/libsmb_context.c
source/pam_smbpass/pam_smb_acct.c
source/pam_smbpass/pam_smb_auth.c
source/pam_smbpass/pam_smb_passwd.c
source/param/loadparm.c
source/param/params.c

index 9cb05c541cc8b6d72f57d2fcf39643e9a13728db..cda5a6a35f50a8e13e69dc4ff5793f23cfe84140 100644 (file)
@@ -33,7 +33,6 @@ extern int do_smb_browse(void); /* mDNS browsing */
 extern bool AllowDebugChange;
 extern bool override_logfile;
 extern char tar_type;
-extern bool in_client;
 
 static int port = 0;
 static char *service;
@@ -4697,7 +4696,7 @@ static int do_message_op(void)
        pc = poptGetContext("smbclient", argc, (const char **) argv, long_options, 0);
        poptSetOtherOptionHelp(pc, "service <password>");
 
-       in_client = true;   /* Make sure that we tell lp_load we are */
+        lp_set_in_client(true); /* Make sure that we tell lp_load we are */
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
 
index e7df22c2bcbe8a364182892934b2c820493b1d56..e827df4b09f8d59eb83231db5769a11ee89fc435 100644 (file)
@@ -35,7 +35,6 @@
  * Globals...
  */
 
-extern bool            in_client;      /* Boolean for client library */
 
 
 /*
@@ -228,7 +227,7 @@ static bool smb_encrypt;
 
   setup_logging("smbspool", True);
 
-  in_client = True;   /* Make sure that we tell lp_load we are */
+  lp_set_in_client(True);       /* Make sure that we tell lp_load we are */
 
   load_case_tables();
 
index 5869b8b8c84bacae07d0504a14656ef9c7a753e1..bb7aee9859fab16e1d1be446a8f64e302c30a01f 100644 (file)
@@ -450,7 +450,7 @@ smbc_init_context(SMBCCTX *context)
                 
                 /* Here we would open the smb.conf file if needed ... */
                 
-                in_client = True; /* FIXME, make a param */
+                lp_set_in_client(True);
                 
                 home = getenv("HOME");
                 if (home) {
index b9bcb31091269fdd1e035b43c4f8c301be088a34..2a8bd265972b8c9e9c21ab36074bc510b0ecb190 100644 (file)
@@ -55,12 +55,11 @@ int pam_sm_acct_mgmt( pam_handle_t *pamh, int flags,
        const char *name;
        struct samu *sampass = NULL;
        void (*oldsig_handler)(int);
-       extern bool in_client;
 
        /* Samba initialization. */
        load_case_tables();
        setup_logging( "pam_smbpass", False );
-       in_client = True;
+        lp_set_in_client(True);
 
        ctrl = set_ctrl( flags, argc, argv );
 
index 3a841adebd67482b0eede80e8bb05665423f5cbc..3dceb52c7db29c590bb5c0971d2c1a89e0476895 100644 (file)
@@ -72,7 +72,6 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags,
        unsigned int ctrl;
        int retval, *ret_data = NULL;
        struct samu *sampass = NULL;
-       extern bool in_client;
        const char *name;
        void (*oldsig_handler)(int) = NULL;
        bool found;
@@ -83,7 +82,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags,
        /* Samba initialization. */
        load_case_tables();
        setup_logging("pam_smbpass",False);
-       in_client = True;
+        lp_set_in_client(True);
 
        ctrl = set_ctrl(flags, argc, argv);
 
index 326a0b59e7c1c87648a7d1aff252ec996b72e8a8..b6de43ff9750ead3c98e253b9b10186051cfd33d 100644 (file)
@@ -98,8 +98,6 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
     unsigned int ctrl;
     int retval;
 
-    extern bool in_client;
-
     struct samu *sampass = NULL;
     void (*oldsig_handler)(int);
     const char *user;
@@ -109,7 +107,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
     /* Samba initialization. */
     load_case_tables();
     setup_logging( "pam_smbpass", False );
-    in_client = True;
+    lp_set_in_client(True);
 
     ctrl = set_ctrl(flags, argc, argv);
 
index 87bc76371f56f174a73b0b2ef0faeb3fbc4571b4..04fade578937d288b9eb76ce06b9df48119090d5 100644 (file)
@@ -53,7 +53,6 @@
 
 #include "includes.h"
 
-bool in_client = False;                /* Not in the client by default */
 bool bLoaded = False;
 
 extern enum protocol_types Protocol;
@@ -71,6 +70,7 @@ extern userdom_struct current_user_info;
 #define HOMES_NAME "homes"
 #endif
 
+static bool in_client = False;         /* Not in the client by default */
 static uint64_t conf_last_seqnum = 0;
 static struct smbconf_ctx *conf_ctx = NULL;
 
@@ -8608,6 +8608,27 @@ void gfree_loadparm(void)
        }
 }
 
+
+/***************************************************************************
+ Allow client apps to specify that they are a client
+***************************************************************************/
+void lp_set_in_client(bool b)
+{
+    in_client = b;
+}
+
+
+/***************************************************************************
+ Determine if we're running in a client app
+***************************************************************************/
+bool lp_is_in_client(void)
+{
+    return in_client;
+}
+
+
+
+
 /***************************************************************************
  Load the services array from the services file. Return True on success, 
  False on failure.
@@ -8718,7 +8739,7 @@ bool lp_load(const char *pszFname,
 
        /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
        /* if bWINSsupport is true and we are in the client            */
-       if (in_client && Globals.bWINSsupport) {
+       if (lp_is_in_client() && Globals.bWINSsupport) {
                lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
        }
 
index 44b44d99b6a16a4057f1b60a8c0175d99274c3b8..e69715e4a3414d802dcbf6a6c3fa01926a778a4a 100644 (file)
@@ -80,8 +80,6 @@
 
 #include "includes.h"
 
-extern bool in_client;
-
 /* -------------------------------------------------------------------------- **
  * Constants...
  */
@@ -519,7 +517,7 @@ static bool Parse( DATA_BLOB *buf, myFILE *InFile,
 static myFILE *OpenConfFile( const char *FileName )
 {
        const char *func = "params.c:OpenConfFile() -";
-       int lvl = in_client?1:0;
+       int lvl = lp_is_in_client() ? 1 : 0;
        myFILE *ret;
 
        ret = SMB_MALLOC_P(myFILE);