Changeset 223 for branches/samba-3.3.x/source/lib
- Timestamp:
- May 24, 2009, 7:51:24 AM (16 years ago)
- Location:
- branches/samba-3.3.x/source/lib
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.3.x/source/lib/charcnv.c
r206 r223 243 243 if (allow_bad_conv) 244 244 goto use_as_is; 245 break;245 return (size_t)-1; 246 246 case E2BIG: 247 247 reason="No more room"; … … 264 264 if (allow_bad_conv) 265 265 goto use_as_is; 266 break; 266 267 return (size_t)-1; 267 268 default: 268 269 if (!conv_silent) 269 270 DEBUG(0,("convert_string_internal: Conversion error: %s(%s)\n",reason,inbuf)); 270 break;271 return (size_t)-1; 271 272 } 272 273 /* smb_panic(reason); */ … … 413 414 goto general_case; 414 415 #else 415 return retval + convert_string_internal(from, to, p, slen, q, dlen, allow_bad_conv); 416 size_t ret = convert_string_internal(from, to, p, slen, q, dlen, allow_bad_conv); 417 if (ret == (size_t)-1) { 418 return ret; 419 } 420 return retval + ret; 416 421 #endif 417 422 } … … 449 454 goto general_case; 450 455 #else 451 return retval + convert_string_internal(from, to, p, slen, q, dlen, allow_bad_conv); 456 size_t ret = convert_string_internal(from, to, p, slen, q, dlen, allow_bad_conv); 457 if (ret == (size_t)-1) { 458 return ret; 459 } 460 return retval + ret; 452 461 #endif 453 462 } … … 485 494 goto general_case; 486 495 #else 487 return retval + convert_string_internal(from, to, p, slen, q, dlen, allow_bad_conv); 496 size_t ret = convert_string_internal(from, to, p, slen, q, dlen, allow_bad_conv); 497 if (ret == (size_t)-1) { 498 return ret; 499 } 500 return retval + ret; 488 501 #endif 489 502 } -
branches/samba-3.3.x/source/lib/dbwrap.c
r206 r223 43 43 } 44 44 45 /* 46 * Fall back using fetch if no genuine parse operation is provided 47 */ 48 49 static int dbwrap_fallback_parse_record(struct db_context *db, TDB_DATA key, 50 int (*parser)(TDB_DATA key, 51 TDB_DATA data, 52 void *private_data), 53 void *private_data) 54 { 55 TDB_DATA data; 56 int res; 57 58 res = db->fetch(db, talloc_tos(), key, &data); 59 if (res != 0) { 60 return res; 61 } 62 63 res = parser(key, data, private_data); 64 TALLOC_FREE(data.dptr); 65 return res; 66 } 67 68 bool db_is_local(const char *name) 69 { 70 #ifdef CLUSTER_SUPPORT 71 const char *sockname = lp_ctdbd_socket(); 72 73 if(!sockname || !*sockname) { 74 sockname = CTDB_PATH; 75 } 76 77 if (lp_clustering() && socket_exist(sockname)) { 78 const char *partname; 79 /* ctdb only wants the file part of the name */ 80 partname = strrchr(name, '/'); 81 if (partname) { 82 partname++; 83 } else { 84 partname = name; 85 } 86 /* allow ctdb for individual databases to be disabled */ 87 if (lp_parm_bool(-1, "ctdb", partname, True)) { 88 return false; 89 } 90 } 91 #endif 92 return true; 93 } 94 45 95 /** 46 96 * open a database … … 102 152 result->fetch = dbwrap_fallback_fetch; 103 153 } 154 if ((result != NULL) && (result->parse_record == NULL)) { 155 result->parse_record = dbwrap_fallback_parse_record; 156 } 104 157 105 158 return result; -
branches/samba-3.3.x/source/lib/dbwrap_ctdb.c
r206 r223 122 122 struct ctdb_rec_data *r; 123 123 size_t m_size, r_size; 124 struct ctdb_marshall_buffer *m2 ;125 126 r = db_ctdb_marshall_record( mem_ctx, reqid, key, header, data);124 struct ctdb_marshall_buffer *m2 = NULL; 125 126 r = db_ctdb_marshall_record(talloc_tos(), reqid, key, header, data); 127 127 if (r == NULL) { 128 128 talloc_free(m); … … 134 134 mem_ctx, offsetof(struct ctdb_marshall_buffer, data)); 135 135 if (m == NULL) { 136 return NULL;136 goto done; 137 137 } 138 138 m->db_id = db_id; … … 146 146 if (m2 == NULL) { 147 147 talloc_free(m); 148 return NULL;148 goto done; 149 149 } 150 150 151 151 memcpy(m_size + (uint8_t *)m2, r, r_size); 152 152 153 m2->count++; 154 155 done: 153 156 talloc_free(r); 154 155 m2->count++;156 157 157 return m2; 158 158 } -
branches/samba-3.3.x/source/lib/dbwrap_rbt.c
r206 r223 132 132 } 133 133 134 node = (struct db_rbt_node *) SMB_MALLOC(134 node = (struct db_rbt_node *)talloc_size(rec_priv->db_ctx, 135 135 offsetof(struct db_rbt_node, data) + rec->key.dsize 136 136 + data.dsize); 137 137 138 138 if (node == NULL) { 139 SAFE_FREE(rec_priv->node);139 TALLOC_FREE(rec_priv->node); 140 140 return NT_STATUS_NO_MEMORY; 141 141 } … … 149 149 150 150 memcpy(this_key.dptr, rec->key.dptr, node->keysize); 151 SAFE_FREE(rec_priv->node);151 TALLOC_FREE(rec_priv->node); 152 152 153 153 memcpy(this_val.dptr, data.dptr, node->valuesize); … … 195 195 196 196 rb_erase(&rec_priv->node->rb_node, &rec_priv->db_ctx->tree); 197 SAFE_FREE(rec_priv->node);197 TALLOC_FREE(rec_priv->node); 198 198 199 199 return NT_STATUS_OK; -
branches/samba-3.3.x/source/lib/dbwrap_tdb.c
r206 r223 177 177 } 178 178 179 static int db_tdb_parse(struct db_context *db, TDB_DATA key, 180 int (*parser)(TDB_DATA key, TDB_DATA data, 181 void *private_data), 182 void *private_data) 183 { 184 struct db_tdb_ctx *ctx = talloc_get_type_abort( 185 db->private_data, struct db_tdb_ctx); 186 187 return tdb_parse_record(ctx->wtdb->tdb, key, parser, private_data); 188 } 189 179 190 static NTSTATUS db_tdb_store(struct db_record *rec, TDB_DATA data, int flag) 180 191 { … … 344 355 result->traverse = db_tdb_traverse; 345 356 result->traverse_read = db_tdb_traverse_read; 357 result->parse_record = db_tdb_parse; 346 358 result->get_seqnum = db_tdb_get_seqnum; 347 359 result->persistent = ((tdb_flags & TDB_CLEAR_IF_FIRST) == 0); -
branches/samba-3.3.x/source/lib/netapi/group.c
r206 r223 1320 1320 *r->out.buffer = NULL; 1321 1321 *r->out.entries_read = 0; 1322 *r->out.total_entries = 0; 1322 1323 1323 1324 switch (r->in.level) { … … 1409 1410 } 1410 1411 1411 if (r->out.entries_read) { 1412 *r->out.entries_read = entries_read; 1413 } 1414 1415 if (r->out.total_entries) { 1416 *r->out.total_entries = entries_read; 1417 } 1412 *r->out.entries_read = entries_read; 1413 *r->out.total_entries = entries_read; 1418 1414 1419 1415 werr = WERR_OK; -
branches/samba-3.3.x/source/lib/netapi/user.c
r206 r223 1511 1511 NTSTATUS status = NT_STATUS_OK; 1512 1512 WERROR werr; 1513 WERROR werr_tmp; 1514 1515 *r->out.entries_read = 0; 1513 1516 1514 1517 ZERO_STRUCT(connect_handle); … … 1555 1558 &returned_size, 1556 1559 &info); 1557 if (!NT_STATUS_IS_OK(status)) { 1558 werr = ntstatus_to_werror(status); 1559 goto done; 1560 } 1561 1562 werr = convert_samr_dispinfo_to_NET_DISPLAY(ctx, &info, 1563 r->in.level, 1564 r->out.entries_read, 1565 r->out.buffer); 1560 werr = ntstatus_to_werror(status); 1561 if (NT_STATUS_IS_ERR(status)) { 1562 goto done; 1563 } 1564 1565 werr_tmp = convert_samr_dispinfo_to_NET_DISPLAY(ctx, &info, 1566 r->in.level, 1567 r->out.entries_read, 1568 r->out.buffer); 1569 if (!W_ERROR_IS_OK(werr_tmp)) { 1570 werr = werr_tmp; 1571 } 1566 1572 done: 1567 1573 if (!cli) { … … 2850 2856 *r->out.buffer = NULL; 2851 2857 *r->out.entries_read = 0; 2858 *r->out.total_entries = 0; 2852 2859 2853 2860 switch (r->in.level) { … … 2944 2951 } 2945 2952 2946 if (r->out.entries_read) { 2947 *r->out.entries_read = entries_read; 2948 } 2949 if (r->out.total_entries) { 2950 *r->out.total_entries = entries_read; 2951 } 2953 *r->out.entries_read = entries_read; 2954 *r->out.total_entries = entries_read; 2952 2955 2953 2956 done: … … 3298 3301 *r->out.buffer = NULL; 3299 3302 *r->out.entries_read = 0; 3303 *r->out.total_entries = 0; 3300 3304 3301 3305 switch (r->in.level) { … … 3459 3463 } 3460 3464 3461 if (r->out.entries_read) { 3462 *r->out.entries_read = entries_read; 3463 } 3464 if (r->out.total_entries) { 3465 *r->out.total_entries = entries_read; 3466 } 3465 *r->out.entries_read = entries_read; 3466 *r->out.total_entries = entries_read; 3467 3467 3468 3468 done: -
branches/samba-3.3.x/source/lib/replace/libreplace_network.m4
r221 r223 9 9 AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) 10 10 AC_CHECK_HEADERS(netinet/in_systm.h) 11 AC_CHECK_HEADERS([netinet/ip.h], [], [], [#ifdef HAVE_NETINET_IN_H 12 #include <netinet/in.h> 13 #endif 14 #ifdef HAVE_NETINET_IN_SYSTM_H 15 #include <netinet/in_systm.h> 16 #endif]) 11 AC_CHECK_HEADERS([netinet/ip.h], [], [],[ 12 #include <sys/types.h> 13 #ifdef HAVE_NETINET_IN_H 14 #include <netinet/in.h> 15 #endif 16 #ifdef HAVE_NETINET_IN_SYSTM_H 17 #include <netinet/in_systm.h> 18 #endif 19 ]) 17 20 AC_CHECK_HEADERS(netinet/tcp.h netinet/in_ip.h) 18 21 AC_CHECK_HEADERS(sys/sockio.h sys/un.h) -
branches/samba-3.3.x/source/lib/smbconf/smbconf.c
r206 r223 44 44 45 45 /** 46 * Tell whether the backend requires messaging to be set up 47 * for the backend to work correctly. 48 */ 49 bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx) 50 { 51 return ctx->ops->requires_messaging(ctx); 52 } 53 54 /** 55 * Tell whether the source is writeable. 56 */ 57 bool smbconf_is_writeable(struct smbconf_ctx *ctx) 58 { 59 return ctx->ops->is_writeable(ctx); 60 } 61 62 /** 46 63 * Close the configuration. 47 64 */ 48 65 void smbconf_shutdown(struct smbconf_ctx *ctx) 49 66 { 50 TALLOC_FREE(ctx);67 talloc_free(ctx); 51 68 } 52 69 … … 141 158 142 159 done: 143 TALLOC_FREE(tmp_ctx);160 talloc_free(tmp_ctx); 144 161 return werr; 145 162 } … … 187 204 struct smbconf_service **service) 188 205 { 189 if (!smbconf_share_exists(ctx, servicename)) {190 return WERR_NO_SUCH_SERVICE;191 }192 193 206 return ctx->ops->get_share(ctx, mem_ctx, servicename, service); 194 207 } … … 214 227 const char *valstr) 215 228 { 216 if (!smbconf_share_exists(ctx, service)) {217 return WERR_NO_SUCH_SERVICE;218 }219 220 229 return ctx->ops->set_parameter(ctx, service, param, valstr); 221 230 } … … 253 262 } 254 263 255 if (!smbconf_share_exists(ctx, service)) {256 return WERR_NO_SUCH_SERVICE;257 }258 259 264 return ctx->ops->get_parameter(ctx, mem_ctx, service, param, valstr); 260 265 } … … 287 292 const char *service, const char *param) 288 293 { 289 if (!smbconf_share_exists(ctx, service)) {290 return WERR_NO_SUCH_SERVICE;291 }292 293 294 return ctx->ops->delete_parameter(ctx, service, param); 294 295 } … … 317 318 uint32_t *num_includes, char ***includes) 318 319 { 319 if (!smbconf_share_exists(ctx, service)) {320 return WERR_NO_SUCH_SERVICE;321 }322 323 320 return ctx->ops->get_includes(ctx, mem_ctx, service, num_includes, 324 321 includes); … … 344 341 uint32_t num_includes, const char **includes) 345 342 { 346 if (!smbconf_share_exists(ctx, service)) {347 return WERR_NO_SUCH_SERVICE;348 }349 350 343 return ctx->ops->set_includes(ctx, service, num_includes, includes); 351 344 } … … 369 362 WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service) 370 363 { 371 if (!smbconf_share_exists(ctx, service)) {372 return WERR_NO_SUCH_SERVICE;373 }374 375 364 return ctx->ops->delete_includes(ctx, service); 376 365 } … … 387 376 return werr; 388 377 } 378 379 WERROR smbconf_transaction_start(struct smbconf_ctx *ctx) 380 { 381 return ctx->ops->transaction_start(ctx); 382 } 383 384 WERROR smbconf_transaction_commit(struct smbconf_ctx *ctx) 385 { 386 return ctx->ops->transaction_commit(ctx); 387 } 388 389 WERROR smbconf_transaction_cancel(struct smbconf_ctx *ctx) 390 { 391 return ctx->ops->transaction_cancel(ctx); 392 } -
branches/samba-3.3.x/source/lib/smbconf/smbconf.h
r206 r223 35 35 }; 36 36 37 38 /**39 * intialization dispatcher function.40 * takes source string in the form of "backend:path"41 */42 WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,43 const char *source);44 45 /**46 * initialization functions for the available modules47 */48 49 WERROR smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,50 const char *path);51 52 WERROR smbconf_init_txt(TALLOC_CTX *mem_ctx,53 struct smbconf_ctx **conf_ctx,54 const char *path);55 56 37 /* 57 38 * the smbconf API functions 58 39 */ 40 bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx); 41 bool smbconf_is_writeable(struct smbconf_ctx *ctx); 59 42 void smbconf_shutdown(struct smbconf_ctx *ctx); 60 43 bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn, … … 112 95 WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx); 113 96 97 WERROR smbconf_transaction_start(struct smbconf_ctx *ctx); 98 WERROR smbconf_transaction_commit(struct smbconf_ctx *ctx); 99 WERROR smbconf_transaction_cancel(struct smbconf_ctx *ctx); 100 114 101 #endif /* _LIBSMBCONF_H_ */ -
branches/samba-3.3.x/source/lib/smbconf/smbconf_init.c
r206 r223 19 19 20 20 #include "includes.h" 21 #include "smbconf_private.h" 22 23 #define INCLUDES_VALNAME "includes" 24 21 #include "lib/smbconf/smbconf_private.h" 22 #include "lib/smbconf/smbconf_txt.h" 23 #include "lib/smbconf/smbconf_reg.h" 25 24 26 25 /** … … 76 75 /* 77 76 * If no separator was given in the source, and the string is 78 * not a know backend, assume file backend and use the source77 * not a known backend, assume file backend and use the source 79 78 * string as a path argument. 80 79 */ … … 83 82 /* 84 83 * Separator was specified but this is not a known backend. 85 * Can't handle this. 84 * As a last resort, try to interpret the original source 85 * string as a file name that contains a ":" sign. 86 * This may occur with an include directive like this: 87 * 'include = /path/to/file.%T' 86 88 */ 87 DEBUG(1, ("smbconf_init: ERROR - unknown backend '%s' given\n", 88 backend)); 89 werr = WERR_INVALID_PARAM; 89 werr = smbconf_init_txt(mem_ctx, conf_ctx, source); 90 90 } 91 91 92 92 done: 93 TALLOC_FREE(tmp_ctx);93 talloc_free(tmp_ctx); 94 94 return werr; 95 95 } -
branches/samba-3.3.x/source/lib/smbconf/smbconf_private.h
r206 r223 24 24 WERROR (*init)(struct smbconf_ctx *ctx, const char *path); 25 25 int (*shutdown)(struct smbconf_ctx *ctx); 26 bool (*requires_messaging)(struct smbconf_ctx *ctx); 27 bool (*is_writeable)(struct smbconf_ctx *ctx); 26 28 WERROR (*open_conf)(struct smbconf_ctx *ctx); 27 29 int (*close_conf)(struct smbconf_ctx *ctx); … … 61 63 WERROR (*delete_includes)(struct smbconf_ctx *ctx, 62 64 const char *service); 65 WERROR (*transaction_start)(struct smbconf_ctx *ctx); 66 WERROR (*transaction_commit)(struct smbconf_ctx *ctx); 67 WERROR (*transaction_cancel)(struct smbconf_ctx *ctx); 63 68 }; 64 69 -
branches/samba-3.3.x/source/lib/smbconf/smbconf_reg.c
r206 r223 19 19 20 20 #include "includes.h" 21 #include " smbconf_private.h"21 #include "lib/smbconf/smbconf_private.h" 22 22 23 23 #define INCLUDES_VALNAME "includes" 24 24 25 25 struct reg_private_data { 26 NT_USER_TOKEN *token;26 struct registry_key *base_key; 27 27 bool open; /* did _we_ open the registry? */ 28 28 }; … … 73 73 74 74 /** 75 * Open a registry key specified by "path"76 */77 static WERROR smbconf_reg_open_path(TALLOC_CTX *mem_ctx,78 struct smbconf_ctx *ctx,79 const char *path,80 uint32 desired_access,81 struct registry_key **key)82 {83 WERROR werr = WERR_OK;84 85 if (ctx == NULL) {86 DEBUG(1, ("Error: configuration is not open!\n"));87 werr = WERR_INVALID_PARAM;88 goto done;89 }90 91 if (rpd(ctx)->token == NULL) {92 DEBUG(1, ("Error: token missing from smbconf_ctx. "93 "was smbconf_init() called?\n"));94 werr = WERR_INVALID_PARAM;95 goto done;96 }97 98 werr = ctx->ops->open_conf(ctx);99 if (!W_ERROR_IS_OK(werr)) {100 DEBUG(1, ("Error opening the registry.\n"));101 goto done;102 }103 104 if (path == NULL) {105 DEBUG(1, ("Error: NULL path string given\n"));106 werr = WERR_INVALID_PARAM;107 goto done;108 }109 110 werr = reg_open_path(mem_ctx, path, desired_access, rpd(ctx)->token,111 key);112 113 if (!W_ERROR_IS_OK(werr)) {114 DEBUG(5, ("Error opening registry path '%s': %s\n",115 path, dos_errstr(werr)));116 }117 118 done:119 return werr;120 }121 122 /**123 75 * Open a subkey of the base key (i.e a service) 124 76 */ … … 129 81 struct registry_key **key) 130 82 { 131 WERROR werr = WERR_OK; 132 char *path = NULL; 83 WERROR werr; 133 84 134 85 if (servicename == NULL) { 135 path = talloc_strdup(mem_ctx, ctx->path); 136 } else { 137 path = talloc_asprintf(mem_ctx, "%s\\%s", ctx->path, 138 servicename); 139 } 140 if (path == NULL) { 141 werr = WERR_NOMEM; 142 goto done; 143 } 144 145 werr = smbconf_reg_open_path(mem_ctx, ctx, path, desired_access, key); 146 147 done: 148 TALLOC_FREE(path); 149 return werr; 150 } 151 152 /** 153 * open the base key 154 */ 155 static WERROR smbconf_reg_open_base_key(TALLOC_CTX *mem_ctx, 156 struct smbconf_ctx *ctx, 157 uint32 desired_access, 158 struct registry_key **key) 159 { 160 return smbconf_reg_open_path(mem_ctx, ctx, ctx->path, desired_access, 161 key); 86 *key = rpd(ctx)->base_key; 87 return WERR_OK; 88 } 89 werr = reg_openkey(mem_ctx, rpd(ctx)->base_key, servicename, 90 desired_access, key); 91 92 if (W_ERROR_EQUAL(werr, WERR_BADFILE)) { 93 werr = WERR_NO_SUCH_SERVICE; 94 } 95 96 return werr; 162 97 } 163 98 … … 177 112 } 178 113 179 TALLOC_FREE(ctx);114 talloc_free(ctx); 180 115 return ret; 181 116 } … … 190 125 { 191 126 WERROR werr = WERR_OK; 192 struct registry_key *create_parent = NULL;193 127 TALLOC_CTX *create_ctx; 194 128 enum winreg_CreateAction action = REG_ACTION_NONE; … … 199 133 create_ctx = talloc_stackframe(); 200 134 201 werr = smbconf_reg_open_base_key(create_ctx, ctx, REG_KEY_WRITE, 202 &create_parent); 203 if (!W_ERROR_IS_OK(werr)) { 204 goto done; 205 } 206 207 werr = reg_createkey(mem_ctx, create_parent, subkeyname, 135 werr = reg_createkey(mem_ctx, rpd(ctx)->base_key, subkeyname, 208 136 REG_KEY_WRITE, newkey, &action); 209 137 if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) { … … 216 144 } 217 145 218 done: 219 TALLOC_FREE(create_ctx); 146 talloc_free(create_ctx); 220 147 return werr; 221 148 } … … 332 259 333 260 done: 334 TALLOC_FREE(tmp_ctx);261 talloc_free(tmp_ctx); 335 262 return werr; 336 263 } … … 437 364 438 365 done: 439 TALLOC_FREE(tmp_ctx);366 talloc_free(tmp_ctx); 440 367 return werr; 441 368 } … … 534 461 535 462 done: 536 TALLOC_FREE(tmp_ctx);463 talloc_free(tmp_ctx); 537 464 return werr; 538 465 } … … 593 520 594 521 done: 595 TALLOC_FREE(mem_ctx);522 talloc_free(mem_ctx); 596 523 return werr; 597 524 } … … 609 536 { 610 537 WERROR werr = WERR_OK; 538 struct nt_user_token *token; 611 539 612 540 if (path == NULL) { … … 621 549 ctx->data = TALLOC_ZERO_P(ctx, struct reg_private_data); 622 550 623 werr = ntstatus_to_werror(registry_create_admin_token(ctx, 624 &(rpd(ctx)->token))); 551 werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token)); 625 552 if (!W_ERROR_IS_OK(werr)) { 626 553 DEBUG(1, ("Error creating admin token\n")); … … 634 561 } 635 562 563 werr = ctx->ops->open_conf(ctx); 564 if (!W_ERROR_IS_OK(werr)) { 565 DEBUG(1, ("Error opening the registry.\n")); 566 goto done; 567 } 568 569 werr = reg_open_path(ctx, ctx->path, 570 SEC_RIGHTS_ENUM_SUBKEYS | REG_KEY_WRITE, 571 token, &rpd(ctx)->base_key); 572 if (!W_ERROR_IS_OK(werr)) { 573 goto done; 574 } 575 636 576 done: 637 577 return werr; … … 641 581 { 642 582 return ctx->ops->close_conf(ctx); 583 } 584 585 static bool smbconf_reg_requires_messaging(struct smbconf_ctx *ctx) 586 { 587 #ifdef CLUSTER_SUPPORT 588 if (lp_clustering() && lp_parm_bool(-1, "ctdb", "registry.tdb", true)) { 589 return true; 590 } 591 #endif 592 return false; 593 } 594 595 static bool smbconf_reg_is_writeable(struct smbconf_ctx *ctx) 596 { 597 /* 598 * The backend has write support. 599 * 600 * TODO: add access checks whether the concrete 601 * config source is really writeable by the calling user. 602 */ 603 return true; 643 604 } 644 605 … … 703 664 TALLOC_CTX* mem_ctx = talloc_stackframe(); 704 665 enum winreg_CreateAction action; 666 struct nt_user_token *token; 667 668 werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token)); 669 if (!W_ERROR_IS_OK(werr)) { 670 DEBUG(1, ("Error creating admin token\n")); 671 goto done; 672 } 705 673 706 674 path = talloc_strdup(mem_ctx, ctx->path); … … 711 679 p = strrchr(path, '\\'); 712 680 *p = '\0'; 713 werr = smbconf_reg_open_path(mem_ctx, ctx, path, REG_KEY_WRITE,714 681 werr = reg_open_path(mem_ctx, path, REG_KEY_WRITE, token, 682 &parent_key); 715 683 716 684 if (!W_ERROR_IS_OK(werr)) { … … 728 696 729 697 done: 730 TALLOC_FREE(mem_ctx);698 talloc_free(mem_ctx); 731 699 return werr; 732 700 } … … 745 713 TALLOC_CTX *tmp_ctx = NULL; 746 714 WERROR werr = WERR_OK; 747 struct registry_key *key = NULL;748 715 char *subkey_name = NULL; 749 716 char **tmp_share_names = NULL; … … 757 724 758 725 /* if there are values in the base key, return NULL as share name */ 759 werr = smbconf_reg_open_base_key(tmp_ctx, ctx, 760 SEC_RIGHTS_ENUM_SUBKEYS, &key); 761 if (!W_ERROR_IS_OK(werr)) { 762 goto done; 763 } 764 765 if (smbconf_reg_key_has_values(key)) { 726 727 if (smbconf_reg_key_has_values(rpd(ctx)->base_key)) { 766 728 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names, 767 729 0, NULL); … … 783 745 784 746 for (count = 0; 785 werr = reg_enumkey(tmp_ctx, key, count, &subkey_name, NULL), 747 werr = reg_enumkey(tmp_ctx, rpd(ctx)->base_key, count, 748 &subkey_name, NULL), 786 749 W_ERROR_IS_OK(werr); 787 750 count++) … … 813 776 814 777 done: 815 TALLOC_FREE(tmp_ctx);778 talloc_free(tmp_ctx); 816 779 return werr; 817 780 } … … 834 797 } 835 798 836 TALLOC_FREE(mem_ctx);799 talloc_free(mem_ctx); 837 800 return ret; 838 801 } … … 845 808 { 846 809 WERROR werr; 847 TALLOC_CTX *mem_ctx = talloc_stackframe();848 810 struct registry_key *key = NULL; 849 811 850 812 if (servicename == NULL) { 851 werr = smbconf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE, 852 &key); 853 } else { 854 werr = smbconf_reg_create_service_key(mem_ctx, ctx, 855 servicename, &key); 856 } 857 858 TALLOC_FREE(mem_ctx); 813 return WERR_OK; 814 } 815 816 werr = smbconf_reg_create_service_key(talloc_tos(), ctx, 817 servicename, &key); 818 819 talloc_free(key); 859 820 return werr; 860 821 } … … 903 864 904 865 done: 905 TALLOC_FREE(tmp_ctx);866 talloc_free(tmp_ctx); 906 867 return werr; 907 868 } … … 914 875 { 915 876 WERROR werr = WERR_OK; 916 struct registry_key *key = NULL;917 877 TALLOC_CTX *mem_ctx = talloc_stackframe(); 918 878 919 werr = smbconf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE, &key);920 if (!W_ERROR_IS_OK(werr)) {921 goto done;922 }923 924 879 if (servicename != NULL) { 925 werr = reg_deletekey_recursive(key, key, servicename); 880 werr = reg_deletekey_recursive(mem_ctx, rpd(ctx)->base_key, 881 servicename); 926 882 } else { 927 werr = smbconf_reg_delete_values(key); 928 } 929 930 done: 931 TALLOC_FREE(mem_ctx); 883 werr = smbconf_reg_delete_values(rpd(ctx)->base_key); 884 } 885 886 talloc_free(mem_ctx); 932 887 return werr; 933 888 } … … 954 909 955 910 done: 956 TALLOC_FREE(mem_ctx);911 talloc_free(mem_ctx); 957 912 return werr; 958 913 } … … 999 954 1000 955 done: 1001 TALLOC_FREE(key);1002 TALLOC_FREE(value);956 talloc_free(key); 957 talloc_free(value); 1003 958 return werr; 1004 959 } … … 1034 989 1035 990 done: 1036 TALLOC_FREE(mem_ctx);991 talloc_free(mem_ctx); 1037 992 return werr; 1038 993 } … … 1058 1013 1059 1014 done: 1060 TALLOC_FREE(tmp_ctx);1015 talloc_free(tmp_ctx); 1061 1016 return werr; 1062 1017 } … … 1088 1043 1089 1044 done: 1090 TALLOC_FREE(tmp_ctx);1045 talloc_free(tmp_ctx); 1091 1046 return werr; 1092 1047 } … … 1113 1068 1114 1069 done: 1115 TALLOC_FREE(tmp_ctx); 1116 return werr; 1070 talloc_free(tmp_ctx); 1071 return werr; 1072 } 1073 1074 static WERROR smbconf_reg_transaction_start(struct smbconf_ctx *ctx) 1075 { 1076 return regdb_transaction_start(); 1077 } 1078 1079 static WERROR smbconf_reg_transaction_commit(struct smbconf_ctx *ctx) 1080 { 1081 return regdb_transaction_commit(); 1082 } 1083 1084 static WERROR smbconf_reg_transaction_cancel(struct smbconf_ctx *ctx) 1085 { 1086 return regdb_transaction_cancel(); 1117 1087 } 1118 1088 … … 1120 1090 .init = smbconf_reg_init, 1121 1091 .shutdown = smbconf_reg_shutdown, 1092 .requires_messaging = smbconf_reg_requires_messaging, 1093 .is_writeable = smbconf_reg_is_writeable, 1122 1094 .open_conf = smbconf_reg_open, 1123 1095 .close_conf = smbconf_reg_close, … … 1135 1107 .set_includes = smbconf_reg_set_includes, 1136 1108 .delete_includes = smbconf_reg_delete_includes, 1109 .transaction_start = smbconf_reg_transaction_start, 1110 .transaction_commit = smbconf_reg_transaction_commit, 1111 .transaction_cancel = smbconf_reg_transaction_cancel, 1137 1112 }; 1138 1113 -
branches/samba-3.3.x/source/lib/smbconf/smbconf_txt.c
r206 r223 139 139 smbconf_find_in_array(param_name, param_names, num_params, &idx)) 140 140 { 141 TALLOC_FREE(param_values[idx]);141 talloc_free(param_values[idx]); 142 142 param_values[idx] = talloc_strdup(cache, param_value); 143 143 if (param_values[idx] == NULL) { … … 161 161 static void smbconf_txt_flush_cache(struct smbconf_ctx *ctx) 162 162 { 163 TALLOC_FREE(pd(ctx)->cache); 163 talloc_free(pd(ctx)->cache); 164 pd(ctx)->cache = NULL; 164 165 } 165 166 … … 222 223 { 223 224 if (path == NULL) { 224 path = get_dyn_CONFIGFILE();225 return WERR_BADFILE; 225 226 } 226 227 ctx->path = talloc_strdup(ctx, path); … … 242 243 { 243 244 return ctx->ops->close_conf(ctx); 245 } 246 247 static bool smbconf_txt_requires_messaging(struct smbconf_ctx *ctx) 248 { 249 return false; 250 } 251 252 static bool smbconf_txt_is_writeable(struct smbconf_ctx *ctx) 253 { 254 /* no write support in this backend yet... */ 255 return false; 244 256 } 245 257 … … 349 361 350 362 done: 351 TALLOC_FREE(tmp_ctx);363 talloc_free(tmp_ctx); 352 364 return werr; 353 365 } … … 448 460 449 461 done: 450 TALLOC_FREE(tmp_ctx);462 talloc_free(tmp_ctx); 451 463 return werr; 452 464 } … … 583 595 584 596 done: 585 TALLOC_FREE(tmp_ctx);597 talloc_free(tmp_ctx); 586 598 return werr; 587 599 } … … 601 613 } 602 614 615 static WERROR smbconf_txt_transaction_start(struct smbconf_ctx *ctx) 616 { 617 return WERR_OK; 618 } 619 620 static WERROR smbconf_txt_transaction_commit(struct smbconf_ctx *ctx) 621 { 622 return WERR_OK; 623 } 624 625 static WERROR smbconf_txt_transaction_cancel(struct smbconf_ctx *ctx) 626 { 627 return WERR_OK; 628 } 603 629 604 630 static struct smbconf_ops smbconf_ops_txt = { 605 631 .init = smbconf_txt_init, 606 632 .shutdown = smbconf_txt_shutdown, 633 .requires_messaging = smbconf_txt_requires_messaging, 634 .is_writeable = smbconf_txt_is_writeable, 607 635 .open_conf = smbconf_txt_open, 608 636 .close_conf = smbconf_txt_close, … … 620 648 .set_includes = smbconf_txt_set_includes, 621 649 .delete_includes = smbconf_txt_delete_includes, 650 .transaction_start = smbconf_txt_transaction_start, 651 .transaction_commit = smbconf_txt_transaction_commit, 652 .transaction_cancel = smbconf_txt_transaction_cancel, 622 653 }; 623 654 -
branches/samba-3.3.x/source/lib/smbconf/smbconf_util.c
r206 r223 68 68 69 69 fail: 70 TALLOC_FREE(ctx);70 talloc_free(ctx); 71 71 return werr; 72 72 } … … 97 97 new_array[count] = talloc_strdup(new_array, string); 98 98 if (new_array[count] == NULL) { 99 TALLOC_FREE(new_array);99 talloc_free(new_array); 100 100 return WERR_NOMEM; 101 101 } -
branches/samba-3.3.x/source/lib/smbconf/testsuite.c
r206 r223 42 42 TALLOC_CTX *mem_ctx = talloc_stackframe(); 43 43 44 printf(" test: get_includes\n");44 printf("TEST: get_includes\n"); 45 45 werr = smbconf_get_global_includes(ctx, mem_ctx, 46 46 &num_includes, &includes); 47 47 if (!W_ERROR_IS_OK(werr)) { 48 printf(" failure: get_includes - %s\n", dos_errstr(werr));48 printf("FAIL: get_includes - %s\n", dos_errstr(werr)); 49 49 goto done; 50 50 } … … 54 54 print_strings("", num_includes, (const char **)includes); 55 55 56 printf(" success: get_includes\n");56 printf("OK: get_includes\n"); 57 57 ret = true; 58 58 59 59 done: 60 TALLOC_FREE(mem_ctx);60 talloc_free(mem_ctx); 61 61 return ret; 62 62 } … … 76 76 TALLOC_CTX *mem_ctx = talloc_stackframe(); 77 77 78 printf(" test: set_get_includes\n");78 printf("TEST: set_get_includes\n"); 79 79 80 80 werr = smbconf_set_global_includes(ctx, set_num_includes, set_includes); 81 81 if (!W_ERROR_IS_OK(werr)) { 82 printf(" failure: get_set_includes (setting includes) - %s\n",82 printf("FAIL: get_set_includes (setting includes) - %s\n", 83 83 dos_errstr(werr)); 84 84 goto done; … … 88 88 &get_includes); 89 89 if (!W_ERROR_IS_OK(werr)) { 90 printf(" failure: get_set_includes (getting includes) - %s\n",90 printf("FAIL: get_set_includes (getting includes) - %s\n", 91 91 dos_errstr(werr)); 92 92 goto done; … … 94 94 95 95 if (get_num_includes != set_num_includes) { 96 printf(" failure: get_set_includes - set %d includes, got %d\n",96 printf("FAIL: get_set_includes - set %d includes, got %d\n", 97 97 set_num_includes, get_num_includes); 98 98 goto done; … … 106 106 print_strings("* ", get_num_includes, 107 107 (const char **)get_includes); 108 printf(" failure: get_set_includes - data mismatch:\n");108 printf("FAIL: get_set_includes - data mismatch:\n"); 109 109 goto done; 110 110 } 111 111 } 112 112 113 printf(" success: set_includes\n");113 printf("OK: set_includes\n"); 114 114 ret = true; 115 115 116 116 done: 117 TALLOC_FREE(mem_ctx);117 talloc_free(mem_ctx); 118 118 return ret; 119 119 } … … 131 131 TALLOC_CTX *mem_ctx = talloc_stackframe(); 132 132 133 printf(" test: delete_includes\n");133 printf("TEST: delete_includes\n"); 134 134 135 135 werr = smbconf_set_global_includes(ctx, set_num_includes, set_includes); 136 136 if (!W_ERROR_IS_OK(werr)) { 137 printf(" failure: delete_includes (setting includes) - %s\n",137 printf("FAIL: delete_includes (setting includes) - %s\n", 138 138 dos_errstr(werr)); 139 139 goto done; … … 142 142 werr = smbconf_delete_global_includes(ctx); 143 143 if (!W_ERROR_IS_OK(werr)) { 144 printf(" failure: delete_includes (deleting includes) - %s\n",144 printf("FAIL: delete_includes (deleting includes) - %s\n", 145 145 dos_errstr(werr)); 146 146 goto done; … … 150 150 &get_includes); 151 151 if (!W_ERROR_IS_OK(werr)) { 152 printf(" failure: delete_includes (getting includes) - %s\n",152 printf("FAIL: delete_includes (getting includes) - %s\n", 153 153 dos_errstr(werr)); 154 154 goto done; … … 156 156 157 157 if (get_num_includes != 0) { 158 printf(" failure: delete_includes (not empty after delete)\n");158 printf("FAIL: delete_includes (not empty after delete)\n"); 159 159 goto done; 160 160 } … … 162 162 werr = smbconf_delete_global_includes(ctx); 163 163 if (!W_ERROR_IS_OK(werr)) { 164 printf(" failuer: delete_includes (delete empty includes) - "164 printf("FAIL: delete_includes (delete empty includes) - " 165 165 "%s\n", dos_errstr(werr)); 166 166 goto done; 167 167 } 168 168 169 printf(" success: delete_includes\n");169 printf("OK: delete_includes\n"); 170 170 ret = true; 171 171 … … 174 174 } 175 175 176 static bool create_conf_file(const char *filename) 177 { 178 FILE *f; 179 180 printf("TEST: creating file\n"); 181 f = sys_fopen(filename, "w"); 182 if (!f) { 183 printf("failure: failed to open %s for writing: %s\n", 184 filename, strerror(errno)); 185 return false; 186 } 187 188 fprintf(f, "[global]\n"); 189 fprintf(f, "\tserver string = smbconf testsuite\n"); 190 fprintf(f, "\tworkgroup = SAMBA\n"); 191 fprintf(f, "\tsecurity = user\n"); 192 193 fclose(f); 194 195 printf("OK: create file\n"); 196 return true; 197 } 198 176 199 static bool torture_smbconf_txt(void) 200 { 201 WERROR werr; 202 bool ret = true; 203 const char *filename = "/tmp/smb.conf.smbconf_testsuite"; 204 struct smbconf_ctx *conf_ctx = NULL; 205 TALLOC_CTX *mem_ctx = talloc_stackframe(); 206 207 printf("test: text backend\n"); 208 209 if (!create_conf_file(filename)) { 210 ret = false; 211 goto done; 212 } 213 214 printf("TEST: init\n"); 215 werr = smbconf_init_txt(mem_ctx, &conf_ctx, filename); 216 if (!W_ERROR_IS_OK(werr)) { 217 printf("FAIL: text backend\[ failed: %s\n", dos_errstr(werr)); 218 ret = false; 219 goto done; 220 } 221 printf("OK: init\n"); 222 223 ret &= test_get_includes(conf_ctx); 224 225 smbconf_shutdown(conf_ctx); 226 227 printf("TEST: unlink file\n"); 228 if (unlink(filename) != 0) { 229 printf("OK: unlink failed: %s\n", strerror(errno)); 230 ret = false; 231 goto done; 232 } 233 printf("OK: unlink file\n"); 234 235 done: 236 printf("%s: text backend\n", ret ? "success" : "failure"); 237 talloc_free(mem_ctx); 238 return ret; 239 } 240 241 static bool torture_smbconf_reg(void) 177 242 { 178 243 WERROR werr; … … 181 246 TALLOC_CTX *mem_ctx = talloc_stackframe(); 182 247 183 printf("test: textbackend\n");184 185 printf(" test: init\n");186 werr = smbconf_init_ txt(mem_ctx, &conf_ctx, NULL);187 if (!W_ERROR_IS_OK(werr)) { 188 printf(" failure: init failed: %s\n", dos_errstr(werr));248 printf("test: registry backend\n"); 249 250 printf("TEST: init\n"); 251 werr = smbconf_init_reg(mem_ctx, &conf_ctx, NULL); 252 if (!W_ERROR_IS_OK(werr)) { 253 printf("FAIL: init failed: %s\n", dos_errstr(werr)); 189 254 ret = false; 190 255 goto done; 191 256 } 192 printf("success: init\n"); 193 194 ret &= test_get_includes(conf_ctx); 195 196 smbconf_shutdown(conf_ctx); 197 198 printf("%s: text backend\n", ret ? "success" : "failure"); 199 200 done: 201 TALLOC_FREE(mem_ctx); 202 return ret; 203 } 204 205 static bool torture_smbconf_reg(void) 206 { 207 WERROR werr; 208 bool ret = true; 209 struct smbconf_ctx *conf_ctx = NULL; 210 TALLOC_CTX *mem_ctx = talloc_stackframe(); 211 212 printf("test: registry backend\n"); 213 214 printf("test: init\n"); 215 werr = smbconf_init_reg(mem_ctx, &conf_ctx, NULL); 216 if (!W_ERROR_IS_OK(werr)) { 217 printf("failure: init failed: %s\n", dos_errstr(werr)); 218 ret = false; 219 goto done; 220 } 221 printf("success: init\n"); 257 printf("OK: init\n"); 222 258 223 259 ret &= test_get_includes(conf_ctx); … … 227 263 smbconf_shutdown(conf_ctx); 228 264 265 done: 229 266 printf("%s: registry backend\n", ret ? "success" : "failure"); 230 231 done: 232 TALLOC_FREE(mem_ctx); 267 talloc_free(mem_ctx); 233 268 return ret; 234 269 } … … 279 314 280 315 done: 281 TALLOC_FREE(mem_ctx);316 talloc_free(mem_ctx); 282 317 return ret ? 0 : -1; 283 318 } -
branches/samba-3.3.x/source/lib/version.c
r206 r223 30 30 #ifdef SAMBA_VERSION_VENDOR_PATCH 31 31 return SAMBA_VERSION_OFFICIAL_STRING "-" SAMBA_VERSION_VENDOR_SUFFIX \ 32 "-" SAMBA_VERSION_VENDOR_PATCH ;32 "-" SAMBA_VERSION_VENDOR_PATCH_STRING; 33 33 #endif /* SAMBA_VERSION_VENDOR_PATCH */ 34 34 return SAMBA_VERSION_OFFICIAL_STRING "-" SAMBA_VERSION_VENDOR_SUFFIX;
Note:
See TracChangeset
for help on using the changeset viewer.