r23657: Prevent setting of a global option in a share definition
authorMichael Adam <obnox@samba.org>
Fri, 29 Jun 2007 13:07:54 +0000 (13:07 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:23:42 +0000 (12:23 -0500)
in "net conf setparm".

Michael

source/param/loadparm.c
source/utils/net_conf.c

index 58ea751fa581e8d3be81873a305b7913a05b7cf0..8c6c0f1afeccf7c29a0da1cbf7804a7e8864bbec 100644 (file)
@@ -2788,6 +2788,24 @@ BOOL lp_parameter_valid(const char *pszParmName)
                (strchr(pszParmName, ':') != NULL));
 }
 
+/***************************************************************************
+ Check whether the given name is the name of a global parameter.
+ Returns True for strings belonging to parameters of class
+ P_GLOBAL, False for all other strings, also for parametric options
+ and strings not belonging to any option.
+***************************************************************************/
+
+BOOL lp_parameter_is_global(const char *pszParmName)
+{
+       int num = map_parameter(pszParmName);
+
+       if (num >= 0) {
+               return (parm_table[num].p_class == P_GLOBAL);
+       }
+
+       return False;
+}
+
 /***************************************************************************
  Map a parameter's string representation to something we can use. 
  Returns False if the parameter string is not recognised, else TRUE.
index 5af2d6ccc53ea0678930ac3f54d0f3119ef27f78..1c61a25ee9ce0af434a932dd862e677bff5296f6 100644 (file)
@@ -178,12 +178,21 @@ static WERROR reg_setvalue_internal(struct registry_key *key,
        }
 
        if (registry_smbconf_valname_forbidden(valname)) {
-               d_fprintf(stderr, "Parameter '%s' not allowed in registry.\n", 
+               d_fprintf(stderr, "Parameter '%s' not allowed in registry.\n",
                          valname);
                werr = WERR_INVALID_PARAM;
                goto done;
        }
 
+       if (!strequal(key->key->name, GLOBAL_NAME) &&
+           lp_parameter_is_global(valname))
+       {
+               d_fprintf(stderr, "Global paramter '%s' not allowed in "
+                         "service definition.\n", valname);
+               werr = WERR_INVALID_PARAM;
+               goto done;
+       }
+
        werr = reg_setvalue(key, valname, &val);
        if (!W_ERROR_IS_OK(werr)) {
                d_fprintf(stderr,