Changeset 988 for vendor/current/source4/libnet
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/source4/libnet
- Files:
-
- 2 added
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/libnet/groupinfo.c
r860 r988 32 32 33 33 struct groupinfo_state { 34 struct dcerpc_ pipe *pipe;34 struct dcerpc_binding_handle *binding_handle; 35 35 struct policy_handle domain_handle; 36 36 struct policy_handle group_handle; … … 88 88 s->monitor_fn(&msg); 89 89 } 90 90 91 91 /* have we actually got name resolved 92 92 - we're looking for only one at the moment */ … … 110 110 /* send request */ 111 111 subreq = dcerpc_samr_OpenGroup_r_send(s, c->event_ctx, 112 s-> pipe->binding_handle,112 s->binding_handle, 113 113 &s->opengroup); 114 114 if (composite_nomem(subreq, c)) return; … … 136 136 if (!composite_is_ok(c)) return; 137 137 138 if (!NT_STATUS_IS_OK(s-> querygroupinfo.out.result)) {139 composite_error(c, s-> querygroupinfo.out.result);138 if (!NT_STATUS_IS_OK(s->opengroup.out.result)) { 139 composite_error(c, s->opengroup.out.result); 140 140 return; 141 141 } … … 162 162 subreq = dcerpc_samr_QueryGroupInfo_r_send(s, 163 163 c->event_ctx, 164 s-> pipe->binding_handle,164 s->binding_handle, 165 165 &s->querygroupinfo); 166 166 if (composite_nomem(subreq, c)) return; … … 213 213 /* queue rpc call, set event handling and new state */ 214 214 subreq = dcerpc_samr_Close_r_send(s, c->event_ctx, 215 s-> pipe->binding_handle,215 s->binding_handle, 216 216 &s->samrclose); 217 217 if (composite_nomem(subreq, c)) return; … … 265 265 * @param io arguments and results of the call 266 266 */ 267 struct composite_context *libnet_rpc_groupinfo_send(struct dcerpc_pipe *p, 267 struct composite_context *libnet_rpc_groupinfo_send(TALLOC_CTX *mem_ctx, 268 struct tevent_context *ev, 269 struct dcerpc_binding_handle *b, 268 270 struct libnet_rpc_groupinfo *io, 269 271 void (*monitor)(struct monitor_msg*)) … … 274 276 struct tevent_req *subreq; 275 277 276 if (! p|| !io) return NULL;277 278 c = composite_create( p, dcerpc_event_context(p));278 if (!b || !io) return NULL; 279 280 c = composite_create(mem_ctx, ev); 279 281 if (c == NULL) return c; 280 282 … … 285 287 286 288 s->level = io->in.level; 287 s-> pipe = p;289 s->binding_handle= b; 288 290 s->domain_handle = io->in.domain_handle; 289 291 s->monitor_fn = monitor; … … 300 302 /* send request */ 301 303 subreq = dcerpc_samr_OpenGroup_r_send(s, c->event_ctx, 302 p->binding_handle,304 s->binding_handle, 303 305 &s->opengroup); 304 306 if (composite_nomem(subreq, c)) return c; … … 322 324 /* send request */ 323 325 subreq = dcerpc_samr_LookupNames_r_send(s, c->event_ctx, 324 p->binding_handle,326 s->binding_handle, 325 327 &s->lookup); 326 328 if (composite_nomem(subreq, c)) return c; … … 372 374 */ 373 375 374 NTSTATUS libnet_rpc_groupinfo(struct dcerpc_pipe *p, 376 NTSTATUS libnet_rpc_groupinfo(struct tevent_context *ev, 377 struct dcerpc_binding_handle *b, 375 378 TALLOC_CTX *mem_ctx, 376 379 struct libnet_rpc_groupinfo *io) 377 380 { 378 struct composite_context *c = libnet_rpc_groupinfo_send(p, io, NULL); 381 struct composite_context *c = libnet_rpc_groupinfo_send(mem_ctx, ev, b, 382 io, NULL); 379 383 return libnet_rpc_groupinfo_recv(c, mem_ctx, io); 380 384 } -
vendor/current/source4/libnet/groupman.c
r860 r988 29 29 30 30 struct groupadd_state { 31 struct dcerpc_ pipe *pipe;31 struct dcerpc_binding_handle *binding_handle; 32 32 struct policy_handle domain_handle; 33 33 struct samr_CreateDomainGroup creategroup; … … 42 42 43 43 44 struct composite_context* libnet_rpc_groupadd_send(struct dcerpc_pipe *p, 44 struct composite_context* libnet_rpc_groupadd_send(TALLOC_CTX *mem_ctx, 45 struct tevent_context *ev, 46 struct dcerpc_binding_handle *b, 45 47 struct libnet_rpc_groupadd *io, 46 48 void (*monitor)(struct monitor_msg*)) … … 50 52 struct tevent_req *subreq; 51 53 52 if (! p|| !io) return NULL;54 if (!b || !io) return NULL; 53 55 54 c = composite_create( p, dcerpc_event_context(p));56 c = composite_create(mem_ctx, ev); 55 57 if (c == NULL) return NULL; 56 58 … … 61 63 62 64 s->domain_handle = io->in.domain_handle; 63 s-> pipe = p;65 s->binding_handle= b; 64 66 s->monitor_fn = monitor; 65 67 … … 78 80 79 81 subreq = dcerpc_samr_CreateDomainGroup_r_send(s, c->event_ctx, 80 s-> pipe->binding_handle,82 s->binding_handle, 81 83 &s->creategroup); 82 84 if (composite_nomem(subreq, c)) return c; … … 94 96 95 97 status = composite_wait(c); 96 if (NT_STATUS_IS_OK(status)) { 97 s = talloc_get_type(c, struct groupadd_state); 98 if (NT_STATUS_IS_OK(status) && io) { 99 s = talloc_get_type(c->private_data, struct groupadd_state); 100 io->out.group_handle = s->group_handle; 98 101 } 99 102 103 talloc_free(c); 100 104 return status; 101 105 } … … 115 119 116 120 c->status = s->creategroup.out.result; 117 if (!composite_is_ok(c)) return;118 119 composite_done(c);120 }121 122 123 NTSTATUS libnet_rpc_groupadd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,124 struct libnet_rpc_groupadd *io)125 {126 struct composite_context *c;127 128 c = libnet_rpc_groupadd_send(p, io, NULL);129 return libnet_rpc_groupadd_recv(c, mem_ctx, io);130 }131 132 133 struct groupdel_state {134 struct dcerpc_pipe *pipe;135 struct policy_handle domain_handle;136 struct policy_handle group_handle;137 struct samr_LookupNames lookupname;138 struct samr_OpenGroup opengroup;139 struct samr_DeleteDomainGroup deletegroup;140 141 /* information about the progress */142 void (*monitor_fn)(struct monitor_msg *);143 };144 145 146 static void continue_groupdel_name_found(struct tevent_req *subreq);147 static void continue_groupdel_group_opened(struct tevent_req *subreq);148 static void continue_groupdel_deleted(struct tevent_req *subreq);149 150 151 struct composite_context* libnet_rpc_groupdel_send(struct dcerpc_pipe *p,152 struct libnet_rpc_groupdel *io,153 void (*monitor)(struct monitor_msg*))154 {155 struct composite_context *c;156 struct groupdel_state *s;157 struct tevent_req *subreq;158 159 /* composite context allocation and setup */160 c = composite_create(p, dcerpc_event_context(p));161 if (c == NULL) return NULL;162 163 s = talloc_zero(c, struct groupdel_state);164 if (composite_nomem(s, c)) return c;165 166 c->private_data = s;167 168 /* store function parameters in the state structure */169 s->pipe = p;170 s->domain_handle = io->in.domain_handle;171 s->monitor_fn = monitor;172 173 /* prepare parameters to send rpc request */174 s->lookupname.in.domain_handle = &io->in.domain_handle;175 s->lookupname.in.num_names = 1;176 s->lookupname.in.names = talloc_zero(s, struct lsa_String);177 s->lookupname.in.names->string = io->in.groupname;178 s->lookupname.out.rids = talloc_zero(s, struct samr_Ids);179 s->lookupname.out.types = talloc_zero(s, struct samr_Ids);180 if (composite_nomem(s->lookupname.out.rids, c)) return c;181 if (composite_nomem(s->lookupname.out.types, c)) return c;182 183 /* send the request */184 subreq = dcerpc_samr_LookupNames_r_send(s, c->event_ctx,185 p->binding_handle,186 &s->lookupname);187 if (composite_nomem(subreq, c)) return c;188 189 tevent_req_set_callback(subreq, continue_groupdel_name_found, c);190 return c;191 }192 193 194 static void continue_groupdel_name_found(struct tevent_req *subreq)195 {196 struct composite_context *c;197 struct groupdel_state *s;198 199 c = tevent_req_callback_data(subreq, struct composite_context);200 s = talloc_get_type(c->private_data, struct groupdel_state);201 202 /* receive samr_LookupNames result */203 c->status = dcerpc_samr_LookupNames_r_recv(subreq, s);204 TALLOC_FREE(subreq);205 if (!composite_is_ok(c)) return;206 207 c->status = s->lookupname.out.result;208 121 if (!NT_STATUS_IS_OK(c->status)) { 209 122 composite_error(c, c->status); … … 211 124 } 212 125 213 /* what to do when there's no group account to delete214 and what if there's more than one rid resolved */215 if (s->lookupname.out.rids->count != s->lookupname.in.num_names) {216 c->status = NT_STATUS_INVALID_NETWORK_RESPONSE;217 composite_error(c, c->status);218 return;219 }220 if (s->lookupname.out.types->count != s->lookupname.in.num_names) {221 c->status = NT_STATUS_INVALID_NETWORK_RESPONSE;222 composite_error(c, c->status);223 return;224 }225 226 /* prepare the arguments for rpc call */227 s->opengroup.in.domain_handle = &s->domain_handle;228 s->opengroup.in.rid = s->lookupname.out.rids->ids[0];229 s->opengroup.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;230 s->opengroup.out.group_handle = &s->group_handle;231 232 /* send rpc request */233 subreq = dcerpc_samr_OpenGroup_r_send(s, c->event_ctx,234 s->pipe->binding_handle,235 &s->opengroup);236 if (composite_nomem(subreq, c)) return;237 238 tevent_req_set_callback(subreq, continue_groupdel_group_opened, c);239 }240 241 242 static void continue_groupdel_group_opened(struct tevent_req *subreq)243 {244 struct composite_context *c;245 struct groupdel_state *s;246 247 c = tevent_req_callback_data(subreq, struct composite_context);248 s = talloc_get_type(c->private_data, struct groupdel_state);249 250 /* receive samr_OpenGroup result */251 c->status = dcerpc_samr_OpenGroup_r_recv(subreq, s);252 TALLOC_FREE(subreq);253 if (!composite_is_ok(c)) return;254 255 c->status = s->opengroup.out.result;256 if (!NT_STATUS_IS_OK(c->status)) {257 composite_error(c, c->status);258 return;259 }260 261 /* prepare the final rpc call arguments */262 s->deletegroup.in.group_handle = &s->group_handle;263 s->deletegroup.out.group_handle = &s->group_handle;264 265 /* send rpc request */266 subreq = dcerpc_samr_DeleteDomainGroup_r_send(s, c->event_ctx,267 s->pipe->binding_handle,268 &s->deletegroup);269 if (composite_nomem(subreq, c)) return;270 271 /* callback handler setup */272 tevent_req_set_callback(subreq, continue_groupdel_deleted, c);273 }274 275 276 static void continue_groupdel_deleted(struct tevent_req *subreq)277 {278 struct composite_context *c;279 struct groupdel_state *s;280 281 c = tevent_req_callback_data(subreq, struct composite_context);282 s = talloc_get_type(c->private_data, struct groupdel_state);283 284 /* receive samr_DeleteGroup result */285 c->status = dcerpc_samr_DeleteDomainGroup_r_recv(subreq, s);286 TALLOC_FREE(subreq);287 if (!composite_is_ok(c)) return;288 289 /* return the actual function call status */290 c->status = s->deletegroup.out.result;291 if (!NT_STATUS_IS_OK(c->status)) {292 composite_error(c, c->status);293 return;294 }295 296 126 composite_done(c); 297 127 } 298 128 299 129 300 NTSTATUS libnet_rpc_groupdel_recv(struct composite_context *c, TALLOC_CTX *mem_ctx, 301 struct libnet_rpc_groupdel *io) 302 { 303 NTSTATUS status; 304 struct groupdel_state *s; 305 306 status = composite_wait(c); 307 if (NT_STATUS_IS_OK(status) && io) { 308 s = talloc_get_type(c->private_data, struct groupdel_state); 309 io->out.group_handle = s->group_handle; 310 } 311 312 talloc_free(c); 313 return status; 314 } 315 316 317 NTSTATUS libnet_rpc_groupdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 318 struct libnet_rpc_groupdel *io) 130 NTSTATUS libnet_rpc_groupadd(struct tevent_context *ev, 131 struct dcerpc_binding_handle *b, 132 TALLOC_CTX *mem_ctx, 133 struct libnet_rpc_groupadd *io) 319 134 { 320 135 struct composite_context *c; 321 136 322 c = libnet_rpc_group del_send(p, io, NULL);323 return libnet_rpc_group del_recv(c, mem_ctx, io);137 c = libnet_rpc_groupadd_send(mem_ctx, ev, b, io, NULL); 138 return libnet_rpc_groupadd_recv(c, mem_ctx, io); 324 139 } -
vendor/current/source4/libnet/groupman.h
r414 r988 34 34 } out; 35 35 }; 36 37 38 struct libnet_rpc_groupdel {39 struct {40 struct policy_handle domain_handle;41 const char *groupname;42 } in;43 struct {44 struct policy_handle group_handle;45 } out;46 }; -
vendor/current/source4/libnet/libnet.c
r740 r988 44 44 45 45 /* make sure dcerpc is initialized */ 46 dcerpc_init( lp_ctx);46 dcerpc_init(); 47 47 48 48 /* name resolution methods */ -
vendor/current/source4/libnet/libnet.h
r740 r988 18 18 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 19 */ 20 #ifndef LIBNET_H 21 #define LIBNET_H 20 22 21 23 #include "librpc/gen_ndr/misc.h" … … 81 83 #include "libnet/libnet_lookup.h" 82 84 #include "libnet/libnet_domain.h" 83 #include "libnet/libnet_export_keytab.h"84 85 #include "libnet/libnet_proto.h" 86 #endif -
vendor/current/source4/libnet/libnet_become_dc.c
r740 r988 736 736 737 737 bool rodc_join; 738 bool critical_only; 738 739 }; 739 740 … … 770 771 &dest_address); 771 772 if (ret != 0) { 772 c->status = map_nt_error_from_unix (errno);773 c->status = map_nt_error_from_unix_common(errno); 773 774 if (!composite_is_ok(c)) return; 774 775 } 775 776 776 c->status = cldap_socket_init(s, s->libnet->event_ctx,777 NULL, dest_address, &s->cldap.sock);778 if (!composite_is_ok(c)) return; 779 780 req = cldap_netlogon_send(s,s->cldap.sock, &s->cldap.io);777 c->status = cldap_socket_init(s, NULL, dest_address, &s->cldap.sock); 778 if (!composite_is_ok(c)) return; 779 780 req = cldap_netlogon_send(s, s->libnet->event_ctx, 781 s->cldap.sock, &s->cldap.io); 781 782 if (composite_nomem(req, c)) return; 782 783 tevent_req_set_callback(req, becomeDC_recv_cldap, s); … … 1047 1048 &basedn); 1048 1049 if (ret != LDB_SUCCESS) { 1050 DEBUG(0,("Failed to get well known DN for DS_GUID_INFRASTRUCTURE_CONTAINER on %s: %s\n", 1051 ldb_dn_get_linearized(ldb_get_default_basedn(s->ldap1.ldb)), 1052 ldb_errstring(s->ldap1.ldb))); 1049 1053 return NT_STATUS_LDAP(ret); 1050 1054 } … … 1052 1056 ret = samdb_reference_dn(s->ldap1.ldb, s, basedn, "fSMORoleOwner", &ntds_dn); 1053 1057 if (ret != LDB_SUCCESS) { 1058 DEBUG(0,("Failed to get reference DN from fsmoRoleOwner on %s: %s\n", 1059 ldb_dn_get_linearized(basedn), 1060 ldb_errstring(s->ldap1.ldb))); 1054 1061 talloc_free(basedn); 1055 1062 return NT_STATUS_LDAP(ret); … … 1068 1075 dns_attrs, "(objectClass=*)"); 1069 1076 if (ret != LDB_SUCCESS) { 1077 DEBUG(0,("Failed to get server DN %s: %s\n", 1078 ldb_dn_get_linearized(server_dn), 1079 ldb_errstring(s->ldap1.ldb))); 1070 1080 return NT_STATUS_LDAP(ret); 1071 1081 } else if (r->count != 1) { … … 1080 1090 talloc_free(r); 1081 1091 1092 ldb_dn_remove_extended_components(ntds_dn); 1082 1093 ret = ldb_search(s->ldap1.ldb, s, &r, ntds_dn, LDB_SCOPE_BASE, 1083 1094 guid_attrs, "(objectClass=*)"); 1084 1095 if (ret != LDB_SUCCESS) { 1096 DEBUG(0,("Failed to get NTDS Settings DN %s: %s\n", 1097 ldb_dn_get_linearized(ntds_dn), 1098 ldb_errstring(s->ldap1.ldb))); 1085 1099 return NT_STATUS_LDAP(ret); 1086 1100 } else if (r->count != 1) { … … 1560 1574 print_str = "print,"; 1561 1575 } 1562 binding_str = talloc_asprintf(s, "ncacn_ip_tcp:%s[%s%sseal]", 1563 s->source_dsa.dns_name, 1564 krb5_str, print_str); 1576 binding_str = talloc_asprintf(s, "ncacn_ip_tcp:%s[%s%sseal,target_hostname=%s]", 1577 s->source_dsa.address, 1578 krb5_str, print_str, 1579 s->source_dsa.dns_name); 1565 1580 if (composite_nomem(binding_str, c)) return; 1566 1581 c->status = dcerpc_parse_binding(s, binding_str, &drsuapi->binding); … … 1569 1584 } 1570 1585 1586 if (DEBUGLEVEL >= 10) { 1587 c->status = dcerpc_binding_set_flags(drsuapi->binding, 1588 DCERPC_DEBUG_PRINT_BOTH, 1589 0); 1590 if (!composite_is_ok(c)) return; 1591 } 1592 1571 1593 creq = dcerpc_pipe_connect_b_send(s, drsuapi->binding, &ndr_table_drsuapi, 1572 1594 s->libnet->cred, s->libnet->event_ctx, … … 1592 1614 1593 1615 c->status = gensec_session_key(s->drsuapi1.pipe->conn->security_state.generic_state, 1616 s, 1594 1617 &s->drsuapi1.gensec_skey); 1595 1618 if (!composite_is_ok(c)) return; … … 1681 1704 break; 1682 1705 } 1706 case 28: { 1707 drsuapi->remote_info28 = drsuapi->bind_r.out.bind_info->info.info28; 1708 break; 1709 } 1710 case 32: { 1711 struct drsuapi_DsBindInfo32 *info32; 1712 info32 = &drsuapi->bind_r.out.bind_info->info.info32; 1713 drsuapi->remote_info28.supported_extensions = info32->supported_extensions; 1714 drsuapi->remote_info28.site_guid = info32->site_guid; 1715 drsuapi->remote_info28.pid = info32->pid; 1716 drsuapi->remote_info28.repl_epoch = info32->repl_epoch; 1717 break; 1718 } 1683 1719 case 48: { 1684 1720 struct drsuapi_DsBindInfo48 *info48; … … 1690 1726 break; 1691 1727 } 1692 case 28: 1693 drsuapi->remote_info28 = drsuapi->bind_r.out.bind_info->info.info28; 1728 case 52: { 1729 struct drsuapi_DsBindInfo52 *info52; 1730 info52 = &drsuapi->bind_r.out.bind_info->info.info52; 1731 drsuapi->remote_info28.supported_extensions = info52->supported_extensions; 1732 drsuapi->remote_info28.site_guid = info52->site_guid; 1733 drsuapi->remote_info28.pid = info52->pid; 1734 drsuapi->remote_info28.repl_epoch = info52->repl_epoch; 1735 break; 1736 } 1737 default: 1738 DEBUG(1, ("Warning: invalid info length in bind info: %d\n", 1739 drsuapi->bind_r.out.bind_info->length)); 1694 1740 break; 1695 1741 } … … 2258 2304 struct drsuapi_DsAddEntry); 2259 2305 char *binding_str; 2306 uint32_t assoc_group_id; 2260 2307 2261 2308 s->ndr_struct_ptr = NULL; … … 2390 2437 r->out.ctr->ctr3.count)); 2391 2438 composite_error(c, NT_STATUS_INVALID_NETWORK_RESPONSE); 2439 return; 2392 2440 } 2393 2441 … … 2411 2459 win_errstr(r->out.ctr->ctr2.extended_err))); 2412 2460 composite_error(c, NT_STATUS_INVALID_NETWORK_RESPONSE); 2461 return; 2413 2462 } 2414 2463 … … 2436 2485 if (!composite_is_ok(c)) return; 2437 2486 2487 if (DEBUGLEVEL >= 10) { 2488 c->status = dcerpc_binding_set_flags(s->drsuapi2.binding, 2489 DCERPC_DEBUG_PRINT_BOTH, 2490 0); 2491 if (!composite_is_ok(c)) return; 2492 } 2493 2438 2494 /* w2k3 uses the same assoc_group_id as on the first connection, so we do */ 2439 s->drsuapi2.binding->assoc_group_id = s->drsuapi1.pipe->assoc_group_id; 2495 assoc_group_id = dcerpc_binding_get_assoc_group_id(s->drsuapi1.pipe->binding); 2496 c->status = dcerpc_binding_set_assoc_group_id(s->drsuapi2.binding, assoc_group_id); 2497 if (!composite_is_ok(c)) return; 2440 2498 2441 2499 becomeDC_drsuapi_connect_send(s, &s->drsuapi2, becomeDC_drsuapi2_connect_recv); … … 2468 2526 2469 2527 c->status = gensec_session_key(s->drsuapi2.pipe->conn->security_state.generic_state, 2528 s, 2470 2529 &s->drsuapi2.gensec_skey); 2471 2530 if (!composite_is_ok(c)) return; … … 2482 2541 struct composite_context *c = s->creq; 2483 2542 char *binding_str; 2543 uint32_t assoc_group_id; 2484 2544 WERROR status; 2485 2545 … … 2502 2562 if (!composite_is_ok(c)) return; 2503 2563 2564 if (DEBUGLEVEL >= 10) { 2565 c->status = dcerpc_binding_set_flags(s->drsuapi3.binding, 2566 DCERPC_DEBUG_PRINT_BOTH, 2567 0); 2568 if (!composite_is_ok(c)) return; 2569 } 2570 2504 2571 /* w2k3 uses the same assoc_group_id as on the first connection, so we do */ 2505 s->drsuapi3.binding->assoc_group_id = s->drsuapi1.pipe->assoc_group_id; 2572 assoc_group_id = dcerpc_binding_get_assoc_group_id(s->drsuapi1.pipe->binding); 2573 c->status = dcerpc_binding_set_assoc_group_id(s->drsuapi3.binding, assoc_group_id); 2574 if (!composite_is_ok(c)) return; 2506 2575 /* w2k3 uses the concurrent multiplex feature on the 3rd connection, so we do */ 2507 s->drsuapi3.binding->flags |= DCERPC_CONCURRENT_MULTIPLEX; 2576 c->status = dcerpc_binding_set_flags(s->drsuapi3.binding, 2577 DCERPC_CONCURRENT_MULTIPLEX, 2578 0); 2579 if (!composite_is_ok(c)) return; 2508 2580 2509 2581 becomeDC_drsuapi_connect_send(s, &s->drsuapi3, becomeDC_drsuapi3_connect_recv); … … 2524 2596 2525 2597 c->status = gensec_session_key(s->drsuapi3.pipe->conn->security_state.generic_state, 2598 s, 2526 2599 &s->drsuapi3.gensec_skey); 2527 2600 if (!composite_is_ok(c)) return; … … 2601 2674 struct drsuapi_DsGetNCChanges *r) 2602 2675 { 2676 uint32_t req_level = 0; 2677 struct drsuapi_DsGetNCChangesRequest5 *req5 = NULL; 2678 struct drsuapi_DsGetNCChangesRequest8 *req8 = NULL; 2679 struct drsuapi_DsGetNCChangesRequest10 *req10 = NULL; 2603 2680 uint32_t ctr_level = 0; 2604 2681 struct drsuapi_DsGetNCChangesCtr1 *ctr1 = NULL; … … 2612 2689 if (!W_ERROR_IS_OK(r->out.result)) { 2613 2690 return r->out.result; 2691 } 2692 2693 switch (r->in.level) { 2694 case 0: 2695 /* none */ 2696 break; 2697 case 5: 2698 req5 = &r->in.req->req5; 2699 break; 2700 case 8: 2701 req8 = &r->in.req->req8; 2702 break; 2703 case 10: 2704 req10 = &r->in.req->req10; 2705 break; 2706 default: 2707 return WERR_INVALID_PARAMETER; 2614 2708 } 2615 2709 … … 2677 2771 s->_sc.dest_dsa = &s->dest_dsa; 2678 2772 s->_sc.partition = partition; 2773 s->_sc.req_level = req_level; 2774 s->_sc.req5 = req5; 2775 s->_sc.req8 = req8; 2776 s->_sc.req10 = req10; 2679 2777 s->_sc.ctr_level = ctr_level; 2680 2778 s->_sc.ctr1 = ctr1; … … 2828 2926 | DRSUAPI_DRS_NEVER_SYNCED 2829 2927 | DRSUAPI_DRS_USE_COMPRESSION; 2928 if (s->critical_only) { 2929 s->domain_part.replica_flags |= DRSUAPI_DRS_CRITICAL_ONLY | DRSUAPI_DRS_GET_ANC; 2930 } 2830 2931 if (s->rodc_join) { 2831 2932 s->schema_part.replica_flags &= ~DRSUAPI_DRS_WRIT_REP; … … 2873 2974 } 2874 2975 2976 if (s->critical_only) { 2977 /* Remove the critical and ANC */ 2978 s->domain_part.replica_flags ^= DRSUAPI_DRS_CRITICAL_ONLY | DRSUAPI_DRS_GET_ANC; 2979 s->critical_only = false; 2980 becomeDC_drsuapi_pull_partition_send(s, &s->drsuapi2, &s->drsuapi3, &s->domain_part, 2981 becomeDC_drsuapi3_pull_domain_recv); 2982 return; 2983 } 2875 2984 becomeDC_drsuapi_update_refs_send(s, &s->drsuapi2, &s->schema_part, 2876 2985 becomeDC_drsuapi2_update_refs_schema_recv); … … 2896 3005 ntds_dns_name = talloc_asprintf(r, "%s._msdcs.%s", 2897 3006 ntds_guid_str, 2898 s-> domain.dns_name);3007 s->forest.dns_name); 2899 3008 if (composite_nomem(ntds_dns_name, c)) return; 2900 3009 … … 3096 3205 if (!composite_is_ok(c)) return; 3097 3206 3207 s->critical_only = true; 3098 3208 becomeDC_drsuapi3_pull_domain_send(s); 3099 3209 } -
vendor/current/source4/libnet/libnet_become_dc.h
r740 r988 108 108 const struct libnet_BecomeDC_DestDSA *dest_dsa; 109 109 const struct libnet_BecomeDC_Partition *partition; 110 uint32_t req_level; 111 const struct drsuapi_DsGetNCChangesRequest5 *req5; 112 const struct drsuapi_DsGetNCChangesRequest8 *req8; 113 const struct drsuapi_DsGetNCChangesRequest10 *req10; 110 114 uint32_t ctr_level; 111 115 const struct drsuapi_DsGetNCChangesCtr1 *ctr1; -
vendor/current/source4/libnet/libnet_domain.c
r740 r988 63 63 struct tevent_req *subreq; 64 64 65 c = talloc_get_type (ctx->async.private_data, struct composite_context);66 s = talloc_get_type (c->private_data, struct domain_open_samr_state);65 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 66 s = talloc_get_type_abort(c->private_data, struct domain_open_samr_state); 67 67 68 68 c->status = libnet_RpcConnect_recv(ctx, s->ctx, c, &s->rpcconn); … … 97 97 98 98 c = tevent_req_callback_data(subreq, struct composite_context); 99 s = talloc_get_type (c->private_data, struct domain_open_samr_state);99 s = talloc_get_type_abort(c->private_data, struct domain_open_samr_state); 100 100 101 101 /* receive samr_Close reply */ … … 144 144 145 145 c = tevent_req_callback_data(subreq, struct composite_context); 146 s = talloc_get_type (c->private_data, struct domain_open_samr_state);146 s = talloc_get_type_abort(c->private_data, struct domain_open_samr_state); 147 147 148 148 /* receive samr_Connect reply */ … … 187 187 188 188 c = tevent_req_callback_data(subreq, struct composite_context); 189 s = talloc_get_type (c->private_data, struct domain_open_samr_state);189 s = talloc_get_type_abort(c->private_data, struct domain_open_samr_state); 190 190 191 191 /* receive samr_LookupDomain reply */ … … 208 208 209 209 /* check the rpc layer status */ 210 if (!composite_is_ok(c)) ;210 if (!composite_is_ok(c)) return; 211 211 212 212 /* check the rpc call itself status */ … … 240 240 241 241 c = tevent_req_callback_data(subreq, struct composite_context); 242 s = talloc_get_type (c->private_data, struct domain_open_samr_state);242 s = talloc_get_type_abort(c->private_data, struct domain_open_samr_state); 243 243 244 244 /* receive samr_OpenDomain reply */ … … 269 269 270 270 struct composite_context *libnet_DomainOpenSamr_send(struct libnet_context *ctx, 271 TALLOC_CTX *mem_ctx, 271 272 struct libnet_DomainOpen *io, 272 273 void (*monitor)(struct monitor_msg*)) … … 277 278 struct tevent_req *subreq; 278 279 279 c = composite_create( ctx, ctx->event_ctx);280 c = composite_create(mem_ctx, ctx->event_ctx); 280 281 if (c == NULL) return NULL; 281 282 … … 309 310 /* libnet context's domain handle is not empty, so check out what 310 311 was opened first, before doing anything */ 311 if (! policy_handle_empty(&ctx->samr.handle)) {312 if (!ndr_policy_handle_empty(&ctx->samr.handle)) { 312 313 if (strequal(ctx->samr.name, io->in.domain_name) && 313 314 ctx->samr.access_mask == io->in.access_mask) { … … 371 372 372 373 if (NT_STATUS_IS_OK(status) && io) { 373 s = talloc_get_type (c->private_data, struct domain_open_samr_state);374 s = talloc_get_type_abort(c->private_data, struct domain_open_samr_state); 374 375 io->out.domain_handle = s->domain_handle; 375 376 … … 415 416 416 417 struct composite_context* libnet_DomainOpenLsa_send(struct libnet_context *ctx, 418 TALLOC_CTX *mem_ctx, 417 419 struct libnet_DomainOpen *io, 418 420 void (*monitor)(struct monitor_msg*)) … … 425 427 426 428 /* create composite context and state */ 427 c = composite_create( ctx, ctx->event_ctx);429 c = composite_create(mem_ctx, ctx->event_ctx); 428 430 if (c == NULL) return c; 429 431 … … 493 495 struct tevent_req *subreq; 494 496 495 c = talloc_get_type (ctx->async.private_data, struct composite_context);496 s = talloc_get_type (c->private_data, struct domain_open_lsa_state);497 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 498 s = talloc_get_type_abort(c->private_data, struct domain_open_lsa_state); 497 499 498 500 /* receive rpc connection */ … … 537 539 538 540 c = tevent_req_callback_data(subreq, struct composite_context); 539 s = talloc_get_type (c->private_data, struct domain_open_lsa_state);541 s = talloc_get_type_abort(c->private_data, struct domain_open_lsa_state); 540 542 541 543 c->status = dcerpc_lsa_OpenPolicy2_r_recv(subreq, s); … … 577 579 /* everything went fine - get the results and 578 580 return the error string */ 579 s = talloc_get_type (c->private_data, struct domain_open_lsa_state);581 s = talloc_get_type_abort(c->private_data, struct domain_open_lsa_state); 580 582 io->out.domain_handle = s->handle; 581 583 … … 607 609 608 610 struct composite_context* libnet_DomainOpen_send(struct libnet_context *ctx, 611 TALLOC_CTX *mem_ctx, 609 612 struct libnet_DomainOpen *io, 610 613 void (*monitor)(struct monitor_msg*)) … … 615 618 case DOMAIN_LSA: 616 619 /* reques to open a policy handle on \pipe\lsarpc */ 617 c = libnet_DomainOpenLsa_send(ctx, io, monitor);620 c = libnet_DomainOpenLsa_send(ctx, mem_ctx, io, monitor); 618 621 break; 619 622 … … 621 624 default: 622 625 /* request to open a domain policy handle on \pipe\samr */ 623 c = libnet_DomainOpenSamr_send(ctx, io, monitor);626 c = libnet_DomainOpenSamr_send(ctx, mem_ctx, io, monitor); 624 627 break; 625 628 } … … 671 674 struct libnet_DomainOpen *io) 672 675 { 673 struct composite_context *c = libnet_DomainOpen_send(ctx, io, NULL);676 struct composite_context *c = libnet_DomainOpen_send(ctx, mem_ctx, io, NULL); 674 677 return libnet_DomainOpen_recv(c, ctx, mem_ctx, io); 675 678 } … … 689 692 690 693 struct composite_context* libnet_DomainCloseLsa_send(struct libnet_context *ctx, 694 TALLOC_CTX *mem_ctx, 691 695 struct libnet_DomainClose *io, 692 696 void (*monitor)(struct monitor_msg*)) … … 697 701 698 702 /* composite context and state structure allocation */ 699 c = composite_create( ctx, ctx->event_ctx);703 c = composite_create(mem_ctx, ctx->event_ctx); 700 704 if (c == NULL) return c; 701 705 … … 740 744 741 745 c = tevent_req_callback_data(subreq, struct composite_context); 742 s = talloc_get_type (c->private_data, struct domain_close_lsa_state);746 s = talloc_get_type_abort(c->private_data, struct domain_close_lsa_state); 743 747 744 748 c->status = dcerpc_lsa_Close_r_recv(subreq, s); … … 796 800 797 801 struct composite_context* libnet_DomainCloseSamr_send(struct libnet_context *ctx, 802 TALLOC_CTX *mem_ctx, 798 803 struct libnet_DomainClose *io, 799 804 void (*monitor)(struct monitor_msg*)) … … 804 809 805 810 /* composite context and state structure allocation */ 806 c = composite_create( ctx, ctx->event_ctx);811 c = composite_create(mem_ctx, ctx->event_ctx); 807 812 if (c == NULL) return c; 808 813 … … 845 850 846 851 c = tevent_req_callback_data(subreq, struct composite_context); 847 s = talloc_get_type (c->private_data, struct domain_close_samr_state);852 s = talloc_get_type_abort(c->private_data, struct domain_close_samr_state); 848 853 849 854 c->status = dcerpc_samr_Close_r_recv(subreq, s); … … 893 898 894 899 struct composite_context* libnet_DomainClose_send(struct libnet_context *ctx, 900 TALLOC_CTX *mem_ctx, 895 901 struct libnet_DomainClose *io, 896 902 void (*monitor)(struct monitor_msg*)) … … 901 907 case DOMAIN_LSA: 902 908 /* request to close policy handle on \pipe\lsarpc */ 903 c = libnet_DomainCloseLsa_send(ctx, io, monitor);909 c = libnet_DomainCloseLsa_send(ctx, mem_ctx, io, monitor); 904 910 break; 905 911 … … 907 913 default: 908 914 /* request to close domain policy handle on \pipe\samr */ 909 c = libnet_DomainCloseSamr_send(ctx, io, monitor);915 c = libnet_DomainCloseSamr_send(ctx, mem_ctx, io, monitor); 910 916 break; 911 917 } … … 942 948 struct composite_context *c; 943 949 944 c = libnet_DomainClose_send(ctx, io, NULL);950 c = libnet_DomainClose_send(ctx, mem_ctx, io, NULL); 945 951 return libnet_DomainClose_recv(c, ctx, mem_ctx, io); 946 952 } … … 982 988 struct tevent_req *subreq; 983 989 984 c = talloc_get_type (ctx->async.private_data, struct composite_context);985 s = talloc_get_type (c->private_data, struct domain_list_state);990 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 991 s = talloc_get_type_abort(c->private_data, struct domain_list_state); 986 992 987 993 c->status = libnet_RpcConnect_recv(ctx, s->ctx, c, &s->rpcconn); … … 1011 1017 1012 1018 c = tevent_req_callback_data(subreq, struct composite_context); 1013 s = talloc_get_type (c->private_data, struct domain_list_state);1019 s = talloc_get_type_abort(c->private_data, struct domain_list_state); 1014 1020 1015 1021 c->status = dcerpc_samr_Connect_r_recv(subreq, s); … … 1055 1061 1056 1062 c = tevent_req_callback_data(subreq, struct composite_context); 1057 s = talloc_get_type (c->private_data, struct domain_list_state);1063 s = talloc_get_type_abort(c->private_data, struct domain_list_state); 1058 1064 1059 1065 c->status = dcerpc_samr_EnumDomains_r_recv(subreq, s); … … 1120 1126 1121 1127 c = tevent_req_callback_data(subreq, struct composite_context); 1122 s = talloc_get_type (c->private_data, struct domain_list_state);1128 s = talloc_get_type_abort(c->private_data, struct domain_list_state); 1123 1129 1124 1130 c->status = dcerpc_samr_Close_r_recv(subreq, s); … … 1138 1144 if (!NT_STATUS_IS_OK(s->samrclose.out.result)) { 1139 1145 composite_error(c, s->samrclose.out.result); 1146 return; 1140 1147 } 1141 1148 … … 1261 1268 status = composite_wait(c); 1262 1269 1263 s = talloc_get_type (c->private_data, struct domain_list_state);1270 s = talloc_get_type_abort(c->private_data, struct domain_list_state); 1264 1271 1265 1272 if (NT_STATUS_IS_OK(status) && ctx && mem_ctx && io) { -
vendor/current/source4/libnet/libnet_export_keytab.c
r740 r988 1 /* 2 Unix SMB/CIFS implementation. 3 4 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2009 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 1 20 #include "includes.h" 2 21 #include "system/kerberos.h" … … 4 23 #include <hdb.h> 5 24 #include "kdc/samba_kdc.h" 6 #include "libnet/libnet.h" 7 8 extern struct hdb_method hdb_samba4; 25 #include "libnet/libnet_export_keytab.h" 9 26 10 27 NTSTATUS libnet_export_keytab(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct libnet_export_keytab *r) … … 29 46 } 30 47 31 ret = smb_krb5_init_context(ctx, ctx-> event_ctx, ctx->lp_ctx, &smb_krb5_context);48 ret = smb_krb5_init_context(ctx, ctx->lp_ctx, &smb_krb5_context); 32 49 if (ret) { 33 50 return NT_STATUS_NO_MEMORY; … … 36 53 ret = krb5_plugin_register(smb_krb5_context->krb5_context, 37 54 PLUGIN_TYPE_DATA, "hdb", 38 &hdb_samba4 );55 &hdb_samba4_interface); 39 56 if(ret) { 40 57 return NT_STATUS_NO_MEMORY; … … 46 63 } 47 64 48 unlink(r->in.keytab_name); 65 if (r->in.principal) { 66 ret = kt_copy_one_principal(smb_krb5_context->krb5_context, from_keytab, r->in.keytab_name, r->in.principal, 0, samba_all_enctypes()); 67 } else { 68 unlink(r->in.keytab_name); 69 ret = kt_copy(smb_krb5_context->krb5_context, from_keytab, r->in.keytab_name); 70 } 49 71 50 ret = kt_copy(smb_krb5_context->krb5_context, from_keytab, r->in.keytab_name);51 72 if(ret) { 52 73 r->out.error_string = smb_get_krb5_error_message(smb_krb5_context->krb5_context, 53 74 ret, mem_ctx); 54 return NT_STATUS_UNSUCCESSFUL; 75 if (ret == KRB5_KT_NOTFOUND) { 76 return NT_STATUS_NO_SUCH_USER; 77 } else { 78 return NT_STATUS_UNSUCCESSFUL; 79 } 55 80 } 56 81 return NT_STATUS_OK; -
vendor/current/source4/libnet/libnet_export_keytab.h
r414 r988 17 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 18 */ 19 #include "includes.h" 20 #include "libnet/libnet.h" 19 21 20 22 struct libnet_export_keytab { 21 23 struct { 22 24 const char *keytab_name; 25 const char *principal; 23 26 } in; 24 27 struct { … … 27 30 }; 28 31 32 NTSTATUS libnet_export_keytab(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct libnet_export_keytab *r); -
vendor/current/source4/libnet/libnet_group.c
r740 r988 68 68 69 69 /* prerequisite: make sure we have a valid samr domain handle */ 70 prereq_met = samr_domain_opened(ctx, s->r.in.domain_name, &c, &s->domain_open,70 prereq_met = samr_domain_opened(ctx, c, s->r.in.domain_name, &c, &s->domain_open, 71 71 continue_domain_opened, monitor); 72 72 if (!prereq_met) return c; … … 77 77 78 78 /* send the request */ 79 create_req = libnet_rpc_groupadd_send(ctx->samr.pipe, &s->group_add, monitor); 79 create_req = libnet_rpc_groupadd_send(s, s->ctx->event_ctx, 80 ctx->samr.samr_handle, 81 &s->group_add, monitor); 80 82 if (composite_nomem(create_req, c)) return c; 81 83 … … 91 93 struct composite_context *create_req; 92 94 93 c = talloc_get_type (ctx->async.private_data, struct composite_context);94 s = talloc_get_type (c->private_data, struct create_group_state);95 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 96 s = talloc_get_type_abort(c->private_data, struct create_group_state); 95 97 96 98 c->status = libnet_DomainOpen_recv(ctx, s->ctx, c, &s->domain_open); … … 102 104 103 105 /* send the request */ 104 create_req = libnet_rpc_groupadd_send(s->ctx->samr.pipe, &s->group_add, 105 s->monitor_fn); 106 create_req = libnet_rpc_groupadd_send(s, s->ctx->event_ctx, 107 s->ctx->samr.samr_handle, 108 &s->group_add, s->monitor_fn); 106 109 if (composite_nomem(create_req, c)) return; 107 110 … … 115 118 struct create_group_state *s; 116 119 117 c = talloc_get_type (ctx->async.private_data, struct composite_context);118 s = talloc_get_type (c->private_data, struct create_group_state);120 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 121 s = talloc_get_type_abort(c->private_data, struct create_group_state); 119 122 120 123 /* receive result of group add call */ … … 140 143 { 141 144 NTSTATUS status; 142 struct create_group_state *s;143 145 144 146 status = composite_wait(c); 145 147 if (!NT_STATUS_IS_OK(status)) { 146 s = talloc_get_type(c->private_data, struct create_group_state);147 148 r->out.error_string = talloc_strdup(mem_ctx, nt_errstr(status)); 148 149 } … … 235 236 236 237 /* prerequisite: make sure the domain is opened */ 237 prereq_met = samr_domain_opened(ctx, s->domain_name, &c, &s->domopen,238 prereq_met = samr_domain_opened(ctx, c, s->domain_name, &c, &s->domopen, 238 239 continue_domain_open_info, monitor); 239 240 if (!prereq_met) return c; … … 260 261 261 262 /* send the request */ 262 info_req = libnet_rpc_groupinfo_send(s->ctx->samr.pipe, &s->info, s->monitor_fn); 263 info_req = libnet_rpc_groupinfo_send(s, s->ctx->event_ctx, 264 s->ctx->samr.samr_handle, 265 &s->info, s->monitor_fn); 263 266 if (composite_nomem(info_req, c)) return c; 264 267 … … 281 284 struct composite_context *lookup_req, *info_req; 282 285 283 c = talloc_get_type (ctx->async.private_data, struct composite_context);284 s = talloc_get_type (c->private_data, struct group_info_state);286 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 287 s = talloc_get_type_abort(c->private_data, struct group_info_state); 285 288 286 289 /* receive domain handle */ … … 309 312 310 313 /* send the request */ 311 info_req = libnet_rpc_groupinfo_send(s->ctx->samr.pipe, &s->info, s->monitor_fn); 314 info_req = libnet_rpc_groupinfo_send(s, s->ctx->event_ctx, 315 s->ctx->samr.samr_handle, 316 &s->info, s->monitor_fn); 312 317 if (composite_nomem(info_req, c)) return; 313 318 … … 329 334 struct composite_context *info_req; 330 335 331 c = talloc_get_type (ctx->async.private_data, struct composite_context);332 s = talloc_get_type (c->private_data, struct group_info_state);336 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 337 s = talloc_get_type_abort(c->private_data, struct group_info_state); 333 338 334 339 /* receive SID assiociated with name found */ … … 340 345 s->lookup.out.sid_type != SID_NAME_ALIAS) { 341 346 composite_error(c, NT_STATUS_NO_SUCH_GROUP); 347 return; 342 348 } 343 349 … … 350 356 351 357 /* send the request */ 352 info_req = libnet_rpc_groupinfo_send(s->ctx->samr.pipe, &s->info, s->monitor_fn); 358 info_req = libnet_rpc_groupinfo_send(s, s->ctx->event_ctx, 359 s->ctx->samr.samr_handle, 360 &s->info, s->monitor_fn); 353 361 if (composite_nomem(info_req, c)) return; 354 362 … … 366 374 struct group_info_state *s; 367 375 368 c = talloc_get_type (ctx->async.private_data, struct composite_context);369 s = talloc_get_type (c->private_data, struct group_info_state);376 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 377 s = talloc_get_type_abort(c->private_data, struct group_info_state); 370 378 371 379 /* receive group information */ … … 395 403 if (NT_STATUS_IS_OK(status)) { 396 404 /* put the results into io structure if everything went fine */ 397 s = talloc_get_type (c->private_data, struct group_info_state);405 s = talloc_get_type_abort(c->private_data, struct group_info_state); 398 406 399 407 io->out.group_name = talloc_steal(mem_ctx, … … 489 497 490 498 /* make sure we have lsa domain handle before doing anything */ 491 prereq_met = lsa_domain_opened(ctx, s->domain_name, &c, &s->domain_open,499 prereq_met = lsa_domain_opened(ctx, c, s->domain_name, &c, &s->domain_open, 492 500 continue_lsa_domain_opened, monitor); 493 501 if (!prereq_met) return c; … … 520 528 struct tevent_req *subreq; 521 529 522 c = talloc_get_type (ctx->async.private_data, struct composite_context);523 s = talloc_get_type (c->private_data, struct grouplist_state);530 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 531 s = talloc_get_type_abort(c->private_data, struct grouplist_state); 524 532 525 533 /* receive lsa domain handle */ … … 554 562 555 563 c = tevent_req_callback_data(subreq, struct composite_context); 556 s = talloc_get_type (c->private_data, struct grouplist_state);564 s = talloc_get_type_abort(c->private_data, struct grouplist_state); 557 565 558 566 /* receive result of rpc request */ … … 565 573 566 574 /* make sure we have samr domain handle before continuing */ 567 prereq_met = samr_domain_opened(s->ctx, s->domain_name, &c, &s->domain_open,575 prereq_met = samr_domain_opened(s->ctx, c, s->domain_name, &c, &s->domain_open, 568 576 continue_samr_domain_opened, s->monitor_fn); 569 577 if (!prereq_met) return; … … 599 607 struct tevent_req *subreq; 600 608 601 c = talloc_get_type (ctx->async.private_data, struct composite_context);602 s = talloc_get_type (c->private_data, struct grouplist_state);609 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 610 s = talloc_get_type_abort(c->private_data, struct grouplist_state); 603 611 604 612 /* receive samr domain handle */ … … 636 644 637 645 c = tevent_req_callback_data(subreq, struct composite_context); 638 s = talloc_get_type (c->private_data, struct grouplist_state);646 s = talloc_get_type_abort(c->private_data, struct grouplist_state); 639 647 640 648 /* receive result of rpc request */ … … 682 690 /* that's it */ 683 691 composite_done(c); 684 692 return; 685 693 } else { 686 694 /* something went wrong */ 687 695 composite_error(c, c->status); 696 return; 688 697 } 689 698 } … … 714 723 NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) { 715 724 716 s = talloc_get_type (c->private_data, struct grouplist_state);725 s = talloc_get_type_abort(c->private_data, struct grouplist_state); 717 726 718 727 /* get results from composite context */ -
vendor/current/source4/libnet/libnet_join.c
r860 r988 54 54 const char *realm = r->out.realm; 55 55 56 struct dcerpc_binding *samr_binding = r->out.samr_binding;56 const struct dcerpc_binding *samr_binding = r->out.samr_binding; 57 57 58 58 struct dcerpc_pipe *drsuapi_pipe; 59 59 struct dcerpc_binding *drsuapi_binding; 60 enum dcerpc_transport_t transport; 60 61 struct drsuapi_DsBind r_drsuapi_bind; 61 62 struct drsuapi_DsCrackNames r_crack_names; … … 94 95 return NT_STATUS_NO_MEMORY; 95 96 } 96 97 drsuapi_binding = talloc_zero(tmp_ctx, struct dcerpc_binding);97 98 drsuapi_binding = dcerpc_binding_dup(tmp_ctx, samr_binding); 98 99 if (!drsuapi_binding) { 99 100 r->out.error_string = NULL; … … 101 102 return NT_STATUS_NO_MEMORY; 102 103 } 103 104 *drsuapi_binding = *samr_binding;104 105 transport = dcerpc_binding_get_transport(drsuapi_binding); 105 106 106 107 /* DRSUAPI is only available on IP_TCP, and locally on NCALRPC */ 107 if (drsuapi_binding->transport != NCALRPC) { 108 drsuapi_binding->transport = NCACN_IP_TCP; 109 } 110 drsuapi_binding->endpoint = NULL; 111 drsuapi_binding->flags |= DCERPC_SEAL; 108 if (transport != NCALRPC) { 109 status = dcerpc_binding_set_transport(drsuapi_binding, NCACN_IP_TCP); 110 if (!NT_STATUS_IS_OK(status)) { 111 r->out.error_string = talloc_asprintf(r, 112 "dcerpc_binding_set_transport failed: %s", 113 nt_errstr(status)); 114 talloc_free(tmp_ctx); 115 return status; 116 } 117 } 118 119 status = dcerpc_binding_set_string_option(drsuapi_binding, "endpoint", NULL); 120 if (!NT_STATUS_IS_OK(status)) { 121 r->out.error_string = talloc_asprintf(r, 122 "dcerpc_binding_set_string_option failed: %s", 123 nt_errstr(status)); 124 talloc_free(tmp_ctx); 125 return status; 126 } 127 128 status = dcerpc_binding_set_flags(drsuapi_binding, DCERPC_SEAL, 0); 129 if (!NT_STATUS_IS_OK(status)) { 130 r->out.error_string = talloc_asprintf(r, 131 "dcerpc_binding_set_flags failed: %s", 132 nt_errstr(status)); 133 talloc_free(tmp_ctx); 134 return status; 135 } 112 136 113 137 status = dcerpc_pipe_connect_b(tmp_ctx, … … 220 244 221 245 remote_ldb_url = talloc_asprintf(tmp_ctx, "ldap://%s", 222 drsuapi_binding->target_hostname);246 dcerpc_binding_get_string_option(drsuapi_binding, "target_hostname")); 223 247 if (!remote_ldb_url) { 224 248 r->out.error_string = NULL; … … 520 544 samr_pipe = connect_with_info->out.dcerpc_pipe; 521 545 522 status = dcerpc_pipe_auth(tmp_ctx, &samr_pipe,523 connect_with_info->out.dcerpc_pipe->binding,524 &ndr_table_samr, ctx->cred, ctx->lp_ctx);525 if (!NT_STATUS_IS_OK(status)) {526 r->out.error_string = talloc_asprintf(mem_ctx,527 "SAMR bind failed: %s",528 nt_errstr(status));529 talloc_free(tmp_ctx);530 return status;531 }532 533 546 /* prepare samr_Connect */ 534 547 ZERO_STRUCT(p_handle); … … 830 843 policy_min_pw_len = pwp.out.info->min_password_length; 831 844 } 832 833 /* Grab a password of that minimum length */ 834 835 password_str = generate_random_password(tmp_ctx, MAX(8, policy_min_pw_len), 255); 845 846 if (r->in.account_pass != NULL) { 847 password_str = talloc_strdup(tmp_ctx, r->in.account_pass); 848 } else { 849 /* Grab a password of that minimum length */ 850 password_str = generate_random_password(tmp_ctx, 851 MAX(8, policy_min_pw_len), 255); 852 } 853 if (!password_str) { 854 r->out.error_string = NULL; 855 talloc_free(tmp_ctx); 856 return NT_STATUS_NO_MEMORY; 857 } 836 858 837 859 /* set full_name and reset flags */ … … 879 901 talloc_reparent(tmp_ctx, mem_ctx, samr_pipe); 880 902 r->out.samr_binding = samr_pipe->binding; 881 talloc_steal(mem_ctx, r->out.samr_binding);882 903 r->out.user_handle = u_handle; 883 904 talloc_steal(mem_ctx, u_handle); … … 898 919 } 899 920 900 static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx, 901 TALLOC_CTX *mem_ctx,902 struct libnet_Join*r)921 NTSTATUS libnet_Join_member(struct libnet_context *ctx, 922 TALLOC_CTX *mem_ctx, 923 struct libnet_Join_member *r) 903 924 { 904 925 NTSTATUS status; … … 918 939 } 919 940 920 r2 = talloc (tmp_mem, struct libnet_JoinDomain);941 r2 = talloc_zero(tmp_mem, struct libnet_JoinDomain); 921 942 if (!r2) { 922 943 r->out.error_string = NULL; … … 925 946 } 926 947 927 if (r->in.join_type == SEC_CHAN_BDC) { 928 acct_type = ACB_SVRTRUST; 929 } else if (r->in.join_type == SEC_CHAN_WKSTA) { 930 acct_type = ACB_WSTRUST; 931 } else { 932 r->out.error_string = NULL; 933 talloc_free(tmp_mem); 934 return NT_STATUS_INVALID_PARAMETER; 935 } 948 acct_type = ACB_WSTRUST; 936 949 937 950 if (r->in.netbios_name != NULL) { … … 956 969 * join the domain 957 970 */ 958 ZERO_STRUCTP(r2);959 971 r2->in.domain_name = r->in.domain_name; 960 972 r2->in.account_name = account_name; … … 963 975 r2->in.acct_type = acct_type; 964 976 r2->in.recreate_account = false; 977 r2->in.account_pass = r->in.account_pass; 965 978 status = libnet_JoinDomain(ctx, r2, r2); 966 979 if (!NT_STATUS_IS_OK(status)) { … … 981 994 set_secrets->realm = r2->out.realm; 982 995 set_secrets->netbios_name = netbios_name; 983 set_secrets->secure_channel_type = r->in.join_type;996 set_secrets->secure_channel_type = SEC_CHAN_WKSTA; 984 997 set_secrets->machine_password = r2->out.join_password; 985 998 set_secrets->key_version_number = r2->out.kvno; … … 1005 1018 } 1006 1019 1007 NTSTATUS libnet_Join(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct libnet_Join *r)1008 {1009 switch (r->in.join_type) {1010 case SEC_CHAN_WKSTA:1011 return libnet_Join_primary_domain(ctx, mem_ctx, r);1012 case SEC_CHAN_BDC:1013 return libnet_Join_primary_domain(ctx, mem_ctx, r);1014 case SEC_CHAN_DOMAIN:1015 case SEC_CHAN_DNS_DOMAIN:1016 case SEC_CHAN_NULL:1017 break;1018 }1019 1020 r->out.error_string = talloc_asprintf(mem_ctx,1021 "Invalid join type specified (%08X) attempting to join domain %s",1022 r->in.join_type, r->in.domain_name);1023 return NT_STATUS_INVALID_PARAMETER;1024 } -
vendor/current/source4/libnet/libnet_join.h
r414 r988 44 44 uint32_t acct_type; 45 45 bool recreate_account; 46 const char *account_pass; 46 47 } in; 47 48 … … 57 58 uint32_t kvno; /* msDS-KeyVersionNumber */ 58 59 struct dcerpc_pipe *samr_pipe; 59 struct dcerpc_binding *samr_binding;60 const struct dcerpc_binding *samr_binding; 60 61 struct policy_handle *user_handle; 61 62 struct dom_sid *account_sid; … … 64 65 }; 65 66 66 struct libnet_Join {67 struct libnet_Join_member { 67 68 struct { 68 69 const char *domain_name; 69 70 const char *netbios_name; 70 enum netr_SchannelType join_type;71 71 enum libnet_Join_level level; 72 const char *account_pass; 72 73 } in; 73 74 -
vendor/current/source4/libnet/libnet_lookup.c
r860 r988 48 48 49 49 struct composite_context *libnet_Lookup_send(struct libnet_context *ctx, 50 TALLOC_CTX *mem_ctx, 50 51 struct libnet_Lookup *io) 51 52 { … … 56 57 57 58 /* allocate context and state structures */ 58 c = composite_create( ctx, ctx->event_ctx);59 c = composite_create(mem_ctx, ctx->event_ctx); 59 60 if (c == NULL) return NULL; 60 61 … … 123 124 status = composite_wait(c); 124 125 if (NT_STATUS_IS_OK(status)) { 126 char **address; 127 125 128 s = talloc_get_type(c->private_data, struct lookup_state); 126 129 127 io->out.address = (const char **)str_list_make_single(mem_ctx, s->address); 128 NT_STATUS_HAVE_NO_MEMORY(io->out.address); 130 address = str_list_make_single(mem_ctx, s->address); 131 NT_STATUS_HAVE_NO_MEMORY(address); 132 io->out.address = discard_const_p(const char *, address); 129 133 } 130 134 … … 145 149 struct libnet_Lookup *io) 146 150 { 147 struct composite_context *c = libnet_Lookup_send(ctx, io);151 struct composite_context *c = libnet_Lookup_send(ctx, mem_ctx, io); 148 152 return libnet_Lookup_recv(c, mem_ctx, io); 149 153 } … … 160 164 */ 161 165 struct composite_context* libnet_LookupHost_send(struct libnet_context *ctx, 166 TALLOC_CTX *mem_ctx, 162 167 struct libnet_Lookup *io) 163 168 { 164 169 io->in.type = NBT_NAME_SERVER; 165 return libnet_Lookup_send(ctx, io);170 return libnet_Lookup_send(ctx, mem_ctx, io); 166 171 } 167 172 … … 174 179 struct libnet_Lookup *io) 175 180 { 176 struct composite_context *c = libnet_LookupHost_send(ctx, io);181 struct composite_context *c = libnet_LookupHost_send(ctx, mem_ctx, io); 177 182 return libnet_Lookup_recv(c, mem_ctx, io); 178 183 } … … 282 287 s->ctx = ctx; 283 288 284 prereq_met = lsa_domain_opened(ctx, io->in.domain_name, &c, &s->domopen,289 prereq_met = lsa_domain_opened(ctx, c, io->in.domain_name, &c, &s->domopen, 285 290 continue_lookup_name, monitor); 286 291 if (!prereq_met) return c; … … 307 312 s->sids.sids = NULL; 308 313 309 s->names = talloc_array( ctx, struct lsa_String, single_name);314 s->names = talloc_array(s, struct lsa_String, single_name); 310 315 if (composite_nomem(s->names, c)) return false; 311 316 s->names[0].string = s->name; … … 319 324 s->lookup.out.count = &s->count; 320 325 s->lookup.out.sids = &s->sids; 321 s->lookup.out.domains = talloc_zero( ctx, struct lsa_RefDomainList *);326 s->lookup.out.domains = talloc_zero(s, struct lsa_RefDomainList *); 322 327 if (composite_nomem(s->lookup.out.domains, c)) return false; 323 328 -
vendor/current/source4/libnet/libnet_rpc.c
r740 r988 26 26 #include "librpc/gen_ndr/ndr_lsa_c.h" 27 27 #include "librpc/gen_ndr/ndr_samr.h" 28 28 #include "auth/credentials/credentials.h" 29 29 30 30 struct rpc_connect_srv_state { … … 80 80 break; 81 81 case LIBNET_RPC_CONNECT_SERVER_ADDRESS: 82 s->binding = talloc_asprintf(s, "ncacn_np:%s", r->in.address); 82 s->binding = talloc_asprintf(s, "ncacn_np:%s[target_hostname=%s]", 83 r->in.address, r->in.name); 83 84 break; 84 85 … … 109 110 case LIBNET_RPC_CONNECT_SERVER: 110 111 case LIBNET_RPC_CONNECT_SERVER_ADDRESS: 111 b->flags = r->in.dcerpc_flags; 112 c->status = dcerpc_binding_set_flags(b, r->in.dcerpc_flags, 0); 113 if (!composite_is_ok(c)) return c; 114 break; 115 default: 116 /* other types have already been checked before */ 117 break; 112 118 } 113 119 114 120 if (DEBUGLEVEL >= 10) { 115 b->flags |= DCERPC_DEBUG_PRINT_BOTH; 116 } 117 118 if (r->level == LIBNET_RPC_CONNECT_SERVER_ADDRESS) { 119 b->target_hostname = talloc_strdup(b, r->in.name); 120 if (composite_nomem(b->target_hostname, c)) { 121 return c; 122 } 121 c->status = dcerpc_binding_set_flags(b, DCERPC_DEBUG_PRINT_BOTH, 0); 122 if (!composite_is_ok(c)) return c; 123 123 } 124 124 … … 152 152 struct monitor_msg msg; 153 153 struct msg_net_rpc_connect data; 154 struct dcerpc_binding *binding= s->r.out.dcerpc_pipe->binding;155 154 const struct dcerpc_binding *b = s->r.out.dcerpc_pipe->binding; 155 156 156 /* prepare monitor message and post it */ 157 data.host = binding->host;158 data.endpoint = binding->endpoint;159 data.transport = binding->transport;160 data.domain_name = binding->target_hostname;161 157 data.host = dcerpc_binding_get_string_option(b, "host"); 158 data.endpoint = dcerpc_binding_get_string_option(b, "endpoint"); 159 data.transport = dcerpc_binding_get_transport(b); 160 data.domain_name = dcerpc_binding_get_string_option(b, "target_hostname"); 161 162 162 msg.type = mon_NetRpcConnect; 163 163 msg.data = (void*)&data; … … 186 186 { 187 187 NTSTATUS status; 188 struct rpc_connect_srv_state *s = talloc_get_type(c->private_data,189 struct rpc_connect_srv_state);190 188 191 189 status = composite_wait(c); 192 190 if (NT_STATUS_IS_OK(status)) { 191 struct rpc_connect_srv_state *s; 192 193 193 /* move the returned rpc pipe between memory contexts */ 194 194 s = talloc_get_type(c->private_data, struct rpc_connect_srv_state); … … 200 200 if (r->in.dcerpc_iface == &ndr_table_samr) { 201 201 ctx->samr.pipe = talloc_reference(ctx, r->out.dcerpc_pipe); 202 ctx->samr.samr_handle = ctx->samr.pipe->binding_handle; 202 203 203 204 } else if (r->in.dcerpc_iface == &ndr_table_lsarpc) { 204 205 ctx->lsa.pipe = talloc_reference(ctx, r->out.dcerpc_pipe); 206 ctx->lsa.lsa_handle = ctx->lsa.pipe->binding_handle; 205 207 } 206 208 … … 366 368 struct monitor_msg msg; 367 369 struct msg_net_rpc_connect data; 368 struct dcerpc_binding *binding= s->r.out.dcerpc_pipe->binding;369 370 data.host = binding->host;371 data.endpoint = binding->endpoint;372 data.transport = binding->transport;373 data.domain_name = binding->target_hostname;374 370 const struct dcerpc_binding *b = s->r.out.dcerpc_pipe->binding; 371 372 data.host = dcerpc_binding_get_string_option(b, "host"); 373 data.endpoint = dcerpc_binding_get_string_option(b, "endpoint"); 374 data.transport = dcerpc_binding_get_transport(b); 375 data.domain_name = dcerpc_binding_get_string_option(b, "target_hostname"); 376 375 377 msg.type = mon_NetRpcConnect; 376 378 msg.data = (void*)&data; … … 421 423 if (r->in.dcerpc_iface == &ndr_table_samr) { 422 424 ctx->samr.pipe = talloc_reference(ctx, r->out.dcerpc_pipe); 423 425 ctx->samr.samr_handle = ctx->samr.pipe->binding_handle; 424 426 } else if (r->in.dcerpc_iface == &ndr_table_lsarpc) { 425 427 ctx->lsa.pipe = talloc_reference(ctx, r->out.dcerpc_pipe); 428 ctx->lsa.lsa_handle = ctx->lsa.pipe->binding_handle; 426 429 } 427 430 … … 533 536 struct rpc_connect_dci_state *s; 534 537 struct tevent_req *subreq; 538 enum dcerpc_transport_t transport; 535 539 536 540 c = talloc_get_type(ctx->async.private_data, struct composite_context); … … 547 551 struct monitor_msg msg; 548 552 struct msg_net_rpc_connect data; 549 struct dcerpc_binding *binding= s->r.out.dcerpc_pipe->binding;550 551 data.host = binding->host;552 data.endpoint = binding->endpoint;553 data.transport = binding->transport;554 data.domain_name = binding->target_hostname;553 const struct dcerpc_binding *b = s->r.out.dcerpc_pipe->binding; 554 555 data.host = dcerpc_binding_get_string_option(b, "host"); 556 data.endpoint = dcerpc_binding_get_string_option(b, "endpoint"); 557 data.transport = dcerpc_binding_get_transport(b); 558 data.domain_name = dcerpc_binding_get_string_option(b, "target_hostname"); 555 559 556 560 msg.type = mon_NetRpcConnect; … … 569 573 570 574 s->attr.sec_qos = &s->qos; 575 576 transport = dcerpc_binding_get_transport(s->lsa_pipe->binding); 577 if (transport == NCACN_IP_TCP) { 578 /* 579 * Skip to creating the actual connection. We can't open a 580 * policy handle over tcpip. 581 */ 582 continue_epm_map_binding_send(c); 583 return; 584 } 571 585 572 586 s->lsa_open_policy.in.attr = &s->attr; … … 770 784 struct rpc_connect_dci_state *s; 771 785 struct composite_context *epm_map_req; 786 struct cli_credentials *epm_creds = NULL; 787 772 788 s = talloc_get_type(c->private_data, struct rpc_connect_dci_state); 773 789 774 790 /* prepare to get endpoint mapping for the requested interface */ 775 s->final_binding = talloc_zero(s, struct dcerpc_binding);791 s->final_binding = dcerpc_binding_dup(s, s->lsa_pipe->binding); 776 792 if (composite_nomem(s->final_binding, c)) return; 777 778 *s->final_binding = *s->lsa_pipe->binding; 779 /* Ensure we keep hold of the member elements */ 780 if (composite_nomem(talloc_reference(s->final_binding, s->lsa_pipe->binding), c)) return; 793 794 epm_creds = cli_credentials_init_anon(s); 795 if (composite_nomem(epm_creds, c)) return; 781 796 782 797 epm_map_req = dcerpc_epm_map_binding_send(c, s->final_binding, s->r.in.dcerpc_iface, 783 s->lsa_pipe->conn->event_ctx, s->ctx->lp_ctx); 798 epm_creds, 799 s->ctx->event_ctx, s->ctx->lp_ctx); 784 800 if (composite_nomem(epm_map_req, c)) return; 785 801 … … 810 826 811 827 /* create secondary connection derived from lsa pipe */ 812 sec_conn_req = dcerpc_secondary_connection_send(s->lsa_pipe, s->final_binding); 828 sec_conn_req = dcerpc_secondary_auth_connection_send(s->lsa_pipe, 829 s->final_binding, 830 s->r.in.dcerpc_iface, 831 s->ctx->cred, 832 s->ctx->lp_ctx); 813 833 if (composite_nomem(sec_conn_req, c)) return; 814 834 … … 829 849 s = talloc_get_type(c->private_data, struct rpc_connect_dci_state); 830 850 831 c->status = dcerpc_secondary_connection_recv(ctx, &s->final_pipe); 851 c->status = dcerpc_secondary_auth_connection_recv(ctx, s->lsa_pipe, 852 &s->final_pipe); 832 853 if (!NT_STATUS_IS_OK(c->status)) { 833 854 s->r.out.error_string = talloc_asprintf(c, … … 845 866 struct monitor_msg msg; 846 867 struct msg_net_rpc_connect data; 847 struct dcerpc_binding *binding= s->r.out.dcerpc_pipe->binding;848 868 const struct dcerpc_binding *b = s->r.out.dcerpc_pipe->binding; 869 849 870 /* prepare monitor message and post it */ 850 data.host = binding->host;851 data.endpoint = binding->endpoint;852 data.transport = binding->transport;853 data.domain_name = binding->target_hostname;854 871 data.host = dcerpc_binding_get_string_option(b, "host"); 872 data.endpoint = dcerpc_binding_get_string_option(b, "endpoint"); 873 data.transport = dcerpc_binding_get_transport(b); 874 data.domain_name = dcerpc_binding_get_string_option(b, "target_hostname"); 875 855 876 msg.type = mon_NetRpcConnect; 856 877 msg.data = (void*)&data; -
vendor/current/source4/libnet/libnet_samdump.c
r740 r988 182 182 char *secret_name = talloc_asprintf(mem_ctx, "G$$%s", t->name); 183 183 for (s=samdump_state->secrets; s; s=s->next) { 184 size_t converted_size = 0; 184 185 char *secret_string; 185 186 if (strcasecmp_m(s->name, secret_name) != 0) { 186 187 continue; 187 188 } 188 if (!convert_string_talloc_ convenience(mem_ctx, lpcfg_iconv_convenience(ctx->lp_ctx), CH_UTF16, CH_UNIX,189 if (!convert_string_talloc_handle(mem_ctx, lpcfg_iconv_handle(ctx->lp_ctx), CH_UTF16, CH_UNIX, 189 190 s->secret.data, s->secret.length, 190 (void **)&secret_string, NULL, false)) {191 (void **)&secret_string, &converted_size)) { 191 192 r->out.error_string = talloc_asprintf(mem_ctx, 192 193 "Could not convert secret for domain %s to a string", -
vendor/current/source4/libnet/libnet_samsync.c
r740 r988 183 183 /* get NETLOGON credentials */ 184 184 185 nt_status = dcerpc_schannel_creds(p->conn->security_state.generic_state, samsync_ctx, &creds);186 if ( !NT_STATUS_IS_OK(nt_status)) {187 r->out.error_string = talloc_strdup(mem_ctx, "Could not obtain NETLOGON credentials from DCERPC/GENSEC layer");185 creds = cli_credentials_get_netlogon_creds(machine_account); 186 if (creds == NULL) { 187 r->out.error_string = talloc_strdup(mem_ctx, "Could not obtain NETLOGON credentials from credentials"); 188 188 talloc_free(samsync_ctx); 189 189 return nt_status; … … 270 270 271 271 if (!NT_STATUS_IS_OK(dbsync_nt_status)) { 272 r->out.error_string = talloc_asprintf(mem_ctx, "libnet_SamSync_netlogon failed: unexpected inconsist ancy. Should not get error %s here", nt_errstr(nt_status));272 r->out.error_string = talloc_asprintf(mem_ctx, "libnet_SamSync_netlogon failed: unexpected inconsistency. Should not get error %s here", nt_errstr(dbsync_nt_status)); 273 273 talloc_free(samsync_ctx); 274 274 return dbsync_nt_status; -
vendor/current/source4/libnet/libnet_samsync_ldb.c
r740 r988 162 162 * domain (found on LSA pipe, database sid may 163 163 * be random) */ 164 samdb_msg_add_dom_sid(state->sam_ldb, mem_ctx, 165 msg, "objectSid", state->dom_sid[database]); 164 ret = samdb_msg_add_dom_sid(state->sam_ldb, 165 mem_ctx, 166 msg, 167 "objectSid", 168 state->dom_sid[database]); 169 if (ret != LDB_SUCCESS) { 170 return NT_STATUS_INTERNAL_ERROR; 171 } 166 172 } else { 167 173 /* Well, we will have to use the one from the database */ … … 169 175 state->base_dn[database], 170 176 "objectSid", NULL); 177 if (state->dom_sid[database] == NULL) { 178 return NT_STATUS_INTERNAL_ERROR; 179 } 171 180 } 172 181 … … 180 189 } 181 190 182 ldb_msg_add_value(msg, "objectGUID", &v, NULL); 191 ret = ldb_msg_add_value(msg, "objectGUID", &v, NULL); 192 if (ret != LDB_SUCCESS) { 193 return NT_STATUS_INTERNAL_ERROR; 194 } 183 195 } 184 196 } else if (database == SAM_DATABASE_BUILTIN) { … … 654 666 { 655 667 uint32_t rid = delta->delta_id_union.rid; 656 struct netr_DELTA_GROUP_MEMBER * group_member = delta->delta_union.group_member;668 struct netr_DELTA_GROUP_MEMBER *delta_group_member = delta->delta_union.group_member; 657 669 struct ldb_message *msg; 658 670 struct ldb_message **msgs; … … 690 702 talloc_free(msgs); 691 703 692 for (i=0; i< group_member->num_rids; i++) {704 for (i=0; i<delta_group_member->num_rids; i++) { 693 705 /* search for the group, by rid */ 694 706 ret = gendb_search(state->sam_ldb, mem_ctx, state->base_dn[database], &msgs, attrs, 695 707 "(&(objectClass=user)(objectSid=%s))", 696 ldap_encode_ndr_dom_sid(mem_ctx, dom_sid_add_rid(mem_ctx, state->dom_sid[database], group_member->rids[i])));708 ldap_encode_ndr_dom_sid(mem_ctx, dom_sid_add_rid(mem_ctx, state->dom_sid[database], delta_group_member->rids[i]))); 697 709 698 710 if (ret == -1) { … … 965 977 966 978 sidstr = dom_sid_string(msg, sid); 967 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(sidstr, msg); 979 if (sidstr == NULL) { 980 TALLOC_FREE(msg); 981 return NT_STATUS_NO_MEMORY; 982 } 968 983 969 984 dnstr = talloc_asprintf(msg, "sid=%s", sidstr); 970 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(dnstr, msg); 985 if (dnstr == NULL) { 986 TALLOC_FREE(msg); 987 return NT_STATUS_NO_MEMORY; 988 } 971 989 972 990 msg->dn = ldb_dn_new(msg, state->pdb, dnstr); 973 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg->dn, msg); 991 if (msg->dn == NULL) { 992 TALLOC_FREE(msg); 993 return NT_STATUS_NO_MEMORY; 994 } 974 995 975 996 for (i=0; i< account->privilege_entries; i++) { -
vendor/current/source4/libnet/libnet_site.c
r740 r988 65 65 if (ret != 0) { 66 66 r->out.error_string = NULL; 67 status = map_nt_error_from_unix(errno); 67 status = map_nt_error_from_unix_common(errno); 68 talloc_free(tmp_ctx); 68 69 return status; 69 70 } 70 71 71 72 /* we want to use non async calls, so we're not passing an event context */ 72 status = cldap_socket_init(tmp_ctx, NULL, NULL,dest_address, &cldap);73 status = cldap_socket_init(tmp_ctx, NULL, dest_address, &cldap); 73 74 if (!NT_STATUS_IS_OK(status)) { 74 75 talloc_free(tmp_ctx); … … 78 79 status = cldap_netlogon(cldap, tmp_ctx, &search); 79 80 if (!NT_STATUS_IS_OK(status) 80 || !search.out.netlogon.data.nt5_ex.client_site) { 81 || search.out.netlogon.data.nt5_ex.client_site == NULL 82 || search.out.netlogon.data.nt5_ex.client_site[0] == '\0') { 81 83 /* 82 84 If cldap_netlogon() returns in error, … … 151 153 152 154 const char *server_dn_str; 153 const char * config_dn_str;155 const char *host; 154 156 struct nbt_name name; 155 157 const char *dest_addr = NULL; … … 168 170 } 169 171 170 make_nbt_name_client(&name, libnet_r->out.samr_binding->host); 171 status = resolve_name(lpcfg_resolve_context(ctx->lp_ctx), &name, r, &dest_addr, ctx->event_ctx); 172 host = dcerpc_binding_get_string_option(libnet_r->out.samr_binding, "host"); 173 make_nbt_name_client(&name, host); 174 status = resolve_name_ex(lpcfg_resolve_context(ctx->lp_ctx), 175 0, 0, 176 &name, r, &dest_addr, ctx->event_ctx); 172 177 if (!NT_STATUS_IS_OK(status)) { 173 178 libnet_r->out.error_string = NULL; … … 190 195 } 191 196 192 config_dn_str = r->out.config_dn_str;193 197 server_dn_str = r->out.server_dn_str; 194 198 -
vendor/current/source4/libnet/libnet_unbecome_dc.c
r740 r988 278 278 &dest_address); 279 279 if (ret != 0) { 280 c->status = map_nt_error_from_unix (errno);280 c->status = map_nt_error_from_unix_common(errno); 281 281 if (!composite_is_ok(c)) return; 282 282 } 283 283 284 c->status = cldap_socket_init(s, s->libnet->event_ctx,285 NULL, dest_address, &s->cldap.sock);286 if (!composite_is_ok(c)) return; 287 288 req = cldap_netlogon_send(s,s->cldap.sock, &s->cldap.io);284 c->status = cldap_socket_init(s, NULL, dest_address, &s->cldap.sock); 285 if (!composite_is_ok(c)) return; 286 287 req = cldap_netlogon_send(s, s->libnet->event_ctx, 288 s->cldap.sock, &s->cldap.io); 289 289 if (composite_nomem(req, c)) return; 290 290 tevent_req_set_callback(req, unbecomeDC_recv_cldap, s); … … 544 544 char *binding_str; 545 545 546 binding_str = talloc_asprintf(s, "ncacn_ip_tcp:%s[seal]", s->source_dsa.dns_name); 546 binding_str = talloc_asprintf(s, "ncacn_ip_tcp:%s[seal,target_hostname=%s]", 547 s->source_dsa.address, 548 s->source_dsa.dns_name); 547 549 if (composite_nomem(binding_str, c)) return; 548 550 … … 550 552 talloc_free(binding_str); 551 553 if (!composite_is_ok(c)) return; 554 555 if (DEBUGLEVEL >= 10) { 556 c->status = dcerpc_binding_set_flags(s->drsuapi.binding, 557 DCERPC_DEBUG_PRINT_BOTH, 558 0); 559 if (!composite_is_ok(c)) return; 560 } 552 561 553 562 creq = dcerpc_pipe_connect_b_send(s, s->drsuapi.binding, &ndr_table_drsuapi, … … 632 641 break; 633 642 } 643 case 28: { 644 s->drsuapi.remote_info28 = s->drsuapi.bind_r.out.bind_info->info.info28; 645 break; 646 } 647 case 32: { 648 struct drsuapi_DsBindInfo32 *info32; 649 info32 = &s->drsuapi.bind_r.out.bind_info->info.info32; 650 s->drsuapi.remote_info28.supported_extensions = info32->supported_extensions; 651 s->drsuapi.remote_info28.site_guid = info32->site_guid; 652 s->drsuapi.remote_info28.pid = info32->pid; 653 s->drsuapi.remote_info28.repl_epoch = info32->repl_epoch; 654 break; 655 } 634 656 case 48: { 635 657 struct drsuapi_DsBindInfo48 *info48; … … 641 663 break; 642 664 } 643 case 28: 644 s->drsuapi.remote_info28 = s->drsuapi.bind_r.out.bind_info->info.info28; 665 case 52: { 666 struct drsuapi_DsBindInfo52 *info52; 667 info52 = &s->drsuapi.bind_r.out.bind_info->info.info52; 668 s->drsuapi.remote_info28.supported_extensions = info52->supported_extensions; 669 s->drsuapi.remote_info28.site_guid = info52->site_guid; 670 s->drsuapi.remote_info28.pid = info52->pid; 671 s->drsuapi.remote_info28.repl_epoch = info52->repl_epoch; 672 break; 673 } 674 default: 675 DEBUG(1, ("Warning: invalid info length in bind info: %d\n", 676 s->drsuapi.bind_r.out.bind_info->length)); 645 677 break; 646 678 } -
vendor/current/source4/libnet/libnet_user.c
r740 r988 80 80 81 81 /* prerequisite: make sure the domain is opened */ 82 prereq_met = samr_domain_opened(ctx, s->r.in.domain_name, &c, &s->domain_open,82 prereq_met = samr_domain_opened(ctx, c, s->r.in.domain_name, &c, &s->domain_open, 83 83 continue_domain_open_create, monitor); 84 84 if (!prereq_met) return c; … … 89 89 90 90 /* send the request */ 91 create_req = libnet_rpc_useradd_send(ctx->samr.pipe, &s->user_add, monitor); 91 create_req = libnet_rpc_useradd_send(s, s->ctx->event_ctx, 92 ctx->samr.samr_handle, 93 &s->user_add, monitor); 92 94 if (composite_nomem(create_req, c)) return c; 93 95 … … 109 111 struct monitor_msg msg; 110 112 111 c = talloc_get_type (ctx->async.private_data, struct composite_context);112 s = talloc_get_type (c->private_data, struct create_user_state);113 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 114 s = talloc_get_type_abort(c->private_data, struct create_user_state); 113 115 114 116 /* receive result of DomainOpen call */ … … 124 126 125 127 /* send the request */ 126 create_req = libnet_rpc_useradd_send(s->ctx->samr.pipe, &s->user_add, s->monitor_fn); 128 create_req = libnet_rpc_useradd_send(s, s->ctx->event_ctx, 129 s->ctx->samr.samr_handle, 130 &s->user_add, s->monitor_fn); 127 131 if (composite_nomem(create_req, c)) return; 128 132 … … 141 145 struct monitor_msg msg; 142 146 143 c = talloc_get_type (ctx->async.private_data, struct composite_context);144 s = talloc_get_type (c->private_data, struct create_user_state);147 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 148 s = talloc_get_type_abort(c->private_data, struct create_user_state); 145 149 146 150 /* receive result of the call */ … … 168 172 { 169 173 NTSTATUS status; 170 struct create_user_state *s;171 174 172 175 r->out.error_string = NULL; … … 175 178 status = composite_wait(c); 176 179 if (!NT_STATUS_IS_OK(status)) { 177 s = talloc_get_type(c->private_data, struct create_user_state);178 180 r->out.error_string = talloc_strdup(mem_ctx, nt_errstr(status)); 179 181 } … … 250 252 251 253 /* prerequisite: make sure the domain is opened before proceeding */ 252 prereq_met = samr_domain_opened(ctx, s->r.in.domain_name, &c, &s->domain_open,254 prereq_met = samr_domain_opened(ctx, c, s->r.in.domain_name, &c, &s->domain_open, 253 255 continue_domain_open_delete, monitor); 254 256 if (!prereq_met) return c; … … 259 261 260 262 /* send request */ 261 delete_req = libnet_rpc_userdel_send(ctx->samr.pipe, &s->user_del, monitor); 263 delete_req = libnet_rpc_userdel_send(s, s->ctx->event_ctx, 264 ctx->samr.samr_handle, 265 &s->user_del, monitor); 262 266 if (composite_nomem(delete_req, c)) return c; 263 267 … … 279 283 struct monitor_msg msg; 280 284 281 c = talloc_get_type (ctx->async.private_data, struct composite_context);282 s = talloc_get_type (c->private_data, struct delete_user_state);285 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 286 s = talloc_get_type_abort(c->private_data, struct delete_user_state); 283 287 284 288 /* receive result of DomainOpen call */ … … 294 298 295 299 /* send request */ 296 delete_req = libnet_rpc_userdel_send(s->ctx->samr.pipe, &s->user_del, s->monitor_fn); 300 delete_req = libnet_rpc_userdel_send(s, s->ctx->event_ctx, 301 s->ctx->samr.samr_handle, 302 &s->user_del, s->monitor_fn); 297 303 if (composite_nomem(delete_req, c)) return; 298 304 … … 311 317 struct monitor_msg msg; 312 318 313 c = talloc_get_type (ctx->async.private_data, struct composite_context);314 s = talloc_get_type (c->private_data, struct delete_user_state);319 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 320 s = talloc_get_type_abort(c->private_data, struct delete_user_state); 315 321 316 322 /* receive result of userdel call */ … … 344 350 status = composite_wait(c); 345 351 if (!NT_STATUS_IS_OK(status)) { 346 s = talloc_get_type (c->private_data, struct delete_user_state);352 s = talloc_get_type_abort(c->private_data, struct delete_user_state); 347 353 r->out.error_string = talloc_steal(mem_ctx, s->r.out.error_string); 348 354 } … … 418 424 s->r = *r; 419 425 420 prereq_met = samr_domain_opened(ctx, s->r.in.domain_name, &c, &s->domain_open,426 prereq_met = samr_domain_opened(ctx, c, s->r.in.domain_name, &c, &s->domain_open, 421 427 continue_domain_open_modify, monitor); 422 428 if (!prereq_met) return c; … … 426 432 s->user_info.in.level = level; 427 433 428 userinfo_req = libnet_rpc_userinfo_send(ctx->samr.pipe, &s->user_info, monitor); 434 userinfo_req = libnet_rpc_userinfo_send(s, s->ctx->event_ctx, 435 ctx->samr.samr_handle, 436 &s->user_info, monitor); 429 437 if (composite_nomem(userinfo_req, c)) return c; 430 438 … … 446 454 struct monitor_msg msg; 447 455 448 c = talloc_get_type (ctx->async.private_data, struct composite_context);449 s = talloc_get_type (c->private_data, struct modify_user_state);456 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 457 s = talloc_get_type_abort(c->private_data, struct modify_user_state); 450 458 451 459 c->status = libnet_DomainOpen_recv(ctx, s->ctx, c, &s->domain_open); … … 458 466 s->user_info.in.level = level; 459 467 460 userinfo_req = libnet_rpc_userinfo_send(s->ctx->samr.pipe, &s->user_info, s->monitor_fn); 468 userinfo_req = libnet_rpc_userinfo_send(s, s->ctx->event_ctx, 469 s->ctx->samr.samr_handle, 470 &s->user_info, s->monitor_fn); 461 471 if (composite_nomem(userinfo_req, c)) return; 462 472 … … 475 485 struct composite_context *usermod_req; 476 486 477 c = talloc_get_type (ctx->async.private_data, struct composite_context);478 s = talloc_get_type (c->private_data, struct modify_user_state);487 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 488 s = talloc_get_type_abort(c->private_data, struct modify_user_state); 479 489 480 490 c->status = libnet_rpc_userinfo_recv(ctx, c, &s->user_info); … … 486 496 c->status = set_user_changes(c, &s->user_mod.in.change, &s->user_info, &s->r); 487 497 488 usermod_req = libnet_rpc_usermod_send(s->ctx->samr.pipe, &s->user_mod, s->monitor_fn); 498 usermod_req = libnet_rpc_usermod_send(s, s->ctx->event_ctx, 499 s->ctx->samr.samr_handle, 500 &s->user_mod, s->monitor_fn); 489 501 if (composite_nomem(usermod_req, c)) return; 490 502 … … 552 564 struct monitor_msg msg; 553 565 554 c = talloc_get_type (ctx->async.private_data, struct composite_context);555 s = talloc_get_type (c->private_data, struct modify_user_state);566 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 567 s = talloc_get_type_abort(c->private_data, struct modify_user_state); 556 568 557 569 c->status = libnet_rpc_usermod_recv(ctx, c, &s->user_mod); … … 664 676 665 677 /* prerequisite: make sure the domain is opened */ 666 prereq_met = samr_domain_opened(ctx, s->domain_name, &c, &s->domopen,678 prereq_met = samr_domain_opened(ctx, c, s->domain_name, &c, &s->domopen, 667 679 continue_domain_open_info, monitor); 668 680 if (!prereq_met) return c; … … 689 701 690 702 /* send the request */ 691 info_req = libnet_rpc_userinfo_send(s->ctx->samr.pipe, 703 info_req = libnet_rpc_userinfo_send(s, s->ctx->event_ctx, 704 s->ctx->samr.samr_handle, 692 705 &s->userinfo, 693 706 s->monitor_fn); … … 714 727 struct monitor_msg msg; 715 728 716 c = talloc_get_type (ctx->async.private_data, struct composite_context);717 s = talloc_get_type (c->private_data, struct user_info_state);729 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 730 s = talloc_get_type_abort(c->private_data, struct user_info_state); 718 731 719 732 /* receive result of DomainOpen call */ … … 745 758 746 759 /* send the request */ 747 info_req = libnet_rpc_userinfo_send(s->ctx->samr.pipe, 760 info_req = libnet_rpc_userinfo_send(s, s->ctx->event_ctx, 761 s->ctx->samr.samr_handle, 748 762 &s->userinfo, 749 763 s->monitor_fn); … … 766 780 struct composite_context *info_req; 767 781 768 c = talloc_get_type (ctx->async.private_data, struct composite_context);769 s = talloc_get_type (c->private_data, struct user_info_state);782 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 783 s = talloc_get_type_abort(c->private_data, struct user_info_state); 770 784 771 785 /* receive result of LookupName call */ … … 785 799 786 800 /* send the request */ 787 info_req = libnet_rpc_userinfo_send(s->ctx->samr.pipe, &s->userinfo, s->monitor_fn); 801 info_req = libnet_rpc_userinfo_send(s, s->ctx->event_ctx, 802 s->ctx->samr.samr_handle, 803 &s->userinfo, s->monitor_fn); 788 804 if (composite_nomem(info_req, c)) return; 789 805 … … 801 817 struct user_info_state *s; 802 818 803 c = talloc_get_type (ctx->async.private_data, struct composite_context);804 s = talloc_get_type (c->private_data, struct user_info_state);819 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 820 s = talloc_get_type_abort(c->private_data, struct user_info_state); 805 821 806 822 /* receive result of userinfo call */ … … 831 847 struct samr_UserInfo21 *info; 832 848 833 s = talloc_get_type (c->private_data, struct user_info_state);849 s = talloc_get_type_abort(c->private_data, struct user_info_state); 834 850 info = &s->userinfo.out.info.info21; 835 851 … … 954 970 955 971 /* make sure we have lsa domain handle before doing anything */ 956 prereq_met = lsa_domain_opened(ctx, s->domain_name, &c, &s->domain_open,972 prereq_met = lsa_domain_opened(ctx, c, s->domain_name, &c, &s->domain_open, 957 973 continue_lsa_domain_opened, monitor); 958 974 if (!prereq_met) return c; … … 985 1001 struct tevent_req *subreq; 986 1002 987 c = talloc_get_type (ctx->async.private_data, struct composite_context);988 s = talloc_get_type (c->private_data, struct userlist_state);1003 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 1004 s = talloc_get_type_abort(c->private_data, struct userlist_state); 989 1005 990 1006 /* receive lsa domain handle */ … … 1019 1035 1020 1036 c = tevent_req_callback_data(subreq, struct composite_context); 1021 s = talloc_get_type (c->private_data, struct userlist_state);1037 s = talloc_get_type_abort(c->private_data, struct userlist_state); 1022 1038 1023 1039 /* receive result of rpc request */ … … 1030 1046 1031 1047 /* make sure we have samr domain handle before continuing */ 1032 prereq_met = samr_domain_opened(s->ctx, s->domain_name, &c, &s->domain_open,1048 prereq_met = samr_domain_opened(s->ctx, c, s->domain_name, &c, &s->domain_open, 1033 1049 continue_samr_domain_opened, s->monitor_fn); 1034 1050 if (!prereq_met) return; … … 1065 1081 struct tevent_req *subreq; 1066 1082 1067 c = talloc_get_type (ctx->async.private_data, struct composite_context);1068 s = talloc_get_type (c->private_data, struct userlist_state);1083 c = talloc_get_type_abort(ctx->async.private_data, struct composite_context); 1084 s = talloc_get_type_abort(c->private_data, struct userlist_state); 1069 1085 1070 1086 /* receive samr domain handle */ … … 1103 1119 1104 1120 c = tevent_req_callback_data(subreq, struct composite_context); 1105 s = talloc_get_type (c->private_data, struct userlist_state);1121 s = talloc_get_type_abort(c->private_data, struct userlist_state); 1106 1122 1107 1123 /* receive result of rpc request */ … … 1149 1165 /* that's it */ 1150 1166 composite_done(c); 1167 return; 1151 1168 1152 1169 } else { 1153 1170 /* something went wrong */ 1154 1171 composite_error(c, c->status); 1172 return; 1155 1173 } 1156 1174 } … … 1181 1199 NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) { 1182 1200 1183 s = talloc_get_type (c->private_data, struct userlist_state);1201 s = talloc_get_type_abort(c->private_data, struct userlist_state); 1184 1202 1185 1203 /* get results from composite context */ -
vendor/current/source4/libnet/libnet_vampire.c
r740 r988 163 163 settings.machine_password = generate_random_password(s, 16, 255); 164 164 settings.targetdir = s->targetdir; 165 165 settings.use_ntvfs = true; 166 166 status = provision_bare(s, s->lp_ctx, &settings, &result); 167 167 … … 220 220 const struct libnet_BecomeDC_StoreChunk *c) 221 221 { 222 struct schema_list {223 struct schema_list *next, *prev;224 const struct drsuapi_DsReplicaObjectListItemEx *obj;225 };226 227 222 WERROR status; 228 223 struct dsdb_schema_prefixmap *pfm_remote; 229 224 const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr; 230 struct schema_list *schema_list = NULL, *schema_list_item, *schema_list_next_item;231 struct dsdb_schema *working_schema;232 225 struct dsdb_schema *provision_schema; 233 226 uint32_t object_count = 0; 234 227 struct drsuapi_DsReplicaObjectListItemEx *first_object; 235 const struct drsuapi_DsReplicaObjectListItemEx *cur;236 228 uint32_t linked_attributes_count; 237 229 struct drsuapi_DsReplicaLinkedAttribute *linked_attributes; … … 244 236 struct ldb_message_element *prefixMap_el; 245 237 uint32_t i; 246 int ret , pass_no;238 int ret; 247 239 bool ok; 248 240 uint64_t seq_num; 249 uint32_t ignore_attids[] = { 250 DRSUAPI_ATTID_auxiliaryClass, 251 DRSUAPI_ATTID_mayContain, 252 DRSUAPI_ATTID_mustContain, 253 DRSUAPI_ATTID_possSuperiors, 254 DRSUAPI_ATTID_systemPossSuperiors, 255 DRSUAPI_ATTID_INVALID 256 }; 241 uint32_t cycle_before_switching; 257 242 258 243 DEBUG(0,("Analyze and apply schema objects\n")); … … 289 274 return NT_STATUS_INVALID_PARAMETER; 290 275 } 276 /* We must set these up to ensure the replMetaData is written 277 * correctly, before our NTDS Settings entry is replicated */ 278 ok = samdb_set_ntds_invocation_id(s->ldb, &c->dest_dsa->invocation_id); 279 if (!ok) { 280 DEBUG(0,("Failed to set cached ntds invocationId\n")); 281 return NT_STATUS_FOOBAR; 282 } 283 ok = samdb_set_ntds_objectGUID(s->ldb, &c->dest_dsa->ntds_guid); 284 if (!ok) { 285 DEBUG(0,("Failed to set cached ntds objectGUID\n")); 286 return NT_STATUS_FOOBAR; 287 } 291 288 292 289 status = dsdb_schema_pfm_from_drsuapi_pfm(mapping_ctr, true, … … 309 306 s_dsa->other_info->dns_name = tmp_dns_name; 310 307 311 schema_ldb = provision_get_schema(s, s->lp_ctx, &s->prefixmap_blob); 308 if (s->self_made_schema == NULL) { 309 DEBUG(0,("libnet_vampire_cb_apply_schema: called with out self_made_schema\n")); 310 return NT_STATUS_INTERNAL_ERROR; 311 } 312 313 schema_ldb = provision_get_schema(s, s->lp_ctx, 314 c->forest->schema_dn_str, 315 &s->prefixmap_blob); 312 316 if (!schema_ldb) { 313 317 DEBUG(0,("Failed to re-load from local provision using remote prefixMap. " … … 324 328 } 325 329 326 /* create a list of objects yet to be converted */ 327 for (cur = first_object; cur; cur = cur->next_object) { 328 schema_list_item = talloc(s, struct schema_list); 329 schema_list_item->obj = cur; 330 DLIST_ADD_END(schema_list, schema_list_item, struct schema_list); 331 } 332 333 /* resolve objects until all are resolved and in local schema */ 334 pass_no = 1; 335 working_schema = provision_schema; 336 337 while (schema_list) { 338 uint32_t converted_obj_count = 0; 339 uint32_t failed_obj_count = 0; 340 TALLOC_CTX *tmp_ctx = talloc_new(s); 341 NT_STATUS_HAVE_NO_MEMORY(tmp_ctx); 342 343 for (schema_list_item = schema_list; schema_list_item; schema_list_item=schema_list_next_item) { 344 struct dsdb_extended_replicated_object object; 345 346 cur = schema_list_item->obj; 347 348 /* Save the next item, now we have saved out 349 * the current one, so we can DLIST_REMOVE it 350 * safely */ 351 schema_list_next_item = schema_list_item->next; 352 353 /* 354 * Convert the objects into LDB messages using the 355 * schema we have so far. It's ok if we fail to convert 356 * an object. We should convert more objects on next pass. 357 */ 358 status = dsdb_convert_object_ex(s->ldb, working_schema, pfm_remote, 359 cur, c->gensec_skey, 360 ignore_attids, 361 tmp_ctx, &object); 362 if (!W_ERROR_IS_OK(status)) { 363 DEBUG(1,("Warning: Failed to convert schema object %s into ldb msg\n", 364 cur->object.identifier->dn)); 365 366 failed_obj_count++; 367 } else { 368 /* 369 * Convert the schema from ldb_message format 370 * (OIDs as OID strings) into schema, using 371 * the remote prefixMap 372 */ 373 status = dsdb_schema_set_el_from_ldb_msg(s->ldb, 374 s->self_made_schema, 375 object.msg); 376 if (!W_ERROR_IS_OK(status)) { 377 DEBUG(1,("Warning: failed to convert object %s into a schema element: %s\n", 378 ldb_dn_get_linearized(object.msg->dn), 379 win_errstr(status))); 380 failed_obj_count++; 381 } else { 382 DLIST_REMOVE(schema_list, schema_list_item); 383 converted_obj_count++; 384 } 385 } 386 } 387 talloc_free(tmp_ctx); 388 389 DEBUG(4,("Schema load pass %d: %d/%d of %d objects left to be converted.\n", 390 pass_no, failed_obj_count, converted_obj_count, object_count)); 391 pass_no++; 392 393 /* check if we converted any objects in this pass */ 394 if (converted_obj_count == 0) { 395 DEBUG(0,("Can't continue Schema load: didn't manage to convert any objects: all %d remaining of %d objects failed to convert\n", failed_obj_count, object_count)); 396 return NT_STATUS_INTERNAL_ERROR; 397 } 398 399 if (schema_list) { 400 /* prepare for another cycle */ 401 working_schema = s->self_made_schema; 402 403 ret = dsdb_setup_sorted_accessors(s->ldb, working_schema); 404 if (LDB_SUCCESS != ret) { 405 DEBUG(0,("Failed to create schema-cache indexes!\n")); 406 return NT_STATUS_INTERNAL_ERROR; 407 } 408 } 409 }; 330 cycle_before_switching = lpcfg_parm_long(s->lp_ctx, NULL, 331 "become dc", 332 "schema convert retrial", 1); 333 334 status = dsdb_repl_resolve_working_schema(s->ldb, s, 335 pfm_remote, 336 cycle_before_switching, 337 provision_schema, 338 s->self_made_schema, 339 object_count, 340 first_object); 341 if (!W_ERROR_IS_OK(status)) { 342 DEBUG(0, ("%s: dsdb_repl_resolve_working_schema() failed: %s", 343 __location__, win_errstr(status))); 344 return werror_to_ntstatus(status); 345 } 410 346 411 347 /* free temp objects for 1st conversion phase */ 412 348 talloc_unlink(s, provision_schema); 413 TALLOC_FREE(schema_list);414 349 415 350 /* … … 439 374 uptodateness_vector, 440 375 c->gensec_skey, 376 0, 441 377 s, &schema_objs); 442 378 if (!W_ERROR_IS_OK(status)) { … … 480 416 prefixMap_el->flags = LDB_FLAG_MOD_ADD; 481 417 482 ret = ldb_modify(s->ldb, msg);418 ret = dsdb_modify(s->ldb, msg, DSDB_FLAG_AS_SYSTEM); 483 419 if (ret != LDB_SUCCESS) { 484 420 DEBUG(0,("Failed to add prefixMap: %s\n", ldb_errstring(s->ldb))); … … 488 424 talloc_free(s_dsa); 489 425 talloc_free(schema_objs); 490 491 /* We must set these up to ensure the replMetaData is written492 * correctly, before our NTDS Settings entry is replicated */493 ok = samdb_set_ntds_invocation_id(s->ldb, &c->dest_dsa->invocation_id);494 if (!ok) {495 DEBUG(0,("Failed to set cached ntds invocationId\n"));496 return NT_STATUS_FOOBAR;497 }498 ok = samdb_set_ntds_objectGUID(s->ldb, &c->dest_dsa->ntds_guid);499 if (!ok) {500 DEBUG(0,("Failed to set cached ntds objectGUID\n"));501 return NT_STATUS_FOOBAR;502 }503 426 504 427 s->schema = dsdb_get_schema(s->ldb, s); … … 518 441 const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr; 519 442 uint32_t nc_object_count; 443 uint32_t nc_total_received = 0; 520 444 uint32_t object_count; 521 445 struct drsuapi_DsReplicaObjectListItemEx *first_object; … … 523 447 uint32_t nc_linked_attributes_count; 524 448 uint32_t linked_attributes_count; 525 struct drsuapi_DsReplicaLinkedAttribute *linked_attributes;526 449 527 450 switch (c->ctr_level) { … … 533 456 nc_linked_attributes_count = 0; 534 457 linked_attributes_count = 0; 535 linked_attributes = NULL;536 458 break; 537 459 case 6: … … 542 464 nc_linked_attributes_count = c->ctr6->nc_linked_attributes_count; 543 465 linked_attributes_count = c->ctr6->linked_attributes_count; 544 linked_attributes = c->ctr6->linked_attributes;545 466 break; 546 467 default: … … 548 469 } 549 470 471 if (!s->schema_part.first_object) { 472 nc_total_received = object_count; 473 } else { 474 nc_total_received = s->schema_part.object_count + object_count; 475 } 550 476 if (nc_object_count) { 551 477 DEBUG(0,("Schema-DN[%s] objects[%u/%u] linked_values[%u/%u]\n", 552 c->partition->nc.dn, object_count, nc_object_count,478 c->partition->nc.dn, nc_total_received, nc_object_count, 553 479 linked_attributes_count, nc_linked_attributes_count)); 554 480 } else { 555 481 DEBUG(0,("Schema-DN[%s] objects[%u] linked_values[%u]\n", 556 c->partition->nc.dn, object_count, linked_attributes_count));482 c->partition->nc.dn, nc_total_received, linked_attributes_count)); 557 483 } 558 484 … … 627 553 const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector; 628 554 struct dsdb_extended_replicated_objects *objs; 555 uint32_t req_replica_flags; 556 uint32_t dsdb_repl_flags = 0; 629 557 struct repsFromTo1 *s_dsa; 630 558 char *tmp_dns_name; 631 559 uint32_t i; 632 560 uint64_t seq_num; 561 bool is_exop = false; 633 562 634 563 s_dsa = talloc_zero(s, struct repsFromTo1); … … 668 597 } 669 598 599 switch (c->req_level) { 600 case 0: 601 /* none */ 602 req_replica_flags = 0; 603 break; 604 case 5: 605 if (c->req5->extended_op != DRSUAPI_EXOP_NONE) { 606 is_exop = true; 607 } 608 req_replica_flags = c->req5->replica_flags; 609 break; 610 case 8: 611 if (c->req8->extended_op != DRSUAPI_EXOP_NONE) { 612 is_exop = true; 613 } 614 req_replica_flags = c->req8->replica_flags; 615 break; 616 case 10: 617 if (c->req10->extended_op != DRSUAPI_EXOP_NONE) { 618 is_exop = true; 619 } 620 req_replica_flags = c->req10->replica_flags; 621 break; 622 default: 623 return NT_STATUS_INVALID_PARAMETER; 624 } 625 626 if (req_replica_flags & DRSUAPI_DRS_CRITICAL_ONLY) { 627 /* 628 * If we only replicate the critical objects 629 * we should not remember what we already 630 * got, as it is incomplete. 631 */ 632 ZERO_STRUCT(s_dsa->highwatermark); 633 uptodateness_vector = NULL; 634 } 635 636 /* TODO: avoid hardcoded flags */ 670 637 s_dsa->replica_flags = DRSUAPI_DRS_WRIT_REP 671 638 | DRSUAPI_DRS_INIT_SYNC … … 687 654 s->total_objects += object_count; 688 655 689 if (nc_object_count) { 690 DEBUG(0,("Partition[%s] objects[%u/%u] linked_values[%u/%u]\n", 691 c->partition->nc.dn, s->total_objects, nc_object_count, 692 linked_attributes_count, nc_linked_attributes_count)); 656 if (is_exop) { 657 if (nc_object_count) { 658 DEBUG(0,("Exop on[%s] objects[%u/%u] linked_values[%u/%u]\n", 659 c->partition->nc.dn, s->total_objects, nc_object_count, 660 linked_attributes_count, nc_linked_attributes_count)); 661 } else { 662 DEBUG(0,("Exop on[%s] objects[%u] linked_values[%u]\n", 663 c->partition->nc.dn, s->total_objects, linked_attributes_count)); 664 } 693 665 } else { 694 DEBUG(0,("Partition[%s] objects[%u] linked_values[%u]\n", 695 c->partition->nc.dn, s->total_objects, linked_attributes_count)); 666 if (nc_object_count) { 667 DEBUG(0,("Partition[%s] objects[%u/%u] linked_values[%u/%u]\n", 668 c->partition->nc.dn, s->total_objects, nc_object_count, 669 linked_attributes_count, nc_linked_attributes_count)); 670 } else { 671 DEBUG(0,("Partition[%s] objects[%u] linked_values[%u]\n", 672 c->partition->nc.dn, s->total_objects, linked_attributes_count)); 673 } 696 674 } 697 675 … … 701 679 DEBUG(0,(__location__ ": Schema is not loaded yet!\n")); 702 680 return NT_STATUS_INTERNAL_ERROR; 681 } 682 683 if (req_replica_flags & DRSUAPI_DRS_FULL_SYNC_IN_PROGRESS) { 684 dsdb_repl_flags |= DSDB_REPL_FLAG_PRIORITISE_INCOMING; 685 } 686 687 if (req_replica_flags & DRSUAPI_DRS_SPECIAL_SECRET_PROCESSING) { 688 dsdb_repl_flags |= DSDB_REPL_FLAG_EXPECT_NO_SECRETS; 703 689 } 704 690 … … 714 700 uptodateness_vector, 715 701 c->gensec_skey, 702 dsdb_repl_flags, 716 703 s, &objs); 717 704 if (!W_ERROR_IS_OK(status)) { … … 743 730 744 731 if (!linked_attributes[i].identifier) { 745 return NT_STATUS_FOOBAR; 732 DEBUG(0, ("No linked attribute identifier\n")); 733 return NT_STATUS_FOOBAR; 746 734 } 747 735 748 736 if (!linked_attributes[i].value.blob) { 749 return NT_STATUS_FOOBAR; 737 DEBUG(0, ("No linked attribute value\n")); 738 return NT_STATUS_FOOBAR; 750 739 } 751 740 … … 753 742 linked_attributes[i].attid); 754 743 if (!sa) { 744 DEBUG(0, ("Unable to find attribute via attribute id %d\n", linked_attributes[i].attid)); 755 745 return NT_STATUS_FOOBAR; 756 746 } … … 768 758 } 769 759 770 static NTSTATUS update_dnshostname_for_server(TALLOC_CTX *mem_ctx,771 struct ldb_context *ldb,772 const char *server_dn_str,773 const char *netbios_name,774 const char *realm)775 {776 int ret;777 struct ldb_message *msg;778 struct ldb_message_element *el;779 struct ldb_dn *server_dn;780 const char *dNSHostName = strlower_talloc(mem_ctx,781 talloc_asprintf(mem_ctx,782 "%s.%s",783 netbios_name,784 realm));785 msg = ldb_msg_new(mem_ctx);786 if (msg == NULL) {787 return NT_STATUS_NO_MEMORY;788 }789 790 server_dn = ldb_dn_new(mem_ctx, ldb, server_dn_str);791 if (!server_dn) {792 return NT_STATUS_INTERNAL_ERROR;793 }794 795 msg->dn = server_dn;796 ret = ldb_msg_add_empty(msg, "dNSHostName", LDB_FLAG_MOD_ADD, &el);797 if (ret != LDB_SUCCESS) {798 return NT_STATUS_INTERNAL_ERROR;799 }800 801 ret = ldb_msg_add_steal_string(msg,802 "dNSHostName",803 talloc_asprintf(el->values, "%s", dNSHostName));804 if (ret != LDB_SUCCESS) {805 return NT_STATUS_INTERNAL_ERROR;806 }807 808 ret = dsdb_modify(ldb, msg, DSDB_MODIFY_PERMISSIVE);809 if (ret != LDB_SUCCESS) {810 DEBUG(0,(__location__ ": Failed to add dnsHostName to the Server object: %s\n",811 ldb_errstring(ldb)));812 return NT_STATUS_INTERNAL_ERROR;813 }814 815 return NT_STATUS_OK;816 }817 818 819 NTSTATUS libnet_Vampire(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,820 struct libnet_Vampire *r)821 {822 struct libnet_JoinDomain *join;823 struct libnet_Replicate rep;824 NTSTATUS status;825 826 const char *account_name;827 const char *netbios_name;828 829 r->out.error_string = NULL;830 831 join = talloc_zero(mem_ctx, struct libnet_JoinDomain);832 if (!join) {833 return NT_STATUS_NO_MEMORY;834 }835 836 if (r->in.netbios_name != NULL) {837 netbios_name = r->in.netbios_name;838 } else {839 netbios_name = talloc_reference(join, lpcfg_netbios_name(ctx->lp_ctx));840 if (!netbios_name) {841 talloc_free(join);842 r->out.error_string = NULL;843 return NT_STATUS_NO_MEMORY;844 }845 }846 847 account_name = talloc_asprintf(join, "%s$", netbios_name);848 if (!account_name) {849 talloc_free(join);850 r->out.error_string = NULL;851 return NT_STATUS_NO_MEMORY;852 }853 854 /* Re-use the domain we are joining as the domain for the user855 * to be authenticated with, unless they specified856 * otherwise */857 cli_credentials_set_domain(ctx->cred, r->in.domain_name, CRED_GUESS_ENV);858 859 join->in.domain_name = r->in.domain_name;860 join->in.account_name = account_name;861 join->in.netbios_name = netbios_name;862 join->in.level = LIBNET_JOINDOMAIN_AUTOMATIC;863 join->in.acct_type = ACB_WSTRUST;864 join->in.recreate_account = false;865 status = libnet_JoinDomain(ctx, join, join);866 if (!NT_STATUS_IS_OK(status)) {867 r->out.error_string = talloc_steal(mem_ctx, join->out.error_string);868 talloc_free(join);869 return status;870 }871 872 rep.in.domain_name = join->out.domain_name;873 rep.in.netbios_name = netbios_name;874 rep.in.targetdir = r->in.targetdir;875 rep.in.domain_sid = join->out.domain_sid;876 rep.in.realm = join->out.realm;877 rep.in.server = join->out.samr_binding->host;878 rep.in.join_password = join->out.join_password;879 rep.in.kvno = join->out.kvno;880 881 status = libnet_Replicate(ctx, mem_ctx, &rep);882 883 r->out.domain_sid = join->out.domain_sid;884 r->out.domain_name = join->out.domain_name;885 r->out.error_string = rep.out.error_string;886 887 return status;888 }889 890 891 892 NTSTATUS libnet_Replicate(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,893 struct libnet_Replicate *r)894 {895 struct provision_store_self_join_settings *set_secrets;896 struct libnet_BecomeDC b;897 struct libnet_vampire_cb_state *s;898 struct ldb_message *msg;899 const char *error_string;900 int ldb_ret;901 uint32_t i;902 NTSTATUS status;903 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);904 const char *account_name;905 const char *netbios_name;906 907 r->out.error_string = NULL;908 909 netbios_name = r->in.netbios_name;910 account_name = talloc_asprintf(tmp_ctx, "%s$", netbios_name);911 if (!account_name) {912 talloc_free(tmp_ctx);913 r->out.error_string = NULL;914 return NT_STATUS_NO_MEMORY;915 }916 917 /* Re-use the domain we are joining as the domain for the user918 * to be authenticated with, unless they specified919 * otherwise */920 cli_credentials_set_domain(ctx->cred, r->in.domain_name, CRED_GUESS_ENV);921 922 s = libnet_vampire_cb_state_init(mem_ctx, ctx->lp_ctx, ctx->event_ctx,923 netbios_name, r->in.domain_name, r->in.realm,924 r->in.targetdir);925 if (!s) {926 return NT_STATUS_NO_MEMORY;927 }928 talloc_steal(s, tmp_ctx);929 930 ZERO_STRUCT(b);931 932 /* Be more robust:933 * We now know the domain and realm for sure - if they didn't934 * put one on the command line, use this for the rest of the935 * join */936 cli_credentials_set_realm(ctx->cred, r->in.realm, CRED_GUESS_ENV);937 cli_credentials_set_domain(ctx->cred, r->in.domain_name, CRED_GUESS_ENV);938 939 /* Now set these values into the smb.conf - we probably had940 * empty or useless defaults here from whatever smb.conf we941 * started with */942 lpcfg_set_cmdline(s->lp_ctx, "realm", r->in.realm);943 lpcfg_set_cmdline(s->lp_ctx, "workgroup", r->in.domain_name);944 945 b.in.domain_dns_name = r->in.realm;946 b.in.domain_netbios_name = r->in.domain_name;947 b.in.domain_sid = r->in.domain_sid;948 b.in.source_dsa_address = r->in.server;949 b.in.dest_dsa_netbios_name = netbios_name;950 951 b.in.callbacks.private_data = s;952 b.in.callbacks.check_options = libnet_vampire_cb_check_options;953 b.in.callbacks.prepare_db = libnet_vampire_cb_prepare_db;954 b.in.callbacks.schema_chunk = libnet_vampire_cb_schema_chunk;955 b.in.callbacks.config_chunk = libnet_vampire_cb_store_chunk;956 b.in.callbacks.domain_chunk = libnet_vampire_cb_store_chunk;957 958 b.in.rodc_join = lpcfg_parm_bool(s->lp_ctx, NULL, "repl", "RODC", false);959 960 status = libnet_BecomeDC(ctx, s, &b);961 if (!NT_STATUS_IS_OK(status)) {962 printf("libnet_BecomeDC() failed - %s\n", nt_errstr(status));963 talloc_free(s);964 return status;965 }966 967 msg = ldb_msg_new(s);968 if (!msg) {969 printf("ldb_msg_new() failed\n");970 talloc_free(s);971 return NT_STATUS_NO_MEMORY;972 }973 msg->dn = ldb_dn_new(msg, s->ldb, "@ROOTDSE");974 if (!msg->dn) {975 printf("ldb_msg_new(@ROOTDSE) failed\n");976 talloc_free(s);977 return NT_STATUS_NO_MEMORY;978 }979 980 ldb_ret = ldb_msg_add_string(msg, "isSynchronized", "TRUE");981 if (ldb_ret != LDB_SUCCESS) {982 printf("ldb_msg_add_string(msg, isSynchronized, TRUE) failed: %d\n", ldb_ret);983 talloc_free(s);984 return NT_STATUS_NO_MEMORY;985 }986 987 for (i=0; i < msg->num_elements; i++) {988 msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;989 }990 991 printf("mark ROOTDSE with isSynchronized=TRUE\n");992 ldb_ret = ldb_modify(s->ldb, msg);993 if (ldb_ret != LDB_SUCCESS) {994 printf("ldb_modify() failed: %d : %s\n", ldb_ret, ldb_errstring(s->ldb));995 talloc_free(s);996 return NT_STATUS_INTERNAL_DB_ERROR;997 }998 /* during dcpromo the 2nd computer adds dNSHostName attribute to his Server object999 * the attribute appears on the original DC after replication1000 */1001 status = update_dnshostname_for_server(s, s->ldb, s->server_dn_str, s->netbios_name, s->realm);1002 if (!NT_STATUS_IS_OK(status)) {1003 printf("Failed to update dNSHostName on Server object - %s\n", nt_errstr(status));1004 talloc_free(s);1005 return status;1006 }1007 /* prepare the transaction - this prepares to commit all the changes in1008 the ldb from the whole vampire. Note that this1009 triggers the writing of the linked attribute backlinks.1010 */1011 if (ldb_transaction_prepare_commit(s->ldb) != LDB_SUCCESS) {1012 printf("Failed to prepare_commit vampire transaction: %s\n", ldb_errstring(s->ldb));1013 return NT_STATUS_INTERNAL_DB_ERROR;1014 }1015 1016 set_secrets = talloc(s, struct provision_store_self_join_settings);1017 if (!set_secrets) {1018 r->out.error_string = NULL;1019 talloc_free(s);1020 return NT_STATUS_NO_MEMORY;1021 }1022 1023 ZERO_STRUCTP(set_secrets);1024 set_secrets->domain_name = r->in.domain_name;1025 set_secrets->realm = r->in.realm;1026 set_secrets->netbios_name = netbios_name;1027 set_secrets->secure_channel_type = SEC_CHAN_BDC;1028 set_secrets->machine_password = r->in.join_password;1029 set_secrets->key_version_number = r->in.kvno;1030 set_secrets->domain_sid = r->in.domain_sid;1031 1032 status = provision_store_self_join(ctx, s->lp_ctx, ctx->event_ctx, set_secrets, &error_string);1033 if (!NT_STATUS_IS_OK(status)) {1034 r->out.error_string = talloc_steal(mem_ctx, error_string);1035 talloc_free(s);1036 return status;1037 }1038 1039 /* commit the transaction now we know the secrets were written1040 * out properly1041 */1042 if (ldb_transaction_commit(s->ldb) != LDB_SUCCESS) {1043 printf("Failed to commit vampire transaction\n");1044 return NT_STATUS_INTERNAL_DB_ERROR;1045 }1046 1047 talloc_free(s);1048 1049 return NT_STATUS_OK;1050 } -
vendor/current/source4/libnet/prereq_domain.c
r414 r988 30 30 31 31 32 bool samr_domain_opened(struct libnet_context *ctx, const char *domain_name, 32 bool samr_domain_opened(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, 33 const char *domain_name, 33 34 struct composite_context **parent_ctx, 34 35 struct libnet_DomainOpen *domain_open, … … 46 47 */ 47 48 48 if ( policy_handle_empty(&ctx->samr.handle)) {49 if (ndr_policy_handle_empty(&ctx->samr.handle)) { 49 50 domain_open->in.type = DOMAIN_SAMR; 50 51 domain_open->in.domain_name = cli_credentials_get_domain(ctx->cred); … … 63 64 */ 64 65 65 if ( policy_handle_empty(&ctx->samr.handle) ||66 if (ndr_policy_handle_empty(&ctx->samr.handle) || 66 67 !strequal(domain_name, ctx->samr.name)) { 67 68 domain_open->in.type = DOMAIN_SAMR; … … 77 78 78 79 /* send request to open the domain */ 79 domopen_req = libnet_DomainOpen_send(ctx, domain_open, monitor);80 domopen_req = libnet_DomainOpen_send(ctx, mem_ctx, domain_open, monitor); 80 81 if (composite_nomem(domopen_req, *parent_ctx)) return false; 81 82 … … 85 86 86 87 87 bool lsa_domain_opened(struct libnet_context *ctx, const char *domain_name, 88 bool lsa_domain_opened(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, 89 const char *domain_name, 88 90 struct composite_context **parent_ctx, 89 91 struct libnet_DomainOpen *domain_open, … … 101 103 */ 102 104 103 if ( policy_handle_empty(&ctx->lsa.handle)) {105 if (ndr_policy_handle_empty(&ctx->lsa.handle)) { 104 106 domain_open->in.type = DOMAIN_LSA; 105 107 domain_open->in.domain_name = cli_credentials_get_domain(ctx->cred); … … 120 122 */ 121 123 122 if ( policy_handle_empty(&ctx->lsa.handle) ||124 if (ndr_policy_handle_empty(&ctx->lsa.handle) || 123 125 !strequal(domain_name, ctx->lsa.name)) { 124 126 domain_open->in.type = DOMAIN_LSA; … … 134 136 135 137 /* send request to open the domain */ 136 domopen_req = libnet_DomainOpen_send(ctx, domain_open, monitor);138 domopen_req = libnet_DomainOpen_send(ctx, mem_ctx, domain_open, monitor); 137 139 /* see the comment above to find out why true is returned here */ 138 140 if (composite_nomem(domopen_req, *parent_ctx)) return true; -
vendor/current/source4/libnet/py_net.c
r740 r988 2 2 Unix SMB/CIFS implementation. 3 3 Samba utility functions 4 4 5 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008-2010 5 6 Copyright (C) Kamen Mazdrashki <kamen.mazdrashki@postpath.com> 2009 … … 21 22 #include <Python.h> 22 23 #include "includes.h" 23 #include <ldb.h>24 24 #include <pyldb.h> 25 #include <pytalloc.h> 25 26 #include "libnet.h" 26 27 #include "auth/credentials/pycredentials.h" … … 30 31 #include "auth/gensec/gensec.h" 31 32 #include "librpc/rpc/pyrpc_util.h" 33 #include "libcli/resolve/resolve.h" 32 34 #include "libcli/finddc.h" 33 #include "libcli/resolve/resolve.h" 35 #include "dsdb/samdb/samdb.h" 36 #include "py_net.h" 37 #include "librpc/rpc/pyrpc_util.h" 34 38 35 39 void initnet(void); 36 40 37 typedef struct { 38 PyObject_HEAD 39 TALLOC_CTX *mem_ctx; 40 struct libnet_context *libnet_ctx; 41 struct tevent_context *ev; 42 } py_net_Object; 43 44 static PyObject *py_net_join(py_net_Object *self, PyObject *args, PyObject *kwargs) 45 { 46 struct libnet_Join r; 41 static PyObject *py_net_join_member(py_net_Object *self, PyObject *args, PyObject *kwargs) 42 { 43 struct libnet_Join_member r; 44 int _level = 0; 47 45 NTSTATUS status; 48 46 PyObject *result; 49 47 TALLOC_CTX *mem_ctx; 50 const char *kwnames[] = { "domain_name", "netbios_name", "join_type", "level", NULL }; 51 52 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ssii:Join", discard_const_p(char *, kwnames), 48 const char *kwnames[] = { "domain_name", "netbios_name", "level", "machinepass", NULL }; 49 50 ZERO_STRUCT(r); 51 52 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ssi|z:Join", discard_const_p(char *, kwnames), 53 53 &r.in.domain_name, &r.in.netbios_name, 54 &r.in.join_type, &r.in.level)) 55 return NULL; 54 &_level, 55 &r.in.account_pass)) { 56 return NULL; 57 } 58 r.in.level = _level; 56 59 57 60 mem_ctx = talloc_new(self->mem_ctx); … … 61 64 } 62 65 63 status = libnet_Join (self->libnet_ctx, mem_ctx, &r);66 status = libnet_Join_member(self->libnet_ctx, mem_ctx, &r); 64 67 if (NT_STATUS_IS_ERR(status)) { 65 68 PyErr_SetString(PyExc_RuntimeError, r.out.error_string?r.out.error_string:nt_errstr(status)); … … 77 80 } 78 81 79 static const char py_net_join_ doc[] = "join(domain_name, netbios_name, join_type, level) -> (join_password, domain_sid, domain_name)\n\n" \82 static const char py_net_join_member_doc[] = "join_member(domain_name, netbios_name, level) -> (join_password, domain_sid, domain_name)\n\n" \ 80 83 "Join the domain with the specified name."; 81 84 82 static PyObject *py_net_set_password(py_net_Object *self, PyObject *args, PyObject *kwargs) 83 { 84 union libnet_SetPassword r; 85 NTSTATUS status; 86 PyObject *py_creds; 85 static PyObject *py_net_change_password(py_net_Object *self, PyObject *args, PyObject *kwargs) 86 { 87 union libnet_ChangePassword r; 88 NTSTATUS status; 87 89 TALLOC_CTX *mem_ctx; 88 90 struct tevent_context *ev; 89 const char *kwnames[] = { "account_name", "domain_name", "newpassword", "credentials", NULL }; 91 const char *kwnames[] = { "newpassword", NULL }; 92 93 ZERO_STRUCT(r); 94 95 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:change_password", 96 discard_const_p(char *, kwnames), 97 &r.generic.in.newpassword)) { 98 return NULL; 99 } 100 101 r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; 102 r.generic.in.account_name = cli_credentials_get_username(self->libnet_ctx->cred); 103 r.generic.in.domain_name = cli_credentials_get_domain(self->libnet_ctx->cred); 104 r.generic.in.oldpassword = cli_credentials_get_password(self->libnet_ctx->cred); 105 106 /* FIXME: we really need to get a context from the caller or we may end 107 * up with 2 event contexts */ 108 ev = s4_event_context_init(NULL); 109 110 mem_ctx = talloc_new(ev); 111 if (mem_ctx == NULL) { 112 PyErr_NoMemory(); 113 return NULL; 114 } 115 116 status = libnet_ChangePassword(self->libnet_ctx, mem_ctx, &r); 117 if (NT_STATUS_IS_ERR(status)) { 118 PyErr_SetString(PyExc_RuntimeError, 119 r.generic.out.error_string?r.generic.out.error_string:nt_errstr(status)); 120 talloc_free(mem_ctx); 121 return NULL; 122 } 123 124 talloc_free(mem_ctx); 125 126 Py_RETURN_NONE; 127 } 128 129 static const char py_net_change_password_doc[] = "change_password(newpassword) -> True\n\n" \ 130 "Change password for a user. You must supply credential with enough rights to do this.\n\n" \ 131 "Sample usage is:\n" \ 132 "net.change_password(newpassword=<new_password>)\n"; 133 134 135 static PyObject *py_net_set_password(py_net_Object *self, PyObject *args, PyObject *kwargs) 136 { 137 union libnet_SetPassword r; 138 NTSTATUS status; 139 TALLOC_CTX *mem_ctx; 140 struct tevent_context *ev; 141 const char *kwnames[] = { "account_name", "domain_name", "newpassword", NULL }; 142 143 ZERO_STRUCT(r); 90 144 91 145 r.generic.level = LIBNET_SET_PASSWORD_GENERIC; 92 146 93 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sssO:set_password", discard_const_p(char *, kwnames), 94 &r.generic.in.account_name, &r.generic.in.domain_name, 95 &r.generic.in.newpassword, &py_creds)) { 147 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sss:set_password", 148 discard_const_p(char *, kwnames), 149 &r.generic.in.account_name, 150 &r.generic.in.domain_name, 151 &r.generic.in.newpassword)) { 96 152 return NULL; 97 153 } … … 123 179 "Set password for a user. You must supply credential with enough rights to do this.\n\n" \ 124 180 "Sample usage is:\n" \ 125 "net.set_password(account_name=<account_name>,\n" \ 126 " domain_name=domain_name,\n" \ 127 " newpassword=new_pass)\n"; 128 129 130 static PyObject *py_net_export_keytab(py_net_Object *self, PyObject *args, PyObject *kwargs) 131 { 132 struct libnet_export_keytab r; 133 TALLOC_CTX *mem_ctx; 134 const char *kwnames[] = { "keytab", NULL }; 135 NTSTATUS status; 136 137 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:export_keytab", discard_const_p(char *, kwnames), 138 &r.in.keytab_name)) { 139 return NULL; 140 } 141 142 mem_ctx = talloc_new(self->mem_ctx); 143 if (mem_ctx == NULL) { 144 PyErr_NoMemory(); 145 return NULL; 146 } 147 148 status = libnet_export_keytab(self->libnet_ctx, mem_ctx, &r); 149 if (NT_STATUS_IS_ERR(status)) { 150 PyErr_SetString(PyExc_RuntimeError, 151 r.out.error_string?r.out.error_string:nt_errstr(status)); 152 talloc_free(mem_ctx); 153 return NULL; 154 } 155 156 talloc_free(mem_ctx); 157 158 Py_RETURN_NONE; 159 } 160 161 static const char py_net_export_keytab_doc[] = "export_keytab(keytab, name)\n\n" 162 "Export the DC keytab to a keytab file."; 181 "net.set_password(account_name=account_name, domain_name=domain_name, newpassword=new_pass)\n"; 182 163 183 164 184 static PyObject *py_net_time(py_net_Object *self, PyObject *args, PyObject *kwargs) … … 273 293 static const char py_net_delete_user_doc[] = "delete_user(username)\n" 274 294 "Delete a user."; 275 276 static PyObject *py_dom_sid_FromSid(struct dom_sid *sid)277 {278 PyObject *mod_security, *dom_sid_Type;279 280 mod_security = PyImport_ImportModule("samba.dcerpc.security");281 if (mod_security == NULL)282 return NULL;283 284 dom_sid_Type = PyObject_GetAttrString(mod_security, "dom_sid");285 if (dom_sid_Type == NULL)286 return NULL;287 288 return py_talloc_reference((PyTypeObject *)dom_sid_Type, sid);289 }290 291 static PyObject *py_net_vampire(py_net_Object *self, PyObject *args, PyObject *kwargs)292 {293 const char *kwnames[] = { "domain", "target_dir", NULL };294 NTSTATUS status;295 TALLOC_CTX *mem_ctx;296 PyObject *ret;297 struct libnet_Vampire r;298 299 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|z", discard_const_p(char *, kwnames),300 &r.in.domain_name, &r.in.targetdir)) {301 return NULL;302 }303 304 r.in.netbios_name = lpcfg_netbios_name(self->libnet_ctx->lp_ctx);305 r.out.error_string = NULL;306 307 mem_ctx = talloc_new(NULL);308 if (mem_ctx == NULL) {309 PyErr_NoMemory();310 return NULL;311 }312 313 status = libnet_Vampire(self->libnet_ctx, mem_ctx, &r);314 315 if (!NT_STATUS_IS_OK(status)) {316 PyErr_SetString(PyExc_RuntimeError,317 r.out.error_string ? r.out.error_string : nt_errstr(status));318 talloc_free(mem_ctx);319 return NULL;320 }321 322 ret = Py_BuildValue("(sO)", r.out.domain_name, py_dom_sid_FromSid(r.out.domain_sid));323 324 talloc_free(mem_ctx);325 326 return ret;327 }328 295 329 296 struct replicate_state { … … 342 309 static PyObject *py_net_replicate_init(py_net_Object *self, PyObject *args, PyObject *kwargs) 343 310 { 344 const char *kwnames[] = { "samdb", "lp", "drspipe", NULL };345 PyObject *py_ldb, *py_lp, *py_drspipe ;311 const char *kwnames[] = { "samdb", "lp", "drspipe", "invocation_id", NULL }; 312 PyObject *py_ldb, *py_lp, *py_drspipe, *py_invocation_id; 346 313 struct ldb_context *samdb; 347 314 struct loadparm_context *lp; … … 349 316 NTSTATUS status; 350 317 351 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO ",318 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO", 352 319 discard_const_p(char *, kwnames), 353 &py_ldb, &py_lp, &py_drspipe)) { 320 &py_ldb, &py_lp, &py_drspipe, 321 &py_invocation_id)) { 354 322 return NULL; 355 323 } … … 365 333 } 366 334 367 samdb = PyLdb_AsLdbContext(py_ldb);335 samdb = pyldb_Ldb_AsLdbContext(py_ldb); 368 336 if (samdb == NULL) { 369 337 PyErr_SetString(PyExc_TypeError, "Expected ldb object"); … … 371 339 return NULL; 372 340 } 341 if (!py_check_dcerpc_type(py_invocation_id, "samba.dcerpc.misc", "GUID")) { 342 343 talloc_free(s); 344 return NULL; 345 } 346 s->dest_dsa.invocation_id = *pytalloc_get_type(py_invocation_id, struct GUID); 373 347 374 348 s->drs_pipe = (dcerpc_InterfaceObject *)(py_drspipe); … … 382 356 383 357 status = gensec_session_key(s->drs_pipe->pipe->conn->security_state.generic_state, 358 s, 384 359 &s->gensec_skey); 385 360 if (!NT_STATUS_IS_OK(status)) { … … 390 365 } 391 366 392 s->forest.dns_name = lpcfg_dnsdomain(lp); 367 s->forest.dns_name = samdb_dn_to_dns_domain(s, ldb_get_root_basedn(samdb)); 368 s->forest.root_dn_str = ldb_dn_get_linearized(ldb_get_root_basedn(samdb)); 369 s->forest.config_dn_str = ldb_dn_get_linearized(ldb_get_config_basedn(samdb)); 370 s->forest.schema_dn_str = ldb_dn_get_linearized(ldb_get_schema_basedn(samdb)); 393 371 394 372 s->chunk.gensec_skey = &s->gensec_skey; … … 397 375 s->chunk.dest_dsa = &s->dest_dsa; 398 376 399 return PyCObject_FromTallocPtr(s);377 return pytalloc_CObject_FromTallocPtr(s); 400 378 } 401 379 … … 406 384 static PyObject *py_net_replicate_chunk(py_net_Object *self, PyObject *args, PyObject *kwargs) 407 385 { 408 const char *kwnames[] = { "state", "level", "ctr", "schema", NULL }; 409 PyObject *py_state, *py_ctr, *py_schema; 386 const char *kwnames[] = { "state", "level", "ctr", 387 "schema", "req_level", "req", 388 NULL }; 389 PyObject *py_state, *py_ctr, *py_schema = Py_None, *py_req = Py_None; 410 390 struct replicate_state *s; 411 391 unsigned level; 392 unsigned req_level = 0; 412 393 NTSTATUS (*chunk_handler)(void *private_data, const struct libnet_BecomeDC_StoreChunk *c); 413 394 NTSTATUS status; 414 395 415 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OIO|O ",396 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OIO|OIO", 416 397 discard_const_p(char *, kwnames), 417 &py_state, &level, &py_ctr, &py_schema)) { 398 &py_state, &level, &py_ctr, 399 &py_schema, &req_level, &py_req)) { 418 400 return NULL; 419 401 } … … 430 412 return NULL; 431 413 } 432 s->chunk.ctr1 = py _talloc_get_ptr(py_ctr);414 s->chunk.ctr1 = pytalloc_get_ptr(py_ctr); 433 415 s->partition.nc = *s->chunk.ctr1->naming_context; 434 416 s->partition.more_data = s->chunk.ctr1->more_data; … … 441 423 return NULL; 442 424 } 443 s->chunk.ctr6 = py _talloc_get_ptr(py_ctr);425 s->chunk.ctr6 = pytalloc_get_ptr(py_ctr); 444 426 s->partition.nc = *s->chunk.ctr6->naming_context; 445 427 s->partition.more_data = s->chunk.ctr6->more_data; … … 452 434 return NULL; 453 435 } 436 437 s->chunk.req5 = NULL; 438 s->chunk.req8 = NULL; 439 s->chunk.req10 = NULL; 440 if (py_req) { 441 switch (req_level) { 442 case 0: 443 break; 444 case 5: 445 if (!py_check_dcerpc_type(py_req, "samba.dcerpc.drsuapi", "DsGetNCChangesRequest5")) { 446 return NULL; 447 } 448 449 s->chunk.req5 = pytalloc_get_ptr(py_req); 450 break; 451 case 8: 452 if (!py_check_dcerpc_type(py_req, "samba.dcerpc.drsuapi", "DsGetNCChangesRequest8")) { 453 return NULL; 454 } 455 456 s->chunk.req8 = pytalloc_get_ptr(py_req); 457 break; 458 case 10: 459 if (!py_check_dcerpc_type(py_req, "samba.dcerpc.drsuapi", "DsGetNCChangesRequest10")) { 460 return NULL; 461 } 462 463 s->chunk.req10 = pytalloc_get_ptr(py_req); 464 break; 465 default: 466 PyErr_Format(PyExc_TypeError, "Bad req_level %u in replicate_chunk", req_level); 467 return NULL; 468 } 469 } 470 s->chunk.req_level = req_level; 454 471 455 472 chunk_handler = libnet_vampire_cb_store_chunk; … … 479 496 find a DC given a domain name and server type 480 497 */ 481 static PyObject *py_net_finddc(py_net_Object *self, PyObject *args )482 { 483 const char *domain _name;498 static PyObject *py_net_finddc(py_net_Object *self, PyObject *args, PyObject *kwargs) 499 { 500 const char *domain = NULL, *address = NULL; 484 501 unsigned server_type; 485 502 NTSTATUS status; … … 487 504 TALLOC_CTX *mem_ctx; 488 505 PyObject *ret; 489 490 if (!PyArg_ParseTuple(args, "sI", &domain_name, &server_type)) { 506 const char * const kwnames[] = { "flags", "domain", "address", NULL }; 507 508 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "I|zz", 509 discard_const_p(char *, kwnames), 510 &server_type, &domain, &address)) { 491 511 return NULL; 492 512 } … … 495 515 496 516 io = talloc_zero(mem_ctx, struct finddcs); 497 io->in.domain_name = domain_name; 517 if (domain != NULL) { 518 io->in.domain_name = domain; 519 } 520 if (address != NULL) { 521 io->in.server_address = address; 522 } 498 523 io->in.minimum_dc_flags = server_type; 499 524 … … 514 539 515 540 516 static const char py_net_vampire_doc[] = "vampire(domain, target_dir=None)\n"517 "Vampire a domain.";518 519 541 static const char py_net_replicate_init_doc[] = "replicate_init(samdb, lp, drspipe)\n" 520 542 "Setup for replicate_chunk calls."; … … 523 545 "Process replication for one chunk"; 524 546 525 static const char py_net_finddc_doc[] = "finddc( domain, server_type)\n"526 " find a DC with the specified server_type bits. Return the DNS name";547 static const char py_net_finddc_doc[] = "finddc(flags=server_type, domain=None, address=None)\n" 548 "Find a DC with the specified 'server_type' bits. The 'domain' and/or 'address' have to be used as additional search criteria. Returns the whole netlogon struct"; 527 549 528 550 static PyMethodDef net_obj_methods[] = { 529 {"join", (PyCFunction)py_net_join, METH_VARARGS|METH_KEYWORDS, py_net_join_doc}, 551 {"join_member", (PyCFunction)py_net_join_member, METH_VARARGS|METH_KEYWORDS, py_net_join_member_doc}, 552 {"change_password", (PyCFunction)py_net_change_password, METH_VARARGS|METH_KEYWORDS, py_net_change_password_doc}, 530 553 {"set_password", (PyCFunction)py_net_set_password, METH_VARARGS|METH_KEYWORDS, py_net_set_password_doc}, 531 {"export_keytab", (PyCFunction)py_net_export_keytab, METH_VARARGS|METH_KEYWORDS, py_net_export_keytab_doc},532 554 {"time", (PyCFunction)py_net_time, METH_VARARGS|METH_KEYWORDS, py_net_time_doc}, 533 555 {"create_user", (PyCFunction)py_net_user_create, METH_VARARGS|METH_KEYWORDS, py_net_create_user_doc}, 534 556 {"delete_user", (PyCFunction)py_net_user_delete, METH_VARARGS|METH_KEYWORDS, py_net_delete_user_doc}, 535 {"vampire", (PyCFunction)py_net_vampire, METH_VARARGS|METH_KEYWORDS, py_net_vampire_doc},536 557 {"replicate_init", (PyCFunction)py_net_replicate_init, METH_VARARGS|METH_KEYWORDS, py_net_replicate_init_doc}, 537 558 {"replicate_chunk", (PyCFunction)py_net_replicate_chunk, METH_VARARGS|METH_KEYWORDS, py_net_replicate_chunk_doc}, 538 {"finddc", (PyCFunction)py_net_finddc, METH_ VARARGS, py_net_finddc_doc},559 {"finddc", (PyCFunction)py_net_finddc, METH_KEYWORDS, py_net_finddc_doc}, 539 560 { NULL } 540 561 }; -
vendor/current/source4/libnet/userinfo.c
r860 r988 31 31 32 32 struct userinfo_state { 33 struct dcerpc_ pipe *pipe;33 struct dcerpc_binding_handle *binding_handle; 34 34 struct policy_handle domain_handle; 35 35 struct policy_handle user_handle; … … 63 63 64 64 c = tevent_req_callback_data(subreq, struct composite_context); 65 s = talloc_get_type (c->private_data, struct userinfo_state);65 s = talloc_get_type_abort(c->private_data, struct userinfo_state); 66 66 67 67 /* receive samr_Lookup reply */ … … 110 110 /* send request */ 111 111 subreq = dcerpc_samr_OpenUser_r_send(s, c->event_ctx, 112 s-> pipe->binding_handle,112 s->binding_handle, 113 113 &s->openuser); 114 114 if (composite_nomem(subreq, c)) return; … … 129 129 130 130 c = tevent_req_callback_data(subreq, struct composite_context); 131 s = talloc_get_type (c->private_data, struct userinfo_state);131 s = talloc_get_type_abort(c->private_data, struct userinfo_state); 132 132 133 133 /* receive samr_OpenUser reply */ … … 136 136 if (!composite_is_ok(c)) return; 137 137 138 if (!NT_STATUS_IS_OK(s-> queryuserinfo.out.result)) {139 composite_error(c, s-> queryuserinfo.out.result);138 if (!NT_STATUS_IS_OK(s->openuser.out.result)) { 139 composite_error(c, s->openuser.out.result); 140 140 return; 141 141 } … … 161 161 /* queue rpc call, set event handling and new state */ 162 162 subreq = dcerpc_samr_QueryUserInfo_r_send(s, c->event_ctx, 163 s-> pipe->binding_handle,163 s->binding_handle, 164 164 &s->queryuserinfo); 165 165 if (composite_nomem(subreq, c)) return; … … 180 180 181 181 c = tevent_req_callback_data(subreq, struct composite_context); 182 s = talloc_get_type (c->private_data, struct userinfo_state);182 s = talloc_get_type_abort(c->private_data, struct userinfo_state); 183 183 184 184 /* receive samr_QueryUserInfo reply */ … … 212 212 /* queue rpc call, set event handling and new state */ 213 213 subreq = dcerpc_samr_Close_r_send(s, c->event_ctx, 214 s-> pipe->binding_handle,214 s->binding_handle, 215 215 &s->samrclose); 216 216 if (composite_nomem(subreq, c)) return; … … 231 231 232 232 c = tevent_req_callback_data(subreq, struct composite_context); 233 s = talloc_get_type (c->private_data, struct userinfo_state);233 s = talloc_get_type_abort(c->private_data, struct userinfo_state); 234 234 235 235 /* receive samr_Close reply */ … … 264 264 * @param io arguments and results of the call 265 265 */ 266 struct composite_context *libnet_rpc_userinfo_send(struct dcerpc_pipe *p, 266 struct composite_context *libnet_rpc_userinfo_send(TALLOC_CTX *mem_ctx, 267 struct tevent_context *ev, 268 struct dcerpc_binding_handle *b, 267 269 struct libnet_rpc_userinfo *io, 268 270 void (*monitor)(struct monitor_msg*)) … … 273 275 struct tevent_req *subreq; 274 276 275 if (! p|| !io) return NULL;276 277 c = composite_create( p, dcerpc_event_context(p));277 if (!b || !io) return NULL; 278 279 c = composite_create(mem_ctx, ev); 278 280 if (c == NULL) return c; 279 281 … … 284 286 285 287 s->level = io->in.level; 286 s-> pipe = p;288 s->binding_handle= b; 287 289 s->domain_handle = io->in.domain_handle; 288 290 s->monitor_fn = monitor; … … 299 301 /* send request */ 300 302 subreq = dcerpc_samr_OpenUser_r_send(s, c->event_ctx, 301 p->binding_handle,303 s->binding_handle, 302 304 &s->openuser); 303 305 if (composite_nomem(subreq, c)) return c; … … 321 323 /* send request */ 322 324 subreq = dcerpc_samr_LookupNames_r_send(s, c->event_ctx, 323 p->binding_handle,325 s->binding_handle, 324 326 &s->lookup); 325 327 if (composite_nomem(subreq, c)) return c; … … 351 353 352 354 if (NT_STATUS_IS_OK(status) && io) { 353 s = talloc_get_type (c->private_data, struct userinfo_state);355 s = talloc_get_type_abort(c->private_data, struct userinfo_state); 354 356 talloc_steal(mem_ctx, s->info); 355 357 io->out.info = *s->info; … … 371 373 */ 372 374 373 NTSTATUS libnet_rpc_userinfo(struct dcerpc_pipe *p, 375 NTSTATUS libnet_rpc_userinfo(struct tevent_context *ev, 376 struct dcerpc_binding_handle *b, 374 377 TALLOC_CTX *mem_ctx, 375 378 struct libnet_rpc_userinfo *io) 376 379 { 377 struct composite_context *c = libnet_rpc_userinfo_send( p, io, NULL);380 struct composite_context *c = libnet_rpc_userinfo_send(mem_ctx, ev, b, io, NULL); 378 381 return libnet_rpc_userinfo_recv(c, mem_ctx, io); 379 382 } -
vendor/current/source4/libnet/userman.c
r860 r988 32 32 33 33 struct useradd_state { 34 struct dcerpc_ pipe *pipe;34 struct dcerpc_binding_handle *binding_handle; 35 35 struct policy_handle domain_handle; 36 36 struct samr_CreateUser createuser; … … 95 95 */ 96 96 97 struct composite_context *libnet_rpc_useradd_send(struct dcerpc_pipe *p, 97 struct composite_context *libnet_rpc_useradd_send(TALLOC_CTX *mem_ctx, 98 struct tevent_context *ev, 99 struct dcerpc_binding_handle *b, 98 100 struct libnet_rpc_useradd *io, 99 101 void (*monitor)(struct monitor_msg*)) … … 103 105 struct tevent_req *subreq; 104 106 105 if (! p|| !io) return NULL;107 if (!b || !io) return NULL; 106 108 107 109 /* composite allocation and setup */ 108 c = composite_create( p, dcerpc_event_context(p));110 c = composite_create(mem_ctx, ev); 109 111 if (c == NULL) return NULL; 110 112 … … 116 118 /* put passed arguments to the state structure */ 117 119 s->domain_handle = io->in.domain_handle; 118 s-> pipe = p;120 s->binding_handle= b; 119 121 s->monitor_fn = monitor; 120 122 … … 133 135 /* send the request */ 134 136 subreq = dcerpc_samr_CreateUser_r_send(s, c->event_ctx, 135 p->binding_handle,137 s->binding_handle, 136 138 &s->createuser); 137 139 if (composite_nomem(subreq, c)) return c; … … 179 181 */ 180 182 181 NTSTATUS libnet_rpc_useradd(struct dcerpc_pipe *p, 183 NTSTATUS libnet_rpc_useradd(struct tevent_context *ev, 184 struct dcerpc_binding_handle *b, 182 185 TALLOC_CTX *mem_ctx, 183 186 struct libnet_rpc_useradd *io) 184 187 { 185 struct composite_context *c = libnet_rpc_useradd_send( p, io, NULL);188 struct composite_context *c = libnet_rpc_useradd_send(mem_ctx, ev, b, io, NULL); 186 189 return libnet_rpc_useradd_recv(c, mem_ctx, io); 187 190 } … … 195 198 196 199 struct userdel_state { 197 struct dcerpc_ pipe *pipe;200 struct dcerpc_binding_handle *binding_handle; 198 201 struct policy_handle domain_handle; 199 202 struct policy_handle user_handle; … … 267 270 /* send rpc request */ 268 271 subreq = dcerpc_samr_OpenUser_r_send(s, c->event_ctx, 269 s-> pipe->binding_handle,272 s->binding_handle, 270 273 &s->openuser); 271 274 if (composite_nomem(subreq, c)) return; … … 317 320 /* send rpc request */ 318 321 subreq = dcerpc_samr_DeleteUser_r_send(s, c->event_ctx, 319 s-> pipe->binding_handle,322 s->binding_handle, 320 323 &s->deleteuser); 321 324 if (composite_nomem(subreq, c)) return; … … 370 373 */ 371 374 372 struct composite_context *libnet_rpc_userdel_send(struct dcerpc_pipe *p, 375 struct composite_context *libnet_rpc_userdel_send(TALLOC_CTX *mem_ctx, 376 struct tevent_context *ev, 377 struct dcerpc_binding_handle *b, 373 378 struct libnet_rpc_userdel *io, 374 379 void (*monitor)(struct monitor_msg*)) … … 379 384 380 385 /* composite context allocation and setup */ 381 c = composite_create( p, dcerpc_event_context(p));386 c = composite_create(mem_ctx, ev); 382 387 if (c == NULL) return NULL; 383 388 … … 388 393 389 394 /* store function parameters in the state structure */ 390 s-> pipe = p;395 s->binding_handle= b; 391 396 s->domain_handle = io->in.domain_handle; 392 397 s->monitor_fn = monitor; … … 404 409 /* send the request */ 405 410 subreq = dcerpc_samr_LookupNames_r_send(s, c->event_ctx, 406 p->binding_handle,411 s->binding_handle, 407 412 &s->lookupname); 408 413 if (composite_nomem(subreq, c)) return c; … … 450 455 */ 451 456 452 NTSTATUS libnet_rpc_userdel(struct dcerpc_pipe *p, 457 NTSTATUS libnet_rpc_userdel(struct tevent_context *ev, 458 struct dcerpc_binding_handle *b, 453 459 TALLOC_CTX *mem_ctx, 454 460 struct libnet_rpc_userdel *io) 455 461 { 456 struct composite_context *c = libnet_rpc_userdel_send( p, io, NULL);462 struct composite_context *c = libnet_rpc_userdel_send(mem_ctx, ev, b, io, NULL); 457 463 return libnet_rpc_userdel_recv(c, mem_ctx, io); 458 464 } … … 470 476 471 477 struct usermod_state { 472 struct dcerpc_ pipe *pipe;478 struct dcerpc_binding_handle *binding_handle; 473 479 struct policy_handle domain_handle; 474 480 struct policy_handle user_handle; … … 540 546 /* send the rpc request */ 541 547 subreq = dcerpc_samr_OpenUser_r_send(s, c->event_ctx, 542 s-> pipe->binding_handle,548 s->binding_handle, 543 549 &s->openuser); 544 550 if (composite_nomem(subreq, c)) return; … … 696 702 a particular info level */ 697 703 subreq = dcerpc_samr_QueryUserInfo_r_send(s, c->event_ctx, 698 s-> pipe->binding_handle,704 s->binding_handle, 699 705 &s->queryuser); 700 706 if (composite_nomem(subreq, c)) return NT_STATUS_NO_MEMORY; … … 708 714 /* send set user info request after making required change */ 709 715 subreq = dcerpc_samr_SetUserInfo_r_send(s, c->event_ctx, 710 s-> pipe->binding_handle,716 s->binding_handle, 711 717 &s->setuser); 712 718 if (composite_nomem(subreq, c)) return NT_STATUS_NO_MEMORY; … … 751 757 struct usermod_state *s; 752 758 union samr_UserInfo *i; 753 uint16_t level ;759 uint16_t level = 0; 754 760 755 761 c = tevent_req_callback_data(subreq, struct composite_context); … … 782 788 /* send the rpc request */ 783 789 subreq = dcerpc_samr_SetUserInfo_r_send(s, c->event_ctx, 784 s-> pipe->binding_handle,790 s->binding_handle, 785 791 &s->setuser); 786 792 if (composite_nomem(subreq, c)) return; … … 831 837 */ 832 838 833 struct composite_context *libnet_rpc_usermod_send(struct dcerpc_pipe *p, 839 struct composite_context *libnet_rpc_usermod_send(TALLOC_CTX *mem_ctx, 840 struct tevent_context *ev, 841 struct dcerpc_binding_handle *b, 834 842 struct libnet_rpc_usermod *io, 835 843 void (*monitor)(struct monitor_msg*)) … … 840 848 841 849 /* composite context allocation and setup */ 842 c = composite_create( p, dcerpc_event_context(p));850 c = composite_create(mem_ctx, ev); 843 851 if (c == NULL) return NULL; 844 852 s = talloc_zero(c, struct usermod_state); … … 848 856 849 857 /* store parameters in the call structure */ 850 s-> pipe = p;858 s->binding_handle= b; 851 859 s->domain_handle = io->in.domain_handle; 852 860 s->change = io->in.change; … … 865 873 /* send the rpc request */ 866 874 subreq = dcerpc_samr_LookupNames_r_send(s, c->event_ctx, 867 p->binding_handle,875 s->binding_handle, 868 876 &s->lookupname); 869 877 if (composite_nomem(subreq, c)) return c; … … 905 913 */ 906 914 907 NTSTATUS libnet_rpc_usermod(struct dcerpc_pipe *p, 915 NTSTATUS libnet_rpc_usermod(struct tevent_context *ev, 916 struct dcerpc_binding_handle *b, 908 917 TALLOC_CTX *mem_ctx, 909 918 struct libnet_rpc_usermod *io) 910 919 { 911 struct composite_context *c = libnet_rpc_usermod_send( p, io, NULL);920 struct composite_context *c = libnet_rpc_usermod_send(mem_ctx, ev, b, io, NULL); 912 921 return libnet_rpc_usermod_recv(c, mem_ctx, io); 913 922 } -
vendor/current/source4/libnet/wscript_build
r740 r988 2 2 3 3 bld.SAMBA_LIBRARY('samba-net', 4 source='libnet.c libnet_passwd.c libnet_time.c libnet_rpc.c libnet_join.c libnet_site.c libnet_become_dc.c libnet_unbecome_dc.c libnet_vampire.c libnet_samdump.c libnet_samsync_ldb.c libnet_user.c libnet_group.c libnet_share.c libnet_lookup.c libnet_domain.c userinfo.c groupinfo.c userman.c groupman.c prereq_domain.c libnet_samsync.c libnet_export_keytab.c',4 source='libnet.c libnet_passwd.c libnet_time.c libnet_rpc.c libnet_join.c libnet_site.c libnet_become_dc.c libnet_unbecome_dc.c libnet_vampire.c libnet_samdump.c libnet_samsync_ldb.c libnet_user.c libnet_group.c libnet_share.c libnet_lookup.c libnet_domain.c userinfo.c groupinfo.c userman.c groupman.c prereq_domain.c libnet_samsync.c', 5 5 autoproto='libnet_proto.h', 6 public_deps=' credentials dcerpc dcerpc-samr RPC_NDR_LSA RPC_NDR_SRVSVC RPC_NDR_DRSUAPI LIBCLI_COMPOSITE LIBCLI_RESOLVE LIBCLI_FINDDCS LIBCLI_CLDAP LIBCLI_FINDDCS gensec_schannel LIBCLI_AUTH ndr smbpasswdparser PROVISION LIBCLI_SAMSYNC HDB_SAMBA4 LIBTSOCKET com_err',6 public_deps='samba-credentials dcerpc dcerpc-samr RPC_NDR_LSA RPC_NDR_SRVSVC RPC_NDR_DRSUAPI cli_composite LIBCLI_RESOLVE LIBCLI_FINDDCS cli_cldap LIBCLI_FINDDCS gensec_schannel LIBCLI_AUTH ndr smbpasswdparser PROVISION LIBCLI_SAMSYNC LIBTSOCKET', 7 7 private_library=True 8 8 ) … … 11 11 bld.SAMBA_PYTHON('python_net', 12 12 source='py_net.c', 13 deps='samba-net pyrpc_util ',13 deps='samba-net pyrpc_util pytalloc-util', 14 14 realname='samba/net.so' 15 15 ) 16 16 17 bld.SAMBA_PYTHON('python_dckeytab', 18 source='py_net_dckeytab.c libnet_export_keytab.c', 19 deps='pyrpc_util HDB_SAMBA4 com_err', 20 realname='samba/dckeytab.so', 21 enabled=bld.CONFIG_SET('SAMBA4_USES_HEIMDAL') 22 )
Note:
See TracChangeset
for help on using the changeset viewer.