r23656: Add initial checking of the validity of a paramter
authorMichael Adam <obnox@samba.org>
Fri, 29 Jun 2007 12:30:41 +0000 (12:30 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:23:42 +0000 (12:23 -0500)
given to "net conf setparm". Add a utility function
lp_parameter_valid() for this to loadparm.c.

Michael

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

index c43a032560553c0a8e149f829b94995e08b2e8c5..58ea751fa581e8d3be81873a305b7913a05b7cf0 100644 (file)
@@ -2776,6 +2776,18 @@ BOOL lp_add_printer(const char *pszPrintername, int iDefaultService)
        return (True);
 }
 
+
+/***************************************************************************
+ Check whether the given parameter name is valid.
+ Parametric options (names containing a colon) are considered valid.
+***************************************************************************/
+
+BOOL lp_parameter_valid(const char *pszParmName)
+{
+       return ((map_parameter(pszParmName) != -1) ||
+               (strchr(pszParmName, ':') != NULL));
+}
+
 /***************************************************************************
  Map a parameter's string representation to something we can use. 
  Returns False if the parameter string is not recognised, else TRUE.
index 021ac0005d72fa677739235edba64cd9dc60b92c..5af2d6ccc53ea0678930ac3f54d0f3119ef27f78 100644 (file)
@@ -167,6 +167,20 @@ static WERROR reg_setvalue_internal(struct registry_key *key,
        else {
                d_fprintf(stderr, "Only value types DWORD and SZ are"
                          "currently implemented for setting values.\n");
+               werr = WERR_INVALID_PARAM;
+               goto done;
+       }
+
+       if (!lp_parameter_valid(valname)) {
+               d_fprintf(stderr, "Invalid parameter '%s' given.\n", valname);
+               werr = WERR_INVALID_PARAM;
+               goto done;
+       }
+
+       if (registry_smbconf_valname_forbidden(valname)) {
+               d_fprintf(stderr, "Parameter '%s' not allowed in registry.\n", 
+                         valname);
+               werr = WERR_INVALID_PARAM;
                goto done;
        }