if a local parameter is changed at the global level then propogate the
authorAndrew Tridgell <tridge@samba.org>
Sat, 14 Mar 1998 11:24:01 +0000 (11:24 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sat, 14 Mar 1998 11:24:01 +0000 (11:24 +0000)
change to all shares that are currently set to the default value.
(This used to be commit b0e1183b2cbeb7a3150b7250cd19d14c9e5508b6)

source3/include/proto.h
source3/param/loadparm.c
source3/web/swat.c

index b324ae6bb1a730b995b20cd14d9026176464bc6d..9c7c37f1a685c8f1d2126325d60286cc9a856ecd 100644 (file)
@@ -1017,6 +1017,7 @@ BOOL lp_add_printer(char *pszPrintername, int iDefaultService);
 BOOL lp_file_list_changed(void);
 void *lp_local_ptr(int snum, void *ptr);
 BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue);
+BOOL lp_is_default(int snum, struct parm_struct *parm);
 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters);
 BOOL lp_snum_ok(int iService);
 BOOL lp_loaded(void);
index 4bd167798c22a5ec56e85a1b3f84c845b8a7147c..27cbc8c8ddd8b047abc11b0f40cbb087d70eabc2 100644 (file)
@@ -1982,6 +1982,19 @@ static void dump_globals(FILE *f)
                }
 }
 
+/***************************************************************************
+return True if a local parameter is currently set to the global default
+***************************************************************************/
+BOOL lp_is_default(int snum, struct parm_struct *parm)
+{
+       int pdiff = PTR_DIFF(parm->ptr,&sDefault);
+                       
+       return equal_parameter(parm->type,
+                              ((char *)pSERVICE(snum)) + pdiff,
+                              ((char *)&sDefault) + pdiff);
+}
+
+
 /***************************************************************************
 Display the contents of a single services record.
 ***************************************************************************/
index 323dfc5adf811a40f02bc936a0012a0238106a8e..650740428f93a57fb3e7dc08a222d145829cd175 100644 (file)
@@ -198,6 +198,27 @@ static int save_reload(void)
 
 
 
+/* commit one parameter */
+static void commit_parameter(int snum, struct parm_struct *parm, char *v)
+{
+       int i;
+       char *s;
+
+       if (snum < 0 && parm->class == P_LOCAL) {
+               /* this handles the case where we are changing a local
+                  variable globally. We need to change the parameter in 
+                  all shares where it is currently set to the default */
+               for (i=0;i<lp_numservices();i++) {
+                       s = lp_servicename(i);
+                       if (s && (*s) && lp_is_default(i, parm)) {
+                               lp_do_parameter(i, parm->label, v);
+                       }
+               }
+       }
+
+       lp_do_parameter(snum, parm->label, v);
+}
+
 /* commit a set of parameters for a service */
 static void commit_parameters(int snum)
 {
@@ -209,7 +230,8 @@ static void commit_parameters(int snum)
        while ((parm = lp_next_parameter(snum, &i, 1))) {
                sprintf(label, "parm_%s", parm->label);
                if ((v = cgi_variable(label))) {
-                       lp_do_parameter(snum, parm->label, v); 
+                       if (parm->flags & FLAG_HIDE) continue;
+                       commit_parameter(snum, parm, v); 
                }
        }
 }