Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/source3/lib/smbconf
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/lib/smbconf/smbconf_reg.c

    r740 r988  
    5151}
    5252
    53 /*
    54  * check whether a given value name is forbidden in registry (smbconf)
    55  */
    56 static bool smbconf_reg_valname_forbidden(const char *valname)
     53/**
     54 * Check whether a given parameter name is valid in the
     55 * smbconf registry backend.
     56 */
     57bool smbconf_reg_parameter_is_valid(const char *param_name)
    5758{
    5859        /* hard code the list of forbidden names here for now */
    59         const char *forbidden_valnames[] = {
     60        const char *forbidden_names[] = {
     61                "state directory",
    6062                "lock directory",
    6163                "lock dir",
    6264                "config backend",
    6365                "include",
    64                 "includes", /* this has a special meaning internally */
     66                /*
     67                 * "includes" has a special meaning internally.
     68                 * It is currently not necessary to list it here since it is
     69                 * not a valid parameter. But for clarity and safety, we keep
     70                 * it for now.
     71                 */
     72                INCLUDES_VALNAME,
    6573                NULL
    6674        };
    6775        const char **forbidden = NULL;
    6876
    69         for (forbidden = forbidden_valnames; *forbidden != NULL; forbidden++) {
    70                 if (strwicmp(valname, *forbidden) == 0) {
    71                         return true;
    72                 }
    73         }
    74         return false;
    75 }
    76 
    77 static bool smbconf_reg_valname_valid(const char *valname)
    78 {
    79         return (!smbconf_reg_valname_forbidden(valname) &&
    80                 lp_parameter_is_valid(valname));
     77        if (!lp_parameter_is_valid(param_name)) {
     78                return false;
     79        }
     80
     81        for (forbidden = forbidden_names; *forbidden != NULL; forbidden++) {
     82                if (strwicmp(param_name, *forbidden) == 0) {
     83                        return false;
     84                }
     85        }
     86
     87        return true;
    8188}
    8289
     
    8794                                           struct smbconf_ctx *ctx,
    8895                                           const char *servicename,
    89                                            uint32 desired_access,
     96                                           uint32_t desired_access,
    9097                                           struct registry_key **key)
    9198{
     
    175182        const char *canon_valstr;
    176183
    177         if (!lp_canonicalize_parameter_with_value(valname, valstr,
    178                                                   &canon_valname,
    179                                                   &canon_valstr))
    180         {
    181                 if (canon_valname == NULL) {
    182                         DEBUG(5, ("invalid parameter '%s' given\n",
    183                                   valname));
    184                 } else {
    185                         DEBUG(5, ("invalid value '%s' given for "
    186                                   "parameter '%s'\n", valstr, valname));
    187                 }
     184        if (!lp_parameter_is_valid(valname)) {
     185                DEBUG(5, ("Invalid parameter '%s' given.\n", valname));
    188186                err = SBC_ERR_INVALID_PARAM;
    189187                goto done;
    190188        }
    191189
    192         if (smbconf_reg_valname_forbidden(canon_valname)) {
     190        if (!smbconf_reg_parameter_is_valid(valname)) {
    193191                DEBUG(5, ("Parameter '%s' not allowed in registry.\n",
    194                           canon_valname));
     192                          valname));
    195193                err = SBC_ERR_INVALID_PARAM;
    196194                goto done;
     
    209207        {
    210208                DEBUG(5, ("Global parameter '%s' not allowed in "
    211                           "service definition ('%s').\n", canon_valname,
     209                          "service definition ('%s').\n", valname,
    212210                          subkeyname));
     211                err = SBC_ERR_INVALID_PARAM;
     212                goto done;
     213        }
     214
     215        if (!lp_canonicalize_parameter_with_value(valname, valstr,
     216                                                  &canon_valname,
     217                                                  &canon_valstr))
     218        {
     219                /*
     220                 * We already know the parameter name is valid.
     221                 * So the value must be invalid.
     222                 */
     223                DEBUG(5, ("invalid value '%s' given for parameter '%s'\n",
     224                          valstr, valname));
    213225                err = SBC_ERR_INVALID_PARAM;
    214226                goto done;
     
    260272        }
    261273
    262         value = TALLOC_ZERO_P(tmp_ctx, struct registry_value);
     274        value = talloc_zero(tmp_ctx, struct registry_value);
    263275        if (value == NULL) {
    264276                err = SBC_ERR_NOMEM;
     
    327339        }
    328340        case REG_MULTI_SZ: {
    329                 uint32 j;
     341                uint32_t j;
    330342                const char **a = NULL;
    331343                if (!pull_reg_multi_sz(mem_ctx, &value->data, &a)) {
     
    457469                char *valstring;
    458470
    459                 if (!smbconf_reg_valname_valid(valname)) {
     471                if (!smbconf_reg_parameter_is_valid(valname)) {
    460472                        continue;
    461473                }
     
    517529        talloc_free(tmp_ctx);
    518530        return err;
    519 }
    520 
    521 static bool smbconf_reg_key_has_values(struct registry_key *key)
    522 {
    523         WERROR werr;
    524         uint32_t num_subkeys;
    525         uint32_t max_subkeylen;
    526         uint32_t max_subkeysize;
    527         uint32_t num_values;
    528         uint32_t max_valnamelen;
    529         uint32_t max_valbufsize;
    530         uint32_t secdescsize;
    531         NTTIME last_changed_time;
    532 
    533         werr = reg_queryinfokey(key, &num_subkeys, &max_subkeylen,
    534                                 &max_subkeysize, &num_values, &max_valnamelen,
    535                                 &max_valbufsize, &secdescsize,
    536                                 &last_changed_time);
    537         if (!W_ERROR_IS_OK(werr)) {
    538                 return false;
    539         }
    540 
    541         return (num_values != 0);
    542531}
    543532
     
    605594        }
    606595
    607         ctx->data = TALLOC_ZERO_P(ctx, struct reg_private_data);
     596        ctx->data = talloc_zero(ctx, struct reg_private_data);
    608597
    609598        werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
     
    646635static bool smbconf_reg_requires_messaging(struct smbconf_ctx *ctx)
    647636{
    648 #ifdef CLUSTER_SUPPORT
    649637        if (lp_clustering() && lp_parm_bool(-1, "ctdb", "registry.tdb", true)) {
    650638                return true;
    651639        }
    652 #endif
     640
    653641        return false;
    654642}
     
    755743        }
    756744
    757         werr = reg_deletekey_recursive(parent_key, p+1);
     745        werr = reg_deletesubkeys_recursive(parent_key, p+1);
    758746        if (!W_ERROR_IS_OK(werr)) {
    759747                err = SBC_ERR_IO_FAILURE;
     
    795783
    796784        tmp_ctx = talloc_stackframe();
    797 
    798         /* if there are values in the base key, return NULL as share name */
    799 
    800         if (smbconf_reg_key_has_values(rpd(ctx)->base_key)) {
    801                 err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
    802                                                    0, NULL);
    803                 if (!SBC_ERROR_IS_OK(err)) {
    804                         goto done;
    805                 }
    806                 added_count++;
    807         }
    808785
    809786        /* make sure "global" is always listed first */
     
    914891        }
    915892
    916         tmp_service = TALLOC_ZERO_P(tmp_ctx, struct smbconf_service);
     893        tmp_service = talloc_zero(tmp_ctx, struct smbconf_service);
    917894        if (tmp_service == NULL) {
    918895                err = SBC_ERR_NOMEM;
     
    1009986        }
    1010987
    1011         if (!smbconf_reg_valname_valid(param)) {
     988        if (!smbconf_reg_parameter_is_valid(param)) {
    1012989                err = SBC_ERR_INVALID_PARAM;
    1013990                goto done;
     
    10541031        }
    10551032
    1056         if (!smbconf_reg_valname_valid(param)) {
     1033        if (!smbconf_reg_parameter_is_valid(param)) {
    10571034                err = SBC_ERR_INVALID_PARAM;
    10581035                goto done;
  • vendor/current/source3/lib/smbconf/smbconf_reg.h

    r740 r988  
    3030                        const char *path);
    3131
     32/**
     33 * Check whether a given parameter name is valid in the
     34 * smbconf registry backend.
     35 */
     36bool smbconf_reg_parameter_is_valid(const char *param_name);
    3237
    3338#endif /*  _LIBSMBCONF_REG_H_  */
  • vendor/current/source3/lib/smbconf/testsuite.c

    r740 r988  
    2626
    2727static void print_strings(const char *prefix,
    28                           uint32_t num_strings, const char **strings)
     28                          uint32_t num_strings,
     29                          const char * const *strings)
    2930{
    3031        uint32_t count;
     
    5758        printf("got %u includes%s\n", num_includes,
    5859               (num_includes > 0) ? ":" : ".");
    59         print_strings("", num_includes, (const char **)includes);
     60        print_strings("", num_includes, (const char * const *)includes);
    6061
    6162        printf("OK: get_includes\n");
     
    107108                if (!strequal(set_includes[count], get_includes[count])) {
    108109                        printf("expected: \n");
    109                         print_strings("* ", set_num_includes, set_includes);
     110                        print_strings("* ", set_num_includes,
     111                                      (const char * const *)set_includes);
    110112                        printf("got: \n");
    111113                        print_strings("* ", get_num_includes,
    112                                       (const char **)get_includes);
     114                                      (const char * const *)get_includes);
    113115                        printf("FAIL: get_set_includes - data mismatch:\n");
    114116                        goto done;
     
    176178
    177179done:
     180        talloc_free(mem_ctx);
    178181        return ret;
    179182}
     
    184187
    185188        printf("TEST: creating file\n");
    186         f = sys_fopen(filename, "w");
     189        f = fopen(filename, "w");
    187190        if (!f) {
    188191                printf("failure: failed to open %s for writing: %s\n",
     
    294297        };
    295298
    296         load_case_tables();
     299        smb_init_locale();
    297300        setup_logging(argv[0], DEBUG_STDERR);
    298301
     
    305308        poptFreeContext(pc);
    306309
    307         ret = lp_load(get_dyn_CONFIGFILE(),
    308                       true,  /* globals_only */
    309                       false, /* save_defaults */
    310                       false, /* add_ipc */
    311                       true   /* initialize globals */);
    312 
     310        ret = lp_load_global(get_dyn_CONFIGFILE());
    313311        if (!ret) {
    314312                printf("failure: error loading the configuration\n");
Note: See TracChangeset for help on using the changeset viewer.