LCOV - code coverage report
Current view: top level - source3/utils - net_conf_util.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 8 15 53.3 %
Date: 2024-04-21 15:09:00 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  *  Samba Unix/Linux SMB client library
       3             :  *  Distributed SMB/CIFS Server Management Utility
       4             :  *  Configuration interface
       5             :  *
       6             :  *  Copyright (C) Michael Adam 2013
       7             :  *
       8             :  *  This program is free software; you can redistribute it and/or modify
       9             :  *  it under the terms of the GNU General Public License as published by
      10             :  *  the Free Software Foundation; either version 3 of the License, or
      11             :  *  (at your option) any later version.
      12             :  *
      13             :  *  This program is distributed in the hope that it will be useful,
      14             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :  *  GNU General Public License for more details.
      17             :  *
      18             :  *  You should have received a copy of the GNU General Public License
      19             :  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
      20             :  */
      21             : 
      22             : /*
      23             :  * Utility functions for net conf and net rpc conf.
      24             :  */
      25             : 
      26             : #include "includes.h"
      27             : #include "lib/smbconf/smbconf.h"
      28             : #include "lib/smbconf/smbconf_reg.h"
      29             : #include "lib/param/loadparm.h"
      30             : #include "net_conf_util.h"
      31             : 
      32          55 : bool net_conf_param_valid(const char *service,
      33             :                           const char *param,
      34             :                           const char *valstr)
      35             : {
      36           0 :         const char *canon_param, *canon_valstr;
      37             : 
      38          55 :         if (!lp_parameter_is_valid(param)) {
      39           0 :                 d_fprintf(stderr, "Invalid parameter '%s' given.\n", param);
      40           0 :                 return false;
      41             :         }
      42             : 
      43          55 :         if (!smbconf_reg_parameter_is_valid(param)) {
      44          20 :                 d_fprintf(stderr, "Parameter '%s' not allowed in registry.\n",
      45             :                           param);
      46          20 :                 return false;
      47             :         }
      48             : 
      49          35 :         if (!strequal(service, GLOBAL_NAME) && lp_parameter_is_global(param)) {
      50           0 :                 d_fprintf(stderr, "Global parameter '%s' not allowed in "
      51             :                           "service definition ('%s').\n", param, service);
      52           0 :                 return false;
      53             :         }
      54             : 
      55          35 :         if (!lp_canonicalize_parameter_with_value(param, valstr,
      56             :                                                   &canon_param,
      57             :                                                   &canon_valstr))
      58             :         {
      59             :                 /*
      60             :                  * We already know the parameter name is valid.
      61             :                  * So the value must be invalid.
      62             :                  */
      63           0 :                 d_fprintf(stderr, "invalid value '%s' given for "
      64             :                           "parameter '%s'\n", valstr, param);
      65           0 :                 return false;
      66             :         }
      67             : 
      68          35 :         return true;
      69             : }

Generated by: LCOV version 1.14