Changeset 988 for vendor/current/source3/lib/smbconf
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/source3/lib/smbconf
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/lib/smbconf/smbconf_reg.c
r740 r988 51 51 } 52 52 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 */ 57 bool smbconf_reg_parameter_is_valid(const char *param_name) 57 58 { 58 59 /* hard code the list of forbidden names here for now */ 59 const char *forbidden_valnames[] = { 60 const char *forbidden_names[] = { 61 "state directory", 60 62 "lock directory", 61 63 "lock dir", 62 64 "config backend", 63 65 "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, 65 73 NULL 66 74 }; 67 75 const char **forbidden = NULL; 68 76 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; 81 88 } 82 89 … … 87 94 struct smbconf_ctx *ctx, 88 95 const char *servicename, 89 uint32 desired_access,96 uint32_t desired_access, 90 97 struct registry_key **key) 91 98 { … … 175 182 const char *canon_valstr; 176 183 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)); 188 186 err = SBC_ERR_INVALID_PARAM; 189 187 goto done; 190 188 } 191 189 192 if ( smbconf_reg_valname_forbidden(canon_valname)) {190 if (!smbconf_reg_parameter_is_valid(valname)) { 193 191 DEBUG(5, ("Parameter '%s' not allowed in registry.\n", 194 canon_valname));192 valname)); 195 193 err = SBC_ERR_INVALID_PARAM; 196 194 goto done; … … 209 207 { 210 208 DEBUG(5, ("Global parameter '%s' not allowed in " 211 "service definition ('%s').\n", canon_valname,209 "service definition ('%s').\n", valname, 212 210 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)); 213 225 err = SBC_ERR_INVALID_PARAM; 214 226 goto done; … … 260 272 } 261 273 262 value = TALLOC_ZERO_P(tmp_ctx, struct registry_value);274 value = talloc_zero(tmp_ctx, struct registry_value); 263 275 if (value == NULL) { 264 276 err = SBC_ERR_NOMEM; … … 327 339 } 328 340 case REG_MULTI_SZ: { 329 uint32 j;341 uint32_t j; 330 342 const char **a = NULL; 331 343 if (!pull_reg_multi_sz(mem_ctx, &value->data, &a)) { … … 457 469 char *valstring; 458 470 459 if (!smbconf_reg_ valname_valid(valname)) {471 if (!smbconf_reg_parameter_is_valid(valname)) { 460 472 continue; 461 473 } … … 517 529 talloc_free(tmp_ctx); 518 530 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);542 531 } 543 532 … … 605 594 } 606 595 607 ctx->data = TALLOC_ZERO_P(ctx, struct reg_private_data);596 ctx->data = talloc_zero(ctx, struct reg_private_data); 608 597 609 598 werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token)); … … 646 635 static bool smbconf_reg_requires_messaging(struct smbconf_ctx *ctx) 647 636 { 648 #ifdef CLUSTER_SUPPORT649 637 if (lp_clustering() && lp_parm_bool(-1, "ctdb", "registry.tdb", true)) { 650 638 return true; 651 639 } 652 #endif 640 653 641 return false; 654 642 } … … 755 743 } 756 744 757 werr = reg_delete key_recursive(parent_key, p+1);745 werr = reg_deletesubkeys_recursive(parent_key, p+1); 758 746 if (!W_ERROR_IS_OK(werr)) { 759 747 err = SBC_ERR_IO_FAILURE; … … 795 783 796 784 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 }808 785 809 786 /* make sure "global" is always listed first */ … … 914 891 } 915 892 916 tmp_service = TALLOC_ZERO_P(tmp_ctx, struct smbconf_service);893 tmp_service = talloc_zero(tmp_ctx, struct smbconf_service); 917 894 if (tmp_service == NULL) { 918 895 err = SBC_ERR_NOMEM; … … 1009 986 } 1010 987 1011 if (!smbconf_reg_ valname_valid(param)) {988 if (!smbconf_reg_parameter_is_valid(param)) { 1012 989 err = SBC_ERR_INVALID_PARAM; 1013 990 goto done; … … 1054 1031 } 1055 1032 1056 if (!smbconf_reg_ valname_valid(param)) {1033 if (!smbconf_reg_parameter_is_valid(param)) { 1057 1034 err = SBC_ERR_INVALID_PARAM; 1058 1035 goto done; -
vendor/current/source3/lib/smbconf/smbconf_reg.h
r740 r988 30 30 const char *path); 31 31 32 /** 33 * Check whether a given parameter name is valid in the 34 * smbconf registry backend. 35 */ 36 bool smbconf_reg_parameter_is_valid(const char *param_name); 32 37 33 38 #endif /* _LIBSMBCONF_REG_H_ */ -
vendor/current/source3/lib/smbconf/testsuite.c
r740 r988 26 26 27 27 static void print_strings(const char *prefix, 28 uint32_t num_strings, const char **strings) 28 uint32_t num_strings, 29 const char * const *strings) 29 30 { 30 31 uint32_t count; … … 57 58 printf("got %u includes%s\n", num_includes, 58 59 (num_includes > 0) ? ":" : "."); 59 print_strings("", num_includes, (const char * *)includes);60 print_strings("", num_includes, (const char * const *)includes); 60 61 61 62 printf("OK: get_includes\n"); … … 107 108 if (!strequal(set_includes[count], get_includes[count])) { 108 109 printf("expected: \n"); 109 print_strings("* ", set_num_includes, set_includes); 110 print_strings("* ", set_num_includes, 111 (const char * const *)set_includes); 110 112 printf("got: \n"); 111 113 print_strings("* ", get_num_includes, 112 (const char * *)get_includes);114 (const char * const *)get_includes); 113 115 printf("FAIL: get_set_includes - data mismatch:\n"); 114 116 goto done; … … 176 178 177 179 done: 180 talloc_free(mem_ctx); 178 181 return ret; 179 182 } … … 184 187 185 188 printf("TEST: creating file\n"); 186 f = sys_fopen(filename, "w");189 f = fopen(filename, "w"); 187 190 if (!f) { 188 191 printf("failure: failed to open %s for writing: %s\n", … … 294 297 }; 295 298 296 load_case_tables();299 smb_init_locale(); 297 300 setup_logging(argv[0], DEBUG_STDERR); 298 301 … … 305 308 poptFreeContext(pc); 306 309 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()); 313 311 if (!ret) { 314 312 printf("failure: error loading the configuration\n");
Note:
See TracChangeset
for help on using the changeset viewer.