Changeset 745 for trunk/server/source4/winbind
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 deleted
- 39 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/winbind/idmap.c
r414 r745 22 22 #include "includes.h" 23 23 #include "auth/auth.h" 24 #include "librpc/gen_ndr/lsa.h"25 #include "librpc/gen_ndr/samr.h"26 24 #include "librpc/gen_ndr/ndr_security.h" 27 #include "lib/ldb/include/ldb.h" 28 #include "lib/ldb/include/ldb_errors.h" 29 #include "lib/ldb_wrap.h" 25 #include <ldb.h> 26 #include "ldb_wrap.h" 30 27 #include "param/param.h" 31 28 #include "winbind/idmap.h" … … 101 98 enum ndr_err_code ndr_err; 102 99 103 ndr_err = ndr_push_struct_blob(&val, mem_ctx, 104 lp_iconv_convenience(idmap_ctx->lp_ctx), 105 sid, 100 ndr_err = ndr_push_struct_blob(&val, mem_ctx, sid, 106 101 (ndr_push_flags_fn_t)ndr_push_dom_sid); 107 102 … … 138 133 } 139 134 140 ndr_err = ndr_pull_struct_blob(val, sid, NULL,sid,135 ndr_err = ndr_pull_struct_blob(val, sid, sid, 141 136 (ndr_pull_flags_fn_t)ndr_pull_dom_sid); 142 137 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 158 153 struct idmap_context *idmap_init(TALLOC_CTX *mem_ctx, 159 154 struct tevent_context *ev_ctx, 160 struct loadparm_context *lp_ctx)155 struct loadparm_context *lp_ctx) 161 156 { 162 157 struct idmap_context *idmap_ctx; … … 170 165 171 166 idmap_ctx->ldb_ctx = ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, 172 lp _idmap_url(lp_ctx),173 system_session( mem_ctx,lp_ctx),174 NULL, 0 , NULL);167 lpcfg_idmap_url(lp_ctx), 168 system_session(lp_ctx), 169 NULL, 0); 175 170 if (idmap_ctx->ldb_ctx == NULL) { 176 171 return NULL; … … 203 198 */ 204 199 205 NTSTATUS idmap_xid_to_sid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, 206 const struct unixid *unixid, struct dom_sid **sid) 200 static NTSTATUS idmap_xid_to_sid(struct idmap_context *idmap_ctx, 201 TALLOC_CTX *mem_ctx, 202 const struct unixid *unixid, 203 struct dom_sid **sid) 207 204 { 208 205 int ret; … … 222 219 break; 223 220 default: 224 DEBUG(1, ("unixid->type must be type gid or uid\n")); 221 DEBUG(1, ("unixid->type must be type gid or uid (got %u) for lookup with id %lu\n", 222 (unsigned)unixid->type, (unsigned long)unixid->id)); 225 223 status = NT_STATUS_NONE_MAPPED; 226 224 goto failed; … … 282 280 * If no mapping exists, a new mapping will be created. 283 281 * 284 * \todo Check if SIDs can be resolved if lp _idmap_trusted_only() == true282 * \todo Check if SIDs can be resolved if lpcfg_idmap_trusted_only() == true 285 283 * \todo Fix backwards compatibility for Samba3 286 284 * … … 288 286 * \param mem_ctx talloc context to use 289 287 * \param sid SID to map to an unixid struct 290 * \param unixid pointer to a unixid struct pointer288 * \param unixid pointer to a unixid struct 291 289 * \return NT_STATUS_OK on success, NT_STATUS_INVALID_SID if the sid is not from 292 290 * a trusted domain and idmap trusted only = true, NT_STATUS_NONE_MAPPED if the 293 291 * mapping failed. 294 292 */ 295 NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, 296 const struct dom_sid *sid, struct unixid **unixid) 293 static NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx, 294 TALLOC_CTX *mem_ctx, 295 const struct dom_sid *sid, 296 struct unixid *unixid) 297 297 { 298 298 int ret; … … 312 312 DEBUG(6, ("This is a local unix uid, just calculate that.\n")); 313 313 status = dom_sid_split_rid(tmp_ctx, sid, NULL, &rid); 314 if (!NT_STATUS_IS_OK(status)) goto failed; 315 316 *unixid = talloc(mem_ctx, struct unixid); 317 if (*unixid == NULL) { 318 status = NT_STATUS_NO_MEMORY; 319 goto failed; 320 } 321 (*unixid)->id = rid; 322 (*unixid)->type = ID_TYPE_UID; 314 if (!NT_STATUS_IS_OK(status)) { 315 talloc_free(tmp_ctx); 316 return status; 317 } 318 319 unixid->id = rid; 320 unixid->type = ID_TYPE_UID; 323 321 324 322 talloc_free(tmp_ctx); … … 330 328 DEBUG(6, ("This is a local unix gid, just calculate that.\n")); 331 329 status = dom_sid_split_rid(tmp_ctx, sid, NULL, &rid); 332 if (!NT_STATUS_IS_OK(status)) goto failed; 333 334 *unixid = talloc(mem_ctx, struct unixid); 335 if (*unixid == NULL) { 336 status = NT_STATUS_NO_MEMORY; 337 goto failed; 338 } 339 (*unixid)->id = rid; 340 (*unixid)->type = ID_TYPE_GID; 330 if (!NT_STATUS_IS_OK(status)) { 331 talloc_free(tmp_ctx); 332 return status; 333 } 334 335 unixid->id = rid; 336 unixid->type = ID_TYPE_GID; 341 337 342 338 talloc_free(tmp_ctx); … … 349 345 if (ret != LDB_SUCCESS) { 350 346 DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); 351 status = NT_STATUS_NONE_MAPPED;352 goto failed;347 talloc_free(tmp_ctx); 348 return NT_STATUS_NONE_MAPPED; 353 349 } 354 350 … … 360 356 if (new_xid == (uint32_t) -1) { 361 357 DEBUG(1, ("Invalid xid mapping.\n")); 362 status = NT_STATUS_NONE_MAPPED;363 goto failed;358 talloc_free(tmp_ctx); 359 return NT_STATUS_NONE_MAPPED; 364 360 } 365 361 366 362 if (type == NULL) { 367 363 DEBUG(1, ("Invalid type for mapping entry.\n")); 368 status = NT_STATUS_NONE_MAPPED; 369 goto failed; 370 } 371 372 *unixid = talloc(mem_ctx, struct unixid); 373 if (*unixid == NULL) { 374 status = NT_STATUS_NO_MEMORY; 375 goto failed; 376 } 377 378 (*unixid)->id = new_xid; 364 talloc_free(tmp_ctx); 365 return NT_STATUS_NONE_MAPPED; 366 } 367 368 unixid->id = new_xid; 379 369 380 370 if (strcmp(type, "ID_TYPE_BOTH") == 0) { 381 (*unixid)->type = ID_TYPE_BOTH;371 unixid->type = ID_TYPE_BOTH; 382 372 } else if (strcmp(type, "ID_TYPE_UID") == 0) { 383 (*unixid)->type = ID_TYPE_UID;373 unixid->type = ID_TYPE_UID; 384 374 } else { 385 (*unixid)->type = ID_TYPE_GID;375 unixid->type = ID_TYPE_GID; 386 376 } 387 377 … … 415 405 } 416 406 417 /*FIXME: if lp _idmap_trusted_only() == true, check if SID can be407 /*FIXME: if lpcfg_idmap_trusted_only() == true, check if SID can be 418 408 * resolved here. */ 419 409 … … 606 596 } 607 597 608 *unixid = talloc(mem_ctx, struct unixid); 609 if (*unixid == NULL) { 610 status = NT_STATUS_NO_MEMORY; 611 goto failed; 612 } 613 614 (*unixid)->id = new_xid; 615 (*unixid)->type = ID_TYPE_BOTH; 598 unixid->id = new_xid; 599 unixid->type = ID_TYPE_BOTH; 616 600 talloc_free(tmp_ctx); 617 601 return NT_STATUS_OK; … … 637 621 638 622 NTSTATUS idmap_xids_to_sids(struct idmap_context *idmap_ctx, 639 TALLOC_CTX *mem_ctx, int count,640 struct id_map ping*id)623 TALLOC_CTX *mem_ctx, 624 struct id_map **id) 641 625 { 642 int i; 643 int error_count = 0; 644 645 for (i = 0; i < count; ++i) { 646 id[i].status = idmap_xid_to_sid(idmap_ctx, mem_ctx, 647 id[i].unixid, &id[i].sid); 648 if (NT_STATUS_EQUAL(id[i].status, NT_STATUS_RETRY)) { 649 id[i].status = idmap_xid_to_sid(idmap_ctx, mem_ctx, 650 id[i].unixid, 651 &id[i].sid); 652 } 653 if (!NT_STATUS_IS_OK(id[i].status)) { 654 DEBUG(1, ("idmapping xid_to_sid failed for id[%d]\n", i)); 626 unsigned int i, error_count = 0; 627 NTSTATUS status; 628 629 for (i = 0; id && id[i]; i++) { 630 status = idmap_xid_to_sid(idmap_ctx, mem_ctx, 631 &id[i]->xid, &id[i]->sid); 632 if (NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) { 633 status = idmap_xid_to_sid(idmap_ctx, mem_ctx, 634 &id[i]->xid, 635 &id[i]->sid); 636 } 637 if (!NT_STATUS_IS_OK(status)) { 638 DEBUG(1, ("idmapping xid_to_sid failed for id[%d]=%lu: %s\n", 639 i, (unsigned long)id[i]->xid.id, nt_errstr(status))); 655 640 error_count++; 656 } 657 } 658 659 if (error_count == count) { 641 id[i]->status = ID_UNMAPPED; 642 } else { 643 id[i]->status = ID_MAPPED; 644 } 645 } 646 647 if (error_count == i) { 660 648 /* Mapping did not work at all. */ 661 649 return NT_STATUS_NONE_MAPPED; … … 682 670 683 671 NTSTATUS idmap_sids_to_xids(struct idmap_context *idmap_ctx, 684 TALLOC_CTX *mem_ctx, int count,685 struct id_map ping*id)672 TALLOC_CTX *mem_ctx, 673 struct id_map **id) 686 674 { 687 int i; 688 int error_count = 0; 689 690 for (i = 0; i < count; ++i) { 691 id[i].status = idmap_sid_to_xid(idmap_ctx, mem_ctx, 692 id[i].sid, &id[i].unixid); 693 if (NT_STATUS_EQUAL(id[i].status, NT_STATUS_RETRY)) { 694 id[i].status = idmap_sid_to_xid(idmap_ctx, mem_ctx, 695 id[i].sid, 696 &id[i].unixid); 697 } 698 if (!NT_STATUS_IS_OK(id[i].status)) { 699 DEBUG(1, ("idmapping sid_to_xid failed for id[%d]\n", i)); 675 unsigned int i, error_count = 0; 676 NTSTATUS status; 677 678 for (i = 0; id && id[i]; i++) { 679 status = idmap_sid_to_xid(idmap_ctx, mem_ctx, 680 id[i]->sid, &id[i]->xid); 681 if (NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) { 682 status = idmap_sid_to_xid(idmap_ctx, mem_ctx, 683 id[i]->sid, 684 &id[i]->xid); 685 } 686 if (!NT_STATUS_IS_OK(status)) { 687 char *str = dom_sid_string(mem_ctx, id[i]->sid); 688 DEBUG(1, ("idmapping sid_to_xid failed for id[%d]=%s: %s\n", 689 i, str, nt_errstr(status))); 690 talloc_free(str); 700 691 error_count++; 701 } 702 } 703 704 if (error_count == count) { 692 id[i]->status = ID_UNMAPPED; 693 } else { 694 id[i]->status = ID_MAPPED; 695 } 696 } 697 698 if (error_count == i) { 705 699 /* Mapping did not work at all. */ 706 700 return NT_STATUS_NONE_MAPPED; -
trunk/server/source4/winbind/idmap.h
r414 r745 20 20 */ 21 21 22 #ifndef _ IDMAP_H_23 #define _ IDMAP_H_22 #ifndef _WINBIND_IDMAP_H_ 23 #define _WINBIND_IDMAP_H_ 24 24 25 #include "librpc/gen_ndr/ winbind.h"25 #include "librpc/gen_ndr/idmap.h" 26 26 27 27 struct idmap_context { -
trunk/server/source4/winbind/wb_async_helpers.c
r414 r745 22 22 23 23 #include "includes.h" 24 #include <tevent.h> 24 25 #include "libcli/composite/composite.h" 25 26 #include "winbind/wb_async_helpers.h" 26 27 27 #include "lib/messaging/irpc.h"28 #include "librpc/gen_ndr/irpc.h"29 #include "auth/credentials/credentials.h"30 28 #include "libcli/security/security.h" 31 #include "libcli/auth/libcli_auth.h"32 #include "librpc/gen_ndr/ndr_netlogon_c.h"33 29 #include "librpc/gen_ndr/ndr_lsa_c.h" 34 30 #include "librpc/gen_ndr/ndr_samr_c.h" 35 31 36 #include "winbind/wb_helper.h"37 32 38 33 struct lsa_lookupsids_state { 39 34 struct composite_context *ctx; 40 int num_sids;35 uint32_t num_sids; 41 36 struct lsa_LookupSids r; 42 37 struct lsa_SidArray sids; … … 47 42 }; 48 43 49 static void lsa_lookupsids_recv_names(struct rpc_request *req);44 static void lsa_lookupsids_recv_names(struct tevent_req *subreq); 50 45 51 46 struct composite_context *wb_lsa_lookupsids_send(TALLOC_CTX *mem_ctx, 52 47 struct dcerpc_pipe *lsa_pipe, 53 48 struct policy_handle *handle, 54 int num_sids,49 uint32_t num_sids, 55 50 const struct dom_sid **sids) 56 51 { 57 52 struct composite_context *result; 58 struct rpc_request *req;59 53 struct lsa_lookupsids_state *state; 60 int i; 54 uint32_t i; 55 struct tevent_req *subreq; 61 56 62 57 result = composite_create(mem_ctx, lsa_pipe->conn->event_ctx); … … 95 90 state->r.out.domains = &state->domains; 96 91 97 req = dcerpc_lsa_LookupSids_send(lsa_pipe, state, &state->r); 98 if (req == NULL) goto failed; 99 100 req->async.callback = lsa_lookupsids_recv_names; 101 req->async.private_data = state; 92 subreq = dcerpc_lsa_LookupSids_r_send(state, 93 result->event_ctx, 94 lsa_pipe->binding_handle, 95 &state->r); 96 if (subreq == NULL) goto failed; 97 tevent_req_set_callback(subreq, lsa_lookupsids_recv_names, state); 98 102 99 return result; 103 100 … … 107 104 } 108 105 109 static void lsa_lookupsids_recv_names(struct rpc_request *req)106 static void lsa_lookupsids_recv_names(struct tevent_req *subreq) 110 107 { 111 108 struct lsa_lookupsids_state *state = 112 talloc_get_type(req->async.private_data, 113 struct lsa_lookupsids_state); 114 int i; 115 116 state->ctx->status = dcerpc_ndr_request_recv(req); 109 tevent_req_callback_data(subreq, 110 struct lsa_lookupsids_state); 111 uint32_t i; 112 113 state->ctx->status = dcerpc_lsa_LookupSids_r_recv(subreq, state); 114 TALLOC_FREE(subreq); 117 115 if (!composite_is_ok(state->ctx)) return; 118 116 state->ctx->status = state->r.out.result; … … 196 194 }; 197 195 198 static void lsa_lookupnames_recv_sids(struct rpc_request *req);196 static void lsa_lookupnames_recv_sids(struct tevent_req *subreq); 199 197 200 198 struct composite_context *wb_lsa_lookupnames_send(TALLOC_CTX *mem_ctx, 201 199 struct dcerpc_pipe *lsa_pipe, 202 200 struct policy_handle *handle, 203 int num_names,201 uint32_t num_names, 204 202 const char **names) 205 203 { 206 204 struct composite_context *result; 207 struct rpc_request *req;208 205 struct lsa_lookupnames_state *state; 206 struct tevent_req *subreq; 209 207 210 208 struct lsa_String *lsa_names; 211 int i;209 uint32_t i; 212 210 213 211 result = composite_create(mem_ctx, lsa_pipe->conn->event_ctx); … … 244 242 state->r.out.domains = &state->domains; 245 243 246 req = dcerpc_lsa_LookupNames_send(lsa_pipe, state, &state->r); 247 if (req == NULL) goto failed; 248 249 req->async.callback = lsa_lookupnames_recv_sids; 250 req->async.private_data = state; 244 subreq = dcerpc_lsa_LookupNames_r_send(state, 245 result->event_ctx, 246 lsa_pipe->binding_handle, 247 &state->r); 248 if (subreq == NULL) goto failed; 249 tevent_req_set_callback(subreq, lsa_lookupnames_recv_sids, state); 250 251 251 return result; 252 252 … … 256 256 } 257 257 258 static void lsa_lookupnames_recv_sids(struct rpc_request *req)258 static void lsa_lookupnames_recv_sids(struct tevent_req *subreq) 259 259 { 260 260 struct lsa_lookupnames_state *state = 261 talloc_get_type(req->async.private_data, 262 struct lsa_lookupnames_state); 263 int i; 264 265 state->ctx->status = dcerpc_ndr_request_recv(req); 261 tevent_req_callback_data(subreq, 262 struct lsa_lookupnames_state); 263 uint32_t i; 264 265 state->ctx->status = dcerpc_lsa_LookupNames_r_recv(subreq, state); 266 TALLOC_FREE(subreq); 266 267 if (!composite_is_ok(state->ctx)) return; 267 268 state->ctx->status = state->r.out.result; … … 323 324 struct dcerpc_pipe *samr_pipe; 324 325 325 int num_rids;326 uint32_t num_rids; 326 327 uint32_t *rids; 327 328 … … 334 335 }; 335 336 336 static void samr_usergroups_recv_open(struct rpc_request *req);337 static void samr_usergroups_recv_groups(struct rpc_request *req);338 static void samr_usergroups_recv_close(struct rpc_request *req);337 static void samr_usergroups_recv_open(struct tevent_req *subreq); 338 static void samr_usergroups_recv_groups(struct tevent_req *subreq); 339 static void samr_usergroups_recv_close(struct tevent_req *subreq); 339 340 340 341 struct composite_context *wb_samr_userdomgroups_send(TALLOC_CTX *mem_ctx, … … 344 345 { 345 346 struct composite_context *result; 346 struct rpc_request *req;347 347 struct samr_getuserdomgroups_state *state; 348 struct tevent_req *subreq; 348 349 349 350 result = composite_create(mem_ctx, samr_pipe->conn->event_ctx); … … 365 366 state->o.out.user_handle = state->user_handle; 366 367 367 req = dcerpc_samr_OpenUser_send(state->samr_pipe, state, &state->o); 368 if (req == NULL) goto failed; 369 370 req->async.callback = samr_usergroups_recv_open; 371 req->async.private_data = state; 368 subreq = dcerpc_samr_OpenUser_r_send(state, 369 result->event_ctx, 370 state->samr_pipe->binding_handle, 371 &state->o); 372 if (subreq == NULL) goto failed; 373 tevent_req_set_callback(subreq, samr_usergroups_recv_open, state); 374 372 375 return result; 373 376 … … 377 380 } 378 381 379 static void samr_usergroups_recv_open(struct rpc_request *req)382 static void samr_usergroups_recv_open(struct tevent_req *subreq) 380 383 { 381 384 struct samr_getuserdomgroups_state *state = 382 talloc_get_type(req->async.private_data, 383 struct samr_getuserdomgroups_state); 384 385 state->ctx->status = dcerpc_ndr_request_recv(req); 385 tevent_req_callback_data(subreq, 386 struct samr_getuserdomgroups_state); 387 388 state->ctx->status = dcerpc_samr_OpenUser_r_recv(subreq, state); 389 TALLOC_FREE(subreq); 386 390 if (!composite_is_ok(state->ctx)) return; 387 391 state->ctx->status = state->o.out.result; … … 391 395 state->g.out.rids = &state->rid_array; 392 396 393 req = dcerpc_samr_GetGroupsForUser_send(state->samr_pipe, state, 394 &state->g); 395 composite_continue_rpc(state->ctx, req, samr_usergroups_recv_groups, 396 state); 397 } 398 399 static void samr_usergroups_recv_groups(struct rpc_request *req) 397 subreq = dcerpc_samr_GetGroupsForUser_r_send(state, 398 state->ctx->event_ctx, 399 state->samr_pipe->binding_handle, 400 &state->g); 401 if (composite_nomem(subreq, state->ctx)) return; 402 tevent_req_set_callback(subreq, samr_usergroups_recv_groups, state); 403 } 404 405 static void samr_usergroups_recv_groups(struct tevent_req *subreq) 400 406 { 401 407 struct samr_getuserdomgroups_state *state = 402 talloc_get_type(req->async.private_data, 403 struct samr_getuserdomgroups_state); 404 405 state->ctx->status = dcerpc_ndr_request_recv(req); 408 tevent_req_callback_data(subreq, 409 struct samr_getuserdomgroups_state); 410 411 state->ctx->status = dcerpc_samr_GetGroupsForUser_r_recv(subreq, state); 412 TALLOC_FREE(subreq); 406 413 if (!composite_is_ok(state->ctx)) return; 407 414 state->ctx->status = state->g.out.result; … … 411 418 state->c.out.handle = state->user_handle; 412 419 413 req = dcerpc_samr_Close_send(state->samr_pipe, state, &state->c); 414 composite_continue_rpc(state->ctx, req, samr_usergroups_recv_close, 415 state); 416 } 417 418 static void samr_usergroups_recv_close(struct rpc_request *req) 420 subreq = dcerpc_samr_Close_r_send(state, 421 state->ctx->event_ctx, 422 state->samr_pipe->binding_handle, 423 &state->c); 424 if (composite_nomem(subreq, state->ctx)) return; 425 tevent_req_set_callback(subreq, samr_usergroups_recv_close, state); 426 } 427 428 static void samr_usergroups_recv_close(struct tevent_req *subreq) 419 429 { 420 430 struct samr_getuserdomgroups_state *state = 421 talloc_get_type(req->async.private_data, 422 struct samr_getuserdomgroups_state); 423 424 state->ctx->status = dcerpc_ndr_request_recv(req); 431 tevent_req_callback_data(subreq, 432 struct samr_getuserdomgroups_state); 433 434 state->ctx->status = dcerpc_samr_Close_r_recv(subreq, state); 435 TALLOC_FREE(subreq); 425 436 if (!composite_is_ok(state->ctx)) return; 426 437 state->ctx->status = state->c.out.result; … … 432 443 NTSTATUS wb_samr_userdomgroups_recv(struct composite_context *ctx, 433 444 TALLOC_CTX *mem_ctx, 434 int *num_rids, uint32_t **rids)445 uint32_t *num_rids, uint32_t **rids) 435 446 { 436 447 struct samr_getuserdomgroups_state *state = … … 438 449 struct samr_getuserdomgroups_state); 439 450 440 int i;451 uint32_t i; 441 452 NTSTATUS status = composite_wait(ctx); 442 453 if (!NT_STATUS_IS_OK(status)) goto done; -
trunk/server/source4/winbind/wb_cmd_getdcname.c
r414 r745 35 35 36 36 static void getdcname_recv_domain(struct composite_context *ctx); 37 static void getdcname_recv_dcname(struct rpc_request *req);37 static void getdcname_recv_dcname(struct tevent_req *subreq); 38 38 39 39 struct composite_context *wb_cmd_getdcname_send(TALLOC_CTX *mem_ctx, … … 73 73 struct cmd_getdcname_state); 74 74 struct wbsrv_domain *domain; 75 struct rpc_request *req;75 struct tevent_req *subreq; 76 76 77 77 state->ctx->status = wb_sid2domain_recv(ctx, &domain); … … 84 84 state->g.out.dcname = talloc(state, const char *); 85 85 86 req = dcerpc_netr_GetAnyDCName_send(domain->netlogon_pipe, state, 87 &state->g); 88 if (composite_nomem(req, state->ctx)) return; 86 subreq = dcerpc_netr_GetAnyDCName_r_send(state, 87 state->ctx->event_ctx, 88 domain->netlogon_pipe->binding_handle, 89 &state->g); 90 if (composite_nomem(subreq, state->ctx)) return; 89 91 90 composite_continue_rpc(state->ctx,req, getdcname_recv_dcname, state);92 tevent_req_set_callback(subreq, getdcname_recv_dcname, state); 91 93 } 92 94 93 static void getdcname_recv_dcname(struct rpc_request *req)95 static void getdcname_recv_dcname(struct tevent_req *subreq) 94 96 { 95 97 struct cmd_getdcname_state *state = 96 t alloc_get_type(req->async.private_data,97 98 tevent_req_callback_data(subreq, 99 struct cmd_getdcname_state); 98 100 99 state->ctx->status = dcerpc_ndr_request_recv(req); 101 state->ctx->status = dcerpc_netr_GetAnyDCName_r_recv(subreq, state); 102 TALLOC_FREE(subreq); 100 103 if (!composite_is_ok(state->ctx)) return; 101 104 state->ctx->status = werror_to_ntstatus(state->g.out.result); … … 112 115 talloc_get_type(c->private_data, struct cmd_getdcname_state); 113 116 NTSTATUS status = composite_wait(c); 117 if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_DOMAIN)) { 118 /* special case: queried DC is PDC */ 119 state->g.out.dcname = &state->g.in.logon_server; 120 status = NT_STATUS_OK; 121 } 114 122 if (NT_STATUS_IS_OK(status)) { 115 123 const char *p = *(state->g.out.dcname); -
trunk/server/source4/winbind/wb_cmd_getgrgid.c
r414 r745 23 23 #include "libcli/composite/composite.h" 24 24 #include "winbind/wb_server.h" 25 #include "winbind/wb_async_helpers.h"26 #include "winbind/wb_helper.h"27 25 #include "smbd/service_task.h" 28 #include "libnet/libnet_proto.h"29 #include "param/param.h"30 #include "libcli/security/proto.h"31 #include "auth/credentials/credentials.h"32 26 33 27 struct cmd_getgrgid_state { … … 137 131 DEBUG(5, ("cmd_getgrgid_recv_group_info called\n")); 138 132 139 gr = talloc (state, struct winbindd_gr);133 gr = talloc_zero(state, struct winbindd_gr); 140 134 if (composite_nomem(gr, state->ctx)) return; 141 135 -
trunk/server/source4/winbind/wb_cmd_getgrnam.c
r414 r745 23 23 #include "libcli/composite/composite.h" 24 24 #include "winbind/wb_server.h" 25 #include "winbind/wb_async_helpers.h"26 #include "param/param.h"27 25 #include "winbind/wb_helper.h" 28 26 #include "smbd/service_task.h" 29 #include "libnet/libnet_proto.h"30 #include "libcli/security/proto.h"31 27 32 28 struct cmd_getgrnam_state { -
trunk/server/source4/winbind/wb_cmd_getpwent.c
r414 r745 23 23 #include "libcli/composite/composite.h" 24 24 #include "winbind/wb_server.h" 25 #include "winbind/wb_async_helpers.h"26 #include "winbind/wb_helper.h"27 25 #include "smbd/service_task.h" 28 #include "libnet/libnet_proto.h"29 26 30 27 struct cmd_getpwent_state { -
trunk/server/source4/winbind/wb_cmd_getpwnam.c
r414 r745 23 23 #include "libcli/composite/composite.h" 24 24 #include "winbind/wb_server.h" 25 #include "winbind/wb_async_helpers.h"26 25 #include "param/param.h" 27 26 #include "winbind/wb_helper.h" 28 27 #include "smbd/service_task.h" 29 #include "libnet/libnet_proto.h"30 28 #include "libcli/security/security.h" 31 29 … … 127 125 WBSRV_SAMBA3_SET_STRING(pw->pw_gecos, user_info->out.full_name); 128 126 WBSRV_SAMBA3_SET_STRING(pw->pw_dir, 129 lp _template_homedir(state->service->task->lp_ctx));127 lpcfg_template_homedir(state->service->task->lp_ctx)); 130 128 all_string_sub(pw->pw_dir, "%WORKGROUP%", state->workgroup_name, 131 129 sizeof(fstring) - 1); … … 133 131 sizeof(fstring) - 1); 134 132 WBSRV_SAMBA3_SET_STRING(pw->pw_shell, 135 lp _template_shell(state->service->task->lp_ctx));133 lpcfg_template_shell(state->service->task->lp_ctx)); 136 134 137 135 state->group_sid = dom_sid_dup(state, user_info->out.primary_group_sid); -
trunk/server/source4/winbind/wb_cmd_getpwuid.c
r414 r745 23 23 #include "libcli/composite/composite.h" 24 24 #include "winbind/wb_server.h" 25 #include "winbind/wb_async_helpers.h"26 #include "winbind/wb_helper.h"27 25 #include "smbd/service_task.h" 28 #include "libnet/libnet_proto.h"29 26 #include "param/param.h" 30 #include "libcli/security/proto.h"31 #include "auth/credentials/credentials.h"32 27 33 28 struct cmd_getpwuid_state { … … 151 146 WBSRV_SAMBA3_SET_STRING(pw->pw_gecos, user_info->out.full_name); 152 147 WBSRV_SAMBA3_SET_STRING(pw->pw_dir, 153 lp _template_homedir(state->service->task->lp_ctx));148 lpcfg_template_homedir(state->service->task->lp_ctx)); 154 149 all_string_sub(pw->pw_dir, "%WORKGROUP%", state->workgroup, 155 150 sizeof(fstring) - 1); … … 157 152 sizeof(fstring) - 1); 158 153 WBSRV_SAMBA3_SET_STRING(pw->pw_shell, 159 lp _template_shell(state->service->task->lp_ctx));154 lpcfg_template_shell(state->service->task->lp_ctx)); 160 155 161 156 pw->pw_uid = state->uid; -
trunk/server/source4/winbind/wb_cmd_list_groups.c
r414 r745 23 23 #include "libcli/composite/composite.h" 24 24 #include "winbind/wb_server.h" 25 #include "winbind/wb_async_helpers.h"26 #include "winbind/wb_helper.h"27 25 #include "smbd/service_task.h" 28 #include "libnet/libnet_proto.h"29 26 30 27 struct cmd_list_groups_state { … … 36 33 uint32_t resume_index; 37 34 char *result; 35 uint32_t num_groups; 38 36 }; 39 37 … … 59 57 state->service = service; 60 58 state->resume_index = 0; 59 state->num_groups = 0; 61 60 state->result = talloc_strdup(state, ""); 62 61 if (composite_nomem(state->result, state->ctx)) return result; … … 93 92 if (!composite_is_ok(state->ctx)) return; 94 93 94 /* we use this entry also for context purposes (libnet_GroupList) */ 95 95 state->domain = domain; 96 96 97 97 /* If this is non-null, we've looked up the domain given in the winbind 98 * request, otherwise we'll just use the default name .*/98 * request, otherwise we'll just use the default name .*/ 99 99 if (state->domain_name == NULL) { 100 100 state->domain_name = talloc_strdup(state, 101 domain->libnet_ctx->samr.name);101 state->domain->libnet_ctx->samr.name); 102 102 if (composite_nomem(state->domain_name, state->ctx)) return; 103 103 } … … 114 114 group_list->in.resume_index = state->resume_index; 115 115 116 ctx = libnet_GroupList_send(domain->libnet_ctx, state, group_list,NULL); 116 ctx = libnet_GroupList_send(state->domain->libnet_ctx, state, 117 group_list, NULL); 117 118 118 119 composite_continue(state->ctx, ctx, cmd_list_groups_recv_group_list, 119 state);120 state); 120 121 } 121 122 … … 137 138 /* If NTSTATUS is neither OK nor MORE_ENTRIES, something broke */ 138 139 if (!NT_STATUS_IS_OK(status) && 139 !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { 140 !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES) && 141 !NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) { 140 142 composite_error(state->ctx, status); 141 143 return; … … 146 148 group_list->out.groups[i].groupname)); 147 149 state->result = talloc_asprintf_append_buffer(state->result, 148 "%s,", 149 group_list->out.groups[i].groupname); 150 "%s,", 151 group_list->out.groups[i].groupname); 152 state->num_groups++; 150 153 } 151 154 … … 153 156 * So we'll trim off the trailing ',' and are done.*/ 154 157 if (NT_STATUS_IS_OK(status)) { 155 int str_len = strlen(state->result);158 size_t str_len = strlen(state->result); 156 159 DEBUG(5, ("list_GroupList_recv returned NT_STATUS_OK\n")); 157 state->result[str_len - 1] = '\0'; 160 if (str_len > 0) { 161 state->result[str_len - 1] = '\0'; 162 } 158 163 composite_done(state->ctx); 159 164 return; … … 172 177 173 178 ctx = libnet_GroupList_send(state->domain->libnet_ctx, state,group_list, 174 NULL);179 NULL); 175 180 176 181 composite_continue(state->ctx, ctx, cmd_list_groups_recv_group_list, 177 state);182 state); 178 183 } 179 184 180 185 NTSTATUS wb_cmd_list_groups_recv(struct composite_context *ctx, 181 186 TALLOC_CTX *mem_ctx, uint32_t *extra_data_len, 182 char **extra_data )187 char **extra_data, uint32_t *num_groups) 183 188 { 184 189 NTSTATUS status = composite_wait(ctx); … … 192 197 *extra_data_len = strlen(state->result); 193 198 *extra_data = talloc_steal(mem_ctx, state->result); 199 *num_groups = state->num_groups; 194 200 } 195 201 -
trunk/server/source4/winbind/wb_cmd_list_trustdom.c
r414 r745 34 34 struct dcerpc_pipe *lsa_pipe; 35 35 struct policy_handle *lsa_policy; 36 int num_domains;36 uint32_t num_domains; 37 37 struct wb_dom_info **domains; 38 38 … … 44 44 static void cmd_list_trustdoms_recv_domain(struct composite_context *ctx); 45 45 static void cmd_list_trustdoms_recv_lsa(struct composite_context *ctx); 46 static void cmd_list_trustdoms_recv_doms(struct rpc_request *req);46 static void cmd_list_trustdoms_recv_doms(struct tevent_req *subreq); 47 47 48 48 struct composite_context *wb_cmd_list_trustdoms_send(TALLOC_CTX *mem_ctx, … … 95 95 talloc_get_type(ctx->async.private_data, 96 96 struct cmd_list_trustdom_state); 97 struct rpc_request *req;97 struct tevent_req *subreq; 98 98 99 99 state->ctx->status = wb_init_lsa_recv(ctx, state, … … 115 115 state->r.out.domains = &state->domainlist; 116 116 117 req = dcerpc_lsa_EnumTrustDom_send(state->lsa_pipe, state, &state->r); 118 composite_continue_rpc(state->ctx, req, cmd_list_trustdoms_recv_doms, 119 state); 120 } 121 122 static void cmd_list_trustdoms_recv_doms(struct rpc_request *req) 117 subreq = dcerpc_lsa_EnumTrustDom_r_send(state, 118 state->ctx->event_ctx, 119 state->lsa_pipe->binding_handle, 120 &state->r); 121 if (composite_nomem(subreq, state->ctx)) return; 122 tevent_req_set_callback(subreq, cmd_list_trustdoms_recv_doms, state); 123 } 124 125 static void cmd_list_trustdoms_recv_doms(struct tevent_req *subreq) 123 126 { 124 127 struct cmd_list_trustdom_state *state = 125 talloc_get_type(req->async.private_data, 126 struct cmd_list_trustdom_state); 127 int i, old_num_domains; 128 129 state->ctx->status = dcerpc_ndr_request_recv(req); 128 tevent_req_callback_data(subreq, 129 struct cmd_list_trustdom_state); 130 uint32_t i, old_num_domains; 131 132 state->ctx->status = dcerpc_lsa_EnumTrustDom_r_recv(subreq, state); 133 TALLOC_FREE(subreq); 130 134 if (!composite_is_ok(state->ctx)) return; 131 135 state->ctx->status = state->r.out.result; … … 148 152 149 153 for (i=0; i<state->r.out.domains->count; i++) { 150 int j = i+old_num_domains;154 uint32_t j = i+old_num_domains; 151 155 state->domains[j] = talloc(state->domains, 152 156 struct wb_dom_info); … … 174 178 state->r.out.domains = &state->domainlist; 175 179 176 req = dcerpc_lsa_EnumTrustDom_send(state->lsa_pipe, state, &state->r); 177 composite_continue_rpc(state->ctx, req, cmd_list_trustdoms_recv_doms, 178 state); 180 subreq = dcerpc_lsa_EnumTrustDom_r_send(state, 181 state->ctx->event_ctx, 182 state->lsa_pipe->binding_handle, 183 &state->r); 184 if (composite_nomem(subreq, state->ctx)) return; 185 tevent_req_set_callback(subreq, cmd_list_trustdoms_recv_doms, state); 179 186 } 180 187 181 188 NTSTATUS wb_cmd_list_trustdoms_recv(struct composite_context *ctx, 182 189 TALLOC_CTX *mem_ctx, 183 int *num_domains,190 uint32_t *num_domains, 184 191 struct wb_dom_info ***domains) 185 192 { -
trunk/server/source4/winbind/wb_cmd_list_users.c
r414 r745 23 23 #include "libcli/composite/composite.h" 24 24 #include "winbind/wb_server.h" 25 #include "winbind/wb_async_helpers.h"26 #include "winbind/wb_helper.h"27 25 #include "smbd/service_task.h" 28 #include "libnet/libnet_proto.h"29 26 30 27 struct cmd_list_users_state { … … 36 33 uint32_t resume_index; 37 34 char *result; 35 uint32_t num_users; 38 36 }; 39 37 … … 59 57 state->service = service; 60 58 state->resume_index = 0; 59 state->num_users = 0; 61 60 state->result = talloc_strdup(state, ""); 62 61 if (composite_nomem(state->result, state->ctx)) return result; … … 137 136 /* If NTSTATUS is neither OK nor MORE_ENTRIES, something broke */ 138 137 if (!NT_STATUS_IS_OK(status) && 139 !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { 138 !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES) && 139 !NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) { 140 140 composite_error(state->ctx, status); 141 141 return; … … 146 146 state->result = talloc_asprintf_append_buffer(state->result, "%s,", 147 147 user_list->out.users[i].username); 148 state->num_users++; 148 149 } 149 150 … … 178 179 NTSTATUS wb_cmd_list_users_recv(struct composite_context *ctx, 179 180 TALLOC_CTX *mem_ctx, uint32_t *extra_data_len, 180 char **extra_data )181 char **extra_data, uint32_t *num_users) 181 182 { 182 183 NTSTATUS status = composite_wait(ctx); … … 190 191 *extra_data_len = strlen(state->result); 191 192 *extra_data = talloc_steal(mem_ctx, state->result); 193 *num_users = state->num_users; 192 194 } 193 195 -
trunk/server/source4/winbind/wb_cmd_lookupname.c
r414 r745 23 23 #include "libcli/composite/composite.h" 24 24 #include "winbind/wb_server.h" 25 #include "winbind/wb_async_helpers.h"26 25 #include "winbind/wb_helper.h" 27 26 #include "smbd/service_task.h" -
trunk/server/source4/winbind/wb_cmd_lookupsid.c
r414 r745 43 43 struct cmd_lookupsid_state *state; 44 44 45 45 DEBUG(5, ("wb_cmd_lookupsid_send called\n")); 46 46 result = composite_create(mem_ctx, service->task->event_ctx); 47 47 if (result == NULL) goto failed; -
trunk/server/source4/winbind/wb_cmd_setpwent.c
r414 r745 23 23 #include "libcli/composite/composite.h" 24 24 #include "winbind/wb_server.h" 25 #include "winbind/wb_async_helpers.h"26 #include "winbind/wb_helper.h"27 25 #include "smbd/service_task.h" 28 #include "libnet/libnet_proto.h"29 26 30 27 struct cmd_setpwent_state { … … 34 31 35 32 struct wbsrv_pwent *result; 33 char *domain_name; 36 34 }; 37 35 … … 84 82 if (composite_nomem(user_list, state->ctx)) return; 85 83 84 state->domain_name = talloc_strdup(state, 85 domain->libnet_ctx->samr.name); 86 86 user_list->in.domain_name = talloc_strdup(state, 87 87 domain->libnet_ctx->samr.name); … … 97 97 NULL); 98 98 99 state->result->page_index = -1; 99 100 composite_continue(state->ctx, ctx, cmd_setpwent_recv_user_list, state); 100 101 } … … 105 106 ctx->async.private_data, struct cmd_setpwent_state); 106 107 struct libnet_UserList *user_list; 107 108 struct libnet_UserList *user_list_send; 108 109 DEBUG(5, ("cmd_setpwent_recv_user_list called\n")); 109 110 … … 112 113 113 114 state->ctx->status = libnet_UserList_recv(ctx, state->result, 114 user_list); 115 if (!composite_is_ok(state->ctx)) return; 115 user_list); 116 if (NT_STATUS_IS_OK(state->ctx->status) || 117 NT_STATUS_EQUAL(state->ctx->status, STATUS_MORE_ENTRIES)) { 118 if (state->result->page_index == -1) { /* First run*/ 119 state->result->user_list = user_list; 120 state->result->page_index = 0; 121 state->result->libnet_ctx = state->libnet_ctx; 122 } else { 123 int i, cnt = state->result->user_list->out.count 124 + user_list->out.count; 125 struct userlist *tmp; 126 tmp = state->result->user_list->out.users; 127 state->result->user_list->out.users = talloc_realloc(state->result, 128 tmp, struct userlist, 129 cnt); 130 tmp = state->result->user_list->out.users; 131 for(i=0;i<user_list->out.count;i++ ) { 132 tmp[state->result->user_list->out.count + i].username 133 = talloc_strdup(state->result, user_list->out.users[i].username); 134 } 135 state->result->user_list->out.count = cnt; 136 talloc_free(user_list); 137 } 116 138 117 state->result->user_list = user_list; 118 state->result->page_index = 0; 119 state->result->libnet_ctx = state->libnet_ctx; 120 121 composite_done(state->ctx); 139 if (NT_STATUS_IS_OK(state->ctx->status) ) { 140 composite_done(state->ctx); 141 } else { 142 user_list_send = talloc(state->result, struct libnet_UserList); 143 if (composite_nomem(user_list_send, state->ctx)) return; 144 user_list_send->in.domain_name = talloc_strdup(state, state->domain_name); 145 user_list_send->in.resume_index = user_list->out.resume_index; 146 user_list_send->in.page_size = 128; 147 ctx = libnet_UserList_send(state->libnet_ctx, state->result, user_list_send, NULL); 148 composite_continue(state->ctx, ctx, cmd_setpwent_recv_user_list, state); 149 } 150 } else { 151 composite_error(state->ctx, state->ctx->status); 152 } 153 return; 122 154 } 123 155 -
trunk/server/source4/winbind/wb_cmd_userdomgroups.c
r414 r745 31 31 struct dom_sid *dom_sid; 32 32 uint32_t user_rid; 33 int num_rids;33 uint32_t num_rids; 34 34 uint32_t *rids; 35 35 }; … … 105 105 NTSTATUS wb_cmd_userdomgroups_recv(struct composite_context *c, 106 106 TALLOC_CTX *mem_ctx, 107 int *num_sids, struct dom_sid ***sids)107 uint32_t *num_sids, struct dom_sid ***sids) 108 108 { 109 109 struct cmd_userdomgroups_state *state = 110 110 talloc_get_type(c->private_data, 111 111 struct cmd_userdomgroups_state); 112 int i;112 uint32_t i; 113 113 NTSTATUS status; 114 114 … … 140 140 struct wbsrv_service *service, 141 141 const struct dom_sid *sid, 142 int *num_sids, struct dom_sid ***sids)142 uint32_t *num_sids, struct dom_sid ***sids) 143 143 { 144 144 struct composite_context *c = -
trunk/server/source4/winbind/wb_cmd_usersids.c
r414 r745 35 35 struct wbsrv_service *service; 36 36 struct dom_sid *user_sid; 37 int num_domgroups;37 uint32_t num_domgroups; 38 38 struct dom_sid **domgroups; 39 39 … … 42 42 struct samr_GetAliasMembership r; 43 43 44 int num_sids;44 uint32_t num_sids; 45 45 struct dom_sid **sids; 46 46 }; … … 48 48 static void usersids_recv_domgroups(struct composite_context *ctx); 49 49 static void usersids_recv_domain(struct composite_context *ctx); 50 static void usersids_recv_aliases(struct rpc_request *req);50 static void usersids_recv_aliases(struct tevent_req *subreq); 51 51 52 52 struct composite_context *wb_cmd_usersids_send(TALLOC_CTX *mem_ctx, … … 103 103 talloc_get_type(ctx->async.private_data, 104 104 struct cmd_usersids_state); 105 struct rpc_request *req;105 struct tevent_req *subreq; 106 106 struct wbsrv_domain *domain; 107 int i;107 uint32_t i; 108 108 109 109 state->ctx->status = wb_sid2domain_recv(ctx, &domain); … … 127 127 state->r.out.rids = &state->rids; 128 128 129 req = dcerpc_samr_GetAliasMembership_send(domain->libnet_ctx->samr.pipe, state, 130 &state->r); 131 composite_continue_rpc(state->ctx, req, usersids_recv_aliases, state); 129 subreq = dcerpc_samr_GetAliasMembership_r_send(state, 130 state->ctx->event_ctx, 131 domain->libnet_ctx->samr.pipe->binding_handle, 132 &state->r); 133 if (composite_nomem(subreq, state->ctx)) return; 134 tevent_req_set_callback(subreq, usersids_recv_aliases, state); 132 135 } 133 136 134 static void usersids_recv_aliases(struct rpc_request *req)137 static void usersids_recv_aliases(struct tevent_req *subreq) 135 138 { 136 139 struct cmd_usersids_state *state = 137 t alloc_get_type(req->async.private_data,138 139 int i;140 tevent_req_callback_data(subreq, 141 struct cmd_usersids_state); 142 uint32_t i; 140 143 141 state->ctx->status = dcerpc_ndr_request_recv(req); 144 state->ctx->status = dcerpc_samr_GetAliasMembership_r_recv(subreq, state); 145 TALLOC_FREE(subreq); 142 146 if (!composite_is_ok(state->ctx)) return; 143 147 state->ctx->status = state->r.out.result; … … 169 173 NTSTATUS wb_cmd_usersids_recv(struct composite_context *ctx, 170 174 TALLOC_CTX *mem_ctx, 171 int *num_sids, struct dom_sid ***sids)175 uint32_t *num_sids, struct dom_sid ***sids) 172 176 { 173 177 NTSTATUS status = composite_wait(ctx); … … 185 189 NTSTATUS wb_cmd_usersids(TALLOC_CTX *mem_ctx, struct wbsrv_service *service, 186 190 const struct dom_sid *sid, 187 int *num_sids, struct dom_sid ***sids)191 uint32_t *num_sids, struct dom_sid ***sids) 188 192 { 189 193 struct composite_context *c = -
trunk/server/source4/winbind/wb_connect_lsa.c
r414 r745 25 25 #include "libcli/composite/composite.h" 26 26 27 #include "libcli/raw/libcliraw.h"28 27 #include "librpc/gen_ndr/ndr_lsa_c.h" 29 28 #include "winbind/wb_server.h" … … 45 44 46 45 static void init_lsa_recv_pipe(struct composite_context *ctx); 47 static void init_lsa_recv_openpol(struct rpc_request *req);46 static void init_lsa_recv_openpol(struct tevent_req *subreq); 48 47 49 48 struct composite_context *wb_init_lsa_send(TALLOC_CTX *mem_ctx, … … 78 77 static void init_lsa_recv_pipe(struct composite_context *ctx) 79 78 { 80 struct rpc_request *req;81 79 struct init_lsa_state *state = 82 80 talloc_get_type(ctx->async.private_data, 83 81 struct init_lsa_state); 82 struct tevent_req *subreq; 84 83 85 84 state->ctx->status = dcerpc_secondary_auth_connection_recv(ctx, state, … … 98 97 state->openpolicy.out.handle = state->handle; 99 98 100 req = dcerpc_lsa_OpenPolicy2_send(state->lsa_pipe, state, 101 &state->openpolicy); 102 composite_continue_rpc(state->ctx, req, init_lsa_recv_openpol, state); 99 subreq = dcerpc_lsa_OpenPolicy2_r_send(state, 100 state->ctx->event_ctx, 101 state->lsa_pipe->binding_handle, 102 &state->openpolicy); 103 if (composite_nomem(subreq, state->ctx)) return; 104 tevent_req_set_callback(subreq, init_lsa_recv_openpol, state); 103 105 } 104 106 105 static void init_lsa_recv_openpol(struct rpc_request *req)107 static void init_lsa_recv_openpol(struct tevent_req *subreq) 106 108 { 107 109 struct init_lsa_state *state = 108 t alloc_get_type(req->async.private_data,109 110 tevent_req_callback_data(subreq, 111 struct init_lsa_state); 110 112 111 state->ctx->status = dcerpc_ndr_request_recv(req); 113 state->ctx->status = dcerpc_lsa_OpenPolicy2_r_recv(subreq, state); 114 TALLOC_FREE(subreq); 112 115 if (!composite_is_ok(state->ctx)) return; 113 116 state->ctx->status = state->openpolicy.out.result; -
trunk/server/source4/winbind/wb_connect_sam.c
r414 r745 24 24 #include "libcli/composite/composite.h" 25 25 26 #include "libcli/raw/libcliraw.h"27 26 #include "libcli/security/security.h" 28 27 #include "librpc/gen_ndr/ndr_samr_c.h" … … 46 45 47 46 static void connect_samr_recv_pipe(struct composite_context *ctx); 48 static void connect_samr_recv_conn(struct rpc_request *req);49 static void connect_samr_recv_open(struct rpc_request *req);47 static void connect_samr_recv_conn(struct tevent_req *subreq); 48 static void connect_samr_recv_open(struct tevent_req *subreq); 50 49 51 50 struct composite_context *wb_connect_samr_send(TALLOC_CTX *mem_ctx, … … 83 82 static void connect_samr_recv_pipe(struct composite_context *ctx) 84 83 { 85 struct rpc_request *req;86 84 struct connect_samr_state *state = 87 85 talloc_get_type(ctx->async.private_data, 88 86 struct connect_samr_state); 87 struct tevent_req *subreq; 89 88 90 89 state->ctx->status = dcerpc_secondary_auth_connection_recv(ctx, state, … … 101 100 state->c.out.connect_handle = state->connect_handle; 102 101 103 req = dcerpc_samr_Connect2_send(state->samr_pipe, state, &state->c); 104 composite_continue_rpc(state->ctx, req, connect_samr_recv_conn, state); 105 return; 102 subreq = dcerpc_samr_Connect2_r_send(state, 103 state->ctx->event_ctx, 104 state->samr_pipe->binding_handle, 105 &state->c); 106 if (composite_nomem(subreq, state->ctx)) return; 107 tevent_req_set_callback(subreq, connect_samr_recv_conn, state); 106 108 } 107 109 108 static void connect_samr_recv_conn(struct rpc_request *req)110 static void connect_samr_recv_conn(struct tevent_req *subreq) 109 111 { 110 112 struct connect_samr_state *state = 111 t alloc_get_type(req->async.private_data,112 113 tevent_req_callback_data(subreq, 114 struct connect_samr_state); 113 115 114 state->ctx->status = dcerpc_ndr_request_recv(req); 116 state->ctx->status = dcerpc_samr_Connect2_r_recv(subreq, state); 117 TALLOC_FREE(subreq); 115 118 if (!composite_is_ok(state->ctx)) return; 116 119 state->ctx->status = state->c.out.result; … … 125 128 state->o.out.domain_handle = state->domain_handle; 126 129 127 req = dcerpc_samr_OpenDomain_send(state->samr_pipe, state, &state->o); 128 composite_continue_rpc(state->ctx, req, 129 connect_samr_recv_open, state); 130 subreq = dcerpc_samr_OpenDomain_r_send(state, 131 state->ctx->event_ctx, 132 state->samr_pipe->binding_handle, 133 &state->o); 134 if (composite_nomem(subreq, state->ctx)) return; 135 tevent_req_set_callback(subreq, connect_samr_recv_open, state); 130 136 } 131 137 132 static void connect_samr_recv_open(struct rpc_request *req)138 static void connect_samr_recv_open(struct tevent_req *subreq) 133 139 { 134 140 struct connect_samr_state *state = 135 t alloc_get_type(req->async.private_data,136 141 tevent_req_callback_data(subreq, 142 struct connect_samr_state); 137 143 138 state->ctx->status = dcerpc_ndr_request_recv(req); 144 state->ctx->status = dcerpc_samr_OpenDomain_r_recv(subreq, state); 145 TALLOC_FREE(subreq); 139 146 if (!composite_is_ok(state->ctx)) return; 140 147 state->ctx->status = state->o.out.result; -
trunk/server/source4/winbind/wb_dom_info.c
r414 r745 27 27 #include "winbind/wb_server.h" 28 28 #include "smbd/service_task.h" 29 #include "librpc/gen_ndr/ndr_irpc.h" 30 #include "librpc/gen_ndr/samr.h" 31 #include "lib/messaging/irpc.h" 32 #include "libcli/finddcs.h" 33 #include "param/param.h" 29 #include "libcli/finddc.h" 34 30 35 31 struct get_dom_info_state { … … 38 34 }; 39 35 40 static void get_dom_info_recv_addrs(struct composite_context *ctx);36 static void get_dom_info_recv_addrs(struct tevent_req *req); 41 37 42 38 struct composite_context *wb_get_dom_info_send(TALLOC_CTX *mem_ctx, 43 39 struct wbsrv_service *service, 44 40 const char *domain_name, 41 const char *dns_domain_name, 45 42 const struct dom_sid *sid) 46 43 { 47 struct composite_context *result, *ctx; 44 struct composite_context *result; 45 struct tevent_req *req; 48 46 struct get_dom_info_state *state; 49 47 struct dom_sid *dom_sid; 48 struct finddcs finddcs_io; 49 50 DEBUG(5, ("wb_get_dom_info_send called\n")); 50 51 result = composite_create(mem_ctx, service->task->event_ctx); 51 52 if (result == NULL) goto failed; … … 68 69 if (dom_sid == NULL) goto failed; 69 70 70 ctx = finddcs_send(mem_ctx, lp_netbios_name(service->task->lp_ctx), 71 lp_nbt_port(service->task->lp_ctx), 72 domain_name, NBT_NAME_LOGON, 73 dom_sid, 74 lp_iconv_convenience(service->task->lp_ctx), 75 lp_resolve_context(service->task->lp_ctx), 76 service->task->event_ctx, 77 service->task->msg_ctx); 78 if (ctx == NULL) goto failed; 71 ZERO_STRUCT(finddcs_io); 72 finddcs_io.in.domain_name = dns_domain_name; 73 finddcs_io.in.domain_sid = dom_sid; 74 finddcs_io.in.minimum_dc_flags = NBT_SERVER_LDAP | NBT_SERVER_DS; 75 if (service->sec_channel_type == SEC_CHAN_RODC) { 76 finddcs_io.in.minimum_dc_flags |= NBT_SERVER_WRITABLE; 77 } 79 78 80 composite_continue(state->ctx, ctx, get_dom_info_recv_addrs, state); 79 req = finddcs_cldap_send(mem_ctx, &finddcs_io, 80 lpcfg_resolve_context(service->task->lp_ctx), 81 service->task->event_ctx); 82 if (req == NULL) goto failed; 83 84 tevent_req_set_callback(req, get_dom_info_recv_addrs, state); 85 81 86 return result; 82 87 … … 86 91 } 87 92 88 static void get_dom_info_recv_addrs(struct composite_context *ctx)93 static void get_dom_info_recv_addrs(struct tevent_req *req) 89 94 { 90 struct get_dom_info_state *state = 91 talloc_get_type(ctx->async.private_data, 92 struct get_dom_info_state); 95 struct get_dom_info_state *state = tevent_req_callback_data(req, struct get_dom_info_state); 96 struct finddcs finddcs_io; 93 97 94 state-> ctx->status = finddcs_recv(ctx, state->info,95 &state->info->num_dcs, 96 &state->info->dcs);98 state->info->dc = talloc(state->info, struct nbt_dc_name); 99 100 state->ctx->status = finddcs_cldap_recv(req, state->info, &finddcs_io); 97 101 if (!composite_is_ok(state->ctx)) return; 102 103 if (finddcs_io.out.netlogon.ntver != NETLOGON_NT_VERSION_5EX) { 104 /* the finddcs code should have mapped the response to 105 the type we want */ 106 DEBUG(0,(__location__ ": unexpected ntver 0x%08x in finddcs response\n", 107 finddcs_io.out.netlogon.ntver)); 108 state->ctx->status = NT_STATUS_UNEXPECTED_NETWORK_ERROR; 109 if (!composite_is_ok(state->ctx)) return; 110 } 111 112 state->info->dc->address = finddcs_io.out.address; 113 state->info->dc->name = finddcs_io.out.netlogon.data.nt5_ex.pdc_dns_name; 98 114 99 115 composite_done(state->ctx); … … 118 134 struct wbsrv_service *service, 119 135 const char *domain_name, 136 const char *dns_domain_name, 120 137 const struct dom_sid *sid, 121 138 struct wb_dom_info **result) 122 139 { 123 140 struct composite_context *ctx = 124 wb_get_dom_info_send(mem_ctx, service, domain_name, sid);141 wb_get_dom_info_send(mem_ctx, service, domain_name, dns_domain_name, sid); 125 142 return wb_get_dom_info_recv(ctx, mem_ctx, result); 126 143 } -
trunk/server/source4/winbind/wb_dom_info_trusted.c
r414 r745 28 28 #include "librpc/gen_ndr/ndr_netlogon_c.h" 29 29 #include "libcli/libcli.h" 30 #include "param/param.h"31 30 32 31 struct trusted_dom_info_state { … … 42 41 43 42 static void trusted_dom_info_recv_domain(struct composite_context *ctx); 44 static void trusted_dom_info_recv_dsr(struct rpc_request *req);45 static void trusted_dom_info_recv_dcname(struct rpc_request *req);43 static void trusted_dom_info_recv_dsr(struct tevent_req *subreq); 44 static void trusted_dom_info_recv_dcname(struct tevent_req *subreq); 46 45 static void trusted_dom_info_recv_dcaddr(struct composite_context *ctx); 47 46 … … 90 89 talloc_get_type(ctx->async.private_data, 91 90 struct trusted_dom_info_state); 92 struct rpc_request *req;91 struct tevent_req *subreq; 93 92 94 93 state->ctx->status = wb_sid2domain_recv(ctx, &state->my_domain); … … 108 107 if (composite_nomem(state->d.out.info, state->ctx)) return; 109 108 110 req = dcerpc_netr_DsRGetDCName_send(state->my_domain->netlogon_pipe, 111 state, &state->d); 112 composite_continue_rpc(state->ctx, req, trusted_dom_info_recv_dsr, 113 state); 109 subreq = dcerpc_netr_DsRGetDCName_r_send(state, 110 state->ctx->event_ctx, 111 state->my_domain->netlogon_pipe->binding_handle, 112 &state->d); 113 if (composite_nomem(subreq, state->ctx)) return; 114 tevent_req_set_callback(subreq, trusted_dom_info_recv_dsr, state); 114 115 } 115 116 … … 118 119 */ 119 120 120 static void trusted_dom_info_recv_dsr(struct rpc_request *req) 121 { 122 struct trusted_dom_info_state *state = 123 talloc_get_type(req->async.private_data, 124 struct trusted_dom_info_state); 125 126 state->ctx->status = dcerpc_ndr_request_recv(req); 121 static void trusted_dom_info_recv_dsr(struct tevent_req *subreq) 122 { 123 struct trusted_dom_info_state *state = 124 tevent_req_callback_data(subreq, 125 struct trusted_dom_info_state); 126 127 state->ctx->status = dcerpc_netr_DsRGetDCName_r_recv(subreq, state); 128 TALLOC_FREE(subreq); 127 129 if (!NT_STATUS_IS_OK(state->ctx->status)) { 128 DEBUG(9, ("dcerpc_n dr_request_recv returned %s\n",130 DEBUG(9, ("dcerpc_netr_DsRGetDCName_recv returned %s\n", 129 131 nt_errstr(state->ctx->status))); 130 132 goto fallback; … … 140 142 141 143 /* Hey, that was easy! */ 142 state->info->num_dcs = 1; 143 state->info->dcs = talloc(state->info, struct nbt_dc_name); 144 state->info->dcs[0].name = talloc_steal(state->info, 144 state->info->dc = talloc(state->info, struct nbt_dc_name); 145 state->info->dc->name = talloc_steal(state->info, 145 146 (*state->d.out.info)->dc_unc); 146 if (*state->info->dc s[0].name == '\\') state->info->dcs[0].name++;147 if (*state->info->dc s[0].name == '\\') state->info->dcs[0].name++;148 149 state->info->dc s[0].address = talloc_steal(state->info,147 if (*state->info->dc->name == '\\') state->info->dc->name++; 148 if (*state->info->dc->name == '\\') state->info->dc->name++; 149 150 state->info->dc->address = talloc_steal(state->info, 150 151 (*state->d.out.info)->dc_address); 151 if (*state->info->dc s[0].address == '\\') state->info->dcs[0].address++;152 if (*state->info->dc s[0].address == '\\') state->info->dcs[0].address++;152 if (*state->info->dc->address == '\\') state->info->dc->address++; 153 if (*state->info->dc->address == '\\') state->info->dc->address++; 153 154 154 155 state->info->dns_name = talloc_steal(state->info, … … 166 167 state->g.out.dcname = talloc(state, const char *); 167 168 168 req = dcerpc_netr_GetAnyDCName_send(state->my_domain->netlogon_pipe, 169 state, &state->g); 170 if (composite_nomem(req, state->ctx)) return; 171 172 composite_continue_rpc(state->ctx, req, trusted_dom_info_recv_dcname, 173 state); 174 } 175 176 static void trusted_dom_info_recv_dcname(struct rpc_request *req) 177 { 178 struct trusted_dom_info_state *state = 179 talloc_get_type(req->async.private_data, 180 struct trusted_dom_info_state); 169 subreq = dcerpc_netr_GetAnyDCName_r_send(state, 170 state->ctx->event_ctx, 171 state->my_domain->netlogon_pipe->binding_handle, 172 &state->g); 173 if (composite_nomem(subreq, state->ctx)) return; 174 175 tevent_req_set_callback(subreq, trusted_dom_info_recv_dcname, state); 176 } 177 178 static void trusted_dom_info_recv_dcname(struct tevent_req *subreq) 179 { 180 struct trusted_dom_info_state *state = 181 tevent_req_callback_data(subreq, 182 struct trusted_dom_info_state); 181 183 struct composite_context *ctx; 182 184 struct nbt_name name; 183 185 184 state->ctx->status = dcerpc_ndr_request_recv(req); 186 state->ctx->status = dcerpc_netr_GetAnyDCName_r_recv(subreq, state); 187 TALLOC_FREE(subreq); 185 188 if (!composite_is_ok(state->ctx)) return; 186 189 state->ctx->status = werror_to_ntstatus(state->g.out.result); … … 188 191 189 192 /* Hey, that was easy! */ 190 state->info->num_dcs = 1; 191 state->info->dcs = talloc(state->info, struct nbt_dc_name); 192 state->info->dcs[0].name = talloc_steal(state->info, 193 state->info->dc = talloc(state->info, struct nbt_dc_name); 194 state->info->dc->name = talloc_steal(state->info, 193 195 *(state->g.out.dcname)); 194 if (*state->info->dc s[0].name == '\\') state->info->dcs[0].name++;195 if (*state->info->dc s[0].name == '\\') state->info->dcs[0].name++;196 if (*state->info->dc->name == '\\') state->info->dc->name++; 197 if (*state->info->dc->name == '\\') state->info->dc->name++; 196 198 197 make_nbt_name(&name, state->info->dc s[0].name, 0x20);198 ctx = resolve_name_send(lp _resolve_context(state->service->task->lp_ctx), state,199 make_nbt_name(&name, state->info->dc->name, 0x20); 200 ctx = resolve_name_send(lpcfg_resolve_context(state->service->task->lp_ctx), state, 199 201 &name, state->service->task->event_ctx); 200 202 … … 210 212 211 213 state->ctx->status = resolve_name_recv(ctx, state->info, 212 &state->info->dc s[0].address);214 &state->info->dc->address); 213 215 if (!composite_is_ok(state->ctx)) return; 214 216 -
trunk/server/source4/winbind/wb_gid2sid.c
r414 r745 24 24 #include "winbind/wb_server.h" 25 25 #include "smbd/service_task.h" 26 #include "winbind/wb_helper.h"27 #include "libcli/security/proto.h"28 #include "winbind/idmap.h"29 26 30 27 struct gid2sid_state { … … 41 38 struct composite_context *result, *ctx; 42 39 struct gid2sid_state *state; 43 struct unixid *unixid; 44 struct id_mapping *ids; 40 struct id_map *ids; 45 41 46 42 DEBUG(5, ("wb_gid2sid_send called\n")); … … 56 52 state->service = service; 57 53 58 unixid = talloc(result, struct unixid); 59 if (composite_nomem(unixid, result)) return result; 60 unixid->id = gid; 61 unixid->type = ID_TYPE_GID; 62 63 ids = talloc(result, struct id_mapping); 54 ids = talloc(result, struct id_map); 64 55 if (composite_nomem(ids, result)) return result; 65 ids->unixid = unixid; 56 ids->xid.id = gid; 57 ids->xid.type = ID_TYPE_GID; 66 58 ids->sid = NULL; 67 59 … … 77 69 struct gid2sid_state *state = talloc_get_type(ctx->async.private_data, 78 70 struct gid2sid_state); 79 struct id_map ping*ids = NULL;71 struct id_map *ids = NULL; 80 72 state->ctx->status = wb_xids2sids_recv(ctx, &ids); 81 73 if (!composite_is_ok(state->ctx)) return; 82 74 83 if ( !NT_STATUS_IS_OK(ids->status)) {84 composite_error(state->ctx, ids->status);75 if (ids->status != ID_MAPPED) { 76 composite_error(state->ctx, NT_STATUS_UNSUCCESSFUL); 85 77 return; 86 78 } -
trunk/server/source4/winbind/wb_init_domain.c
r414 r745 23 23 #include "includes.h" 24 24 #include "libcli/composite/composite.h" 25 #include "libcli/smb_composite/smb_composite.h"26 25 #include "winbind/wb_server.h" 27 #include "winbind/wb_async_helpers.h"28 #include "winbind/wb_helper.h"29 26 #include "smbd/service_task.h" 30 27 #include "librpc/gen_ndr/ndr_netlogon.h" … … 33 30 #include "libcli/libcli.h" 34 31 35 #include "libcli/auth/credentials.h"36 32 #include "libcli/security/security.h" 37 33 38 #include "libcli/ldap/ldap_client.h"39 34 40 35 #include "auth/credentials/credentials.h" … … 76 71 static void init_domain_recv_netlogonpipe(struct composite_context *ctx); 77 72 static void init_domain_recv_lsa_pipe(struct composite_context *ctx); 78 static void init_domain_recv_lsa_policy(struct rpc_request *req);79 static void init_domain_recv_queryinfo(struct rpc_request *req);73 static void init_domain_recv_lsa_policy(struct tevent_req *subreq); 74 static void init_domain_recv_queryinfo(struct tevent_req *subreq); 80 75 static void init_domain_recv_samr(struct composite_context *ctx); 81 76 … … 134 129 if (state->domain->info == NULL) goto failed; 135 130 136 /* Caller should check, but to be safe: */ 137 if (dom_info->num_dcs < 1) { 138 goto failed; 139 } 140 141 /* For now, we just pick the first. The next step will be to 142 * walk the entire list. Also need to fix finddcs() to return 143 * the entire list */ 144 state->domain->dc_name = dom_info->dcs[0].name; 145 state->domain->dc_address = dom_info->dcs[0].address; 131 state->domain->dc_name = dom_info->dc->name; 132 state->domain->dc_address = dom_info->dc->address; 146 133 147 134 state->domain->libnet_ctx = libnet_context_init(service->task->event_ctx, … … 164 151 165 152 if ((!cli_credentials_is_anonymous(state->domain->libnet_ctx->cred)) && 166 ((lp _server_role(service->task->lp_ctx) == ROLE_DOMAIN_MEMBER) ||167 (lp _server_role(service->task->lp_ctx) == ROLE_DOMAIN_CONTROLLER)) &&153 ((lpcfg_server_role(service->task->lp_ctx) == ROLE_DOMAIN_MEMBER) || 154 (lpcfg_server_role(service->task->lp_ctx) == ROLE_DOMAIN_CONTROLLER)) && 168 155 (dom_sid_equal(state->domain->info->sid, 169 156 state->service->primary_sid))) { … … 171 158 172 159 /* For debugging, it can be a real pain if all the traffic is encrypted */ 173 if (lp _winbind_sealed_pipes(service->task->lp_ctx)) {160 if (lpcfg_winbind_sealed_pipes(service->task->lp_ctx)) { 174 161 state->domain->netlogon_binding->flags |= (DCERPC_SIGN | DCERPC_SEAL ); 175 162 } else { … … 217 204 218 205 /* For debugging, it can be a real pain if all the traffic is encrypted */ 219 if (lp _winbind_sealed_pipes(state->service->task->lp_ctx)) {206 if (lpcfg_winbind_sealed_pipes(state->service->task->lp_ctx)) { 220 207 state->domain->lsa_binding->flags |= (DCERPC_SIGN | DCERPC_SEAL ); 221 208 } else { … … 270 257 static void init_domain_recv_lsa_pipe(struct composite_context *ctx) 271 258 { 272 struct rpc_request *req;273 259 struct init_domain_state *state = 274 260 talloc_get_type(ctx->async.private_data, 275 261 struct init_domain_state); 262 struct tevent_req *subreq; 276 263 277 264 state->ctx->status = dcerpc_secondary_auth_connection_recv(ctx, state->domain, … … 300 287 state->lsa_openpolicy.out.handle = &state->domain->libnet_ctx->lsa.handle; 301 288 302 req = dcerpc_lsa_OpenPolicy2_send(state->domain->libnet_ctx->lsa.pipe, state, 303 &state->lsa_openpolicy); 304 305 composite_continue_rpc(state->ctx, req, init_domain_recv_lsa_policy, state); 289 subreq = dcerpc_lsa_OpenPolicy2_r_send(state, 290 state->ctx->event_ctx, 291 state->domain->libnet_ctx->lsa.pipe->binding_handle, 292 &state->lsa_openpolicy); 293 if (composite_nomem(subreq, state->ctx)) return; 294 tevent_req_set_callback(subreq, init_domain_recv_lsa_policy, state); 306 295 } 307 296 … … 309 298 * obtain some basic information about the domain */ 310 299 311 static void init_domain_recv_lsa_policy(struct rpc_request *req)300 static void init_domain_recv_lsa_policy(struct tevent_req *subreq) 312 301 { 313 302 struct init_domain_state *state = 314 talloc_get_type(req->async.private_data, 315 struct init_domain_state); 316 317 state->ctx->status = dcerpc_ndr_request_recv(req); 303 tevent_req_callback_data(subreq, 304 struct init_domain_state); 305 306 state->ctx->status = dcerpc_lsa_OpenPolicy2_r_recv(subreq, state); 307 TALLOC_FREE(subreq); 318 308 if ((!NT_STATUS_IS_OK(state->ctx->status) 319 309 || !NT_STATUS_IS_OK(state->lsa_openpolicy.out.result))) { … … 335 325 state->queryinfo.out.info = &state->info; 336 326 337 req = dcerpc_lsa_QueryInfoPolicy_send(state->domain->libnet_ctx->lsa.pipe, state, 338 &state->queryinfo); 339 composite_continue_rpc(state->ctx, req, 340 init_domain_recv_queryinfo, state); 341 } 342 343 static void init_domain_recv_queryinfo(struct rpc_request *req) 327 subreq = dcerpc_lsa_QueryInfoPolicy_r_send(state, 328 state->ctx->event_ctx, 329 state->domain->libnet_ctx->lsa.pipe->binding_handle, 330 &state->queryinfo); 331 if (composite_nomem(subreq, state->ctx)) return; 332 tevent_req_set_callback(subreq, init_domain_recv_queryinfo, state); 333 } 334 335 static void init_domain_recv_queryinfo(struct tevent_req *subreq) 344 336 { 345 337 struct init_domain_state *state = 346 talloc_get_type(req->async.private_data, struct init_domain_state); 338 tevent_req_callback_data(subreq, 339 struct init_domain_state); 347 340 struct lsa_DomainInfo *dominfo; 348 341 struct composite_context *ctx; 349 342 350 state->ctx->status = dcerpc_ndr_request_recv(req); 343 state->ctx->status = dcerpc_lsa_QueryInfoPolicy_r_recv(subreq, state); 344 TALLOC_FREE(subreq); 351 345 if (!composite_is_ok(state->ctx)) return; 352 346 state->ctx->status = state->queryinfo.out.result; -
trunk/server/source4/winbind/wb_irpc.c
r414 r745 23 23 #include "lib/messaging/irpc.h" 24 24 #include "libcli/composite/composite.h" 25 #include "libcli/security/proto.h"26 25 #include "librpc/gen_ndr/ndr_winbind.h" 27 26 #include "smbd/service_task.h" … … 69 68 70 69 status = wb_sam_logon_recv(ctx, s, s->req); 70 71 irpc_send_reply(s->msg, status); 72 } 73 74 struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state { 75 struct irpc_message *msg; 76 struct winbind_DsrUpdateReadOnlyServerDnsRecords *req; 77 }; 78 79 static void wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback(struct composite_context *ctx); 80 81 static NTSTATUS wb_irpc_DsrUpdateReadOnlyServerDnsRecords(struct irpc_message *msg, 82 struct winbind_DsrUpdateReadOnlyServerDnsRecords *req) 83 { 84 struct wbsrv_service *service = talloc_get_type(msg->private_data, 85 struct wbsrv_service); 86 struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state *s; 87 struct composite_context *ctx; 88 89 DEBUG(5, ("wb_irpc_DsrUpdateReadOnlyServerDnsRecords called\n")); 90 91 s = talloc(msg, struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state); 92 NT_STATUS_HAVE_NO_MEMORY(s); 93 94 s->msg = msg; 95 s->req = req; 96 97 ctx = wb_update_rodc_dns_send(msg, service, req); 98 NT_STATUS_HAVE_NO_MEMORY(ctx); 99 100 ctx->async.fn = wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback; 101 ctx->async.private_data = s; 102 103 msg->defer_reply = true; 104 return NT_STATUS_OK; 105 } 106 107 static void wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback(struct composite_context *ctx) 108 { 109 struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state *s = talloc_get_type(ctx->async.private_data, 110 struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state); 111 NTSTATUS status; 112 113 DEBUG(5, ("wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback called\n")); 114 115 status = wb_update_rodc_dns_recv(ctx, s, s->req); 71 116 72 117 irpc_send_reply(s->msg, status); … … 87 132 struct wbsrv_service); 88 133 struct wb_irpc_get_idmap_state *s; 89 struct composite_context *ctx ;134 struct composite_context *ctx = NULL; 90 135 91 136 DEBUG(5, ("wb_irpc_get_idmap called\n")); … … 151 196 NT_STATUS_NOT_OK_RETURN(status); 152 197 198 status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_DSRUPDATEREADONLYSERVERDNSRECORDS, 199 wb_irpc_DsrUpdateReadOnlyServerDnsRecords, service); 200 NT_STATUS_NOT_OK_RETURN(status); 201 153 202 status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_GET_IDMAP, 154 203 wb_irpc_get_idmap, service); -
trunk/server/source4/winbind/wb_name2domain.c
r414 r745 25 25 #include "smbd/service_task.h" 26 26 #include "winbind/wb_helper.h" 27 #include "param/param.h"28 27 29 28 struct name2domain_state { -
trunk/server/source4/winbind/wb_pam_auth.c
r414 r745 28 28 #include "libcli/auth/libcli_auth.h" 29 29 #include "librpc/gen_ndr/ndr_netlogon.h" 30 #include "librpc/gen_ndr/ndr_netlogon_c.h"31 30 #include "librpc/gen_ndr/winbind.h" 32 31 #include "param/param.h" … … 144 143 145 144 ndr_err = ndr_push_struct_blob( 146 &tmp_blob, state, lp_iconv_convenience(state->lp_ctx), 147 state->req->out.validation.sam3, 145 &tmp_blob, state, state->req->out.validation.sam3, 148 146 (ndr_push_flags_fn_t)ndr_push_netr_SamInfo3); 149 147 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 180 178 state->unix_username = talloc_asprintf(state, "%s%s%s", 181 179 state->domain_name, 182 lp _winbind_separator(state->lp_ctx),180 lpcfg_winbind_separator(state->lp_ctx), 183 181 state->user_name); 184 182 if (composite_nomem(state->unix_username, state->ctx)) return; … … 222 220 DATA_BLOB chal, nt_resp, lm_resp, names_blob; 223 221 int flags = CLI_CRED_NTLM_AUTH; 224 if (lp _client_lanman_auth(service->task->lp_ctx)) {222 if (lpcfg_client_lanman_auth(service->task->lp_ctx)) { 225 223 flags |= CLI_CRED_LANMAN_AUTH; 226 224 } 227 225 228 if (lp _client_ntlmv2_auth(service->task->lp_ctx)) {226 if (lpcfg_client_ntlmv2_auth(service->task->lp_ctx)) { 229 227 flags |= CLI_CRED_NTLMv2_AUTH; 230 228 } … … 261 259 } 262 260 263 NTSTATUS wb_cmd_pam_auth_recv(struct composite_context *c) 264 { 265 struct pam_auth_crap_state *state = 266 talloc_get_type(c->private_data, struct pam_auth_crap_state); 267 NTSTATUS status = composite_wait(c); 268 talloc_free(state); 269 return status; 270 } 261 NTSTATUS wb_cmd_pam_auth_recv(struct composite_context *c, 262 TALLOC_CTX *mem_ctx, 263 DATA_BLOB *info3, 264 struct netr_UserSessionKey *user_session_key, 265 struct netr_LMSessionKey *lm_key, 266 char **unix_username) 267 { 268 struct pam_auth_crap_state *state = 269 talloc_get_type(c->private_data, struct pam_auth_crap_state); 270 NTSTATUS status = composite_wait(c); 271 if (NT_STATUS_IS_OK(status)) { 272 if (info3) { 273 info3->length = state->info3.length; 274 info3->data = talloc_steal(mem_ctx, state->info3.data); 275 } 276 if (user_session_key) { 277 *user_session_key = state->user_session_key; 278 } 279 if (lm_key) { 280 *lm_key = state->lm_key; 281 } 282 if (unix_username) { 283 *unix_username = talloc_steal(mem_ctx, state->unix_username); 284 } 285 } 286 talloc_free(state); 287 return status; 288 } -
trunk/server/source4/winbind/wb_sam_logon.c
r414 r745 28 28 #include "auth/credentials/credentials.h" 29 29 #include "libcli/auth/libcli_auth.h" 30 #include "librpc/gen_ndr/ndr_netlogon.h"31 30 #include "librpc/gen_ndr/ndr_netlogon_c.h" 32 31 #include "librpc/gen_ndr/winbind.h" … … 45 44 46 45 static void wb_sam_logon_recv_domain(struct composite_context *ctx); 47 static void wb_sam_logon_recv_samlogon(struct rpc_request *req);46 static void wb_sam_logon_recv_samlogon(struct tevent_req *subreq); 48 47 49 48 /* … … 80 79 struct wb_sam_logon_state *s = talloc_get_type(creq->async.private_data, 81 80 struct wb_sam_logon_state); 82 struct rpc_request *req;83 81 struct wbsrv_domain *domain; 82 struct tevent_req *subreq; 84 83 85 84 s->ctx->status = wb_sid2domain_recv(creq, &domain); … … 115 114 if (composite_nomem(s->r_mem_ctx, s->ctx)) return; 116 115 117 req = dcerpc_netr_LogonSamLogon_send(domain->netlogon_pipe, s->r_mem_ctx, &s->r); 118 composite_continue_rpc(s->ctx, req, wb_sam_logon_recv_samlogon, s); 116 subreq = dcerpc_netr_LogonSamLogon_r_send(s, 117 s->ctx->event_ctx, 118 domain->netlogon_pipe->binding_handle, 119 &s->r); 120 if (composite_nomem(subreq, s->ctx)) return; 121 tevent_req_set_callback(subreq, wb_sam_logon_recv_samlogon, s); 119 122 } 120 123 … … 124 127 Check the SamLogon reply and decrypt the session keys 125 128 */ 126 static void wb_sam_logon_recv_samlogon(struct rpc_request *req)129 static void wb_sam_logon_recv_samlogon(struct tevent_req *subreq) 127 130 { 128 struct wb_sam_logon_state *s = t alloc_get_type(req->async.private_data,131 struct wb_sam_logon_state *s = tevent_req_callback_data(subreq, 129 132 struct wb_sam_logon_state); 130 133 131 s->ctx->status = dcerpc_ndr_request_recv(req); 134 s->ctx->status = dcerpc_netr_LogonSamLogon_r_recv(subreq, s->r_mem_ctx); 135 TALLOC_FREE(subreq); 132 136 if (!composite_is_ok(s->ctx)) return; 133 137 -
trunk/server/source4/winbind/wb_samba3_cmd.c
r414 r745 24 24 #include "includes.h" 25 25 #include "winbind/wb_server.h" 26 #include "winbind/wb_async_helpers.h"27 26 #include "param/param.h" 28 27 #include "winbind/wb_helper.h" 29 28 #include "libcli/composite/composite.h" 30 29 #include "version.h" 31 #include "librpc/gen_ndr/n etlogon.h"30 #include "librpc/gen_ndr/ndr_netlogon.h" 32 31 #include "libcli/security/security.h" 33 #include " auth/ntlm/pam_errors.h"32 #include "../libcli/auth/pam_errors.h" 34 33 #include "auth/credentials/credentials.h" 35 34 #include "smbd/service_task.h" 35 36 /* 37 support the old Samba3 TXT form of the info3 38 */ 39 static NTSTATUS wb_samba3_append_info3_as_txt(TALLOC_CTX *mem_ctx, 40 struct wbsrv_samba3_call *s3call, 41 DATA_BLOB info3b) 42 { 43 struct netr_SamInfo3 *info3; 44 char *ex; 45 uint32_t i; 46 enum ndr_err_code ndr_err; 47 48 info3 = talloc(mem_ctx, struct netr_SamInfo3); 49 NT_STATUS_HAVE_NO_MEMORY(info3); 50 51 /* The Samba3 protocol has a redundent 4 bytes at the start */ 52 info3b.data += 4; 53 info3b.length -= 4; 54 55 ndr_err = ndr_pull_struct_blob(&info3b, 56 mem_ctx, 57 info3, 58 (ndr_pull_flags_fn_t)ndr_pull_netr_SamInfo3); 59 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 60 return ndr_map_error2ntstatus(ndr_err); 61 } 62 63 s3call->response->data.auth.info3.logon_time = 64 nt_time_to_unix(info3->base.last_logon); 65 s3call->response->data.auth.info3.logoff_time = 66 nt_time_to_unix(info3->base.last_logoff); 67 s3call->response->data.auth.info3.kickoff_time = 68 nt_time_to_unix(info3->base.acct_expiry); 69 s3call->response->data.auth.info3.pass_last_set_time = 70 nt_time_to_unix(info3->base.last_password_change); 71 s3call->response->data.auth.info3.pass_can_change_time = 72 nt_time_to_unix(info3->base.allow_password_change); 73 s3call->response->data.auth.info3.pass_must_change_time = 74 nt_time_to_unix(info3->base.force_password_change); 75 76 s3call->response->data.auth.info3.logon_count = info3->base.logon_count; 77 s3call->response->data.auth.info3.bad_pw_count = info3->base.bad_password_count; 78 79 s3call->response->data.auth.info3.user_rid = info3->base.rid; 80 s3call->response->data.auth.info3.group_rid = info3->base.primary_gid; 81 fstrcpy(s3call->response->data.auth.info3.dom_sid, dom_sid_string(mem_ctx, info3->base.domain_sid)); 82 83 s3call->response->data.auth.info3.num_groups = info3->base.groups.count; 84 s3call->response->data.auth.info3.user_flgs = info3->base.user_flags; 85 86 s3call->response->data.auth.info3.acct_flags = info3->base.acct_flags; 87 s3call->response->data.auth.info3.num_other_sids = info3->sidcount; 88 89 fstrcpy(s3call->response->data.auth.info3.user_name, 90 info3->base.account_name.string); 91 fstrcpy(s3call->response->data.auth.info3.full_name, 92 info3->base.full_name.string); 93 fstrcpy(s3call->response->data.auth.info3.logon_script, 94 info3->base.logon_script.string); 95 fstrcpy(s3call->response->data.auth.info3.profile_path, 96 info3->base.profile_path.string); 97 fstrcpy(s3call->response->data.auth.info3.home_dir, 98 info3->base.home_directory.string); 99 fstrcpy(s3call->response->data.auth.info3.dir_drive, 100 info3->base.home_drive.string); 101 102 fstrcpy(s3call->response->data.auth.info3.logon_srv, 103 info3->base.logon_server.string); 104 fstrcpy(s3call->response->data.auth.info3.logon_dom, 105 info3->base.domain.string); 106 107 ex = talloc_strdup(mem_ctx, ""); 108 NT_STATUS_HAVE_NO_MEMORY(ex); 109 110 for (i=0; i < info3->base.groups.count; i++) { 111 ex = talloc_asprintf_append_buffer(ex, "0x%08X:0x%08X\n", 112 info3->base.groups.rids[i].rid, 113 info3->base.groups.rids[i].attributes); 114 NT_STATUS_HAVE_NO_MEMORY(ex); 115 } 116 117 for (i=0; i < info3->sidcount; i++) { 118 char *sid; 119 120 sid = dom_sid_string(mem_ctx, info3->sids[i].sid); 121 NT_STATUS_HAVE_NO_MEMORY(sid); 122 123 ex = talloc_asprintf_append_buffer(ex, "%s:0x%08X\n", 124 sid, 125 info3->sids[i].attributes); 126 NT_STATUS_HAVE_NO_MEMORY(ex); 127 128 talloc_free(sid); 129 } 130 131 s3call->response->extra_data.data = ex; 132 s3call->response->length += talloc_get_size(ex); 133 134 return NT_STATUS_OK; 135 } 36 136 37 137 /* … … 42 142 struct wbsrv_samba3_call *s3call) 43 143 { 44 struct winbindd_response *resp = &s3call->response;144 struct winbindd_response *resp = s3call->response; 45 145 if (!NT_STATUS_IS_OK(status)) { 46 146 resp->result = WINBINDD_ERROR; … … 67 167 struct wbsrv_samba3_call *s3call) 68 168 { 69 struct winbindd_response *resp = &s3call->response;169 struct winbindd_response *resp = s3call->response; 70 170 if (NT_STATUS_IS_OK(status)) { 71 171 resp->result = WINBINDD_OK; … … 83 183 NTSTATUS wbsrv_samba3_interface_version(struct wbsrv_samba3_call *s3call) 84 184 { 85 s3call->response .result = WINBINDD_OK;86 s3call->response .data.interface_version = WINBIND_INTERFACE_VERSION;185 s3call->response->result = WINBINDD_OK; 186 s3call->response->data.interface_version = WINBIND_INTERFACE_VERSION; 87 187 return NT_STATUS_OK; 88 188 } … … 90 190 NTSTATUS wbsrv_samba3_info(struct wbsrv_samba3_call *s3call) 91 191 { 92 s3call->response .result = WINBINDD_OK;93 s3call->response .data.info.winbind_separator = *lp_winbind_separator(s3call->wbconn->lp_ctx);94 WBSRV_SAMBA3_SET_STRING(s3call->response .data.info.samba_version,192 s3call->response->result = WINBINDD_OK; 193 s3call->response->data.info.winbind_separator = *lpcfg_winbind_separator(s3call->wbconn->lp_ctx); 194 WBSRV_SAMBA3_SET_STRING(s3call->response->data.info.samba_version, 95 195 SAMBA_VERSION_STRING); 96 196 return NT_STATUS_OK; … … 99 199 NTSTATUS wbsrv_samba3_domain_name(struct wbsrv_samba3_call *s3call) 100 200 { 101 s3call->response .result = WINBINDD_OK;102 WBSRV_SAMBA3_SET_STRING(s3call->response .data.domain_name,103 lp _workgroup(s3call->wbconn->lp_ctx));201 s3call->response->result = WINBINDD_OK; 202 WBSRV_SAMBA3_SET_STRING(s3call->response->data.domain_name, 203 lpcfg_workgroup(s3call->wbconn->lp_ctx)); 104 204 return NT_STATUS_OK; 105 205 } … … 107 207 NTSTATUS wbsrv_samba3_netbios_name(struct wbsrv_samba3_call *s3call) 108 208 { 109 s3call->response .result = WINBINDD_OK;110 WBSRV_SAMBA3_SET_STRING(s3call->response .data.netbios_name,111 lp _netbios_name(s3call->wbconn->lp_ctx));209 s3call->response->result = WINBINDD_OK; 210 WBSRV_SAMBA3_SET_STRING(s3call->response->data.netbios_name, 211 lpcfg_netbios_name(s3call->wbconn->lp_ctx)); 112 212 return NT_STATUS_OK; 113 213 } … … 115 215 NTSTATUS wbsrv_samba3_priv_pipe_dir(struct wbsrv_samba3_call *s3call) 116 216 { 117 const char *path = s3call->wbconn->listen_socket->service->priv_socket_path; 118 s3call->response.result = WINBINDD_OK; 119 s3call->response.extra_data.data = discard_const(path); 120 121 s3call->response.length += strlen(path) + 1; 217 struct loadparm_context *lp_ctx = s3call->wbconn->listen_socket->service->task->lp_ctx; 218 const char *priv_socket_dir = lpcfg_winbindd_privileged_socket_directory(lp_ctx); 219 220 s3call->response->result = WINBINDD_OK; 221 s3call->response->extra_data.data = discard_const(priv_socket_dir); 222 223 s3call->response->length += strlen(priv_socket_dir) + 1; 122 224 return NT_STATUS_OK; 123 225 } … … 125 227 NTSTATUS wbsrv_samba3_ping(struct wbsrv_samba3_call *s3call) 126 228 { 127 s3call->response .result = WINBINDD_OK;229 s3call->response->result = WINBINDD_OK; 128 230 return NT_STATUS_OK; 129 231 } … … 132 234 { 133 235 DEBUG(5, ("wbsrv_samba3_domain_info called, stub\n")); 134 s3call->response .result = WINBINDD_OK;135 fstrcpy(s3call->response .data.domain_info.name,136 s3call->request .domain_name);137 fstrcpy(s3call->response .data.domain_info.alt_name,138 s3call->request .domain_name);139 fstrcpy(s3call->response .data.domain_info.sid, "S-1-2-3-4");140 s3call->response .data.domain_info.native_mode = false;141 s3call->response .data.domain_info.active_directory = false;142 s3call->response .data.domain_info.primary = false;236 s3call->response->result = WINBINDD_OK; 237 fstrcpy(s3call->response->data.domain_info.name, 238 s3call->request->domain_name); 239 fstrcpy(s3call->response->data.domain_info.alt_name, 240 s3call->request->domain_name); 241 fstrcpy(s3call->response->data.domain_info.sid, "S-1-2-3-4"); 242 s3call->response->data.domain_info.native_mode = false; 243 s3call->response->data.domain_info.active_directory = false; 244 s3call->response->data.domain_info.primary = false; 143 245 144 246 return NT_STATUS_OK; … … 197 299 NTSTATUS status; 198 300 199 status = wb_cmd_pam_auth_recv(ctx );301 status = wb_cmd_pam_auth_recv(ctx, s3call, NULL, NULL, NULL, NULL); 200 302 201 303 if (!NT_STATUS_IS_OK(status)) goto done; … … 221 323 222 324 ctx = wb_cmd_getdcname_send(s3call, service, 223 s3call->request .domain_name);325 s3call->request->domain_name); 224 326 NT_STATUS_HAVE_NO_MEMORY(ctx); 225 327 … … 241 343 if (!NT_STATUS_IS_OK(status)) goto done; 242 344 243 s3call->response .result = WINBINDD_OK;244 WBSRV_SAMBA3_SET_STRING(s3call->response .data.dc_name, dcname);345 s3call->response->result = WINBINDD_OK; 346 WBSRV_SAMBA3_SET_STRING(s3call->response->data.dc_name, dcname); 245 347 246 348 done: … … 261 363 DEBUG(5, ("wbsrv_samba3_userdomgroups called\n")); 262 364 263 sid = dom_sid_parse_talloc(s3call, s3call->request .data.sid);365 sid = dom_sid_parse_talloc(s3call, s3call->request->data.sid); 264 366 if (sid == NULL) { 265 367 DEBUG(5, ("Could not parse sid %s\n", 266 s3call->request .data.sid));368 s3call->request->data.sid)); 267 369 return NT_STATUS_NO_MEMORY; 268 370 } … … 283 385 talloc_get_type(ctx->async.private_data, 284 386 struct wbsrv_samba3_call); 285 int i, num_sids;387 uint32_t i, num_sids; 286 388 struct dom_sid **sids; 287 389 char *sids_string; … … 307 409 } 308 410 309 s3call->response .result = WINBINDD_OK;310 s3call->response .extra_data.data = sids_string;311 s3call->response .length += strlen(sids_string)+1;312 s3call->response .data.num_entries = num_sids;411 s3call->response->result = WINBINDD_OK; 412 s3call->response->extra_data.data = sids_string; 413 s3call->response->length += strlen(sids_string)+1; 414 s3call->response->data.num_entries = num_sids; 313 415 314 416 done: … … 328 430 DEBUG(5, ("wbsrv_samba3_usersids called\n")); 329 431 330 sid = dom_sid_parse_talloc(s3call, s3call->request .data.sid);432 sid = dom_sid_parse_talloc(s3call, s3call->request->data.sid); 331 433 if (sid == NULL) { 332 434 DEBUG(5, ("Could not parse sid %s\n", 333 s3call->request .data.sid));435 s3call->request->data.sid)); 334 436 return NT_STATUS_NO_MEMORY; 335 437 } … … 350 452 talloc_get_type(ctx->async.private_data, 351 453 struct wbsrv_samba3_call); 352 int i, num_sids;454 uint32_t i, num_sids; 353 455 struct dom_sid **sids; 354 456 char *sids_string; … … 373 475 } 374 476 375 s3call->response .result = WINBINDD_OK;376 s3call->response .extra_data.data = sids_string;377 s3call->response .length += strlen(sids_string);378 s3call->response .data.num_entries = num_sids;477 s3call->response->result = WINBINDD_OK; 478 s3call->response->extra_data.data = sids_string; 479 s3call->response->length += strlen(sids_string); 480 s3call->response->data.num_entries = num_sids; 379 481 380 482 /* Hmmmm. Nasty protocol -- who invented the zeros between the … … 407 509 408 510 ctx = wb_cmd_lookupname_send(s3call, service, 409 s3call->request .data.name.dom_name,410 s3call->request .data.name.name);511 s3call->request->data.name.dom_name, 512 s3call->request->data.name.name); 411 513 NT_STATUS_HAVE_NO_MEMORY(ctx); 412 514 … … 429 531 if (!NT_STATUS_IS_OK(status)) goto done; 430 532 431 s3call->response .result = WINBINDD_OK;432 s3call->response .data.sid.type = sid->type;433 WBSRV_SAMBA3_SET_STRING(s3call->response .data.sid.sid,533 s3call->response->result = WINBINDD_OK; 534 s3call->response->data.sid.type = sid->type; 535 WBSRV_SAMBA3_SET_STRING(s3call->response->data.sid.sid, 434 536 dom_sid_string(s3call, sid->sid)); 435 537 … … 453 555 DEBUG(5, ("wbsrv_samba3_lookupsid called\n")); 454 556 455 sid = dom_sid_parse_talloc(s3call, s3call->request .data.sid);557 sid = dom_sid_parse_talloc(s3call, s3call->request->data.sid); 456 558 if (sid == NULL) { 457 559 DEBUG(5, ("Could not parse sid %s\n", 458 s3call->request .data.sid));560 s3call->request->data.sid)); 459 561 return NT_STATUS_NO_MEMORY; 460 562 } … … 481 583 if (!NT_STATUS_IS_OK(status)) goto done; 482 584 483 s3call->response .result = WINBINDD_OK;484 s3call->response .data.name.type = sid->type;485 WBSRV_SAMBA3_SET_STRING(s3call->response .data.name.dom_name,585 s3call->response->result = WINBINDD_OK; 586 s3call->response->data.name.type = sid->type; 587 WBSRV_SAMBA3_SET_STRING(s3call->response->data.name.dom_name, 486 588 sid->domain); 487 WBSRV_SAMBA3_SET_STRING(s3call->response .data.name.name, sid->name);589 WBSRV_SAMBA3_SET_STRING(s3call->response->data.name.name, sid->name); 488 590 489 591 done: 490 592 wbsrv_samba3_async_epilogue(status, s3call); 593 } 594 595 /* 596 This is a stub function in order to limit error message in the pam_winbind module 597 */ 598 NTSTATUS wbsrv_samba3_pam_logoff(struct wbsrv_samba3_call *s3call) 599 { 600 NTSTATUS status; 601 struct winbindd_response *resp = s3call->response; 602 603 status = NT_STATUS_OK; 604 605 DEBUG(5, ("wbsrv_samba3_pam_logoff called\n")); 606 DEBUG(10, ("Winbind logoff not implemented\n")); 607 resp->result = WINBINDD_OK; 608 609 WBSRV_SAMBA3_SET_STRING(resp->data.auth.nt_status_string, 610 nt_errstr(status)); 611 WBSRV_SAMBA3_SET_STRING(resp->data.auth.error_string, 612 get_friendly_nt_error_msg(status)); 613 614 resp->data.auth.pam_error = nt_status_to_pam(status); 615 resp->data.auth.nt_status = NT_STATUS_V(status); 616 DEBUG(5, ("wbsrv_samba3_pam_logoff called\n")); 617 618 return NT_STATUS_OK; 491 619 } 492 620 … … 512 640 DEBUG(5, ("wbsrv_samba3_pam_auth_crap called\n")); 513 641 514 chal.data = s3call->request .data.auth_crap.chal;515 chal.length = sizeof(s3call->request .data.auth_crap.chal);516 nt_resp.data = (uint8_t *)s3call->request .data.auth_crap.nt_resp;517 nt_resp.length = s3call->request .data.auth_crap.nt_resp_len;518 lm_resp.data = (uint8_t *)s3call->request .data.auth_crap.lm_resp;519 lm_resp.length = s3call->request .data.auth_crap.lm_resp_len;642 chal.data = s3call->request->data.auth_crap.chal; 643 chal.length = sizeof(s3call->request->data.auth_crap.chal); 644 nt_resp.data = (uint8_t *)s3call->request->data.auth_crap.nt_resp; 645 nt_resp.length = s3call->request->data.auth_crap.nt_resp_len; 646 lm_resp.data = (uint8_t *)s3call->request->data.auth_crap.lm_resp; 647 lm_resp.length = s3call->request->data.auth_crap.lm_resp_len; 520 648 521 649 ctx = wb_cmd_pam_auth_crap_send( 522 650 s3call, service, 523 s3call->request .data.auth_crap.logon_parameters,524 s3call->request .data.auth_crap.domain,525 s3call->request .data.auth_crap.user,526 s3call->request .data.auth_crap.workstation,651 s3call->request->data.auth_crap.logon_parameters, 652 s3call->request->data.auth_crap.domain, 653 s3call->request->data.auth_crap.user, 654 s3call->request->data.auth_crap.workstation, 527 655 chal, nt_resp, lm_resp); 528 656 NT_STATUS_HAVE_NO_MEMORY(ctx); … … 549 677 if (!NT_STATUS_IS_OK(status)) goto done; 550 678 551 if (s3call->request .flags & WBFLAG_PAM_USER_SESSION_KEY) {552 memcpy(s3call->response .data.auth.user_session_key,679 if (s3call->request->flags & WBFLAG_PAM_USER_SESSION_KEY) { 680 memcpy(s3call->response->data.auth.user_session_key, 553 681 &user_session_key.key, 554 sizeof(s3call->response.data.auth.user_session_key)); 555 } 556 557 if (s3call->request.flags & WBFLAG_PAM_INFO3_NDR) { 558 s3call->response.extra_data.data = info3.data; 559 s3call->response.length += info3.length; 560 } 561 562 if (s3call->request.flags & WBFLAG_PAM_LMKEY) { 563 memcpy(s3call->response.data.auth.first_8_lm_hash, 682 sizeof(s3call->response->data.auth.user_session_key)); 683 } 684 685 if (s3call->request->flags & WBFLAG_PAM_INFO3_TEXT) { 686 status = wb_samba3_append_info3_as_txt(ctx, s3call, info3); 687 if (!NT_STATUS_IS_OK(status)) { 688 DEBUG(10,("Failed to append INFO3 (TXT): %s\n", 689 nt_errstr(status))); 690 goto done; 691 } 692 } 693 694 if (s3call->request->flags & WBFLAG_PAM_INFO3_NDR) { 695 s3call->response->extra_data.data = info3.data; 696 s3call->response->length += info3.length; 697 } 698 699 if (s3call->request->flags & WBFLAG_PAM_LMKEY) { 700 memcpy(s3call->response->data.auth.first_8_lm_hash, 564 701 lm_key.key, 565 sizeof(s3call->response .data.auth.first_8_lm_hash));702 sizeof(s3call->response->data.auth.first_8_lm_hash)); 566 703 } 567 704 568 if (s3call->request.flags & WBFLAG_PAM_UNIX_NAME) { 569 s3call->response.extra_data.data = unix_username; 570 s3call->response.length += strlen(unix_username)+1; 705 if (s3call->request->flags & WBFLAG_PAM_UNIX_NAME) { 706 WBSRV_SAMBA3_SET_STRING(s3call->response->data.auth.unix_username,unix_username); 571 707 } 572 708 … … 593 729 594 730 if (!wb_samba3_split_username(s3call, s3call->wbconn->lp_ctx, 595 s3call->request .data.auth.user,731 s3call->request->data.auth.user, 596 732 &domain, &user)) { 597 733 return NT_STATUS_NO_SUCH_USER; … … 606 742 cli_credentials_set_username(credentials, user, CRED_SPECIFIED); 607 743 608 cli_credentials_set_password(credentials, s3call->request .data.auth.pass, CRED_SPECIFIED);744 cli_credentials_set_password(credentials, s3call->request->data.auth.pass, CRED_SPECIFIED); 609 745 610 746 ctx = wb_cmd_pam_auth_send(s3call, service, credentials); … … 623 759 struct wbsrv_samba3_call); 624 760 NTSTATUS status; 625 626 status = wb_cmd_pam_auth_recv(ctx); 761 DATA_BLOB info3; 762 struct netr_UserSessionKey user_session_key; 763 struct netr_LMSessionKey lm_key; 764 char *unix_username; 765 766 status = wb_cmd_pam_auth_recv(ctx, s3call, &info3, 767 &user_session_key, &lm_key, &unix_username); 627 768 628 769 if (!NT_STATUS_IS_OK(status)) goto done; 770 771 if (s3call->request->flags & WBFLAG_PAM_USER_SESSION_KEY) { 772 memcpy(s3call->response->data.auth.user_session_key, 773 &user_session_key.key, 774 sizeof(s3call->response->data.auth.user_session_key)); 775 } 776 777 if (s3call->request->flags & WBFLAG_PAM_INFO3_TEXT) { 778 status = wb_samba3_append_info3_as_txt(ctx, s3call, info3); 779 if (!NT_STATUS_IS_OK(status)) { 780 DEBUG(10,("Failed to append INFO3 (TXT): %s\n", 781 nt_errstr(status))); 782 goto done; 783 } 784 } 785 786 if (s3call->request->flags & WBFLAG_PAM_INFO3_NDR) { 787 s3call->response->extra_data.data = info3.data; 788 s3call->response->length += info3.length; 789 } 790 791 if (s3call->request->flags & WBFLAG_PAM_LMKEY) { 792 memcpy(s3call->response->data.auth.first_8_lm_hash, 793 lm_key.key, 794 sizeof(s3call->response->data.auth.first_8_lm_hash)); 795 } 796 797 if (s3call->request->flags & WBFLAG_PAM_UNIX_NAME) { 798 WBSRV_SAMBA3_SET_STRING(s3call->response->data.auth.unix_username,unix_username); 799 } 800 629 801 630 802 done: … … 660 832 talloc_get_type(ctx->async.private_data, 661 833 struct wbsrv_samba3_call); 662 int i, num_domains;834 uint32_t i, num_domains; 663 835 struct wb_dom_info **domains; 664 836 NTSTATUS status; … … 687 859 } 688 860 689 s3call->response .result = WINBINDD_OK;861 s3call->response->result = WINBINDD_OK; 690 862 if (num_domains > 0) { 691 s3call->response.extra_data.data = result; 692 s3call->response.length += strlen(result)+1; 863 s3call->response->extra_data.data = result; 864 s3call->response->length += strlen(result)+1; 865 s3call->response->data.num_entries = num_domains; 693 866 } 694 867 … … 708 881 709 882 ctx = wb_cmd_list_groups_send(s3call, service, 710 s3call->request .domain_name);883 s3call->request->domain_name); 711 884 NT_STATUS_HAVE_NO_MEMORY(ctx); 712 885 … … 724 897 uint32_t extra_data_len; 725 898 char *extra_data; 899 uint32_t num_groups; 726 900 NTSTATUS status; 727 901 … … 729 903 730 904 status = wb_cmd_list_groups_recv(ctx, s3call, &extra_data_len, 731 &extra_data );905 &extra_data, &num_groups); 732 906 733 907 if (NT_STATUS_IS_OK(status)) { 734 s3call->response .extra_data.data = extra_data;735 s3call->response .length += extra_data_len;908 s3call->response->extra_data.data = extra_data; 909 s3call->response->length += extra_data_len; 736 910 if (extra_data) { 737 s3call->response.length += 1; 911 s3call->response->length += 1; 912 s3call->response->data.num_entries = num_groups; 738 913 } 739 914 } … … 755 930 756 931 ctx = wb_cmd_list_users_send(s3call, service, 757 s3call->request .domain_name);932 s3call->request->domain_name); 758 933 NT_STATUS_HAVE_NO_MEMORY(ctx); 759 934 … … 771 946 uint32_t extra_data_len; 772 947 char *extra_data; 948 uint32_t num_users; 773 949 NTSTATUS status; 774 950 … … 776 952 777 953 status = wb_cmd_list_users_recv(ctx, s3call, &extra_data_len, 778 &extra_data );954 &extra_data, &num_users); 779 955 780 956 if (NT_STATUS_IS_OK(status)) { 781 s3call->response .extra_data.data = extra_data;782 s3call->response .length += extra_data_len;957 s3call->response->extra_data.data = extra_data; 958 s3call->response->length += extra_data_len; 783 959 if (extra_data) { 784 s3call->response.length += 1; 960 s3call->response->length += 1; 961 s3call->response->data.num_entries = num_users; 785 962 } 786 963 } … … 802 979 803 980 ctx = wb_cmd_getpwnam_send(s3call, service, 804 s3call->request .data.username);981 s3call->request->data.username); 805 982 NT_STATUS_HAVE_NO_MEMORY(ctx); 806 983 … … 823 1000 status = wb_cmd_getpwnam_recv(ctx, s3call, &pw); 824 1001 if(NT_STATUS_IS_OK(status)) 825 s3call->response .data.pw = *pw;1002 s3call->response->data.pw = *pw; 826 1003 827 1004 wbsrv_samba3_async_epilogue(status, s3call); … … 838 1015 839 1016 ctx = wb_cmd_getpwuid_send(s3call, service, 840 s3call->request .data.uid);1017 s3call->request->data.uid); 841 1018 NT_STATUS_HAVE_NO_MEMORY(ctx); 842 1019 … … 859 1036 status = wb_cmd_getpwuid_recv(ctx, s3call, &pw); 860 1037 if (NT_STATUS_IS_OK(status)) 861 s3call->response .data.pw = *pw;1038 s3call->response->data.pw = *pw; 862 1039 863 1040 wbsrv_samba3_async_epilogue(status, s3call); … … 917 1094 918 1095 ctx = wb_cmd_getpwent_send(s3call, service, pwent, 919 s3call->request .data.num_entries);1096 s3call->request->data.num_entries); 920 1097 NT_STATUS_HAVE_NO_MEMORY(ctx); 921 1098 … … 941 1118 uint32_t extra_len = sizeof(struct winbindd_pw) * num_users; 942 1119 943 s3call->response .data.num_entries = num_users;944 s3call->response .extra_data.data = pw;945 s3call->response .length += extra_len;1120 s3call->response->data.num_entries = num_users; 1121 s3call->response->extra_data.data = pw; 1122 s3call->response->length += extra_len; 946 1123 } 947 1124 … … 959 1136 960 1137 s3call->wbconn->protocol_private_data = NULL; 961 s3call->response .result = WINBINDD_OK;1138 s3call->response->result = WINBINDD_OK; 962 1139 return NT_STATUS_OK; 963 1140 } … … 975 1152 976 1153 ctx = wb_cmd_getgrnam_send(s3call, service, 977 s3call->request .data.groupname);1154 s3call->request->data.groupname); 978 1155 NT_STATUS_HAVE_NO_MEMORY(ctx); 979 1156 … … 996 1173 status = wb_cmd_getgrnam_recv(ctx, s3call, &gr); 997 1174 if(NT_STATUS_IS_OK(status)) 998 s3call->response .data.gr = *gr;1175 s3call->response->data.gr = *gr; 999 1176 1000 1177 wbsrv_samba3_async_epilogue(status, s3call); … … 1011 1188 1012 1189 ctx = wb_cmd_getgrgid_send(s3call, service, 1013 s3call->request .data.gid);1190 s3call->request->data.gid); 1014 1191 NT_STATUS_HAVE_NO_MEMORY(ctx); 1015 1192 … … 1032 1209 status = wb_cmd_getgrgid_recv(ctx, s3call, &gr); 1033 1210 if (NT_STATUS_IS_OK(status)) 1034 s3call->response.data.gr = *gr; 1035 1036 wbsrv_samba3_async_epilogue(status, s3call); 1037 } 1211 s3call->response->data.gr = *gr; 1212 1213 wbsrv_samba3_async_epilogue(status, s3call); 1214 } 1215 1216 static void getgroups_recv(struct composite_context *ctx); 1038 1217 1039 1218 NTSTATUS wbsrv_samba3_getgroups(struct wbsrv_samba3_call *s3call) 1040 1219 { 1220 struct composite_context *ctx; 1221 struct wbsrv_service *service = s3call->wbconn->listen_socket->service; 1222 1041 1223 DEBUG(5, ("wbsrv_samba3_getgroups called\n")); 1042 s3call->response.result = WINBINDD_ERROR; 1043 return NT_STATUS_OK; 1044 } 1224 /* S3 code do the same so why not ... */ 1225 s3call->request->data.username[sizeof(s3call->request->data.username)-1]='\0'; 1226 ctx = wb_cmd_getgroups_send(s3call, service, s3call->request->data.username); 1227 NT_STATUS_HAVE_NO_MEMORY(ctx); 1228 1229 ctx->async.fn = getgroups_recv; 1230 ctx->async.private_data = s3call; 1231 s3call->flags |= WBSRV_CALL_FLAGS_REPLY_ASYNC; 1232 return NT_STATUS_OK; 1233 } 1234 1235 static void getgroups_recv(struct composite_context *ctx) 1236 { 1237 struct wbsrv_samba3_call *s3call = 1238 talloc_get_type(ctx->async.private_data, 1239 struct wbsrv_samba3_call); 1240 gid_t *gids; 1241 uint32_t num_groups; 1242 NTSTATUS status; 1243 DEBUG(5, ("getgroups_recv called\n")); 1244 1245 status = wb_cmd_getgroups_recv(ctx, s3call, &gids, &num_groups); 1246 if (NT_STATUS_IS_OK(status)) { 1247 uint32_t extra_len = sizeof(gid_t) * num_groups; 1248 1249 s3call->response->data.num_entries = num_groups; 1250 s3call->response->extra_data.data = gids; 1251 s3call->response->length += extra_len; 1252 } else { 1253 s3call->response->result = WINBINDD_ERROR; 1254 } 1255 1256 wbsrv_samba3_async_epilogue(status, s3call); 1257 } 1258 1259 static void setgrent_recv(struct composite_context *ctx); 1045 1260 1046 1261 NTSTATUS wbsrv_samba3_setgrent(struct wbsrv_samba3_call *s3call) 1047 1262 { 1263 struct composite_context *ctx; 1264 struct wbsrv_service *service = s3call->wbconn->listen_socket->service; 1265 1048 1266 DEBUG(5, ("wbsrv_samba3_setgrent called\n")); 1049 s3call->response.result = WINBINDD_OK; 1050 return NT_STATUS_OK; 1051 } 1267 1268 ctx = wb_cmd_setgrent_send(s3call, service); 1269 NT_STATUS_HAVE_NO_MEMORY(ctx); 1270 1271 ctx->async.fn = setgrent_recv; 1272 ctx->async.private_data = s3call; 1273 s3call->flags |= WBSRV_CALL_FLAGS_REPLY_ASYNC; 1274 return NT_STATUS_OK; 1275 } 1276 1277 static void setgrent_recv(struct composite_context *ctx) 1278 { 1279 struct wbsrv_samba3_call *s3call = 1280 talloc_get_type(ctx->async.private_data, 1281 struct wbsrv_samba3_call); 1282 NTSTATUS status; 1283 struct wbsrv_grent *grent; 1284 1285 DEBUG(5, ("setpwent_recv called\n")); 1286 1287 status = wb_cmd_setgrent_recv(ctx, s3call->wbconn, &grent); 1288 if (NT_STATUS_IS_OK(status)) { 1289 s3call->wbconn->protocol_private_data = grent; 1290 } 1291 1292 wbsrv_samba3_async_epilogue(status, s3call); 1293 } 1294 1295 static void getgrent_recv(struct composite_context *ctx); 1052 1296 1053 1297 NTSTATUS wbsrv_samba3_getgrent(struct wbsrv_samba3_call *s3call) 1054 1298 { 1299 struct composite_context *ctx; 1300 struct wbsrv_service *service = s3call->wbconn->listen_socket->service; 1301 struct wbsrv_grent *grent; 1302 1055 1303 DEBUG(5, ("wbsrv_samba3_getgrent called\n")); 1056 s3call->response.result = WINBINDD_ERROR; 1057 return NT_STATUS_OK; 1304 1305 NT_STATUS_HAVE_NO_MEMORY(s3call->wbconn->protocol_private_data); 1306 1307 grent = talloc_get_type(s3call->wbconn->protocol_private_data, 1308 struct wbsrv_grent); 1309 NT_STATUS_HAVE_NO_MEMORY(grent); 1310 1311 ctx = wb_cmd_getgrent_send(s3call, service, grent, 1312 s3call->request->data.num_entries); 1313 NT_STATUS_HAVE_NO_MEMORY(ctx); 1314 1315 ctx->async.fn = getgrent_recv; 1316 ctx->async.private_data = s3call; 1317 s3call->flags |= WBSRV_CALL_FLAGS_REPLY_ASYNC; 1318 return NT_STATUS_OK; 1319 } 1320 1321 static void getgrent_recv(struct composite_context *ctx) 1322 { 1323 struct wbsrv_samba3_call *s3call = 1324 talloc_get_type(ctx->async.private_data, 1325 struct wbsrv_samba3_call); 1326 NTSTATUS status; 1327 struct winbindd_gr *gr; 1328 uint32_t num_groups; 1329 1330 DEBUG(5, ("getgrent_recv called\n")); 1331 1332 status = wb_cmd_getgrent_recv(ctx, s3call, &gr, &num_groups); 1333 if (NT_STATUS_IS_OK(status)) { 1334 uint32_t extra_len = sizeof(struct winbindd_gr) * num_groups; 1335 1336 s3call->response->data.num_entries = num_groups; 1337 s3call->response->extra_data.data = gr; 1338 s3call->response->length += extra_len; 1339 } 1340 1341 wbsrv_samba3_async_epilogue(status, s3call); 1058 1342 } 1059 1343 … … 1061 1345 { 1062 1346 DEBUG(5, ("wbsrv_samba3_endgrent called\n")); 1063 s3call->response .result = WINBINDD_OK;1347 s3call->response->result = WINBINDD_OK; 1064 1348 return NT_STATUS_OK; 1065 1349 } … … 1076 1360 DEBUG(5, ("wbsrv_samba3_sid2uid called\n")); 1077 1361 1078 sid = dom_sid_parse_talloc(s3call, s3call->request .data.sid);1362 sid = dom_sid_parse_talloc(s3call, s3call->request->data.sid); 1079 1363 NT_STATUS_HAVE_NO_MEMORY(sid); 1080 1364 … … 1098 1382 DEBUG(5, ("sid2uid_recv called\n")); 1099 1383 1100 status = wb_sid2uid_recv(ctx, &s3call->response .data.uid);1384 status = wb_sid2uid_recv(ctx, &s3call->response->data.uid); 1101 1385 1102 1386 wbsrv_samba3_async_epilogue(status, s3call); … … 1114 1398 DEBUG(5, ("wbsrv_samba3_sid2gid called\n")); 1115 1399 1116 sid = dom_sid_parse_talloc(s3call, s3call->request .data.sid);1400 sid = dom_sid_parse_talloc(s3call, s3call->request->data.sid); 1117 1401 NT_STATUS_HAVE_NO_MEMORY(sid); 1118 1402 … … 1136 1420 DEBUG(5, ("sid2gid_recv called\n")); 1137 1421 1138 status = wb_sid2gid_recv(ctx, &s3call->response .data.gid);1422 status = wb_sid2gid_recv(ctx, &s3call->response->data.gid); 1139 1423 1140 1424 wbsrv_samba3_async_epilogue(status, s3call); … … 1151 1435 DEBUG(5, ("wbsrv_samba3_uid2sid called\n")); 1152 1436 1153 ctx = wb_uid2sid_send(s3call, service, s3call->request .data.uid);1437 ctx = wb_uid2sid_send(s3call, service, s3call->request->data.uid); 1154 1438 NT_STATUS_HAVE_NO_MEMORY(ctx); 1155 1439 … … 1182 1466 /* But we assume this worked, so we'll set the string. Work 1183 1467 * done. */ 1184 WBSRV_SAMBA3_SET_STRING(s3call->response .data.sid.sid, sid_str);1185 s3call->response .data.sid.type = SID_NAME_USER;1468 WBSRV_SAMBA3_SET_STRING(s3call->response->data.sid.sid, sid_str); 1469 s3call->response->data.sid.type = SID_NAME_USER; 1186 1470 } 1187 1471 … … 1199 1483 DEBUG(5, ("wbsrv_samba3_gid2sid called\n")); 1200 1484 1201 ctx = wb_gid2sid_send(s3call, service, s3call->request .data.gid);1485 ctx = wb_gid2sid_send(s3call, service, s3call->request->data.gid); 1202 1486 NT_STATUS_HAVE_NO_MEMORY(ctx); 1203 1487 … … 1227 1511 wbsrv_samba3_async_epilogue(NT_STATUS_NO_MEMORY,s3call); 1228 1512 1229 WBSRV_SAMBA3_SET_STRING(s3call->response .data.sid.sid, sid_str);1230 s3call->response .data.sid.type = SID_NAME_DOMAIN;1231 } 1232 1233 wbsrv_samba3_async_epilogue(status, s3call); 1234 } 1235 1513 WBSRV_SAMBA3_SET_STRING(s3call->response->data.sid.sid, sid_str); 1514 s3call->response->data.sid.type = SID_NAME_DOMAIN; 1515 } 1516 1517 wbsrv_samba3_async_epilogue(status, s3call); 1518 } 1519 -
trunk/server/source4/winbind/wb_samba3_protocol.c
r414 r745 24 24 #include "smbd/service_stream.h" 25 25 #include "lib/stream/packet.h" 26 #include "lib/tsocket/tsocket.h" 26 27 27 28 /* … … 44 45 45 46 46 NTSTATUS wbsrv_samba3_pull_request(DATA_BLOB blob, struct wbsrv_connection *wbconn, 47 struct wbsrv_samba3_call **_call) 48 { 49 struct wbsrv_samba3_call *call; 50 51 if (blob.length != sizeof(call->request)) { 47 NTSTATUS wbsrv_samba3_pull_request(struct wbsrv_samba3_call *call) 48 { 49 if (call->in.length != sizeof(*call->request)) { 52 50 DEBUG(0,("wbsrv_samba3_pull_request: invalid blob length %lu should be %lu\n" 53 51 " make sure you use the correct winbind client tools!\n", 54 (long) blob.length, (long)sizeof(call->request)));52 (long)call->in.length, (long)sizeof(*call->request))); 55 53 return NT_STATUS_INVALID_PARAMETER; 56 54 } 57 55 58 call = talloc_zero(wbconn, struct wbsrv_samba3_call);59 NT_STATUS_HAVE_NO_MEMORY(call );56 call->request = talloc_zero(call, struct winbindd_request); 57 NT_STATUS_HAVE_NO_MEMORY(call->request); 60 58 61 59 /* the packet layout is the same as the in memory layout of the request, so just copy it */ 62 memcpy(&call->request, blob.data, sizeof(call->request)); 63 64 call->wbconn = wbconn; 65 call->event_ctx = call->wbconn->conn->event.ctx; 66 67 *_call = call; 60 memcpy(call->request, call->in.data, sizeof(*call->request)); 61 68 62 return NT_STATUS_OK; 69 63 } … … 71 65 NTSTATUS wbsrv_samba3_handle_call(struct wbsrv_samba3_call *s3call) 72 66 { 73 DEBUG(10, ("Got winbind samba3 request %d\n", s3call->request.cmd)); 74 75 s3call->response.length = sizeof(s3call->response); 76 77 switch(s3call->request.cmd) { 67 DEBUG(10, ("Got winbind samba3 request %d\n", s3call->request->cmd)); 68 69 s3call->response = talloc_zero(s3call, struct winbindd_response); 70 NT_STATUS_HAVE_NO_MEMORY(s3call->request); 71 72 s3call->response->length = sizeof(*s3call->response); 73 74 switch(s3call->request->cmd) { 78 75 case WINBINDD_INTERFACE_VERSION: 79 76 return wbsrv_samba3_interface_version(s3call); … … 179 176 return wbsrv_samba3_domain_info(s3call); 180 177 178 case WINBINDD_PAM_LOGOFF: 179 return wbsrv_samba3_pam_logoff(s3call); 180 181 181 /* Unimplemented commands */ 182 183 182 case WINBINDD_GETPWSID: 184 183 case WINBINDD_PAM_CHAUTHTOK: 185 case WINBINDD_PAM_LOGOFF:186 184 case WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP: 187 185 case WINBINDD_LOOKUPRIDS: … … 189 187 case WINBINDD_ALLOCATE_UID: 190 188 case WINBINDD_ALLOCATE_GID: 191 case WINBINDD_SET_MAPPING:192 case WINBINDD_REMOVE_MAPPING:193 case WINBINDD_SET_HWM:194 189 case WINBINDD_SHOW_SEQUENCE: 195 190 case WINBINDD_WINS_BYIP: … … 200 195 case WINBINDD_INIT_CONNECTION: 201 196 case WINBINDD_DUAL_SIDS2XIDS: 202 case WINBINDD_DUAL_SET_MAPPING:203 case WINBINDD_DUAL_REMOVE_MAPPING:204 case WINBINDD_DUAL_SET_HWM:205 197 case WINBINDD_DUAL_USERINFO: 206 198 case WINBINDD_DUAL_GETSIDALIASES: … … 209 201 case WINBINDD_NUM_CMDS: 210 202 DEBUG(10, ("Unimplemented winbind samba3 request %d\n", 211 s3call->request .cmd));203 s3call->request->cmd)); 212 204 break; 213 205 } 214 206 215 s3call->response .result = WINBINDD_ERROR;207 s3call->response->result = WINBINDD_ERROR; 216 208 return NT_STATUS_OK; 217 209 } 218 210 219 static NTSTATUS wbsrv_samba3_push_reply(struct wbsrv_samba3_call *call, TALLOC_CTX *mem_ctx, DATA_BLOB *_blob) 220 { 221 DATA_BLOB blob; 211 static NTSTATUS wbsrv_samba3_push_reply(struct wbsrv_samba3_call *call) 212 { 222 213 uint8_t *extra_data; 223 214 size_t extra_data_len = 0; 224 215 225 extra_data = (uint8_t *)call->response .extra_data.data;216 extra_data = (uint8_t *)call->response->extra_data.data; 226 217 if (extra_data != NULL) { 227 extra_data_len = call->response .length -228 sizeof( call->response);229 } 230 231 blob = data_blob_talloc(mem_ctx, NULL, call->response.length);232 NT_STATUS_HAVE_NO_MEMORY( blob.data);218 extra_data_len = call->response->length - 219 sizeof(*call->response); 220 } 221 222 call->out = data_blob_talloc(call, NULL, call->response->length); 223 NT_STATUS_HAVE_NO_MEMORY(call->out.data); 233 224 234 225 /* don't push real pointer values into sockets */ 235 226 if (extra_data) { 236 call->response.extra_data.data = (void *)0xFFFFFFFF; 237 } 238 memcpy(blob.data, &call->response, sizeof(call->response)); 227 call->response->extra_data.data = (void *)0xFFFFFFFF; 228 } 229 230 memcpy(call->out.data, call->response, sizeof(*call->response)); 239 231 /* set back the pointer */ 240 call->response .extra_data.data = extra_data;232 call->response->extra_data.data = extra_data; 241 233 242 234 if (extra_data) { 243 memcpy(blob.data + sizeof(call->response), extra_data, extra_data_len); 244 } 245 246 *_blob = blob; 235 memcpy(call->out.data + sizeof(*call->response), 236 extra_data, 237 extra_data_len); 238 } 239 247 240 return NT_STATUS_OK; 248 241 } 242 243 static void wbsrv_samba3_send_reply_done(struct tevent_req *subreq); 249 244 250 245 /* … … 256 251 NTSTATUS wbsrv_samba3_send_reply(struct wbsrv_samba3_call *call) 257 252 { 258 struct wbsrv_connection *wb conn = call->wbconn;259 DATA_BLOB rep;253 struct wbsrv_connection *wbsrv_conn = call->wbconn; 254 struct tevent_req *subreq; 260 255 NTSTATUS status; 261 256 262 status = wbsrv_samba3_push_reply(call , call, &rep);257 status = wbsrv_samba3_push_reply(call); 263 258 NT_STATUS_NOT_OK_RETURN(status); 264 259 265 status = packet_send(call->wbconn->packet, rep); 266 260 call->out_iov[0].iov_base = (char *) call->out.data; 261 call->out_iov[0].iov_len = call->out.length; 262 263 subreq = tstream_writev_queue_send(call, 264 wbsrv_conn->conn->event.ctx, 265 wbsrv_conn->tstream, 266 wbsrv_conn->send_queue, 267 call->out_iov, 1); 268 if (subreq == NULL) { 269 wbsrv_terminate_connection(wbsrv_conn, "wbsrv_call_loop: " 270 "no memory for tstream_writev_queue_send"); 271 return NT_STATUS_NO_MEMORY; 272 } 273 tevent_req_set_callback(subreq, wbsrv_samba3_send_reply_done, call); 274 275 return status; 276 } 277 278 static void wbsrv_samba3_send_reply_done(struct tevent_req *subreq) 279 { 280 struct wbsrv_samba3_call *call = tevent_req_callback_data(subreq, 281 struct wbsrv_samba3_call); 282 int sys_errno; 283 int rc; 284 285 rc = tstream_writev_queue_recv(subreq, &sys_errno); 286 TALLOC_FREE(subreq); 287 if (rc == -1) { 288 const char *reason; 289 290 reason = talloc_asprintf(call, "wbsrv_samba3_send_reply_done: " 291 "tstream_writev_queue_recv() - %d:%s", 292 sys_errno, strerror(sys_errno)); 293 if (reason == NULL) { 294 reason = "wbsrv_samba3_send_reply_done: " 295 "tstream_writev_queue_recv() failed"; 296 } 297 298 wbsrv_terminate_connection(call->wbconn, reason); 299 return; 300 } 301 267 302 talloc_free(call); 268 269 if (!NT_STATUS_IS_OK(status)) { 270 wbsrv_terminate_connection(wbconn, 271 "failed to packet_send winbindd reply"); 272 return status; 273 } 274 /* the call isn't needed any more */ 275 return status; 276 } 277 278 NTSTATUS wbsrv_samba3_process(void *private_data, DATA_BLOB blob) 303 } 304 305 NTSTATUS wbsrv_samba3_process(struct wbsrv_samba3_call *call) 279 306 { 280 307 NTSTATUS status; 281 struct wbsrv_connection *wbconn = talloc_get_type(private_data, 282 struct wbsrv_connection); 283 struct wbsrv_samba3_call *call; 284 status = wbsrv_samba3_pull_request(blob, wbconn, &call); 308 309 status = wbsrv_samba3_pull_request(call); 285 310 286 311 if (!NT_STATUS_IS_OK(status)) { 287 312 return status; 288 313 } 289 314 290 315 status = wbsrv_samba3_handle_call(call); 291 316 -
trunk/server/source4/winbind/wb_server.c
r414 r745 3 3 Main winbindd server routines 4 4 5 Copyright (C) Stefan Metzmacher 2005 5 Copyright (C) Stefan Metzmacher 2005-2008 6 6 Copyright (C) Andrew Tridgell 2005 7 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2010 7 8 8 9 This program is free software; you can redistribute it and/or modify … … 21 22 22 23 #include "includes.h" 23 #include "lib/socket/socket.h"24 #include "../lib/util/dlinklist.h"25 #include "lib/events/events.h"26 #include "smbd/service_task.h"27 24 #include "smbd/process_model.h" 28 #include "smbd/service_stream.h"29 #include "nsswitch/winbind_nss_config.h"30 25 #include "winbind/wb_server.h" 31 26 #include "lib/stream/packet.h" 32 #include "smbd/service.h" 27 #include "lib/tsocket/tsocket.h" 28 #include "libcli/util/tstream.h" 29 #include "param/param.h" 33 30 #include "param/secrets.h" 34 #include "param/param.h"35 31 36 32 void wbsrv_terminate_connection(struct wbsrv_connection *wbconn, const char *reason) … … 39 35 } 40 36 37 static void wbsrv_call_loop(struct tevent_req *subreq) 38 { 39 struct wbsrv_connection *wbsrv_conn = tevent_req_callback_data(subreq, 40 struct wbsrv_connection); 41 struct wbsrv_samba3_call *call; 42 NTSTATUS status; 43 44 call = talloc_zero(wbsrv_conn, struct wbsrv_samba3_call); 45 if (call == NULL) { 46 wbsrv_terminate_connection(wbsrv_conn, "wbsrv_call_loop: " 47 "no memory for wbsrv_samba3_call"); 48 return; 49 } 50 call->wbconn = wbsrv_conn; 51 52 status = tstream_read_pdu_blob_recv(subreq, 53 call, 54 &call->in); 55 TALLOC_FREE(subreq); 56 if (!NT_STATUS_IS_OK(status)) { 57 const char *reason; 58 59 reason = talloc_asprintf(call, "wbsrv_call_loop: " 60 "tstream_read_pdu_blob_recv() - %s", 61 nt_errstr(status)); 62 if (!reason) { 63 reason = nt_errstr(status); 64 } 65 66 wbsrv_terminate_connection(wbsrv_conn, reason); 67 return; 68 } 69 70 DEBUG(10,("Received winbind TCP packet of length %lu from %s\n", 71 (long) call->in.length, 72 tsocket_address_string(wbsrv_conn->conn->remote_address, call))); 73 74 status = wbsrv_samba3_process(call); 75 if (!NT_STATUS_IS_OK(status)) { 76 const char *reason; 77 78 reason = talloc_asprintf(call, "wbsrv_call_loop: " 79 "tstream_read_pdu_blob_recv() - %s", 80 nt_errstr(status)); 81 if (!reason) { 82 reason = nt_errstr(status); 83 } 84 85 wbsrv_terminate_connection(wbsrv_conn, reason); 86 return; 87 } 88 89 /* 90 * The winbind pdu's has the length as 4 byte (initial_read_size), 91 * wbsrv_samba3_packet_full_request provides the pdu length then. 92 */ 93 subreq = tstream_read_pdu_blob_send(wbsrv_conn, 94 wbsrv_conn->conn->event.ctx, 95 wbsrv_conn->tstream, 96 4, /* initial_read_size */ 97 wbsrv_samba3_packet_full_request, 98 wbsrv_conn); 99 if (subreq == NULL) { 100 wbsrv_terminate_connection(wbsrv_conn, "wbsrv_call_loop: " 101 "no memory for tstream_read_pdu_blob_send"); 102 return; 103 } 104 tevent_req_set_callback(subreq, wbsrv_call_loop, wbsrv_conn); 105 } 106 107 static void wbsrv_accept(struct stream_connection *conn) 108 { 109 struct wbsrv_listen_socket *wbsrv_socket = talloc_get_type(conn->private_data, 110 struct wbsrv_listen_socket); 111 struct wbsrv_connection *wbsrv_conn; 112 struct tevent_req *subreq; 113 int rc; 114 115 wbsrv_conn = talloc_zero(conn, struct wbsrv_connection); 116 if (wbsrv_conn == NULL) { 117 stream_terminate_connection(conn, "wbsrv_accept: out of memory"); 118 return; 119 } 120 121 wbsrv_conn->send_queue = tevent_queue_create(conn, "wbsrv_accept"); 122 if (wbsrv_conn->send_queue == NULL) { 123 stream_terminate_connection(conn, 124 "wbsrv_accept: out of memory"); 125 return; 126 } 127 128 TALLOC_FREE(conn->event.fde); 129 130 rc = tstream_bsd_existing_socket(wbsrv_conn, 131 socket_get_fd(conn->socket), 132 &wbsrv_conn->tstream); 133 if (rc < 0) { 134 stream_terminate_connection(conn, 135 "wbsrv_accept: out of memory"); 136 return; 137 } 138 139 wbsrv_conn->conn = conn; 140 wbsrv_conn->listen_socket = wbsrv_socket; 141 wbsrv_conn->lp_ctx = wbsrv_socket->service->task->lp_ctx; 142 conn->private_data = wbsrv_conn; 143 144 /* 145 * The winbind pdu's has the length as 4 byte (initial_read_size), 146 * wbsrv_samba3_packet_full_request provides the pdu length then. 147 */ 148 subreq = tstream_read_pdu_blob_send(wbsrv_conn, 149 wbsrv_conn->conn->event.ctx, 150 wbsrv_conn->tstream, 151 4, /* initial_read_size */ 152 wbsrv_samba3_packet_full_request, 153 wbsrv_conn); 154 if (subreq == NULL) { 155 wbsrv_terminate_connection(wbsrv_conn, "wbsrv_accept: " 156 "no memory for tstream_read_pdu_blob_send"); 157 return; 158 } 159 tevent_req_set_callback(subreq, wbsrv_call_loop, wbsrv_conn); 160 } 161 41 162 /* 42 called on a tcp recv error 43 */ 44 static void wbsrv_recv_error(void *private_data, NTSTATUS status) 45 { 46 struct wbsrv_connection *wbconn = talloc_get_type(private_data, struct wbsrv_connection); 47 wbsrv_terminate_connection(wbconn, nt_errstr(status)); 48 } 49 50 static void wbsrv_accept(struct stream_connection *conn) 51 { 52 struct wbsrv_listen_socket *listen_socket = talloc_get_type(conn->private_data, 53 struct wbsrv_listen_socket); 54 struct wbsrv_connection *wbconn; 55 56 wbconn = talloc_zero(conn, struct wbsrv_connection); 57 if (!wbconn) { 58 stream_terminate_connection(conn, "wbsrv_accept: out of memory"); 59 return; 60 } 61 wbconn->conn = conn; 62 wbconn->listen_socket = listen_socket; 63 wbconn->lp_ctx = listen_socket->service->task->lp_ctx; 64 conn->private_data = wbconn; 65 66 wbconn->packet = packet_init(wbconn); 67 if (wbconn->packet == NULL) { 68 wbsrv_terminate_connection(wbconn, "wbsrv_accept: out of memory"); 69 return; 70 } 71 packet_set_private(wbconn->packet, wbconn); 72 packet_set_socket(wbconn->packet, conn->socket); 73 packet_set_callback(wbconn->packet, wbsrv_samba3_process); 74 packet_set_full_request(wbconn->packet, wbsrv_samba3_packet_full_request); 75 packet_set_error_handler(wbconn->packet, wbsrv_recv_error); 76 packet_set_event_context(wbconn->packet, conn->event.ctx); 77 packet_set_fde(wbconn->packet, conn->event.fde); 78 packet_set_serialise(wbconn->packet); 79 } 80 81 /* 82 receive some data on a winbind connection 163 called on a tcp recv 83 164 */ 84 165 static void wbsrv_recv(struct stream_connection *conn, uint16_t flags) 85 166 { 86 struct wbsrv_connection *wbconn = talloc_get_type(conn->private_data, 87 struct wbsrv_connection); 88 packet_recv(wbconn->packet); 89 167 struct wbsrv_connection *wbsrv_conn = talloc_get_type(conn->private_data, 168 struct wbsrv_connection); 169 wbsrv_terminate_connection(wbsrv_conn, "wbsrv_recv: called"); 90 170 } 91 171 … … 95 175 static void wbsrv_send(struct stream_connection *conn, uint16_t flags) 96 176 { 97 struct wbsrv_connection *wbconn = talloc_get_type(conn->private_data, 98 struct wbsrv_connection); 99 packet_queue_run(wbconn->packet); 177 struct wbsrv_connection *wbsrv_conn = talloc_get_type(conn->private_data, 178 struct wbsrv_connection); 179 /* this should never be triggered! */ 180 wbsrv_terminate_connection(wbsrv_conn, "wbsrv_send: called"); 100 181 } 101 182 … … 117 198 struct wbsrv_service *service; 118 199 struct wbsrv_listen_socket *listen_socket; 200 char *errstring; 201 struct dom_sid *primary_sid; 119 202 120 203 task_server_set_title(task, "task[winbind]"); … … 123 206 ask for the single process model ops and pass these to the 124 207 stream_setup_socket() call. */ 125 model_ops = process_model_startup( task->event_ctx,"single");208 model_ops = process_model_startup("single"); 126 209 if (!model_ops) { 127 210 task_server_terminate(task, … … 131 214 132 215 /* Make sure the directory for the Samba3 socket exists, and is of the correct permissions */ 133 if (!directory_create_or_exist(lp _winbindd_socket_directory(task->lp_ctx), geteuid(), 0755)) {216 if (!directory_create_or_exist(lpcfg_winbindd_socket_directory(task->lp_ctx), geteuid(), 0755)) { 134 217 task_server_terminate(task, 135 218 "Cannot create winbindd pipe directory", true); … … 138 221 139 222 /* Make sure the directory for the Samba3 socket exists, and is of the correct permissions */ 140 if (!directory_create_or_exist(lp _winbindd_privileged_socket_directory(task->lp_ctx), geteuid(), 0750)) {223 if (!directory_create_or_exist(lpcfg_winbindd_privileged_socket_directory(task->lp_ctx), geteuid(), 0750)) { 141 224 task_server_terminate(task, 142 225 "Cannot create winbindd privileged pipe directory", true); … … 148 231 service->task = task; 149 232 150 status = wbsrv_setup_domains(service); 151 if (!NT_STATUS_IS_OK(status)) { 152 task_server_terminate(task, nt_errstr(status), true); 153 return; 154 } 233 234 /* Find the primary SID, depending if we are a standalone 235 * server (what good is winbind in this case, but anyway...), 236 * or are in a domain as a member or a DC */ 237 switch (lpcfg_server_role(service->task->lp_ctx)) { 238 case ROLE_STANDALONE: 239 primary_sid = secrets_get_domain_sid(service, 240 service->task->lp_ctx, 241 lpcfg_netbios_name(service->task->lp_ctx), 242 &service->sec_channel_type, 243 &errstring); 244 if (!primary_sid) { 245 char *message = talloc_asprintf(task, 246 "Cannot start Winbind (standalone configuration): %s: " 247 "Have you provisioned this server (%s) or changed it's name?", 248 errstring, lpcfg_netbios_name(service->task->lp_ctx)); 249 task_server_terminate(task, message, true); 250 return; 251 } 252 break; 253 case ROLE_DOMAIN_MEMBER: 254 primary_sid = secrets_get_domain_sid(service, 255 service->task->lp_ctx, 256 lpcfg_workgroup(service->task->lp_ctx), 257 &service->sec_channel_type, 258 &errstring); 259 if (!primary_sid) { 260 char *message = talloc_asprintf(task, "Cannot start Winbind (domain member): %s: " 261 "Have you joined the %s domain?", 262 errstring, lpcfg_workgroup(service->task->lp_ctx)); 263 task_server_terminate(task, message, true); 264 return; 265 } 266 break; 267 case ROLE_DOMAIN_CONTROLLER: 268 primary_sid = secrets_get_domain_sid(service, 269 service->task->lp_ctx, 270 lpcfg_workgroup(service->task->lp_ctx), 271 &service->sec_channel_type, 272 &errstring); 273 if (!primary_sid) { 274 char *message = talloc_asprintf(task, "Cannot start Winbind (domain controller): %s: " 275 "Have you provisioned the %s domain?", 276 errstring, lpcfg_workgroup(service->task->lp_ctx)); 277 task_server_terminate(task, message, true); 278 return; 279 } 280 break; 281 } 282 service->primary_sid = primary_sid; 155 283 156 284 service->idmap_ctx = idmap_init(service, task->event_ctx, task->lp_ctx); … … 159 287 return; 160 288 } 289 290 service->priv_pipe_dir = lpcfg_winbindd_privileged_socket_directory(task->lp_ctx); 291 service->pipe_dir = lpcfg_winbindd_socket_directory(task->lp_ctx); 161 292 162 293 /* setup the unprivileged samba3 socket */ … … 164 295 if (!listen_socket) goto nomem; 165 296 listen_socket->socket_path = talloc_asprintf(listen_socket, "%s/%s", 166 lp_winbindd_socket_directory(task->lp_ctx),167 WINBINDD_S AMBA3_SOCKET);297 service->pipe_dir, 298 WINBINDD_SOCKET_NAME); 168 299 if (!listen_socket->socket_path) goto nomem; 169 300 listen_socket->service = service; 170 301 listen_socket->privileged = false; 171 status = stream_setup_socket(task ->event_ctx, task->lp_ctx, model_ops,302 status = stream_setup_socket(task, task->event_ctx, task->lp_ctx, model_ops, 172 303 &wbsrv_ops, "unix", 173 304 listen_socket->socket_path, &port, 174 lp _socket_options(task->lp_ctx),305 lpcfg_socket_options(task->lp_ctx), 175 306 listen_socket); 176 307 if (!NT_STATUS_IS_OK(status)) goto listen_failed; … … 180 311 if (!listen_socket) goto nomem; 181 312 listen_socket->socket_path 182 = service->priv_socket_path183 313 = talloc_asprintf(listen_socket, "%s/%s", 184 lp_winbindd_privileged_socket_directory(task->lp_ctx), 185 WINBINDD_SAMBA3_SOCKET); 186 if (!listen_socket->socket_path) goto nomem; 314 service->priv_pipe_dir, 315 WINBINDD_SOCKET_NAME); 187 316 if (!listen_socket->socket_path) goto nomem; 188 317 listen_socket->service = service; 189 318 listen_socket->privileged = true; 190 status = stream_setup_socket(task ->event_ctx, task->lp_ctx, model_ops,319 status = stream_setup_socket(task, task->event_ctx, task->lp_ctx, model_ops, 191 320 &wbsrv_ops, "unix", 192 321 listen_socket->socket_path, &port, 193 lp _socket_options(task->lp_ctx),322 lpcfg_socket_options(task->lp_ctx), 194 323 listen_socket); 195 324 if (!NT_STATUS_IS_OK(status)) goto listen_failed; -
trunk/server/source4/winbind/wb_server.h
r414 r745 25 25 #include "libnet/libnet.h" 26 26 27 #define WINBINDD_SAMBA3_SOCKET "pipe"28 /* the privileged socket is in smbd_tmp_dir() */29 #define WINBINDD_SAMBA3_PRIVILEGED_SOCKET "winbind_pipe"30 31 27 /* this struct stores global data for the winbind task */ 32 28 struct wbsrv_service { … … 34 30 35 31 const struct dom_sid *primary_sid; 32 enum netr_SchannelType sec_channel_type; 36 33 struct wbsrv_domain *domains; 37 34 struct idmap_context *idmap_ctx; 38 39 const char *p riv_socket_path;35 const char *priv_pipe_dir; 36 const char *pipe_dir; 40 37 }; 41 38 … … 52 49 const char *dns_name; 53 50 const struct dom_sid *sid; 54 55 int num_dcs; 56 struct nbt_dc_name *dcs; 51 struct nbt_dc_name *dc; 57 52 }; 58 53 … … 101 96 uint32_t pending_calls; 102 97 103 struct packet_context *packet; 98 struct tstream_context *tstream; 99 100 struct tevent_queue *send_queue; 104 101 105 102 struct loadparm_context *lp_ctx; … … 107 104 108 105 #define WBSRV_SAMBA3_SET_STRING(dest, src) do { \ 106 memset(dest, 0, sizeof(dest));\ 109 107 safe_strcpy(dest, src, sizeof(dest)-1);\ 110 108 } while(0) … … 116 114 /* Current UserList structure, contains 1+ user structs */ 117 115 struct libnet_UserList *user_list; 116 117 /* Index of the next user struct in the current UserList struct */ 118 uint32_t page_index; 119 120 /* The libnet_ctx to use for the libnet_UserList call */ 121 struct libnet_context *libnet_ctx; 122 }; 123 /* 124 state of a grent query 125 */ 126 struct wbsrv_grent { 127 /* Current UserList structure, contains 1+ user structs */ 128 struct libnet_GroupList *group_list; 118 129 119 130 /* Index of the next user struct in the current UserList struct */ … … 149 160 struct wbsrv_connection *wbconn; 150 161 151 /* the backend should use this event context */152 struct tevent_context *event_ctx;153 154 162 /* here the backend can store stuff like composite_context's ... */ 155 163 void *private_data; 156 164 157 165 /* the request structure of the samba3 protocol */ 158 struct winbindd_request request;166 struct winbindd_request *request; 159 167 160 168 /* the response structure of the samba3 protocol*/ 161 struct winbindd_response response; 169 struct winbindd_response *response; 170 171 DATA_BLOB in; 172 DATA_BLOB out; 173 struct iovec out_iov[1]; 162 174 }; 163 175 … … 165 177 struct netr_UserSessionKey; 166 178 struct winbind_SamLogon; 179 struct winbind_DsrUpdateReadOnlyServerDnsRecords; 167 180 168 181 #include "winbind/wb_async_helpers.h" -
trunk/server/source4/winbind/wb_sid2domain.c
r414 r745 24 24 #include "winbind/wb_server.h" 25 25 #include "smbd/service_task.h" 26 #include "winbind/wb_async_helpers.h"27 26 #include "libcli/security/security.h" 28 27 #include "../lib/util/dlinklist.h" … … 64 63 struct composite_context *result, *ctx; 65 64 struct sid2domain_state *state; 66 65 DEBUG(5, ("wb_sid2domain_send called\n")); 67 66 result = composite_create(mem_ctx, service->task->event_ctx); 68 67 if (result == NULL) goto failed; … … 86 85 if (dom_sid_equal(service->primary_sid, sid) || 87 86 dom_sid_in_domain(service->primary_sid, sid)) { 88 ctx = wb_get_dom_info_send(state, service, lp_workgroup(service->task->lp_ctx), 87 ctx = wb_get_dom_info_send(state, service, 88 lpcfg_workgroup(service->task->lp_ctx), 89 lpcfg_realm(service->task->lp_ctx), 89 90 service->primary_sid); 90 91 if (ctx == NULL) goto failed; -
trunk/server/source4/winbind/wb_sid2gid.c
r414 r745 24 24 #include "winbind/wb_server.h" 25 25 #include "smbd/service_task.h" 26 #include "winbind/wb_helper.h"27 26 #include "libcli/security/security.h" 28 #include "winbind/idmap.h"29 27 30 28 struct sid2gid_state { … … 41 39 struct composite_context *result, *ctx; 42 40 struct sid2gid_state *state; 43 struct id_map ping*ids;41 struct id_map *ids; 44 42 45 43 DEBUG(5, ("wb_sid2gid_send called\n")); … … 55 53 state->service = service; 56 54 57 ids = talloc(result, struct id_map ping);55 ids = talloc(result, struct id_map); 58 56 if (composite_nomem(ids, result)) return result; 59 57 … … 73 71 struct sid2gid_state); 74 72 75 struct id_map ping*ids = NULL;73 struct id_map *ids = NULL; 76 74 77 75 state->ctx->status = wb_sids2xids_recv(ctx, &ids); 78 76 if (!composite_is_ok(state->ctx)) return; 79 77 80 if ( !NT_STATUS_IS_OK(ids->status)) {81 composite_error(state->ctx, ids->status);78 if (ids->status != ID_MAPPED) { 79 composite_error(state->ctx, NT_STATUS_UNSUCCESSFUL); 82 80 return; 83 81 } 84 82 85 if (ids-> unixid->type == ID_TYPE_BOTH ||86 ids-> unixid->type == ID_TYPE_GID) {87 state->gid = ids-> unixid->id;83 if (ids->xid.type == ID_TYPE_BOTH || 84 ids->xid.type == ID_TYPE_GID) { 85 state->gid = ids->xid.id; 88 86 composite_done(state->ctx); 89 87 } else { -
trunk/server/source4/winbind/wb_sid2uid.c
r414 r745 24 24 #include "winbind/wb_server.h" 25 25 #include "smbd/service_task.h" 26 #include "winbind/wb_helper.h"27 26 #include "libcli/security/security.h" 28 #include "winbind/idmap.h"29 27 30 28 struct sid2uid_state { … … 41 39 struct composite_context *result, *ctx; 42 40 struct sid2uid_state *state; 43 struct id_map ping*ids;41 struct id_map *ids; 44 42 45 43 DEBUG(5, ("wb_sid2uid_send called\n")); … … 55 53 state->service = service; 56 54 57 ids = talloc(result, struct id_map ping);55 ids = talloc(result, struct id_map); 58 56 if (composite_nomem(ids, result)) return result; 59 57 … … 73 71 struct sid2uid_state); 74 72 75 struct id_map ping*ids = NULL;73 struct id_map *ids = NULL; 76 74 77 75 state->ctx->status = wb_sids2xids_recv(ctx, &ids); 78 76 if (!composite_is_ok(state->ctx)) return; 79 77 80 if ( !NT_STATUS_IS_OK(ids->status)) {81 composite_error(state->ctx, ids->status);78 if (ids->status != ID_MAPPED) { 79 composite_error(state->ctx, NT_STATUS_UNSUCCESSFUL); 82 80 return; 83 81 } 84 82 85 if (ids-> unixid->type == ID_TYPE_BOTH ||86 ids-> unixid->type == ID_TYPE_UID) {87 state->uid = ids-> unixid->id;83 if (ids->xid.type == ID_TYPE_BOTH || 84 ids->xid.type == ID_TYPE_UID) { 85 state->uid = ids->xid.id; 88 86 composite_done(state->ctx); 89 87 } else { -
trunk/server/source4/winbind/wb_sids2xids.c
r414 r745 24 24 #include "winbind/wb_server.h" 25 25 #include "smbd/service_task.h" 26 #include "winbind/wb_helper.h"27 #include "libcli/security/proto.h"28 #include "winbind/idmap.h"29 26 30 27 struct sids2xids_state { 31 28 struct composite_context *ctx; 32 29 struct wbsrv_service *service; 33 struct id_map ping*ids;30 struct id_map *ids; 34 31 int count; 35 32 }; … … 37 34 struct composite_context *wb_sids2xids_send(TALLOC_CTX *mem_ctx, 38 35 struct wbsrv_service *service, 39 int count, struct id_mapping*ids)36 unsigned int count, struct id_map *ids) 40 37 { 41 38 struct composite_context *result; 42 39 struct sids2xids_state *state; 40 struct id_map **pointer_array; 41 unsigned int i; 43 42 44 43 DEBUG(5, ("wb_sids2xids_send called\n")); … … 56 55 state->ids = ids; 57 56 57 /* We need to convert between calling conventions here - the 58 * values are filled in by reference, so we just need to 59 * provide pointers to them */ 60 pointer_array = talloc_array(state, struct id_map *, count+1); 61 if (composite_nomem(pointer_array, result)) return result; 62 63 for (i=0; i < count; i++) { 64 pointer_array[i] = &ids[i]; 65 } 66 pointer_array[i] = NULL; 67 58 68 state->ctx->status = idmap_sids_to_xids(service->idmap_ctx, mem_ctx, 59 count, state->ids);69 pointer_array); 60 70 if (!composite_is_ok(state->ctx)) return result; 61 71 … … 65 75 66 76 NTSTATUS wb_sids2xids_recv(struct composite_context *ctx, 67 struct id_map ping**ids)77 struct id_map **ids) 68 78 { 69 79 NTSTATUS status = composite_wait(ctx); … … 73 83 DEBUG(5, ("wb_sids2xids_recv called\n")); 74 84 85 /* We don't have to mess with pointer_array on the way out, as 86 * the results are filled into the pointers the caller 87 * supplied */ 75 88 *ids = state->ids; 76 89 -
trunk/server/source4/winbind/wb_uid2sid.c
r414 r745 24 24 #include "winbind/wb_server.h" 25 25 #include "smbd/service_task.h" 26 #include "winbind/wb_helper.h"27 #include "libcli/security/proto.h"28 #include "winbind/idmap.h"29 26 30 27 struct uid2sid_state { … … 41 38 struct composite_context *result, *ctx; 42 39 struct uid2sid_state *state; 43 struct unixid *unixid; 44 struct id_mapping *ids; 40 struct id_map *ids; 45 41 46 42 DEBUG(5, ("wb_uid2sid_send called\n")); … … 56 52 state->service = service; 57 53 58 unixid = talloc(result, struct unixid); 59 if (composite_nomem(unixid, result)) return result; 60 unixid->id = uid; 61 unixid->type = ID_TYPE_UID; 62 63 ids = talloc(result, struct id_mapping); 54 ids = talloc(result, struct id_map); 64 55 if (composite_nomem(ids, result)) return result; 65 ids->unixid = unixid;66 56 ids->sid = NULL; 57 ids->xid.id = uid; 58 ids->xid.type = ID_TYPE_UID; 67 59 68 60 ctx = wb_xids2sids_send(result, service, 1, ids); … … 77 69 struct uid2sid_state *state = talloc_get_type(ctx->async.private_data, 78 70 struct uid2sid_state); 79 struct id_map ping*ids = NULL;71 struct id_map *ids = NULL; 80 72 81 73 state->ctx->status = wb_xids2sids_recv(ctx, &ids); 82 74 if (!composite_is_ok(state->ctx)) return; 83 75 84 if ( !NT_STATUS_IS_OK(ids->status)) {85 composite_error(state->ctx, ids->status);76 if (ids->status != ID_MAPPED) { 77 composite_error(state->ctx, NT_STATUS_UNSUCCESSFUL); 86 78 return; 87 79 } -
trunk/server/source4/winbind/wb_utils.c
r414 r745 32 32 char **domain, char **user) 33 33 { 34 char *p = strchr(domuser, *lp _winbind_separator(lp_ctx));34 char *p = strchr(domuser, *lpcfg_winbind_separator(lp_ctx)); 35 35 36 36 if (p == NULL) { 37 *domain = talloc_strdup(mem_ctx, lp _workgroup(lp_ctx));37 *domain = talloc_strdup(mem_ctx, lpcfg_workgroup(lp_ctx)); 38 38 } else { 39 39 *domain = talloc_strndup(mem_ctx, domuser, -
trunk/server/source4/winbind/wb_xids2sids.c
r414 r745 24 24 #include "winbind/wb_server.h" 25 25 #include "smbd/service_task.h" 26 #include "winbind/wb_helper.h"27 #include "libcli/security/proto.h"28 #include "winbind/idmap.h"29 26 30 27 struct xids2sids_state { 31 28 struct composite_context *ctx; 32 29 struct wbsrv_service *service; 33 struct id_map ping*ids;30 struct id_map *ids; 34 31 int count; 35 32 }; … … 37 34 struct composite_context *wb_xids2sids_send(TALLOC_CTX *mem_ctx, 38 35 struct wbsrv_service *service, 39 int count, struct id_mapping*ids)36 unsigned int count, struct id_map *ids) 40 37 { 41 38 struct composite_context *result; 42 39 struct xids2sids_state *state; 40 struct id_map **pointer_array; 41 unsigned int i; 43 42 44 43 DEBUG(5, ("wb_xids2sids_send called\n")); … … 56 55 state->ids = ids; 57 56 57 /* We need to convert between calling conventions here - the 58 * values are filled in by reference, so we just need to 59 * provide pointers to them */ 60 pointer_array = talloc_array(state, struct id_map *, count+1); 61 if (composite_nomem(pointer_array, result)) return result; 62 63 for (i=0; i < count; i++) { 64 pointer_array[i] = &ids[i]; 65 } 66 pointer_array[i] = NULL; 67 58 68 state->ctx->status = idmap_xids_to_sids(service->idmap_ctx, mem_ctx, 59 count, state->ids);69 pointer_array); 60 70 if (!composite_is_ok(state->ctx)) return result; 61 71 … … 65 75 66 76 NTSTATUS wb_xids2sids_recv(struct composite_context *ctx, 67 struct id_map ping**ids)77 struct id_map **ids) 68 78 { 69 79 NTSTATUS status = composite_wait(ctx); … … 73 83 DEBUG(5, ("wb_xids2sids_recv called.\n")); 74 84 85 /* We don't have to mess with pointer_array on the way out, as 86 * the results are filled into the pointers the caller 87 * supplied */ 75 88 *ids = state->ids; 76 89
Note:
See TracChangeset
for help on using the changeset viewer.