Changeset 988 for vendor/current/source4/dsdb/kcc
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/source4/dsdb/kcc
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/dsdb/kcc/kcc_connection.c
r740 r988 47 47 48 48 tmp_ctx = talloc_new(s); 49 new_dn = samdb_ntds_settings_dn(s->samdb); 49 if (!tmp_ctx) { 50 DEBUG(0, ("failed to talloc\n")); 51 ret = LDB_ERR_OPERATIONS_ERROR; 52 goto done; 53 } 54 new_dn = samdb_ntds_settings_dn(s->samdb, tmp_ctx); 50 55 if (!new_dn) { 51 56 DEBUG(0, ("failed to find NTDS settings\n")); … … 66 71 goto done; 67 72 } 68 ret = dsdb_find_dn_by_guid(s->samdb, tmp_ctx, &conn->dsa_guid, &server_dn);73 ret = dsdb_find_dn_by_guid(s->samdb, tmp_ctx, &conn->dsa_guid, 0, &server_dn); 69 74 if (ret != LDB_SUCCESS) { 70 75 DEBUG(0, ("failed to find fromServer DN '%s'\n", … … 81 86 ldb_msg_add_linearized_dn(msg, "fromServer", server_dn); 82 87 /* ldb_msg_add_value(msg, "schedule", &schedule_val, NULL); */ 83 samdb_msg_add_uint(s->samdb, msg, msg, "options", 1); 88 89 samdb_msg_add_uint(s->samdb, msg, msg, 90 "options", NTDSCONN_OPT_IS_GENERATED); 84 91 85 92 ret = ldb_add(s->samdb, msg); … … 105 112 106 113 tmp_ctx = talloc_new(s); 107 ret = dsdb_find_dn_by_guid(s->samdb, tmp_ctx, &conn->obj_guid, &dn);114 ret = dsdb_find_dn_by_guid(s->samdb, tmp_ctx, &conn->obj_guid, 0, &dn); 108 115 if (ret != LDB_SUCCESS) { 109 116 DEBUG(0, ("failed to find nTDSConnection's DN: %s\n", … … 133 140 int ret; 134 141 142 /* XXX 143 * 144 * This routine is not respecting connections that the 145 * administrator can specifically create (NTDSCONN_OPT_IS_GENERATED 146 * bit will not be set) 147 */ 135 148 for (i = 0; ntds_list && i < ntds_list->count; i++) { 136 149 struct kcc_connection *ntds = &ntds_list->servers[i]; … … 177 190 const char *attrs[] = { "objectGUID", "fromServer", NULL }; 178 191 struct kcc_connection_list *list; 179 192 TALLOC_CTX *tmp_ctx; 180 193 kcctpl_test(s); 181 194 182 base_dn = samdb_ntds_settings_dn(s->samdb); 195 tmp_ctx = talloc_new(mem_ctx); 196 if (!tmp_ctx) { 197 DEBUG(0, ("failed to talloc\n")); 198 return NULL; 199 } 200 201 base_dn = samdb_ntds_settings_dn(s->samdb, tmp_ctx); 183 202 if (!base_dn) { 184 203 DEBUG(0, ("failed to find our own NTDS settings DN\n")); 185 return NULL; 186 } 187 188 ret = ldb_search(s->samdb, mem_ctx, &res, base_dn, LDB_SCOPE_ONELEVEL, 204 talloc_free(tmp_ctx); 205 return NULL; 206 } 207 208 ret = ldb_search(s->samdb, tmp_ctx, &res, base_dn, LDB_SCOPE_ONELEVEL, 189 209 attrs, "objectClass=nTDSConnection"); 190 210 if (ret != LDB_SUCCESS) { 191 211 DEBUG(0, ("failed nTDSConnection search: %s\n", 192 212 ldb_strerror(ret))); 193 return NULL; 194 } 195 196 list = talloc(mem_ctx, struct kcc_connection_list); 213 talloc_free(tmp_ctx); 214 return NULL; 215 } 216 217 list = talloc(tmp_ctx, struct kcc_connection_list); 197 218 if (!list) { 198 219 DEBUG(0, ("out of memory")); 199 220 return NULL; 200 221 } 201 list->servers = talloc_array( mem_ctx, struct kcc_connection,222 list->servers = talloc_array(list, struct kcc_connection, 202 223 res->count); 203 224 if (!list->servers) { 204 225 DEBUG(0, ("out of memory")); 226 talloc_free(tmp_ctx); 205 227 return NULL; 206 228 } … … 226 248 } 227 249 DEBUG(4, ("found %d existing nTDSConnection objects\n", list->count)); 250 talloc_steal(mem_ctx, list); 251 talloc_free(tmp_ctx); 228 252 return list; 229 253 } -
vendor/current/source4/dsdb/kcc/kcc_connection.h
r740 r988 28 28 struct GUID obj_guid; 29 29 struct GUID dsa_guid; 30 struct GUID invocation_id; 30 31 uint8_t schedule[84]; 31 32 }; -
vendor/current/source4/dsdb/kcc/kcc_deleted.c
r740 r988 45 45 int ret; 46 46 uint32_t tombstoneLifetime; 47 bool do_fs = false; 47 48 49 time_t interval = lpcfg_parm_int(s->task->lp_ctx, NULL, "kccsrv", 50 "check_deleted_full_scan_interval", 86400); 48 51 time_t t = time(NULL); 52 49 53 if (t - s->last_deleted_check < lpcfg_parm_int(s->task->lp_ctx, NULL, "kccsrv", 50 54 "check_deleted_interval", 600)) { … … 58 62 return NT_STATUS_INTERNAL_DB_CORRUPTION; 59 63 } 64 if (s->last_full_scan_deleted_check > 0 && ((t - s->last_full_scan_deleted_check) > interval )) { 65 do_fs = true; 66 s->last_full_scan_deleted_check = t; 67 } 68 69 if (s->last_full_scan_deleted_check == 0) { 70 /* 71 * If we never made a full scan set the last full scan event to be in the past 72 * and that 9/10 of the full scan interval has already passed. 73 * This is done to avoid the full scan to fire just at the begining of samba 74 * or a couple of minutes after the start. 75 * With this "setup" and default values of interval, the full scan will fire 76 * 2.4 hours after the start of samba 77 */ 78 s->last_full_scan_deleted_check = t - ((9 * interval) / 10); 79 } 60 80 61 81 for (part=s->partitions; part; part=part->next) { … … 64 84 const char *attrs[] = { "whenChanged", NULL }; 65 85 unsigned int i; 86 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); 87 if (!tmp_ctx) { 88 return NT_STATUS_NO_MEMORY; 89 } 66 90 67 ret = dsdb_get_deleted_objects_dn(s->samdb, mem_ctx, part->dn, &do_dn);91 ret = dsdb_get_deleted_objects_dn(s->samdb, tmp_ctx, part->dn, &do_dn); 68 92 if (ret != LDB_SUCCESS) { 93 TALLOC_FREE(tmp_ctx); 69 94 /* some partitions have no Deleted Objects 70 95 container */ 71 96 continue; 72 97 } 73 ret = dsdb_search(s->samdb, do_dn, &res, do_dn, LDB_SCOPE_ONELEVEL, attrs, 74 DSDB_SEARCH_SHOW_RECYCLED, NULL); 98 99 if (!do_fs && ldb_dn_compare(ldb_get_config_basedn(s->samdb), part->dn)) { 100 ret = dsdb_search(s->samdb, tmp_ctx, &res, do_dn, LDB_SCOPE_ONELEVEL, attrs, 101 DSDB_SEARCH_SHOW_RECYCLED, NULL); 102 } else { 103 if (do_fs) { 104 DEBUG(1, ("Doing a full scan on %s and looking for deleted object\n", 105 ldb_dn_get_linearized(part->dn))); 106 } 107 ret = dsdb_search(s->samdb, tmp_ctx, &res, part->dn, LDB_SCOPE_SUBTREE, attrs, 108 DSDB_SEARCH_SHOW_RECYCLED, "(isDeleted=TRUE)"); 109 } 75 110 76 111 if (ret != LDB_SUCCESS) { 77 112 DEBUG(1,(__location__ ": Failed to search for deleted objects in %s\n", 78 ldb_dn_get_linearized(do_dn))); 79 talloc_free(do_dn);113 ldb_dn_get_linearized(do_dn))); 114 TALLOC_FREE(tmp_ctx); 80 115 continue; 81 116 } … … 85 120 time_t whenChanged = 0; 86 121 122 if (ldb_dn_compare(do_dn, res->msgs[i]->dn) == 0) { 123 /* Skip the Deleted Object Container */ 124 continue; 125 } 87 126 tstring = ldb_msg_find_attr_as_string(res->msgs[i], "whenChanged", NULL); 88 127 if (tstring) { … … 90 129 } 91 130 if (t - whenChanged > tombstoneLifetime*60*60*24) { 92 ret = ldb_delete(s->samdb, res->msgs[i]->dn);131 ret = dsdb_delete(s->samdb, res->msgs[i]->dn, DSDB_SEARCH_SHOW_RECYCLED|DSDB_MODIFY_RELAX); 93 132 if (ret != LDB_SUCCESS) { 94 133 DEBUG(1,(__location__ ": Failed to remove deleted object %s\n", … … 101 140 } 102 141 103 talloc_free(do_dn);142 TALLOC_FREE(tmp_ctx); 104 143 } 105 144 -
vendor/current/source4/dsdb/kcc/kcc_drs_replica_info.c
r740 r988 215 215 uint32_t attr_version; 216 216 NTTIME attr_change_time; 217 uint32_t attr_originating_usn ;217 uint32_t attr_originating_usn = 0; 218 218 219 219 /* … … 387 387 const char *ntds_guid_str, struct ncList **master_nc_list) 388 388 { 389 const char *attrs[] = { "hasMasterNCs", NULL }; 389 const char *post_2003_attrs[] = { "msDS-hasMasterNCs", "hasPartialReplicaNCs", NULL }; 390 const char *pre_2003_attrs[] = { "hasMasterNCs", "hasPartialReplicaNCs", NULL }; 391 const char **attrs = post_2003_attrs; 390 392 struct ldb_result *res; 391 393 struct ncList *nc_list = NULL; … … 395 397 char *nc_str; 396 398 399 /* In W2003 and greater, msDS-hasMasterNCs attribute lists the writable NC replicas */ 397 400 ret = ldb_search(samdb, mem_ctx, &res, ldb_get_config_basedn(samdb), 398 LDB_SCOPE_DEFAULT, attrs, "(objectguid=%s)", ntds_guid_str);401 LDB_SCOPE_DEFAULT, post_2003_attrs, "(objectguid=%s)", ntds_guid_str); 399 402 400 403 if (ret != LDB_SUCCESS) { 401 404 DEBUG(0,(__location__ ": Failed objectguid search - %s\n", ldb_errstring(samdb))); 405 406 attrs = post_2003_attrs; 407 ret = ldb_search(samdb, mem_ctx, &res, ldb_get_config_basedn(samdb), 408 LDB_SCOPE_DEFAULT, pre_2003_attrs, "(objectguid=%s)", ntds_guid_str); 409 } 410 411 if (ret != LDB_SUCCESS) { 412 DEBUG(0,(__location__ ": Failed objectguid search - %s\n", ldb_errstring(samdb))); 402 413 return WERR_INTERNAL_ERROR; 403 414 } … … 409 420 410 421 for (i = 0; i < res->count; i++) { 411 struct ldb_message_element *msg_elem = ldb_msg_find_element(res->msgs[i], "hasMasterNCs"); 412 unsigned int k; 413 414 if (!msg_elem || msg_elem->num_values == 0) { 415 DEBUG(0,(__location__ ": Failed: Attribute hasMasterNCs not found - %s\n", 416 ldb_errstring(samdb))); 417 return WERR_INTERNAL_ERROR; 422 struct ldb_message_element *msg_elem; 423 unsigned int k, a; 424 425 for (a=0; attrs[a]; a++) { 426 msg_elem = ldb_msg_find_element(res->msgs[i], attrs[a]); 427 if (!msg_elem || msg_elem->num_values == 0) { 428 continue; 429 } 430 431 for (k = 0; k < msg_elem->num_values; k++) { 432 /* copy the string on msg_elem->values[k]->data to nc_str */ 433 nc_str = talloc_strndup(mem_ctx, (char *)msg_elem->values[k].data, msg_elem->values[k].length); 434 W_ERROR_HAVE_NO_MEMORY(nc_str); 435 436 nc_list_elem = talloc_zero(mem_ctx, struct ncList); 437 W_ERROR_HAVE_NO_MEMORY(nc_list_elem); 438 nc_list_elem->dn = ldb_dn_new(mem_ctx, samdb, nc_str); 439 W_ERROR_HAVE_NO_MEMORY(nc_list_elem); 440 DLIST_ADD(nc_list, nc_list_elem); 441 } 418 442 } 419 420 for (k = 0; k < msg_elem->num_values; k++) {421 /* copy the string on msg_elem->values[k]->data to nc_str */422 nc_str = talloc_strndup(mem_ctx, (char *)msg_elem->values[k].data, msg_elem->values[k].length);423 W_ERROR_HAVE_NO_MEMORY(nc_str);424 425 nc_list_elem = talloc_zero(mem_ctx, struct ncList);426 W_ERROR_HAVE_NO_MEMORY(nc_list_elem);427 nc_list_elem->dn = ldb_dn_new(mem_ctx, samdb, nc_str);428 W_ERROR_HAVE_NO_MEMORY(nc_list_elem);429 DLIST_ADD(nc_list, nc_list_elem);430 }431 432 443 } 433 444 … … 458 469 W_ERROR_HAVE_NO_MEMORY(nc_list_elem); 459 470 nc_list_elem->dn = nc_dn; 460 DLIST_ADD_END(*nc_list, nc_list_elem , struct ncList*);471 DLIST_ADD_END(*nc_list, nc_list_elem); 461 472 } else { 462 473 /* ncs := getNCs() from ldb database. … … 523 534 524 535 ret = dsdb_find_dn_by_guid(samdb, mem_ctx, &reps_from->source_dsa_obj_guid, 536 DSDB_SEARCH_SHOW_RECYCLED, 525 537 &source_dsa_dn); 526 538 … … 534 546 neigh->naming_context_dn = ldb_dn_get_linearized(nc_dn); 535 547 536 if (dsdb_find_guid_by_dn(samdb, nc_dn, &neigh->naming_context_obj_guid) 548 if (dsdb_find_guid_by_dn(samdb, nc_dn, 549 &neigh->naming_context_obj_guid) 537 550 != LDB_SUCCESS) { 538 551 return WERR_DS_DRA_INTERNAL_ERROR; … … 541 554 if (!GUID_all_zero(&reps_from->transport_guid)) { 542 555 ret = dsdb_find_dn_by_guid(samdb, mem_ctx, &reps_from->transport_guid, 556 DSDB_SEARCH_SHOW_RECYCLED, 543 557 &transport_obj_dn); 544 558 if (ret != LDB_SUCCESS) { … … 616 630 617 631 if (GUID_all_zero(&req_src_dsa_guid) || 618 GUID_ compare(&req_src_dsa_guid, &reps_from->source_dsa_obj_guid) == 0)619 {632 GUID_equal(&req_src_dsa_guid, 633 &reps_from->source_dsa_obj_guid)) { 620 634 621 635 if (i >= base_index) { … … 658 672 neigh->source_dsa_obj_guid = reps_to->source_dsa_obj_guid; 659 673 660 ret = dsdb_find_dn_by_guid(samdb, mem_ctx, &reps_to->source_dsa_obj_guid, &source_dsa_dn); 674 ret = dsdb_find_dn_by_guid(samdb, mem_ctx, 675 &reps_to->source_dsa_obj_guid, 676 DSDB_SEARCH_SHOW_RECYCLED, 677 &source_dsa_dn); 661 678 if (ret != LDB_SUCCESS) { 662 679 DEBUG(0,(__location__ ": Failed to find DN for neighbor GUID %s\n", … … 676 693 } 677 694 695 neigh->last_success = reps_to->last_success; 696 neigh->result_last_attempt = reps_to->result_last_attempt; 697 neigh->consecutive_sync_failures = reps_to->consecutive_sync_failures; 678 698 return WERR_OK; 679 699 } … … 771 791 TALLOC_CTX *mem_ctx; 772 792 enum drsuapi_DsReplicaInfoType info_type; 773 uint32_t flags;774 const char *attribute_name, *value_dn;775 793 776 794 service = talloc_get_type(msg->private_data, struct kccsrv_service); … … 811 829 object_dn_str = req2->object_dn; 812 830 req_src_dsa_guid = req2->source_dsa_guid; 813 flags = req2->flags;814 attribute_name = req2->attribute_name;815 value_dn = req2->value_dn_str;816 831 } 817 832 … … 846 861 break; 847 862 case DRSUAPI_DS_REPLICA_INFO_CURSORS3: /* On MS-DRSR it is DS_REPL_INFO_CURSORS_3_FOR_NC */ 848 status = WERR_ INVALID_LEVEL;863 status = WERR_NOT_SUPPORTED; 849 864 break; 850 865 case DRSUAPI_DS_REPLICA_INFO_UPTODATE_VECTOR_V1: /* On MS-DRSR it is DS_REPL_INFO_UPTODATE_VECTOR_V1 */ 851 status = WERR_ INVALID_LEVEL;866 status = WERR_NOT_SUPPORTED; 852 867 break; 853 868 case DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA: /* On MS-DRSR it is DS_REPL_INFO_METADATA_FOR_OBJ */ 854 status = WERR_INVALID_LEVEL; 869 /* 870 * It should be too complicated to filter the metadata2 to remove the additional data 871 * as metadata2 is a superset of metadata 872 */ 873 status = WERR_NOT_SUPPORTED; 855 874 break; 856 875 case DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2: /* On MS-DRSR it is DS_REPL_INFO_METADATA_FOR_OBJ */ … … 859 878 break; 860 879 case DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA: /* On MS-DRSR it is DS_REPL_INFO_METADATA_FOR_ATTR_VALUE */ 861 status = WERR_ INVALID_LEVEL;880 status = WERR_NOT_SUPPORTED; 862 881 break; 863 882 case DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2: /* On MS-DRSR it is DS_REPL_INFO_METADATA_2_FOR_ATTR_VALUE */ 864 status = WERR_ INVALID_LEVEL;883 status = WERR_NOT_SUPPORTED; 865 884 break; 866 885 case DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES: /* On MS-DRSR it is DS_REPL_INFO_KCC_DSA_CONNECT_FAILURES */ 867 status = WERR_ INVALID_LEVEL;886 status = WERR_NOT_SUPPORTED; 868 887 break; 869 888 case DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES: /* On MS-DRSR it is DS_REPL_INFO_KCC_LINK_FAILURES */ 870 status = WERR_ INVALID_LEVEL;889 status = WERR_NOT_SUPPORTED; 871 890 break; 872 891 case DRSUAPI_DS_REPLICA_INFO_CLIENT_CONTEXTS: /* On MS-DRSR it is DS_REPL_INFO_CLIENT_CONTEXTS */ 873 status = WERR_ INVALID_LEVEL;892 status = WERR_NOT_SUPPORTED; 874 893 break; 875 894 case DRSUAPI_DS_REPLICA_INFO_SERVER_OUTGOING_CALLS: /* On MS-DRSR it is DS_REPL_INFO_SERVER_OUTGOING_CALLS */ 876 status = WERR_ INVALID_LEVEL;895 status = WERR_NOT_SUPPORTED; 877 896 break; 878 897 default: -
vendor/current/source4/dsdb/kcc/kcc_periodic.c
r740 r988 36 36 #include "librpc/gen_ndr/ndr_irpc_c.h" 37 37 #include "param/param.h" 38 #include "dsdb/common/util.h" 38 39 39 40 /* … … 42 43 static bool kccsrv_same_source_dsa(struct repsFromToBlob *r1, struct repsFromToBlob *r2) 43 44 { 44 return GUID_ compare(&r1->ctr.ctr1.source_dsa_obj_guid,45 &r2->ctr.ctr1.source_dsa_obj_guid) == 0;45 return GUID_equal(&r1->ctr.ctr1.source_dsa_obj_guid, 46 &r2->ctr.ctr1.source_dsa_obj_guid); 46 47 } 47 48 … … 70 71 struct GUID invocation_id = r1->source_dsa_invocation_id; 71 72 unsigned int i, j; 73 TALLOC_CTX *tmp_ctx; 72 74 73 75 /* we are expecting only version 1 */ 74 76 SMB_ASSERT(r->version == 1); 77 78 tmp_ctx = talloc_new(p); 79 if (!tmp_ctx) { 80 return false; 81 } 75 82 76 83 for (i=0; i<res->count; i++) { … … 93 100 } 94 101 for (j=0; j<el->num_values; j++) { 95 dn = ldb_dn_from_ldb_val( p, p->service->samdb, &el->values[j]);102 dn = ldb_dn_from_ldb_val(tmp_ctx, p->service->samdb, &el->values[j]); 96 103 if (!ldb_dn_validate(dn)) { 97 104 talloc_free(dn); … … 99 106 } 100 107 if (ldb_dn_compare(dn, p->dn) == 0) { 101 talloc_free(dn);102 108 DEBUG(5,("%s %s match on %s in %s\n", 103 109 r1->other_info->dns_name, … … 105 111 ldb_dn_get_linearized(dn), 106 112 ldb_dn_get_linearized(msg->dn))); 113 talloc_free(tmp_ctx); 107 114 return true; 108 115 } … … 110 117 } 111 118 } 119 talloc_free(tmp_ctx); 112 120 return false; 113 121 } … … 156 164 tevent_req_callback_data(subreq, 157 165 struct kccsrv_notify_drepl_server_state); 158 NTSTATUS status; 159 160 status = dcerpc_dreplsrv_refresh_r_recv(subreq, state); 166 167 dcerpc_dreplsrv_refresh_r_recv(subreq, state); 161 168 TALLOC_FREE(subreq); 162 169 … … 165 172 } 166 173 167 staticuint32_t kccsrv_replica_flags(struct kccsrv_service *s)174 uint32_t kccsrv_replica_flags(struct kccsrv_service *s) 168 175 { 169 176 if (s->am_rodc) { … … 184 191 * add any missing repsFrom structures to our partitions 185 192 */ 186 staticNTSTATUS kccsrv_add_repsFrom(struct kccsrv_service *s, TALLOC_CTX *mem_ctx,187 188 193 NTSTATUS kccsrv_add_repsFrom(struct kccsrv_service *s, TALLOC_CTX *mem_ctx, 194 struct repsFromToBlob *reps, uint32_t count, 195 struct ldb_result *res) 189 196 { 190 197 struct kccsrv_partition *p; … … 227 234 * if it is a master 228 235 */ 229 if ( !check_MasterNC(p, &reps[i], res)) {236 if (res && !check_MasterNC(p, &reps[i], res)) { 230 237 /* its not a master, we don't 231 238 want to pull from it */ … … 247 254 for (i=0; i<our_count; i++) { 248 255 if (!reps_in_list(&our_reps[i], reps, count) || 249 !check_MasterNC(p, &our_reps[i], res)) {256 (res && !check_MasterNC(p, &our_reps[i], res))) { 250 257 DEBUG(4,(__location__ ": Removed repsFrom for %s\n", 251 258 our_reps[i].ctr.ctr1.other_info->dns_name)); … … 310 317 } 311 318 319 320 /* 321 form a unique list of DNs from a search result and a given set of attributes 322 */ 323 static int kccsrv_dn_list(struct ldb_context *ldb, struct ldb_result *res, 324 TALLOC_CTX *mem_ctx, 325 const char **attrs, 326 struct ldb_dn ***dn_list, int *dn_count) 327 { 328 int i; 329 struct ldb_dn **nc_list = NULL; 330 int nc_count = 0; 331 332 nc_list = talloc_array(mem_ctx, struct ldb_dn *, 0); 333 if (nc_list == NULL) { 334 return LDB_ERR_OPERATIONS_ERROR; 335 } 336 337 /* gather up a list of all NCs in this forest */ 338 for (i=0; i<res->count; i++) { 339 struct ldb_message *msg = res->msgs[i]; 340 int j; 341 for (j=0; attrs[j]; j++) { 342 struct ldb_message_element *el; 343 int k; 344 345 el = ldb_msg_find_element(msg, attrs[j]); 346 if (el == NULL) continue; 347 for (k=0; k<el->num_values; k++) { 348 struct ldb_dn *dn; 349 dn = ldb_dn_from_ldb_val(nc_list, ldb, &el->values[k]); 350 if (dn != NULL) { 351 int l; 352 for (l=0; l<nc_count; l++) { 353 if (ldb_dn_compare(nc_list[l], dn) == 0) break; 354 } 355 if (l < nc_count) continue; 356 nc_list = talloc_realloc(mem_ctx, nc_list, struct ldb_dn *, nc_count+1); 357 if (nc_list == NULL) { 358 return LDB_ERR_OPERATIONS_ERROR; 359 } 360 nc_list[nc_count] = dn; 361 nc_count++; 362 } 363 } 364 } 365 } 366 367 (*dn_list) = nc_list; 368 (*dn_count) = nc_count; 369 return LDB_SUCCESS; 370 } 371 372 373 /* 374 look for any additional global catalog partitions that we should be 375 replicating (by looking for msDS-HasDomainNCs), and add them to our 376 hasPartialReplicaNCs NTDS attribute 377 */ 378 static int kccsrv_gc_update(struct kccsrv_service *s, struct ldb_result *res) 379 { 380 int i; 381 struct ldb_dn **nc_list = NULL; 382 int nc_count = 0; 383 struct ldb_dn **our_nc_list = NULL; 384 int our_nc_count = 0; 385 const char *attrs1[] = { "msDS-hasMasterNCs", "hasMasterNCs", "msDS-HasDomainNCs", NULL }; 386 const char *attrs2[] = { "msDS-hasMasterNCs", "hasMasterNCs", "msDS-HasDomainNCs", "hasPartialReplicaNCs", NULL }; 387 int ret; 388 TALLOC_CTX *tmp_ctx = talloc_new(res); 389 struct ldb_result *res2; 390 struct ldb_message *msg; 391 392 /* get a complete list of NCs for the forest */ 393 ret = kccsrv_dn_list(s->samdb, res, tmp_ctx, attrs1, &nc_list, &nc_count); 394 if (ret != LDB_SUCCESS) { 395 DEBUG(1,("Failed to get NC list for GC update - %s\n", ldb_errstring(s->samdb))); 396 talloc_free(tmp_ctx); 397 return ret; 398 } 399 400 /* get a list of what NCs we are already replicating */ 401 ret = dsdb_search_dn(s->samdb, tmp_ctx, &res2, samdb_ntds_settings_dn(s->samdb, tmp_ctx), attrs2, 0); 402 if (ret != LDB_SUCCESS) { 403 DEBUG(1,("Failed to get our NC list attributes for GC update - %s\n", ldb_errstring(s->samdb))); 404 talloc_free(tmp_ctx); 405 return ret; 406 } 407 408 ret = kccsrv_dn_list(s->samdb, res2, tmp_ctx, attrs2, &our_nc_list, &our_nc_count); 409 if (ret != LDB_SUCCESS) { 410 DEBUG(1,("Failed to get our NC list for GC update - %s\n", ldb_errstring(s->samdb))); 411 talloc_free(tmp_ctx); 412 return ret; 413 } 414 415 msg = ldb_msg_new(tmp_ctx); 416 if (msg == NULL) { 417 talloc_free(tmp_ctx); 418 return LDB_ERR_OPERATIONS_ERROR; 419 } 420 msg->dn = res2->msgs[0]->dn; 421 422 /* see if we are missing any */ 423 for (i=0; i<nc_count; i++) { 424 int j; 425 for (j=0; j<our_nc_count; j++) { 426 if (ldb_dn_compare(nc_list[i], our_nc_list[j]) == 0) break; 427 } 428 if (j == our_nc_count) { 429 /* its a new one */ 430 ret = ldb_msg_add_string(msg, "hasPartialReplicaNCs", 431 ldb_dn_get_extended_linearized(msg, nc_list[i], 1)); 432 if (ret != LDB_SUCCESS) { 433 talloc_free(tmp_ctx); 434 return ret; 435 } 436 437 } 438 } 439 440 if (msg->num_elements == 0) { 441 /* none to add */ 442 talloc_free(tmp_ctx); 443 return LDB_SUCCESS; 444 } 445 446 if (s->am_rodc) { 447 DEBUG(5, ("%d partial replica should be added but we are RODC so we skip\n", msg->num_elements)); 448 talloc_free(tmp_ctx); 449 return LDB_SUCCESS; 450 } 451 452 msg->elements[0].flags = LDB_FLAG_MOD_ADD; 453 454 ret = dsdb_modify(s->samdb, msg, 0); 455 if (ret != LDB_SUCCESS) { 456 DEBUG(0,("Failed to add hasPartialReplicaNCs - %s\n", 457 ldb_errstring(s->samdb))); 458 } 459 460 talloc_free(tmp_ctx); 461 return ret; 462 } 463 464 312 465 /* 313 466 this is the core of our initial simple KCC … … 320 473 unsigned int i; 321 474 int ret; 322 const char *attrs[] = { "objectGUID", "invocationID", "msDS-hasMasterNCs", "hasMasterNCs", NULL };475 const char *attrs[] = { "objectGUID", "invocationID", "msDS-hasMasterNCs", "hasMasterNCs", "msDS-HasDomainNCs", NULL }; 323 476 struct repsFromToBlob *reps = NULL; 324 477 uint32_t count = 0; 325 478 struct kcc_connection_list *ntds_conn, *dsa_conn; 326 479 327 ret = ldb_search(s->samdb, mem_ctx, &res, s->config_dn, LDB_SCOPE_SUBTREE,328 attrs, "objectClass=nTDSDSA");480 ret = dsdb_search(s->samdb, mem_ctx, &res, s->config_dn, LDB_SCOPE_SUBTREE, 481 attrs, DSDB_SEARCH_SHOW_EXTENDED_DN, "objectClass=nTDSDSA"); 329 482 if (ret != LDB_SUCCESS) { 330 483 DEBUG(0,(__location__ ": Failed nTDSDSA search - %s\n", ldb_errstring(s->samdb))); … … 332 485 } 333 486 487 if (samdb_is_gc(s->samdb)) { 488 kccsrv_gc_update(s, res); 489 } 490 334 491 /* get the current list of connections */ 335 492 ntds_conn = kccsrv_find_connections(s, mem_ctx); … … 342 499 343 500 ntds_guid = samdb_result_guid(res->msgs[i], "objectGUID"); 344 if (GUID_ compare(&ntds_guid, &s->ntds_guid) == 0) {501 if (GUID_equal(&ntds_guid, &s->ntds_guid)) { 345 502 /* don't replicate with ourselves */ 346 503 continue; … … 357 514 358 515 r1->other_info = talloc_zero(reps, struct repsFromTo1OtherInfo); 359 r1->other_info->dns_name = talloc_asprintf(r1->other_info, "%s._msdcs.%s", 360 GUID_string(mem_ctx, &ntds_guid), 361 lpcfg_dnsdomain(s->task->lp_ctx)); 516 r1->other_info->dns_name = samdb_ntds_msdcs_dns_name(s->samdb, reps, &ntds_guid); 362 517 r1->source_dsa_obj_guid = ntds_guid; 363 518 r1->source_dsa_invocation_id = invocation_id; … … 424 579 service->periodic.next_event = next_time; 425 580 426 new_te = event_add_timed(service->task->event_ctx, service,581 new_te = tevent_add_timer(service->task->event_ctx, service, 427 582 service->periodic.next_event, 428 583 kccsrv_periodic_handler_te, service); … … 447 602 NTSTATUS status; 448 603 449 DEBUG(4,("kccsrv_periodic_run(): simpleupdate\n"));604 DEBUG(4,("kccsrv_periodic_run(): update\n")); 450 605 451 606 mem_ctx = talloc_new(service); 452 status = kccsrv_simple_update(service, mem_ctx); 453 if (!NT_STATUS_IS_OK(status)) { 454 DEBUG(0,("kccsrv_simple_update failed - %s\n", nt_errstr(status))); 607 608 if (service->samba_kcc_code) 609 status = kccsrv_samba_kcc(service); 610 else { 611 status = kccsrv_simple_update(service, mem_ctx); 612 if (!NT_STATUS_IS_OK(status)) 613 DEBUG(0,("kccsrv_simple_update failed - %s\n", 614 nt_errstr(status))); 455 615 } 456 616 … … 461 621 talloc_free(mem_ctx); 462 622 } 623 624 /* Called when samba_kcc script has finished 625 */ 626 static void samba_kcc_done(struct tevent_req *subreq) 627 { 628 struct kccsrv_service *service = 629 tevent_req_callback_data(subreq, struct kccsrv_service); 630 int rc; 631 int sys_errno; 632 633 service->periodic.subreq = NULL; 634 635 rc = samba_runcmd_recv(subreq, &sys_errno); 636 TALLOC_FREE(subreq); 637 638 if (rc != 0) 639 service->periodic.status = 640 map_nt_error_from_unix_common(sys_errno); 641 else 642 service->periodic.status = NT_STATUS_OK; 643 644 if (!NT_STATUS_IS_OK(service->periodic.status)) 645 DEBUG(0,(__location__ ": Failed samba_kcc - %s\n", 646 nt_errstr(service->periodic.status))); 647 else 648 DEBUG(3,("Completed samba_kcc OK\n")); 649 } 650 651 /* Invocation of the samba_kcc python script for replication 652 * topology generation. 653 */ 654 NTSTATUS kccsrv_samba_kcc(struct kccsrv_service *service) 655 { 656 NTSTATUS status = NT_STATUS_OK; 657 const char * const *samba_kcc_command = 658 lpcfg_samba_kcc_command(service->task->lp_ctx); 659 660 /* kill any existing child */ 661 TALLOC_FREE(service->periodic.subreq); 662 663 DEBUG(2, ("Calling samba_kcc script\n")); 664 service->periodic.subreq = samba_runcmd_send(service, 665 service->task->event_ctx, 666 timeval_current_ofs(40, 0), 667 2, 0, samba_kcc_command, NULL); 668 669 if (service->periodic.subreq == NULL) { 670 status = NT_STATUS_NO_MEMORY; 671 goto xerror; 672 } 673 tevent_req_set_callback(service->periodic.subreq, 674 samba_kcc_done, service); 675 676 xerror: 677 if (!NT_STATUS_IS_OK(status)) 678 DEBUG(0,(__location__ ": failed - %s\n", nt_errstr(status))); 679 return status; 680 } -
vendor/current/source4/dsdb/kcc/kcc_service.c
r740 r988 35 35 #include "librpc/gen_ndr/ndr_drsblobs.h" 36 36 #include "param/param.h" 37 #include "libds/common/roles.h" 37 38 38 39 /* … … 142 143 } 143 144 145 146 struct kcc_manual_runcmd_state { 147 struct irpc_message *msg; 148 struct drsuapi_DsExecuteKCC *r; 149 struct kccsrv_service *service; 150 }; 151 152 153 /* 154 * Called when samba_kcc script has finished 155 */ 156 static void manual_samba_kcc_done(struct tevent_req *subreq) 157 { 158 struct kcc_manual_runcmd_state *st = 159 tevent_req_callback_data(subreq, 160 struct kcc_manual_runcmd_state); 161 int rc; 162 int sys_errno; 163 NTSTATUS status; 164 165 st->service->periodic.subreq = NULL; 166 167 rc = samba_runcmd_recv(subreq, &sys_errno); 168 TALLOC_FREE(subreq); 169 170 if (rc != 0) { 171 status = map_nt_error_from_unix_common(sys_errno); 172 } else { 173 status = NT_STATUS_OK; 174 } 175 176 if (!NT_STATUS_IS_OK(status)) { 177 DEBUG(0,(__location__ ": Failed manual run of samba_kcc - %s\n", 178 nt_errstr(status))); 179 } else { 180 DEBUG(3,("Completed manual run of samba_kcc OK\n")); 181 } 182 183 if (!(st->r->in.req->ctr1.flags & DRSUAPI_DS_EXECUTE_KCC_ASYNCHRONOUS_OPERATION)) { 184 irpc_send_reply(st->msg, status); 185 } 186 } 187 144 188 static NTSTATUS kccsrv_execute_kcc(struct irpc_message *msg, struct drsuapi_DsExecuteKCC *r) 145 189 { 146 190 TALLOC_CTX *mem_ctx; 147 NTSTATUS status ;191 NTSTATUS status = NT_STATUS_OK; 148 192 struct kccsrv_service *service = talloc_get_type(msg->private_data, struct kccsrv_service); 149 193 150 mem_ctx = talloc_new(service); 151 status = kccsrv_simple_update(service, mem_ctx); 152 153 if (!NT_STATUS_IS_OK(status)) { 154 DEBUG(0,("kccsrv_simple_update failed - %s\n", nt_errstr(status))); 194 const char * const *samba_kcc_command; 195 struct kcc_manual_runcmd_state *st; 196 197 if (!service->samba_kcc_code) { 198 mem_ctx = talloc_new(service); 199 200 status = kccsrv_simple_update(service, mem_ctx); 201 if (!NT_STATUS_IS_OK(status)) { 202 DEBUG(0,("kccsrv_execute_kcc failed - %s\n", 203 nt_errstr(status))); 204 } 155 205 talloc_free(mem_ctx); 206 207 return NT_STATUS_OK; 208 } 209 210 /* Invocation of the samba_kcc python script for replication 211 * topology generation. 212 */ 213 214 samba_kcc_command = 215 lpcfg_samba_kcc_command(service->task->lp_ctx); 216 217 st = talloc(msg, struct kcc_manual_runcmd_state); 218 if (st == NULL) { 219 return NT_STATUS_NO_MEMORY; 220 } 221 222 st->msg = msg; 223 st->r = r; 224 st->service = service; 225 226 /* don't run at the same time as an existing child */ 227 if (service->periodic.subreq) { 228 status = NT_STATUS_DS_BUSY; 156 229 return status; 157 230 } 158 231 159 talloc_free(mem_ctx); 160 return NT_STATUS_OK; 232 DEBUG(2, ("Calling samba_kcc script\n")); 233 service->periodic.subreq = samba_runcmd_send(service, 234 service->task->event_ctx, 235 timeval_current_ofs(40, 0), 236 2, 0, samba_kcc_command, NULL); 237 238 if (service->periodic.subreq == NULL) { 239 status = NT_STATUS_NO_MEMORY; 240 DEBUG(0,(__location__ ": failed - %s\n", nt_errstr(status))); 241 return status; 242 } else { 243 tevent_req_set_callback(service->periodic.subreq, 244 manual_samba_kcc_done, st); 245 } 246 247 if (r->in.req->ctr1.flags & DRSUAPI_DS_EXECUTE_KCC_ASYNCHRONOUS_OPERATION) { 248 /* This actually means reply right away, let it run in the background */ 249 } else { 250 /* mark the request as replied async, the caller wants to know when this is finished */ 251 msg->defer_reply = true; 252 } 253 return status; 254 161 255 } 162 256 … … 182 276 task_server_terminate(task, "kccsrv: no KCC required in domain member configuration", false); 183 277 return; 184 case ROLE_ DOMAIN_CONTROLLER:278 case ROLE_ACTIVE_DIRECTORY_DC: 185 279 /* Yes, we want a KCC */ 186 280 break; … … 223 317 } 224 318 225 periodic_startup_interval = lpcfg_parm_int(task->lp_ctx, NULL, "kccsrv", 226 "periodic_startup_interval", 15); /* in seconds */ 227 service->periodic.interval = lpcfg_parm_int(task->lp_ctx, NULL, "kccsrv", 228 "periodic_interval", 300); /* in seconds */ 319 periodic_startup_interval = 320 lpcfg_parm_int(task->lp_ctx, NULL, "kccsrv", 321 "periodic_startup_interval", 15); /* in seconds */ 322 service->periodic.interval = 323 lpcfg_parm_int(task->lp_ctx, NULL, "kccsrv", 324 "periodic_interval", 300); /* in seconds */ 325 326 /* (kccsrv:samba_kcc=true) will run newer samba_kcc replication 327 * topology generation code. 328 */ 329 service->samba_kcc_code = lpcfg_parm_bool(task->lp_ctx, NULL, 330 "kccsrv", "samba_kcc", false); 229 331 230 332 status = kccsrv_periodic_schedule(service, periodic_startup_interval); -
vendor/current/source4/dsdb/kcc/kcc_service.h
r740 r988 78 78 /* here we have a reference to the timed event the schedules the periodic stuff */ 79 79 struct tevent_timer *te; 80 81 /* samba_runcmd_send service for samba_kcc */ 82 struct tevent_req *subreq; 83 84 /* return status of samba_kcc */ 85 NTSTATUS status; 86 80 87 } periodic; 81 88 82 89 time_t last_deleted_check; 83 90 91 time_t last_full_scan_deleted_check; 92 84 93 bool am_rodc; 94 95 /* run new samba_kcc topology generator code */ 96 bool samba_kcc_code; 85 97 }; 86 98 -
vendor/current/source4/dsdb/kcc/kcc_topology.c
r740 r988 29 29 #define FLAG_CR_NTDS_NC 0x00000001 30 30 #define FLAG_CR_NTDS_DOMAIN 0x00000002 31 32 #define NTDSCONN_OPT_IS_GENERATED 0x0000000133 #define NTDSCONN_OPT_TWOWAY_SYNC 0x0000000234 #define NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULT 0x0000000435 #define NTDSCONN_OPT_USE_NOTIFY 0x0000000836 #define NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION 0x0000001037 #define NTDSCONN_OPT_USER_OWNED_SCHEDULE 0x0000002038 #define NTDSCONN_OPT_RODC_TOPOLOGY 0x0000004039 31 40 32 #define NTDSDSA_OPT_IS_GC 0x00000001 … … 514 506 graph->vertices.data = talloc_zero_array(graph, struct kcctpl_vertex, 515 507 guids.count); 516 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(graph->vertices.data, graph); 508 if (graph->vertices.data == NULL) { 509 TALLOC_FREE(graph); 510 return NT_STATUS_NO_MEMORY; 511 } 517 512 518 513 TYPESAFE_QSORT(guids.data, guids.count, GUID_compare); … … 548 543 549 544 edge = talloc_zero(tmp_ctx, struct kcctpl_multi_edge); 550 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(edge, tmp_ctx); 545 if (edge == NULL) { 546 TALLOC_FREE(tmp_ctx); 547 return NT_STATUS_NO_MEMORY; 548 } 551 549 552 550 edge->id = samdb_result_guid(site_link, "objectGUID"); … … 589 587 590 588 edge->vertex_ids.data = talloc_array(edge, struct GUID, el->num_values); 591 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(edge->vertex_ids.data, tmp_ctx); 589 if (edge->vertex_ids.data == NULL) { 590 TALLOC_FREE(tmp_ctx); 591 return NT_STATUS_NO_MEMORY; 592 } 592 593 edge->vertex_ids.count = el->num_values; 593 594 … … 650 651 651 652 set = talloc_zero(tmp_ctx, struct kcctpl_multi_edge_set); 652 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(set, tmp_ctx); 653 if (set == NULL) { 654 TALLOC_FREE(tmp_ctx); 655 return NT_STATUS_NO_MEMORY; 656 } 653 657 654 658 for (i = 0; i < res_site_link->count; i++) { … … 674 678 struct GUID, 675 679 set->edge_ids.count + 1); 676 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, tmp_ctx); 680 if (new_data == NULL) { 681 TALLOC_FREE(tmp_ctx); 682 return NT_STATUS_NO_MEMORY; 683 } 677 684 new_data[set->edge_ids.count] = site_link_guid; 678 685 set->edge_ids.data = new_data; … … 703 710 704 711 set = talloc_zero(tmp_ctx, struct kcctpl_multi_edge_set); 705 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(set, tmp_ctx); 712 if (set == NULL) { 713 TALLOC_FREE(tmp_ctx); 714 return NT_STATUS_NO_MEMORY; 715 } 706 716 707 717 set->id = samdb_result_guid(bridge, "objectGUID"); … … 761 771 struct GUID, 762 772 set->edge_ids.count + 1); 763 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, tmp_ctx); 773 if (new_data == NULL) { 774 TALLOC_FREE(tmp_ctx); 775 return NT_STATUS_NO_MEMORY; 776 } 764 777 new_data[set->edge_ids.count] = site_link_guid; 765 778 set->edge_ids.data = new_data; … … 829 842 new_data = talloc_realloc(tmp_ctx, vertex_ids.data, struct GUID, 830 843 vertex_ids.count + 1); 831 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, tmp_ctx); 844 if (new_data == NULL) { 845 TALLOC_FREE(tmp_ctx); 846 return NT_STATUS_NO_MEMORY; 847 } 832 848 new_data[vertex_ids.count] = guid; 833 849 vertex_ids.data = new_data; … … 914 930 struct kcctpl_multi_edge, 915 931 graph->edges.count + 1); 916 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, tmp_ctx); 932 if (new_data == NULL) { 933 TALLOC_FREE(tmp_ctx); 934 return NT_STATUS_NO_MEMORY; 935 } 917 936 new_data[graph->edges.count] = *edge; 918 937 graph->edges.data = new_data; … … 939 958 struct kcctpl_multi_edge_set, 940 959 graph->edge_sets.count + 1); 941 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, tmp_ctx); 960 if (new_data == NULL) { 961 TALLOC_FREE(tmp_ctx); 962 return NT_STATUS_NO_MEMORY; 963 } 942 964 new_data[graph->edge_sets.count] = *edge_set; 943 965 graph->edge_sets.data = new_data; … … 982 1004 struct kcctpl_multi_edge_set, 983 1005 graph->edge_sets.count + 1); 984 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, 985 tmp_ctx); 1006 if (new_data == NULL) { 1007 TALLOC_FREE(tmp_ctx); 1008 return NT_STATUS_NO_MEMORY; 1009 } 986 1010 new_data[graph->edge_sets.count] = *edge_set; 987 1011 graph->edge_sets.data = new_data; … … 1016 1040 NT_STATUS_HAVE_NO_MEMORY(tmp_ctx); 1017 1041 1018 settings_dn = samdb_ntds_settings_dn(ldb );1042 settings_dn = samdb_ntds_settings_dn(ldb, tmp_ctx); 1019 1043 if (!settings_dn) { 1020 1044 DEBUG(1, (__location__ ": failed to find our own NTDS Settings " … … 1294 1318 struct ldb_message, 1295 1319 bridgeheads.count + 1); 1296 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, tmp_ctx); 1320 if (new_data == NULL) { 1321 TALLOC_FREE(tmp_ctx); 1322 return NT_STATUS_NO_MEMORY; 1323 } 1297 1324 new_data[bridgeheads.count + 1] = *dc; 1298 1325 bridgeheads.data = new_data; … … 1536 1563 struct GUID, 1537 1564 vertex->accept_red_red.count + 1); 1538 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, tmp_ctx); 1565 if (new_data == NULL) { 1566 TALLOC_FREE(tmp_ctx); 1567 return NT_STATUS_NO_MEMORY; 1568 } 1539 1569 new_data[vertex->accept_red_red.count + 1] = transport_guid; 1540 1570 vertex->accept_red_red.data = new_data; … … 1545 1575 struct GUID, 1546 1576 vertex->accept_black.count + 1); 1547 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, tmp_ctx); 1577 if (new_data == NULL) { 1578 TALLOC_FREE(tmp_ctx); 1579 return NT_STATUS_NO_MEMORY; 1580 } 1548 1581 new_data[vertex->accept_black.count + 1] = transport_guid; 1549 1582 vertex->accept_black.data = new_data; … … 1725 1758 struct kcctpl_multi_edge, 1726 1759 copy.count + 1); 1727 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, tmp_ctx); 1760 if (new_data == NULL) { 1761 TALLOC_FREE(tmp_ctx); 1762 return NT_STATUS_NO_MEMORY; 1763 } 1728 1764 new_data[copy.count + 1] = *edge; 1729 1765 copy.data = new_data; … … 1937 1973 struct kcctpl_vertex, 1938 1974 vertices.count - 1); 1939 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, tmp_ctx); 1975 if (new_data == NULL) { 1976 TALLOC_FREE(tmp_ctx); 1977 return NT_STATUS_NO_MEMORY; 1978 } 1940 1979 talloc_free(vertices.data); 1941 1980 vertices.data = new_data; … … 2119 2158 struct kcctpl_vertex, 2120 2159 vertices.count + 1); 2121 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, tmp_ctx); 2160 if (new_data == NULL) { 2161 TALLOC_FREE(tmp_ctx); 2162 return NT_STATUS_NO_MEMORY; 2163 } 2122 2164 new_data[vertices.count] = *vertex; 2123 2165 vertices.data = new_data; … … 2332 2374 2333 2375 new_edge = talloc(tmp_ctx, struct kcctpl_multi_edge); 2334 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_edge, tmp_ctx); 2376 if (new_edge == NULL) { 2377 TALLOC_FREE(tmp_ctx); 2378 return NT_STATUS_NO_MEMORY; 2379 } 2335 2380 2336 2381 new_edge->id = GUID_random(); /* TODO: what should be new_edge->GUID? */ … … 2338 2383 2339 2384 new_edge->vertex_ids.data = talloc_array(new_edge, struct GUID, 2); 2340 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_edge->vertex_ids.data, tmp_ctx); 2385 if (new_edge->vertex_ids.data == NULL) { 2386 TALLOC_FREE(tmp_ctx); 2387 return NT_STATUS_NO_MEMORY; 2388 } 2341 2389 2342 2390 new_edge->vertex_ids.data[0] = vertex1->id; … … 2350 2398 struct kcctpl_multi_edge, 2351 2399 output_edges.count + 1); 2352 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, tmp_ctx); 2400 if (new_data == NULL) { 2401 TALLOC_FREE(tmp_ctx); 2402 return NT_STATUS_NO_MEMORY; 2403 } 2353 2404 new_data[output_edges.count + 1] = *new_edge; 2354 2405 output_edges.data = new_data; … … 2357 2408 new_data_id = talloc_realloc(vertex1, vertex1->edge_ids.data, 2358 2409 struct GUID, vertex1->edge_ids.count); 2359 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data_id, tmp_ctx); 2410 if (new_data_id == NULL) { 2411 TALLOC_FREE(tmp_ctx); 2412 return NT_STATUS_NO_MEMORY; 2413 } 2360 2414 new_data_id[vertex1->edge_ids.count] = new_edge->id; 2361 2415 talloc_free(vertex1->edge_ids.data); … … 2365 2419 new_data_id = talloc_realloc(vertex2, vertex2->edge_ids.data, 2366 2420 struct GUID, vertex2->edge_ids.count); 2367 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data_id, tmp_ctx); 2421 if (new_data_id == NULL) { 2422 TALLOC_FREE(tmp_ctx); 2423 return NT_STATUS_NO_MEMORY; 2424 } 2368 2425 new_data_id[vertex2->edge_ids.count] = new_edge->id; 2369 2426 talloc_free(vertex2->edge_ids.data); … … 2601 2658 struct GUID, 2602 2659 vertex->edge_ids.count + 1); 2603 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, 2604 tmp_ctx); 2660 if (new_data == NULL) { 2661 TALLOC_FREE(tmp_ctx); 2662 return NT_STATUS_NO_MEMORY; 2663 } 2605 2664 new_data[vertex->edge_ids.count] = edge->id; 2606 2665 vertex->edge_ids.data = new_data; … … 2732 2791 "enabledConnection", NULL }; 2733 2792 unsigned int i, valid_connections; 2734 struct GUID_list keep_connections ;2793 struct GUID_list keep_connections = {0}; 2735 2794 2736 2795 tmp_ctx = talloc_new(service); … … 2738 2797 2739 2798 r_site_dn = ldb_dn_copy(tmp_ctx, r_bridgehead->dn); 2740 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(r_site_dn, tmp_ctx); 2799 if (r_site_dn == NULL) { 2800 TALLOC_FREE(tmp_ctx); 2801 return NT_STATUS_NO_MEMORY; 2802 } 2741 2803 2742 2804 ok = ldb_dn_remove_child_components(r_site_dn, 3); … … 2757 2819 2758 2820 l_site_dn = ldb_dn_copy(tmp_ctx, l_bridgehead->dn); 2759 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(l_site_dn, tmp_ctx); 2821 if (l_site_dn == NULL) { 2822 TALLOC_FREE(tmp_ctx); 2823 return NT_STATUS_NO_MEMORY; 2824 } 2760 2825 2761 2826 ok = ldb_dn_remove_child_components(l_site_dn, 3); … … 3076 3141 struct GUID, 3077 3142 keep_connections.count + 1); 3078 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, 3079 tmp_ctx); 3143 if (new_data == NULL) { 3144 TALLOC_FREE(tmp_ctx); 3145 return NT_STATUS_NO_MEMORY; 3146 } 3080 3147 new_data[keep_connections.count] = conn_guid; 3081 3148 keep_connections.data = new_data; … … 3120 3187 struct GUID, 3121 3188 keep_connections.count + 1); 3122 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data, tmp_ctx); 3189 if (new_data == NULL) { 3190 TALLOC_FREE(tmp_ctx); 3191 return NT_STATUS_NO_MEMORY; 3192 } 3123 3193 new_data[keep_connections.count] = new_guid; 3124 3194 keep_connections.data = new_data; … … 3230 3300 struct kcctpl_vertex *other_site_vertex; 3231 3301 struct ldb_result *res; 3232 struct ldb_message *transport, *r_bridgehead, *l_bridgehead; 3302 struct ldb_message *transport, *r_bridgehead; 3303 struct ldb_message *l_bridgehead = NULL; 3233 3304 uint8_t schedule[84]; 3234 3305 uint32_t first_available, j, interval; … … 3378 3449 3379 3450 partitions_dn = samdb_partitions_dn(service->samdb, tmp_ctx); 3380 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(partitions_dn, tmp_ctx); 3451 if (partitions_dn == NULL) { 3452 TALLOC_FREE(tmp_ctx); 3453 return NT_STATUS_NO_MEMORY; 3454 } 3381 3455 3382 3456 ret = ldb_search(service->samdb, tmp_ctx, &res, partitions_dn, LDB_SCOPE_ONELEVEL, … … 3460 3534 NTSTATUS status; 3461 3535 TALLOC_CTX *tmp_ctx = talloc_new(service); 3462 struct GUID_list keep ;3463 bool all_connected ;3536 struct GUID_list keep = {0}; 3537 bool all_connected = false; 3464 3538 3465 3539 DEBUG(5, ("Testing kcctpl_create_intersite_connections\n"));
Note:
See TracChangeset
for help on using the changeset viewer.