Changeset 745 for trunk/server/nsswitch/libwbclient
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 4 deleted
- 12 edited
- 1 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/nsswitch/libwbclient/libwbclient.h
r414 r745 32 32 #include "nsswitch/winbind_struct_protocol.h" 33 33 34 #include <talloc.h>35 36 34 /* Public headers */ 37 35 38 36 #include "wbclient.h" 39 #include "wbc_async.h"40 37 41 38 /* Private headers */ -
trunk/server/nsswitch/libwbclient/tests/wbclient.c
r414 r745 2 2 Unix SMB/CIFS implementation. 3 3 SMB torture tester 4 Copyright (C) Guenther Deschner 2009 4 Copyright (C) Guenther Deschner 2009-2010 5 5 6 6 This program is free software; you can redistribute it and/or modify … … 18 18 */ 19 19 20 #include "includes.h" 20 #include "lib/replace/replace.h" 21 #include "libcli/util/ntstatus.h" 22 #include "libcli/util/werror.h" 23 #include "lib/util/data_blob.h" 24 #include "lib/util/time.h" 21 25 #include "nsswitch/libwbclient/wbclient.h" 22 26 #include "torture/smbtorture.h" 23 27 #include "torture/winbind/proto.h" 28 #include "lib/util/util_net.h" 29 #include "lib/util/charset/charset.h" 30 #include "libcli/auth/libcli_auth.h" 31 #include "source4/param/param.h" 32 #include "lib/util/util.h" 33 #include "lib/crypto/arcfour.h" 24 34 25 35 #define WBC_ERROR_EQUAL(x,y) (x == y) … … 40 50 torture_assert_wbc_ok(tctx, wbcPing(), 41 51 "wbcPing failed"); 52 53 return true; 54 } 55 56 static bool test_wbc_pingdc(struct torture_context *tctx) 57 { 58 torture_assert_wbc_equal(tctx, wbcPingDc("random_string", NULL), WBC_ERR_NOT_IMPLEMENTED, 59 "wbcPingDc failed"); 60 torture_assert_wbc_ok(tctx, wbcPingDc(NULL, NULL), 61 "wbcPingDc failed"); 42 62 43 63 return true; … … 109 129 torture_assert_str_equal(tctx, sid_string, sid_string2, 110 130 "sid strings differ"); 131 wbcFreeMemory(sid_string2); 111 132 112 133 return true; … … 125 146 torture_assert_str_equal(tctx, guid_string, guid_string2, 126 147 "guid strings differ"); 148 wbcFreeMemory(guid_string2); 127 149 128 150 return true; … … 131 153 static bool test_wbc_domain_info(struct torture_context *tctx) 132 154 { 133 const char *domain_name = NULL;134 155 struct wbcDomainInfo *info; 135 156 struct wbcInterfaceDetails *details; … … 137 158 torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), 138 159 "wbcInterfaceDetails failed"); 139 140 domain_name = talloc_strdup(tctx, details->netbios_domain); 160 torture_assert_wbc_ok( 161 tctx, wbcDomainInfo(details->netbios_domain, &info), 162 "wbcDomainInfo failed"); 141 163 wbcFreeMemory(details); 142 164 143 torture_assert_wbc_ok(tctx, wbcDomainInfo(domain_name, &info),144 "wbcDomainInfo failed");145 165 torture_assert(tctx, info, 146 166 "wbcDomainInfo returned NULL pointer"); 167 wbcFreeMemory(info); 147 168 148 169 return true; … … 186 207 torture_assert(tctx, name, 187 208 "wbcLookupSid returned no name"); 209 wbcFreeMemory(domain); 210 wbcFreeMemory(name); 188 211 torture_assert_wbc_ok(tctx, wbcLookupUserSids(&sid, true, &num_sids, &sids), 189 212 "wbcLookupUserSids failed"); 213 torture_assert_wbc_ok( 214 tctx, wbcGetDisplayName(&sid, &domain, &name, 215 &name_type), 216 "wbcGetDisplayName failed"); 217 wbcFreeMemory(domain); 218 wbcFreeMemory(name); 219 wbcFreeMemory(sids); 190 220 } 221 wbcFreeMemory(users); 191 222 192 223 return true; … … 226 257 "wbcLookupSid returned no name"); 227 258 } 259 wbcFreeMemory(groups); 228 260 229 261 return true; … … 265 297 */ 266 298 } 299 wbcFreeMemory(domains); 267 300 268 301 return true; … … 283 316 torture_assert_wbc_ok(tctx, wbcLookupDomainController(domain_name, 0, &dc_info), 284 317 "wbcLookupDomainController failed"); 318 wbcFreeMemory(dc_info); 285 319 286 320 return true; … … 301 335 torture_assert_wbc_ok(tctx, wbcLookupDomainControllerEx(domain_name, NULL, NULL, 0, &dc_info), 302 336 "wbcLookupDomainControllerEx failed"); 303 304 return true; 305 } 306 337 wbcFreeMemory(dc_info); 338 339 return true; 340 } 341 342 static bool test_wbc_resolve_winsbyname(struct torture_context *tctx) 343 { 344 const char *name; 345 char *ip; 346 wbcErr ret; 347 348 name = torture_setting_string(tctx, "host", NULL); 349 350 ret = wbcResolveWinsByName(name, &ip); 351 352 if (is_ipaddress(name)) { 353 torture_assert_wbc_equal(tctx, ret, WBC_ERR_DOMAIN_NOT_FOUND, "wbcResolveWinsByName failed"); 354 } else { 355 torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByName failed"); 356 } 357 358 return true; 359 } 360 361 static bool test_wbc_resolve_winsbyip(struct torture_context *tctx) 362 { 363 const char *ip; 364 char *name; 365 wbcErr ret; 366 367 ip = torture_setting_string(tctx, "host", NULL); 368 369 ret = wbcResolveWinsByIP(ip, &name); 370 371 torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByIP failed"); 372 373 wbcFreeMemory(name); 374 375 return true; 376 } 377 378 static bool test_wbc_lookup_rids(struct torture_context *tctx) 379 { 380 struct wbcDomainSid builtin; 381 uint32_t rids[2] = { 544, 545 }; 382 const char *domain_name, **names; 383 enum wbcSidType *types; 384 wbcErr ret; 385 386 wbcStringToSid("S-1-5-32", &builtin); 387 388 ret = wbcLookupRids(&builtin, 2, rids, &domain_name, &names, 389 &types); 390 torture_assert_wbc_ok(tctx, ret, "wbcLookupRids failed"); 391 392 torture_assert_str_equal( 393 tctx, names[0], "Administrators", 394 "S-1-5-32-544 not mapped to 'Administrators'"); 395 torture_assert_str_equal( 396 tctx, names[1], "Users", "S-1-5-32-545 not mapped to 'Users'"); 397 398 wbcFreeMemory((char *)domain_name); 399 wbcFreeMemory(names); 400 wbcFreeMemory(types); 401 402 return true; 403 } 404 405 static bool test_wbc_get_sidaliases(struct torture_context *tctx) 406 { 407 struct wbcDomainSid builtin; 408 struct wbcDomainInfo *info; 409 struct wbcInterfaceDetails *details; 410 struct wbcDomainSid sids[2]; 411 uint32_t *rids; 412 uint32_t num_rids; 413 wbcErr ret; 414 415 torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), 416 "wbcInterfaceDetails failed"); 417 torture_assert_wbc_ok( 418 tctx, wbcDomainInfo(details->netbios_domain, &info), 419 "wbcDomainInfo failed"); 420 wbcFreeMemory(details); 421 422 sids[0] = info->sid; 423 sids[0].sub_auths[sids[0].num_auths++] = 500; 424 sids[1] = info->sid; 425 sids[1].sub_auths[sids[1].num_auths++] = 512; 426 wbcFreeMemory(info); 427 428 torture_assert_wbc_ok( 429 tctx, wbcStringToSid("S-1-5-32", &builtin), 430 "wbcStringToSid failed"); 431 432 ret = wbcGetSidAliases(&builtin, sids, 2, &rids, &num_rids); 433 torture_assert_wbc_ok(tctx, ret, "wbcGetSidAliases failed"); 434 435 wbcFreeMemory(rids); 436 437 return true; 438 } 439 440 static bool test_wbc_authenticate_user_int(struct torture_context *tctx, 441 const char *correct_password) 442 { 443 struct wbcAuthUserParams params; 444 struct wbcAuthUserInfo *info = NULL; 445 struct wbcAuthErrorInfo *error = NULL; 446 wbcErr ret; 447 448 ret = wbcAuthenticateUser(getenv("USERNAME"), correct_password); 449 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 450 "wbcAuthenticateUser failed"); 451 452 ZERO_STRUCT(params); 453 params.account_name = getenv("USERNAME"); 454 params.level = WBC_AUTH_USER_LEVEL_PLAIN; 455 params.password.plaintext = correct_password; 456 457 ret = wbcAuthenticateUserEx(¶ms, &info, &error); 458 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 459 "wbcAuthenticateUserEx failed"); 460 wbcFreeMemory(info); 461 info = NULL; 462 463 wbcFreeMemory(error); 464 error = NULL; 465 466 params.password.plaintext = "wrong"; 467 ret = wbcAuthenticateUserEx(¶ms, &info, &error); 468 torture_assert_wbc_equal(tctx, ret, WBC_ERR_AUTH_ERROR, 469 "wbcAuthenticateUserEx succeeded where it " 470 "should have failed"); 471 wbcFreeMemory(info); 472 info = NULL; 473 474 wbcFreeMemory(error); 475 error = NULL; 476 477 return true; 478 } 479 480 static bool test_wbc_authenticate_user(struct torture_context *tctx) 481 { 482 return test_wbc_authenticate_user_int(tctx, getenv("PASSWORD")); 483 } 484 485 static bool test_wbc_change_password(struct torture_context *tctx) 486 { 487 wbcErr ret; 488 const char *oldpass = getenv("PASSWORD"); 489 const char *newpass = "Koo8irei"; 490 491 struct samr_CryptPassword new_nt_password; 492 struct samr_CryptPassword new_lm_password; 493 struct samr_Password old_nt_hash_enc; 494 struct samr_Password old_lanman_hash_enc; 495 496 uint8_t old_nt_hash[16]; 497 uint8_t old_lanman_hash[16]; 498 uint8_t new_nt_hash[16]; 499 uint8_t new_lanman_hash[16]; 500 501 struct wbcChangePasswordParams params; 502 503 if (oldpass == NULL) { 504 torture_skip(tctx, 505 "skipping wbcChangeUserPassword test as old password cannot be retrieved\n"); 506 } 507 508 ZERO_STRUCT(params); 509 510 E_md4hash(oldpass, old_nt_hash); 511 E_md4hash(newpass, new_nt_hash); 512 513 if (lpcfg_client_lanman_auth(tctx->lp_ctx) && 514 E_deshash(newpass, new_lanman_hash) && 515 E_deshash(oldpass, old_lanman_hash)) { 516 517 /* E_deshash returns false for 'long' passwords (> 14 518 DOS chars). This allows us to match Win2k, which 519 does not store a LM hash for these passwords (which 520 would reduce the effective password length to 14) */ 521 522 encode_pw_buffer(new_lm_password.data, newpass, STR_UNICODE); 523 arcfour_crypt(new_lm_password.data, old_nt_hash, 516); 524 E_old_pw_hash(new_nt_hash, old_lanman_hash, 525 old_lanman_hash_enc.hash); 526 527 params.old_password.response.old_lm_hash_enc_length = 528 sizeof(old_lanman_hash_enc.hash); 529 params.old_password.response.old_lm_hash_enc_data = 530 old_lanman_hash_enc.hash; 531 params.new_password.response.lm_length = 532 sizeof(new_lm_password.data); 533 params.new_password.response.lm_data = 534 new_lm_password.data; 535 } else { 536 ZERO_STRUCT(new_lm_password); 537 ZERO_STRUCT(old_lanman_hash_enc); 538 } 539 540 encode_pw_buffer(new_nt_password.data, newpass, STR_UNICODE); 541 542 arcfour_crypt(new_nt_password.data, old_nt_hash, 516); 543 E_old_pw_hash(new_nt_hash, old_nt_hash, old_nt_hash_enc.hash); 544 545 params.old_password.response.old_nt_hash_enc_length = 546 sizeof(old_nt_hash_enc.hash); 547 params.old_password.response.old_nt_hash_enc_data = 548 old_nt_hash_enc.hash; 549 params.new_password.response.nt_length = sizeof(new_nt_password.data); 550 params.new_password.response.nt_data = new_nt_password.data; 551 552 params.level = WBC_CHANGE_PASSWORD_LEVEL_RESPONSE; 553 params.account_name = getenv("USERNAME"); 554 params.domain_name = "SAMBA-TEST"; 555 556 ret = wbcChangeUserPasswordEx(¶ms, NULL, NULL, NULL); 557 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 558 "wbcChangeUserPassword failed"); 559 560 if (!test_wbc_authenticate_user_int(tctx, "Koo8irei")) { 561 return false; 562 } 563 564 ret = wbcChangeUserPassword(getenv("USERNAME"), "Koo8irei", 565 getenv("PASSWORD")); 566 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 567 "wbcChangeUserPassword failed"); 568 569 return test_wbc_authenticate_user_int(tctx, getenv("PASSWORD")); 570 } 571 572 static bool test_wbc_logon_user(struct torture_context *tctx) 573 { 574 struct wbcLogonUserParams params; 575 struct wbcLogonUserInfo *info = NULL; 576 struct wbcAuthErrorInfo *error = NULL; 577 struct wbcUserPasswordPolicyInfo *policy = NULL; 578 struct wbcInterfaceDetails *iface; 579 struct wbcDomainSid sid; 580 enum wbcSidType sidtype; 581 char *sidstr; 582 wbcErr ret; 583 584 ZERO_STRUCT(params); 585 586 ret = wbcLogonUser(¶ms, &info, &error, &policy); 587 torture_assert_wbc_equal(tctx, ret, WBC_ERR_INVALID_PARAM, 588 "wbcLogonUser succeeded where it should " 589 "have failed"); 590 591 params.username = getenv("USERNAME"); 592 params.password = getenv("PASSWORD"); 593 594 ret = wbcAddNamedBlob(¶ms.num_blobs, ¶ms.blobs, 595 "foo", 0, discard_const_p(uint8_t, "bar"), 4); 596 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 597 "wbcAddNamedBlob failed"); 598 599 ret = wbcLogonUser(¶ms, &info, &error, &policy); 600 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 601 "wbcLogonUser failed"); 602 wbcFreeMemory(info); info = NULL; 603 wbcFreeMemory(error); error = NULL; 604 wbcFreeMemory(policy); policy = NULL; 605 606 params.password = "wrong"; 607 608 ret = wbcLogonUser(¶ms, &info, &error, &policy); 609 torture_assert_wbc_equal(tctx, ret, WBC_ERR_AUTH_ERROR, 610 "wbcLogonUser should have failed with " 611 "WBC_ERR_AUTH_ERROR"); 612 wbcFreeMemory(info); info = NULL; 613 wbcFreeMemory(error); error = NULL; 614 wbcFreeMemory(policy); policy = NULL; 615 616 ret = wbcAddNamedBlob(¶ms.num_blobs, ¶ms.blobs, 617 "membership_of", 0, 618 discard_const_p(uint8_t, "S-1-2-3-4"), 619 strlen("S-1-2-3-4")+1); 620 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 621 "wbcAddNamedBlob failed"); 622 params.password = getenv("PASSWORD"); 623 ret = wbcLogonUser(¶ms, &info, &error, &policy); 624 torture_assert_wbc_equal(tctx, ret, WBC_ERR_AUTH_ERROR, 625 "wbcLogonUser should have failed with " 626 "WBC_ERR_AUTH_ERROR"); 627 wbcFreeMemory(info); info = NULL; 628 wbcFreeMemory(error); error = NULL; 629 wbcFreeMemory(policy); policy = NULL; 630 wbcFreeMemory(params.blobs); 631 params.blobs = NULL; params.num_blobs = 0; 632 633 ret = wbcInterfaceDetails(&iface); 634 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 635 "wbcInterfaceDetails failed"); 636 637 ret = wbcLookupName(iface->netbios_domain, getenv("USERNAME"), &sid, 638 &sidtype); 639 wbcFreeMemory(iface); 640 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 641 "wbcLookupName failed"); 642 643 ret = wbcSidToString(&sid, &sidstr); 644 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 645 "wbcSidToString failed"); 646 647 ret = wbcAddNamedBlob(¶ms.num_blobs, ¶ms.blobs, 648 "membership_of", 0, 649 (uint8_t *)sidstr, strlen(sidstr)+1); 650 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 651 "wbcAddNamedBlob failed"); 652 wbcFreeMemory(sidstr); 653 params.password = getenv("PASSWORD"); 654 ret = wbcLogonUser(¶ms, &info, &error, &policy); 655 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 656 "wbcLogonUser failed"); 657 wbcFreeMemory(info); info = NULL; 658 wbcFreeMemory(error); error = NULL; 659 wbcFreeMemory(policy); policy = NULL; 660 wbcFreeMemory(params.blobs); 661 params.blobs = NULL; params.num_blobs = 0; 662 663 return true; 664 } 665 666 static bool test_wbc_getgroups(struct torture_context *tctx) 667 { 668 wbcErr ret; 669 uint32_t num_groups; 670 gid_t *groups; 671 672 ret = wbcGetGroups(getenv("USERNAME"), &num_groups, &groups); 673 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 674 "wbcGetGroups failed"); 675 wbcFreeMemory(groups); 676 return true; 677 } 307 678 308 679 struct torture_suite *torture_wbclient(void) 309 680 { 310 struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), " WBCLIENT");681 struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "wbclient"); 311 682 312 683 torture_suite_add_simple_test(suite, "wbcPing", test_wbc_ping); 684 torture_suite_add_simple_test(suite, "wbcPingDc", test_wbc_pingdc); 313 685 torture_suite_add_simple_test(suite, "wbcLibraryDetails", test_wbc_library_details); 314 686 torture_suite_add_simple_test(suite, "wbcInterfaceDetails", test_wbc_interface_details); … … 322 694 torture_suite_add_simple_test(suite, "wbcLookupDomainController", test_wbc_lookupdc); 323 695 torture_suite_add_simple_test(suite, "wbcLookupDomainControllerEx", test_wbc_lookupdcex); 696 torture_suite_add_simple_test(suite, "wbcResolveWinsByName", test_wbc_resolve_winsbyname); 697 torture_suite_add_simple_test(suite, "wbcResolveWinsByIP", test_wbc_resolve_winsbyip); 698 torture_suite_add_simple_test(suite, "wbcLookupRids", 699 test_wbc_lookup_rids); 700 torture_suite_add_simple_test(suite, "wbcGetSidAliases", 701 test_wbc_get_sidaliases); 702 torture_suite_add_simple_test(suite, "wbcAuthenticateUser", 703 test_wbc_authenticate_user); 704 torture_suite_add_simple_test(suite, "wbcLogonUser", 705 test_wbc_logon_user); 706 torture_suite_add_simple_test(suite, "wbcChangeUserPassword", 707 test_wbc_change_password); 708 torture_suite_add_simple_test(suite, "wbcGetGroups", 709 test_wbc_getgroups); 324 710 325 711 return suite; -
trunk/server/nsswitch/libwbclient/wbc_guid.c
r414 r745 30 30 char **guid_string) 31 31 { 32 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;32 char *result; 33 33 34 if (!guid) {35 wbc_status = WBC_ERR_INVALID_PARAM;36 BAIL_ON_WBC_ERROR(wbc_status);34 result = (char *)wbcAllocateMemory(37, 1, NULL); 35 if (result == NULL) { 36 return WBC_ERR_NO_MEMORY; 37 37 } 38 snprintf(result, 37, 39 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", 40 guid->time_low, guid->time_mid, 41 guid->time_hi_and_version, 42 guid->clock_seq[0], 43 guid->clock_seq[1], 44 guid->node[0], guid->node[1], 45 guid->node[2], guid->node[3], 46 guid->node[4], guid->node[5]); 47 *guid_string = result; 38 48 39 *guid_string = talloc_asprintf(NULL, 40 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", 41 guid->time_low, guid->time_mid, 42 guid->time_hi_and_version, 43 guid->clock_seq[0], 44 guid->clock_seq[1], 45 guid->node[0], guid->node[1], 46 guid->node[2], guid->node[3], 47 guid->node[4], guid->node[5]); 48 BAIL_ON_PTR_ERROR((*guid_string), wbc_status); 49 50 wbc_status = WBC_ERR_SUCCESS; 51 52 done: 53 return wbc_status; 49 return WBC_ERR_SUCCESS; 54 50 } 55 51 -
trunk/server/nsswitch/libwbclient/wbc_idmap.c
r480 r745 5 5 6 6 Copyright (C) Gerald (Jerry) Carter 2007 7 8 7 9 8 This library is free software; you can redistribute it and/or … … 25 24 #include "replace.h" 26 25 #include "libwbclient.h" 26 #include "../winbind_client.h" 27 27 28 28 /* Convert a Windows SID to a Unix uid, allocating an uid if needed */ … … 31 31 struct winbindd_request request; 32 32 struct winbindd_response response; 33 char *sid_string = NULL;34 33 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 35 34 … … 44 43 ZERO_STRUCT(response); 45 44 46 wbc_status = wbcSidToString(sid, &sid_string); 47 BAIL_ON_WBC_ERROR(wbc_status); 48 49 strncpy(request.data.sid, sid_string, sizeof(request.data.sid)-1); 50 wbcFreeMemory(sid_string); 45 wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid)); 51 46 52 47 /* Make request */ … … 126 121 struct winbindd_response response; 127 122 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 128 char *sid_string = NULL;129 123 130 124 if (!sid || !pgid) { … … 138 132 ZERO_STRUCT(response); 139 133 140 wbc_status = wbcSidToString(sid, &sid_string); 141 BAIL_ON_WBC_ERROR(wbc_status); 142 143 strncpy(request.data.sid, sid_string, sizeof(request.data.sid)-1); 144 wbcFreeMemory(sid_string); 134 wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid)); 145 135 146 136 /* Make request */ … … 159 149 } 160 150 151 161 152 /* Convert a Windows SID to a Unix gid if there already is a mapping */ 162 153 … … 166 157 return WBC_ERR_NOT_IMPLEMENTED; 167 158 } 159 168 160 169 161 /* Convert a Unix gid to a Windows SID, allocating a SID if needed */ … … 271 263 #define _ID_TYPE_GID 2 272 264 273 /* Set an user id mapping */265 /* Set an user id mapping - not implemented any more */ 274 266 wbcErr wbcSetUidMapping(uid_t uid, const struct wbcDomainSid *sid) 275 267 { 276 struct winbindd_request request; 277 struct winbindd_response response; 278 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 279 char *sid_string = NULL; 280 281 if (!sid) { 282 return WBC_ERR_INVALID_PARAM; 283 } 284 285 /* Initialise request */ 286 287 ZERO_STRUCT(request); 288 ZERO_STRUCT(response); 289 290 /* Make request */ 291 292 request.data.dual_idmapset.id = uid; 293 request.data.dual_idmapset.type = _ID_TYPE_UID; 294 295 wbc_status = wbcSidToString(sid, &sid_string); 296 BAIL_ON_WBC_ERROR(wbc_status); 297 298 strncpy(request.data.dual_idmapset.sid, sid_string, 299 sizeof(request.data.dual_idmapset.sid)-1); 300 wbcFreeMemory(sid_string); 301 302 wbc_status = wbcRequestResponsePriv(WINBINDD_SET_MAPPING, 303 &request, &response); 304 BAIL_ON_WBC_ERROR(wbc_status); 305 306 done: 307 return wbc_status; 308 } 309 310 /* Set a group id mapping */ 268 return WBC_ERR_NOT_IMPLEMENTED; 269 } 270 271 /* Set a group id mapping - not implemented any more */ 311 272 wbcErr wbcSetGidMapping(gid_t gid, const struct wbcDomainSid *sid) 312 273 { 313 struct winbindd_request request; 314 struct winbindd_response response; 315 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 316 char *sid_string = NULL; 317 318 if (!sid) { 319 return WBC_ERR_INVALID_PARAM; 320 } 321 322 /* Initialise request */ 323 324 ZERO_STRUCT(request); 325 ZERO_STRUCT(response); 326 327 /* Make request */ 328 329 request.data.dual_idmapset.id = gid; 330 request.data.dual_idmapset.type = _ID_TYPE_GID; 331 332 wbc_status = wbcSidToString(sid, &sid_string); 333 BAIL_ON_WBC_ERROR(wbc_status); 334 335 strncpy(request.data.dual_idmapset.sid, sid_string, 336 sizeof(request.data.dual_idmapset.sid)-1); 337 wbcFreeMemory(sid_string); 338 339 wbc_status = wbcRequestResponsePriv(WINBINDD_SET_MAPPING, 340 &request, &response); 341 BAIL_ON_WBC_ERROR(wbc_status); 342 343 done: 344 return wbc_status; 345 } 346 347 /* Remove a user id mapping */ 274 return WBC_ERR_NOT_IMPLEMENTED; 275 } 276 277 /* Remove a user id mapping - not implemented any more */ 348 278 wbcErr wbcRemoveUidMapping(uid_t uid, const struct wbcDomainSid *sid) 349 279 { 350 struct winbindd_request request; 351 struct winbindd_response response; 352 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 353 char *sid_string = NULL; 354 355 if (!sid) { 356 return WBC_ERR_INVALID_PARAM; 357 } 358 359 /* Initialise request */ 360 361 ZERO_STRUCT(request); 362 ZERO_STRUCT(response); 363 364 /* Make request */ 365 366 request.data.dual_idmapset.id = uid; 367 request.data.dual_idmapset.type = _ID_TYPE_UID; 368 369 wbc_status = wbcSidToString(sid, &sid_string); 370 BAIL_ON_WBC_ERROR(wbc_status); 371 372 strncpy(request.data.dual_idmapset.sid, sid_string, 373 sizeof(request.data.dual_idmapset.sid)-1); 374 wbcFreeMemory(sid_string); 375 376 wbc_status = wbcRequestResponsePriv(WINBINDD_REMOVE_MAPPING, 377 &request, &response); 378 BAIL_ON_WBC_ERROR(wbc_status); 379 380 done: 381 return wbc_status; 382 } 383 384 /* Remove a group id mapping */ 280 return WBC_ERR_NOT_IMPLEMENTED; 281 } 282 283 /* Remove a group id mapping - not implemented any more */ 385 284 wbcErr wbcRemoveGidMapping(gid_t gid, const struct wbcDomainSid *sid) 386 285 { 387 struct winbindd_request request; 388 struct winbindd_response response; 389 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 390 char *sid_string = NULL; 391 392 if (!sid) { 393 return WBC_ERR_INVALID_PARAM; 394 } 395 396 /* Initialise request */ 397 398 ZERO_STRUCT(request); 399 ZERO_STRUCT(response); 400 401 /* Make request */ 402 403 request.data.dual_idmapset.id = gid; 404 request.data.dual_idmapset.type = _ID_TYPE_GID; 405 406 wbc_status = wbcSidToString(sid, &sid_string); 407 BAIL_ON_WBC_ERROR(wbc_status); 408 409 strncpy(request.data.dual_idmapset.sid, sid_string, 410 sizeof(request.data.dual_idmapset.sid)-1); 411 wbcFreeMemory(sid_string); 412 413 wbc_status = wbcRequestResponsePriv(WINBINDD_REMOVE_MAPPING, 414 &request, &response); 415 BAIL_ON_WBC_ERROR(wbc_status); 416 417 done: 418 return wbc_status; 419 } 420 421 /* Set the highwater mark for allocated uids. */ 286 return WBC_ERR_NOT_IMPLEMENTED; 287 } 288 289 /* Set the highwater mark for allocated uids - not implemented any more */ 422 290 wbcErr wbcSetUidHwm(uid_t uid_hwm) 423 291 { 424 struct winbindd_request request; 425 struct winbindd_response response; 426 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 427 428 /* Initialise request */ 429 430 ZERO_STRUCT(request); 431 ZERO_STRUCT(response); 432 433 /* Make request */ 434 435 request.data.dual_idmapset.id = uid_hwm; 436 request.data.dual_idmapset.type = _ID_TYPE_UID; 437 438 wbc_status = wbcRequestResponsePriv(WINBINDD_SET_HWM, 439 &request, &response); 440 BAIL_ON_WBC_ERROR(wbc_status); 441 442 done: 443 return wbc_status; 444 } 445 446 /* Set the highwater mark for allocated gids. */ 292 return WBC_ERR_NOT_IMPLEMENTED; 293 } 294 295 /* Set the highwater mark for allocated gids - not implemented any more */ 447 296 wbcErr wbcSetGidHwm(gid_t gid_hwm) 448 297 { 449 struct winbindd_request request; 450 struct winbindd_response response; 451 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 452 453 /* Initialise request */ 454 455 ZERO_STRUCT(request); 456 ZERO_STRUCT(response); 457 458 /* Make request */ 459 460 request.data.dual_idmapset.id = gid_hwm; 461 request.data.dual_idmapset.type = _ID_TYPE_GID; 462 463 wbc_status = wbcRequestResponsePriv(WINBINDD_SET_HWM, 464 &request, &response); 465 BAIL_ON_WBC_ERROR(wbc_status); 466 467 done: 468 return wbc_status; 469 } 298 return WBC_ERR_NOT_IMPLEMENTED; 299 } 300 301 /* Convert a list of SIDs */ 302 wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids, 303 struct wbcUnixId *ids) 304 { 305 struct winbindd_request request; 306 struct winbindd_response response; 307 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 308 int buflen, extra_len; 309 uint32_t i; 310 char *sidlist, *p, *extra_data; 311 312 buflen = num_sids * (WBC_SID_STRING_BUFLEN + 1) + 1; 313 314 sidlist = (char *)malloc(buflen); 315 if (sidlist == NULL) { 316 return WBC_ERR_NO_MEMORY; 317 } 318 319 p = sidlist; 320 321 for (i=0; i<num_sids; i++) { 322 int remaining; 323 int len; 324 325 remaining = buflen - (p - sidlist); 326 327 len = wbcSidToStringBuf(&sids[i], p, remaining); 328 if (len > remaining) { 329 free(sidlist); 330 return WBC_ERR_UNKNOWN_FAILURE; 331 } 332 333 p += len; 334 *p++ = '\n'; 335 } 336 *p++ = '\0'; 337 338 ZERO_STRUCT(request); 339 ZERO_STRUCT(response); 340 341 request.extra_data.data = sidlist; 342 request.extra_len = p - sidlist; 343 344 wbc_status = wbcRequestResponse(WINBINDD_SIDS_TO_XIDS, 345 &request, &response); 346 free(sidlist); 347 if (!WBC_ERROR_IS_OK(wbc_status)) { 348 return wbc_status; 349 } 350 351 extra_len = response.length - sizeof(struct winbindd_response); 352 extra_data = (char *)response.extra_data.data; 353 354 if ((extra_len <= 0) || (extra_data[extra_len-1] != '\0')) { 355 goto wbc_err_invalid; 356 } 357 358 p = extra_data; 359 360 for (i=0; i<num_sids; i++) { 361 struct wbcUnixId *id = &ids[i]; 362 char *q; 363 364 switch (p[0]) { 365 case 'U': 366 id->type = WBC_ID_TYPE_UID; 367 id->id.uid = strtoul(p+1, &q, 10); 368 break; 369 case 'G': 370 id->type = WBC_ID_TYPE_GID; 371 id->id.gid = strtoul(p+1, &q, 10); 372 break; 373 default: 374 id->type = WBC_ID_TYPE_NOT_SPECIFIED; 375 q = p; 376 break; 377 }; 378 if (q[0] != '\n') { 379 goto wbc_err_invalid; 380 } 381 p = q+1; 382 } 383 wbc_status = WBC_ERR_SUCCESS; 384 goto done; 385 386 wbc_err_invalid: 387 wbc_status = WBC_ERR_INVALID_RESPONSE; 388 done: 389 winbindd_free_response(&response); 390 return wbc_status; 391 } -
trunk/server/nsswitch/libwbclient/wbc_pam.c
r599 r745 26 26 #include "replace.h" 27 27 #include "libwbclient.h" 28 #include "../winbind_client.h" 28 29 29 30 /* Authenticate a username/password pair */ … … 47 48 } 48 49 49 static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx, 50 const struct winbindd_response *resp, 50 static bool sid_attr_compose(struct wbcSidWithAttr *s, 51 const struct wbcDomainSid *d, 52 uint32_t rid, uint32_t attr) 53 { 54 if (d->num_auths >= WBC_MAXSUBAUTHS) { 55 return false; 56 } 57 s->sid = *d; 58 s->sid.sub_auths[s->sid.num_auths++] = rid; 59 s->attributes = attr; 60 return true; 61 } 62 63 static void wbcAuthUserInfoDestructor(void *ptr) 64 { 65 struct wbcAuthUserInfo *i = (struct wbcAuthUserInfo *)ptr; 66 free(i->account_name); 67 free(i->user_principal); 68 free(i->full_name); 69 free(i->domain_name); 70 free(i->dns_domain_name); 71 free(i->logon_server); 72 free(i->logon_script); 73 free(i->profile_path); 74 free(i->home_directory); 75 free(i->home_drive); 76 free(i->sids); 77 } 78 79 static wbcErr wbc_create_auth_info(const struct winbindd_response *resp, 51 80 struct wbcAuthUserInfo **_i) 52 81 { … … 58 87 uint32_t j; 59 88 60 i = talloc(mem_ctx, struct wbcAuthUserInfo); 89 i = (struct wbcAuthUserInfo *)wbcAllocateMemory( 90 1, sizeof(struct wbcAuthUserInfo), 91 wbcAuthUserInfoDestructor); 61 92 BAIL_ON_PTR_ERROR(i, wbc_status); 62 93 63 94 i->user_flags = resp->data.auth.info3.user_flgs; 64 95 65 i->account_name = talloc_strdup(i,resp->data.auth.info3.user_name);96 i->account_name = strdup(resp->data.auth.info3.user_name); 66 97 BAIL_ON_PTR_ERROR(i->account_name, wbc_status); 67 98 i->user_principal= NULL; 68 i->full_name = talloc_strdup(i,resp->data.auth.info3.full_name);99 i->full_name = strdup(resp->data.auth.info3.full_name); 69 100 BAIL_ON_PTR_ERROR(i->full_name, wbc_status); 70 i->domain_name = talloc_strdup(i,resp->data.auth.info3.logon_dom);101 i->domain_name = strdup(resp->data.auth.info3.logon_dom); 71 102 BAIL_ON_PTR_ERROR(i->domain_name, wbc_status); 72 103 i->dns_domain_name= NULL; … … 90 121 i->pass_must_change_time= resp->data.auth.info3.pass_must_change_time; 91 122 92 i->logon_server = talloc_strdup(i,resp->data.auth.info3.logon_srv);123 i->logon_server = strdup(resp->data.auth.info3.logon_srv); 93 124 BAIL_ON_PTR_ERROR(i->logon_server, wbc_status); 94 i->logon_script = talloc_strdup(i,resp->data.auth.info3.logon_script);125 i->logon_script = strdup(resp->data.auth.info3.logon_script); 95 126 BAIL_ON_PTR_ERROR(i->logon_script, wbc_status); 96 i->profile_path = talloc_strdup(i,resp->data.auth.info3.profile_path);127 i->profile_path = strdup(resp->data.auth.info3.profile_path); 97 128 BAIL_ON_PTR_ERROR(i->profile_path, wbc_status); 98 i->home_directory= talloc_strdup(i,resp->data.auth.info3.home_dir);129 i->home_directory= strdup(resp->data.auth.info3.home_dir); 99 130 BAIL_ON_PTR_ERROR(i->home_directory, wbc_status); 100 i->home_drive = talloc_strdup(i,resp->data.auth.info3.dir_drive);131 i->home_drive = strdup(resp->data.auth.info3.dir_drive); 101 132 BAIL_ON_PTR_ERROR(i->home_drive, wbc_status); 102 133 … … 105 136 i->num_sids += resp->data.auth.info3.num_other_sids; 106 137 107 i->sids = talloc_array(i, struct wbcSidWithAttr, i->num_sids); 138 i->sids = (struct wbcSidWithAttr *)calloc( 139 sizeof(struct wbcSidWithAttr), i->num_sids); 108 140 BAIL_ON_PTR_ERROR(i->sids, wbc_status); 109 141 … … 112 144 BAIL_ON_WBC_ERROR(wbc_status); 113 145 114 #define _SID_COMPOSE(s, d, r, a) { \115 (s).sid = d; \116 if ((s).sid.num_auths < WBC_MAXSUBAUTHS) { \117 (s).sid.sub_auths[(s).sid.num_auths++] = r; \118 } else { \119 wbc_status = WBC_ERR_INVALID_SID; \120 BAIL_ON_WBC_ERROR(wbc_status); \121 } \122 (s).attributes = a; \123 } while (0)124 125 146 sn = 0; 126 _SID_COMPOSE(i->sids[sn], domain_sid, 127 resp->data.auth.info3.user_rid, 128 0); 147 if (!sid_attr_compose(&i->sids[sn], &domain_sid, 148 resp->data.auth.info3.user_rid, 0)) { 149 wbc_status = WBC_ERR_INVALID_SID; 150 goto done; 151 } 129 152 sn++; 130 _SID_COMPOSE(i->sids[sn], domain_sid, 131 resp->data.auth.info3.group_rid, 132 0); 153 if (!sid_attr_compose(&i->sids[sn], &domain_sid, 154 resp->data.auth.info3.group_rid, 0)) { 155 wbc_status = WBC_ERR_INVALID_SID; 156 goto done; 157 } 133 158 sn++; 134 159 … … 158 183 } 159 184 160 _SID_COMPOSE(i->sids[sn], domain_sid, 161 rid, attrs); 185 if (!sid_attr_compose(&i->sids[sn], &domain_sid, 186 rid, attrs)) { 187 wbc_status = WBC_ERR_INVALID_SID; 188 goto done; 189 } 162 190 sn++; 163 191 } … … 203 231 i = NULL; 204 232 done: 205 talloc_free(i); 206 return wbc_status; 207 } 208 209 static wbcErr wbc_create_error_info(TALLOC_CTX *mem_ctx, 210 const struct winbindd_response *resp, 211 struct wbcAuthErrorInfo **_e) 233 wbcFreeMemory(i); 234 return wbc_status; 235 } 236 237 static void wbcAuthErrorInfoDestructor(void *ptr) 238 { 239 struct wbcAuthErrorInfo *e = (struct wbcAuthErrorInfo *)ptr; 240 free(e->nt_string); 241 free(e->display_string); 242 } 243 244 static wbcErr wbc_create_error_info(const struct winbindd_response *resp, 245 struct wbcAuthErrorInfo **_e) 212 246 { 213 247 wbcErr wbc_status = WBC_ERR_SUCCESS; 214 248 struct wbcAuthErrorInfo *e; 215 249 216 e = talloc(mem_ctx, struct wbcAuthErrorInfo); 250 e = (struct wbcAuthErrorInfo *)wbcAllocateMemory( 251 1, sizeof(struct wbcAuthErrorInfo), 252 wbcAuthErrorInfoDestructor); 217 253 BAIL_ON_PTR_ERROR(e, wbc_status); 218 254 219 255 e->nt_status = resp->data.auth.nt_status; 220 256 e->pam_error = resp->data.auth.pam_error; 221 e->nt_string = talloc_strdup(e,resp->data.auth.nt_status_string);257 e->nt_string = strdup(resp->data.auth.nt_status_string); 222 258 BAIL_ON_PTR_ERROR(e->nt_string, wbc_status); 223 259 224 e->display_string = talloc_strdup(e,resp->data.auth.error_string);260 e->display_string = strdup(resp->data.auth.error_string); 225 261 BAIL_ON_PTR_ERROR(e->display_string, wbc_status); 226 262 … … 229 265 230 266 done: 231 talloc_free(e); 232 return wbc_status; 233 } 234 235 static wbcErr wbc_create_password_policy_info(TALLOC_CTX *mem_ctx, 236 const struct winbindd_response *resp, 267 wbcFreeMemory(e); 268 return wbc_status; 269 } 270 271 static wbcErr wbc_create_password_policy_info(const struct winbindd_response *resp, 237 272 struct wbcUserPasswordPolicyInfo **_i) 238 273 { … … 240 275 struct wbcUserPasswordPolicyInfo *i; 241 276 242 i = talloc(mem_ctx, struct wbcUserPasswordPolicyInfo); 277 i = (struct wbcUserPasswordPolicyInfo *)wbcAllocateMemory( 278 1, sizeof(struct wbcUserPasswordPolicyInfo), NULL); 243 279 BAIL_ON_PTR_ERROR(i, wbc_status); 244 280 … … 253 289 254 290 done: 255 talloc_free(i); 256 return wbc_status; 257 } 258 259 static wbcErr wbc_create_logon_info(TALLOC_CTX *mem_ctx, 260 struct winbindd_response *resp, 291 wbcFreeMemory(i); 292 return wbc_status; 293 } 294 295 static void wbcLogonUserInfoDestructor(void *ptr) 296 { 297 struct wbcLogonUserInfo *i = (struct wbcLogonUserInfo *)ptr; 298 wbcFreeMemory(i->info); 299 wbcFreeMemory(i->blobs); 300 } 301 302 static wbcErr wbc_create_logon_info(struct winbindd_response *resp, 261 303 struct wbcLogonUserInfo **_i) 262 304 { … … 264 306 struct wbcLogonUserInfo *i; 265 307 266 i = talloc_zero(mem_ctx, struct wbcLogonUserInfo); 308 i = (struct wbcLogonUserInfo *)wbcAllocateMemory( 309 1, sizeof(struct wbcLogonUserInfo), 310 wbcLogonUserInfoDestructor); 267 311 BAIL_ON_PTR_ERROR(i, wbc_status); 268 312 269 wbc_status = wbc_create_auth_info( i,resp, &i->info);313 wbc_status = wbc_create_auth_info(resp, &i->info); 270 314 BAIL_ON_WBC_ERROR(wbc_status); 271 315 272 if (resp->data.auth.krb5ccname && 273 strlen(resp->data.auth.krb5ccname)) { 316 if (resp->data.auth.krb5ccname[0] != '\0') { 274 317 wbc_status = wbcAddNamedBlob(&i->num_blobs, 275 318 &i->blobs, … … 281 324 } 282 325 283 if (resp->data.auth.unix_username && 284 strlen(resp->data.auth.unix_username)) { 326 if (resp->data.auth.unix_username[0] != '\0') { 285 327 wbc_status = wbcAddNamedBlob(&i->num_blobs, 286 328 &i->blobs, … … 295 337 i = NULL; 296 338 done: 297 if (!WBC_ERROR_IS_OK(wbc_status) && i) { 298 wbcFreeMemory(i->blobs); 299 } 300 301 talloc_free(i); 302 return wbc_status; 303 } 339 wbcFreeMemory(i); 340 return wbc_status; 341 } 342 304 343 305 344 /* Authenticate with more detailed information */ … … 437 476 request.flags |= WBFLAG_BIG_NTLMV2_BLOB; 438 477 request.extra_len = params->password.response.nt_length; 439 request.extra_data.data = talloc_zero_array(NULL, char, request.extra_len); 478 request.extra_data.data = (char *)malloc( 479 request.extra_len); 440 480 if (request.extra_data.data == NULL) { 441 481 wbc_status = WBC_ERR_NO_MEMORY; … … 471 511 if (response.data.auth.nt_status != 0) { 472 512 if (error) { 473 wbc_status = wbc_create_error_info(NULL, 474 &response, 513 wbc_status = wbc_create_error_info(&response, 475 514 error); 476 515 BAIL_ON_WBC_ERROR(wbc_status); … … 483 522 484 523 if (info) { 485 wbc_status = wbc_create_auth_info(NULL, 486 &response, 487 info); 524 wbc_status = wbc_create_auth_info(&response, info); 488 525 BAIL_ON_WBC_ERROR(wbc_status); 489 526 } 490 527 491 528 done: 492 if (response.extra_data.data) 493 free(response.extra_data.data); 494 495 talloc_free(request.extra_data.data); 529 winbindd_free_response(&response); 530 531 free(request.extra_data.data); 496 532 497 533 return wbc_status; … … 520 556 if (response.data.auth.nt_status != 0) { 521 557 if (error) { 522 wbc_status = wbc_create_error_info(NULL, 523 &response, 558 wbc_status = wbc_create_error_info(&response, 524 559 error); 525 560 BAIL_ON_WBC_ERROR(wbc_status); … … 557 592 if (response.data.auth.nt_status != 0) { 558 593 if (error) { 559 wbc_status = wbc_create_error_info(NULL, 560 &response, 594 wbc_status = wbc_create_error_info(&response, 561 595 error); 562 596 BAIL_ON_WBC_ERROR(wbc_status); … … 601 635 if (response.data.auth.nt_status != 0) { 602 636 if (error) { 603 wbc_status = wbc_create_error_info(NULL, 604 &response, 637 wbc_status = wbc_create_error_info(&response, 605 638 error); 606 639 BAIL_ON_WBC_ERROR(wbc_status); … … 688 721 if (response.data.auth.nt_status != 0) { 689 722 if (error) { 690 wbc_status = wbc_create_error_info(NULL, 691 &response, 723 wbc_status = wbc_create_error_info(&response, 692 724 error); 693 725 BAIL_ON_WBC_ERROR(wbc_status); … … 758 790 if (!params->account_name) { 759 791 wbc_status = WBC_ERR_INVALID_PARAM; 760 BAIL_ON_WBC_ERROR(wbc_status);792 goto done; 761 793 } 762 794 … … 782 814 if (!params->account_name) { 783 815 wbc_status = WBC_ERR_INVALID_PARAM; 784 BAIL_ON_WBC_ERROR(wbc_status);816 goto done; 785 817 } 786 818 … … 806 838 if (!params->account_name || !params->domain_name) { 807 839 wbc_status = WBC_ERR_INVALID_PARAM; 808 BAIL_ON_WBC_ERROR(wbc_status);840 goto done; 809 841 } 810 842 … … 812 844 !params->old_password.response.old_lm_hash_enc_data) { 813 845 wbc_status = WBC_ERR_INVALID_PARAM; 814 BAIL_ON_WBC_ERROR(wbc_status);846 goto done; 815 847 } 816 848 … … 818 850 params->old_password.response.old_lm_hash_enc_data) { 819 851 wbc_status = WBC_ERR_INVALID_PARAM; 820 BAIL_ON_WBC_ERROR(wbc_status);852 goto done; 821 853 } 822 854 … … 824 856 !params->old_password.response.old_nt_hash_enc_data) { 825 857 wbc_status = WBC_ERR_INVALID_PARAM; 826 BAIL_ON_WBC_ERROR(wbc_status);858 goto done; 827 859 } 828 860 … … 830 862 params->old_password.response.old_nt_hash_enc_data) { 831 863 wbc_status = WBC_ERR_INVALID_PARAM; 832 BAIL_ON_WBC_ERROR(wbc_status);864 goto done; 833 865 } 834 866 … … 836 868 !params->new_password.response.lm_data) { 837 869 wbc_status = WBC_ERR_INVALID_PARAM; 838 BAIL_ON_WBC_ERROR(wbc_status);870 goto done; 839 871 } 840 872 … … 842 874 params->new_password.response.lm_data) { 843 875 wbc_status = WBC_ERR_INVALID_PARAM; 844 BAIL_ON_WBC_ERROR(wbc_status);876 goto done; 845 877 } 846 878 … … 848 880 !params->new_password.response.nt_data) { 849 881 wbc_status = WBC_ERR_INVALID_PARAM; 850 BAIL_ON_WBC_ERROR(wbc_status);882 goto done; 851 883 } 852 884 … … 854 886 params->new_password.response.nt_data) { 855 887 wbc_status = WBC_ERR_INVALID_PARAM; 856 BAIL_ON_WBC_ERROR(wbc_status);888 goto done; 857 889 } 858 890 … … 900 932 default: 901 933 wbc_status = WBC_ERR_INVALID_PARAM; 902 BAIL_ON_WBC_ERROR(wbc_status);934 goto done; 903 935 break; 904 936 } … … 917 949 if (response.data.auth.nt_status != 0) { 918 950 if (error) { 919 wbc_status = wbc_create_error_info(NULL, 920 &response, 951 wbc_status = wbc_create_error_info(&response, 921 952 error); 922 953 BAIL_ON_WBC_ERROR(wbc_status); … … 926 957 927 958 if (policy) { 928 wbc_status = wbc_create_password_policy_info(NULL, 929 &response, 959 wbc_status = wbc_create_password_policy_info(&response, 930 960 policy); 931 961 BAIL_ON_WBC_ERROR(wbc_status); … … 975 1005 { 976 1006 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 977 int cmd = 0;978 1007 struct winbindd_request request; 979 1008 struct winbindd_response response; … … 1014 1043 /* Initialize request */ 1015 1044 1016 cmd = WINBINDD_PAM_AUTH;1017 1045 request.flags = WBFLAG_PAM_INFO3_TEXT | 1018 1046 WBFLAG_PAM_USER_SESSION_KEY | … … 1076 1104 } 1077 1105 1078 wbc_status = wbcRequestResponse( cmd,1106 wbc_status = wbcRequestResponse(WINBINDD_PAM_AUTH, 1079 1107 &request, 1080 1108 &response); … … 1082 1110 if (response.data.auth.nt_status != 0) { 1083 1111 if (error) { 1084 wbc_status = wbc_create_error_info(NULL, 1085 &response, 1112 wbc_status = wbc_create_error_info(&response, 1086 1113 error); 1087 1114 BAIL_ON_WBC_ERROR(wbc_status); … … 1094 1121 1095 1122 if (info) { 1096 wbc_status = wbc_create_logon_info(NULL, 1097 &response, 1123 wbc_status = wbc_create_logon_info(&response, 1098 1124 info); 1099 1125 BAIL_ON_WBC_ERROR(wbc_status); … … 1101 1127 1102 1128 if (policy) { 1103 wbc_status = wbc_create_password_policy_info(NULL, 1104 &response, 1129 wbc_status = wbc_create_password_policy_info(&response, 1105 1130 policy); 1106 1131 BAIL_ON_WBC_ERROR(wbc_status); … … 1108 1133 1109 1134 done: 1110 if (response.extra_data.data) 1111 free(response.extra_data.data); 1112 1113 return wbc_status; 1135 winbindd_free_response(&response); 1136 1137 return wbc_status; 1138 } 1139 1140 static void wbcCredentialCacheInfoDestructor(void *ptr) 1141 { 1142 struct wbcCredentialCacheInfo *i = 1143 (struct wbcCredentialCacheInfo *)ptr; 1144 wbcFreeMemory(i->blobs); 1114 1145 } 1115 1146 … … 1187 1218 1188 1219 if (request.extra_len != 0) { 1189 request.extra_data.data = talloc_array( 1190 NULL, char, request.extra_len); 1220 request.extra_data.data = (char *)malloc(request.extra_len); 1191 1221 if (request.extra_data.data == NULL) { 1192 1222 status = WBC_ERR_NO_MEMORY; … … 1211 1241 } 1212 1242 1213 result = talloc(NULL, struct wbcCredentialCacheInfo); 1243 result = (struct wbcCredentialCacheInfo *)wbcAllocateMemory( 1244 1, sizeof(struct wbcCredentialCacheInfo), 1245 wbcCredentialCacheInfoDestructor); 1214 1246 if (result == NULL) { 1215 1247 status = WBC_ERR_NO_MEMORY; … … 1217 1249 } 1218 1250 result->num_blobs = 0; 1219 result->blobs = talloc(result, struct wbcNamedBlob); 1220 if (result->blobs == NULL) { 1221 status = WBC_ERR_NO_MEMORY; 1222 goto fail; 1223 } 1251 result->blobs = NULL; 1224 1252 status = wbcAddNamedBlob(&result->num_blobs, &result->blobs, 1225 1253 "auth_blob", 0, … … 1237 1265 } 1238 1266 1239 if (response.extra_data.data)1240 free(response.extra_data.data);1241 1267 *info = result; 1242 re turn WBC_ERR_SUCCESS;1243 1268 result = NULL; 1269 status = WBC_ERR_SUCCESS; 1244 1270 fail: 1245 TALLOC_FREE(request.extra_data.data); 1246 if (response.extra_data.data) 1247 free(response.extra_data.data); 1248 talloc_free(result); 1271 free(request.extra_data.data); 1272 winbindd_free_response(&response); 1273 wbcFreeMemory(result); 1249 1274 return status; 1250 1275 } -
trunk/server/nsswitch/libwbclient/wbc_pwd.c
r414 r745 25 25 #include "replace.h" 26 26 #include "libwbclient.h" 27 #include "../winbind_client.h" 27 28 28 29 /** @brief The maximum number of pwent structs to get from winbindd … … 40 41 **/ 41 42 43 static void wbcPasswdDestructor(void *ptr) 44 { 45 struct passwd *pw = (struct passwd *)ptr; 46 free(pw->pw_name); 47 free(pw->pw_passwd); 48 free(pw->pw_gecos); 49 free(pw->pw_shell); 50 free(pw->pw_dir); 51 } 52 42 53 static struct passwd *copy_passwd_entry(struct winbindd_pw *p) 43 54 { 44 struct passwd *pwd = NULL; 45 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 46 47 pwd = talloc(NULL, struct passwd); 48 BAIL_ON_PTR_ERROR(pwd, wbc_status); 49 50 pwd->pw_name = talloc_strdup(pwd,p->pw_name); 51 BAIL_ON_PTR_ERROR(pwd->pw_name, wbc_status); 52 53 pwd->pw_passwd = talloc_strdup(pwd, p->pw_passwd); 54 BAIL_ON_PTR_ERROR(pwd->pw_passwd, wbc_status); 55 56 pwd->pw_gecos = talloc_strdup(pwd, p->pw_gecos); 57 BAIL_ON_PTR_ERROR(pwd->pw_gecos, wbc_status); 58 59 pwd->pw_shell = talloc_strdup(pwd, p->pw_shell); 60 BAIL_ON_PTR_ERROR(pwd->pw_shell, wbc_status); 61 62 pwd->pw_dir = talloc_strdup(pwd, p->pw_dir); 63 BAIL_ON_PTR_ERROR(pwd->pw_dir, wbc_status); 64 65 pwd->pw_uid = p->pw_uid; 66 pwd->pw_gid = p->pw_gid; 67 68 done: 69 if (!WBC_ERROR_IS_OK(wbc_status)) { 70 talloc_free(pwd); 71 pwd = NULL; 72 } 73 74 return pwd; 55 struct passwd *pw = NULL; 56 57 pw = (struct passwd *)wbcAllocateMemory(1, sizeof(struct passwd), 58 wbcPasswdDestructor); 59 if (pw == NULL) { 60 return NULL; 61 } 62 pw->pw_name = strdup(p->pw_name); 63 if (pw->pw_name == NULL) { 64 goto fail; 65 } 66 pw->pw_passwd = strdup(p->pw_passwd); 67 if (pw->pw_passwd == NULL) { 68 goto fail; 69 } 70 pw->pw_gecos = strdup(p->pw_gecos); 71 if (pw->pw_gecos == NULL) { 72 goto fail; 73 } 74 pw->pw_shell = strdup(p->pw_shell); 75 if (pw->pw_shell == NULL) { 76 goto fail; 77 } 78 pw->pw_dir = strdup(p->pw_dir); 79 if (pw->pw_dir == NULL) { 80 goto fail; 81 } 82 pw->pw_uid = p->pw_uid; 83 pw->pw_gid = p->pw_gid; 84 return pw; 85 86 fail: 87 wbcFreeMemory(pw); 88 return NULL; 75 89 } 76 90 … … 78 92 * 79 93 **/ 94 95 static void wbcGroupDestructor(void *ptr) 96 { 97 struct group *gr = (struct group *)ptr; 98 int i; 99 100 free(gr->gr_name); 101 free(gr->gr_passwd); 102 103 /* if the array was partly created this can be NULL */ 104 if (gr->gr_mem == NULL) { 105 return; 106 } 107 108 for (i=0; gr->gr_mem[i] != NULL; i++) { 109 free(gr->gr_mem[i]); 110 } 111 free(gr->gr_mem); 112 } 80 113 81 114 static struct group *copy_group_entry(struct winbindd_gr *g, 82 115 char *mem_buf) 83 116 { 84 struct group *grp = NULL; 85 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 117 struct group *gr = NULL; 86 118 int i; 87 119 char *mem_p, *mem_q; 88 120 89 grp = talloc(NULL, struct group); 90 BAIL_ON_PTR_ERROR(grp, wbc_status); 91 92 grp->gr_name = talloc_strdup(grp, g->gr_name); 93 BAIL_ON_PTR_ERROR(grp->gr_name, wbc_status); 94 95 grp->gr_passwd = talloc_strdup(grp, g->gr_passwd); 96 BAIL_ON_PTR_ERROR(grp->gr_passwd, wbc_status); 97 98 grp->gr_gid = g->gr_gid; 99 100 grp->gr_mem = talloc_array(grp, char*, g->num_gr_mem+1); 121 gr = (struct group *)wbcAllocateMemory( 122 1, sizeof(struct group), wbcGroupDestructor); 123 if (gr == NULL) { 124 return NULL; 125 } 126 127 gr->gr_name = strdup(g->gr_name); 128 if (gr->gr_name == NULL) { 129 goto fail; 130 } 131 gr->gr_passwd = strdup(g->gr_passwd); 132 if (gr->gr_passwd == NULL) { 133 goto fail; 134 } 135 gr->gr_gid = g->gr_gid; 136 137 gr->gr_mem = (char **)calloc(g->num_gr_mem+1, sizeof(char *)); 138 if (gr->gr_mem == NULL) { 139 goto fail; 140 } 101 141 102 142 mem_p = mem_q = mem_buf; 103 143 for (i=0; i<g->num_gr_mem && mem_p; i++) { 104 if ((mem_q = strchr(mem_p, ',')) != NULL) { 144 mem_q = strchr(mem_p, ','); 145 if (mem_q != NULL) { 105 146 *mem_q = '\0'; 106 147 } 107 148 108 grp->gr_mem[i] = talloc_strdup(grp, mem_p); 109 BAIL_ON_PTR_ERROR(grp->gr_mem[i], wbc_status); 149 gr->gr_mem[i] = strdup(mem_p); 150 if (gr->gr_mem[i] == NULL) { 151 goto fail; 152 } 110 153 111 154 if (mem_q == NULL) { … … 115 158 mem_p = mem_q + 1; 116 159 } 117 grp->gr_mem[i] = NULL; 118 119 wbc_status = WBC_ERR_SUCCESS; 120 121 done: 122 if (!WBC_ERROR_IS_OK(wbc_status)) { 123 talloc_free(grp); 124 grp = NULL; 125 } 126 127 return grp; 160 gr->gr_mem[i] = NULL; 161 162 return gr; 163 164 fail: 165 wbcFreeMemory(gr); 166 return NULL; 128 167 } 129 168 … … 198 237 struct winbindd_request request; 199 238 struct winbindd_response response; 200 char * sid_string = NULL;201 239 202 240 if (!pwd) { … … 205 243 } 206 244 207 wbc_status = wbcSidToString(sid, &sid_string);208 BAIL_ON_WBC_ERROR(wbc_status);209 210 245 /* Initialize request */ 211 246 … … 213 248 ZERO_STRUCT(response); 214 249 215 strncpy(request.data.sid, sid_string, sizeof(request.data.sid));250 wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid)); 216 251 217 252 wbc_status = wbcRequestResponse(WINBINDD_GETPWSID, … … 224 259 225 260 done: 226 if (sid_string) {227 wbcFreeMemory(sid_string);228 }229 230 261 return wbc_status; 231 262 } … … 262 293 263 294 done: 264 if (response.extra_data.data) 265 free(response.extra_data.data); 295 winbindd_free_response(&response); 266 296 267 297 return wbc_status; … … 297 327 298 328 done: 299 if (response.extra_data.data) 300 free(response.extra_data.data); 329 winbindd_free_response(&response); 301 330 302 331 return wbc_status; … … 325 354 if (pw_cache_size > 0) { 326 355 pw_cache_idx = pw_cache_size = 0; 327 if (pw_response.extra_data.data) { 328 free(pw_response.extra_data.data); 329 } 356 winbindd_free_response(&pw_response); 330 357 } 331 358 … … 347 374 if (pw_cache_size > 0) { 348 375 pw_cache_idx = pw_cache_size = 0; 349 if (pw_response.extra_data.data) { 350 free(pw_response.extra_data.data); 351 } 376 winbindd_free_response(&pw_response); 352 377 } 353 378 … … 376 401 pw_cache_idx = 0; 377 402 378 if (pw_response.extra_data.data) { 379 free(pw_response.extra_data.data); 380 ZERO_STRUCT(pw_response); 381 } 403 winbindd_free_response(&pw_response); 382 404 383 405 ZERO_STRUCT(request); … … 427 449 if (gr_cache_size > 0) { 428 450 gr_cache_idx = gr_cache_size = 0; 429 if (gr_response.extra_data.data) { 430 free(gr_response.extra_data.data); 431 } 451 winbindd_free_response(&gr_response); 432 452 } 433 453 … … 449 469 if (gr_cache_size > 0) { 450 470 gr_cache_idx = gr_cache_size = 0; 451 if (gr_response.extra_data.data) { 452 free(gr_response.extra_data.data); 453 } 471 winbindd_free_response(&gr_response); 454 472 } 455 473 … … 479 497 gr_cache_idx = 0; 480 498 481 if (gr_response.extra_data.data) { 482 free(gr_response.extra_data.data); 483 ZERO_STRUCT(gr_response); 484 } 499 winbindd_free_response(&gr_response); 485 500 486 501 ZERO_STRUCT(request); … … 528 543 gr_cache_idx = 0; 529 544 530 if (gr_response.extra_data.data) { 531 free(gr_response.extra_data.data); 532 ZERO_STRUCT(gr_response); 533 } 545 winbindd_free_response(&gr_response); 546 ZERO_STRUCT(gr_response); 534 547 535 548 ZERO_STRUCT(request); … … 587 600 BAIL_ON_WBC_ERROR(wbc_status); 588 601 589 groups = talloc_array(NULL, gid_t, response.data.num_entries); 602 groups = (gid_t *)wbcAllocateMemory( 603 response.data.num_entries, sizeof(gid_t), NULL); 590 604 BAIL_ON_PTR_ERROR(groups, wbc_status); 591 605 … … 601 615 602 616 done: 603 if (response.extra_data.data) { 604 free(response.extra_data.data); 605 } 606 if (groups) { 607 talloc_free(groups); 608 } 609 610 return wbc_status; 611 } 617 winbindd_free_response(&response); 618 wbcFreeMemory(groups); 619 return wbc_status; 620 } -
trunk/server/nsswitch/libwbclient/wbc_sid.c
r414 r745 5 5 6 6 Copyright (C) Gerald (Jerry) Carter 2007 7 Copyright (C) Volker Lendecke 2010 7 8 8 9 … … 25 26 #include "replace.h" 26 27 #include "libwbclient.h" 27 28 29 /* Convert a binary SID to a character string */30 wbcErr wbcSidToString(const struct wbcDomainSid *sid, 31 char **sid_string) 32 { 33 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 28 #include "../winbind_client.h" 29 30 /* Convert a sid to a string into a buffer. Return the string 31 * length. If buflen is too small, return the string length that would 32 * result if it was long enough. */ 33 int wbcSidToStringBuf(const struct wbcDomainSid *sid, char *buf, int buflen) 34 { 34 35 uint32_t id_auth; 35 int i; 36 char *tmp = NULL; 36 int i, ofs; 37 37 38 38 if (!sid) { 39 wbc_status = WBC_ERR_INVALID_SID; 40 BAIL_ON_WBC_ERROR(wbc_status); 41 } 39 strlcpy(buf, "(NULL SID)", buflen); 40 return 10; /* strlen("(NULL SID)") */ 41 } 42 43 /* 44 * BIG NOTE: this function only does SIDS where the identauth is not 45 * >= ^32 in a range of 2^48. 46 */ 42 47 43 48 id_auth = sid->id_auth[5] + … … 46 51 (sid->id_auth[2] << 24); 47 52 48 tmp = talloc_asprintf(NULL, "S-%d-%d", sid->sid_rev_num, id_auth); 49 BAIL_ON_PTR_ERROR(tmp, wbc_status); 50 51 for (i=0; i<sid->num_auths; i++) { 52 char *tmp2; 53 tmp2 = talloc_asprintf_append(tmp, "-%u", sid->sub_auths[i]); 54 BAIL_ON_PTR_ERROR(tmp2, wbc_status); 55 56 tmp = tmp2; 57 } 58 59 *sid_string = tmp; 60 tmp = NULL; 61 62 wbc_status = WBC_ERR_SUCCESS; 63 64 done: 65 talloc_free(tmp); 66 67 return wbc_status; 53 ofs = snprintf(buf, buflen, "S-%u-%lu", 54 (unsigned int)sid->sid_rev_num, (unsigned long)id_auth); 55 56 for (i = 0; i < sid->num_auths; i++) { 57 ofs += snprintf(buf + ofs, MAX(buflen - ofs, 0), "-%lu", 58 (unsigned long)sid->sub_auths[i]); 59 } 60 return ofs; 61 } 62 63 /* Convert a binary SID to a character string */ 64 wbcErr wbcSidToString(const struct wbcDomainSid *sid, 65 char **sid_string) 66 { 67 char buf[WBC_SID_STRING_BUFLEN]; 68 char *result; 69 int len; 70 71 if (!sid) { 72 return WBC_ERR_INVALID_SID; 73 } 74 75 len = wbcSidToStringBuf(sid, buf, sizeof(buf)); 76 77 if (len+1 > sizeof(buf)) { 78 return WBC_ERR_INVALID_SID; 79 } 80 81 result = (char *)wbcAllocateMemory(len+1, 1, NULL); 82 if (result == NULL) { 83 return WBC_ERR_NO_MEMORY; 84 } 85 memcpy(result, buf, len+1); 86 87 *sid_string = result; 88 return WBC_ERR_SUCCESS; 68 89 } 69 90 … … 132 153 sid->sub_auths[sid->num_auths++] = x; 133 154 134 if ( (*q!='-') || (*q=='\0'))155 if (*q != '-') { 135 156 break; 157 } 136 158 p = q + 1; 137 159 } … … 150 172 151 173 } 174 152 175 153 176 /* Convert a domain and name to SID */ … … 194 217 } 195 218 219 196 220 /* Convert a SID to a domain and name */ 197 221 wbcErr wbcLookupSid(const struct wbcDomainSid *sid, … … 203 227 struct winbindd_response response; 204 228 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 205 char *sid_string = NULL; 206 char *domain = NULL; 207 char *name = NULL; 208 enum wbcSidType name_type = WBC_SID_NAME_USE_NONE; 229 char *domain, *name; 209 230 210 231 if (!sid) { 211 wbc_status = WBC_ERR_INVALID_PARAM; 212 BAIL_ON_WBC_ERROR(wbc_status); 232 return WBC_ERR_INVALID_PARAM; 213 233 } 214 234 … … 218 238 ZERO_STRUCT(response); 219 239 220 /* dst is already null terminated from the memset above */ 221 222 wbc_status = wbcSidToString(sid, &sid_string); 223 BAIL_ON_WBC_ERROR(wbc_status); 224 225 strncpy(request.data.sid, sid_string, sizeof(request.data.sid)-1); 226 wbcFreeMemory(sid_string); 240 wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid)); 227 241 228 242 /* Make request */ 229 243 230 wbc_status = wbcRequestResponse(WINBINDD_LOOKUPSID, 231 &request, 232 &response); 233 BAIL_ON_WBC_ERROR(wbc_status); 244 wbc_status = wbcRequestResponse(WINBINDD_LOOKUPSID, &request, 245 &response); 246 if (!WBC_ERROR_IS_OK(wbc_status)) { 247 return wbc_status; 248 } 234 249 235 250 /* Copy out result */ 236 251 237 domain = talloc_strdup(NULL, response.data.name.dom_name); 238 BAIL_ON_PTR_ERROR(domain, wbc_status); 239 240 name = talloc_strdup(NULL, response.data.name.name); 241 BAIL_ON_PTR_ERROR(name, wbc_status); 242 243 name_type = (enum wbcSidType)response.data.name.type; 244 252 wbc_status = WBC_ERR_NO_MEMORY; 253 domain = NULL; 254 name = NULL; 255 256 domain = wbcStrDup(response.data.name.dom_name); 257 if (domain == NULL) { 258 goto done; 259 } 260 name = wbcStrDup(response.data.name.name); 261 if (name == NULL) { 262 goto done; 263 } 264 if (pdomain != NULL) { 265 *pdomain = domain; 266 domain = NULL; 267 } 268 if (pname != NULL) { 269 *pname = name; 270 name = NULL; 271 } 272 if (pname_type != NULL) { 273 *pname_type = (enum wbcSidType)response.data.name.type; 274 } 245 275 wbc_status = WBC_ERR_SUCCESS; 246 247 done: 248 if (WBC_ERROR_IS_OK(wbc_status)) { 249 if (pdomain != NULL) { 250 *pdomain = domain; 251 } else { 252 TALLOC_FREE(domain); 253 } 254 if (pname != NULL) { 255 *pname = name; 256 } else { 257 TALLOC_FREE(name); 258 } 259 if (pname_type != NULL) { 260 *pname_type = name_type; 261 } 262 } 263 else { 264 #if 0 265 /* 266 * Found by Coverity: In this particular routine we can't end 267 * up here with a non-NULL name. Further up there are just two 268 * exit paths that lead here, neither of which leave an 269 * allocated name. If you add more paths up there, re-activate 270 * this. 271 */ 272 if (name != NULL) { 273 talloc_free(name); 274 } 275 #endif 276 if (domain != NULL) { 277 talloc_free(domain); 278 } 279 } 280 276 done: 277 wbcFreeMemory(name); 278 wbcFreeMemory(domain); 279 return wbc_status; 280 } 281 282 static void wbcDomainInfosDestructor(void *ptr) 283 { 284 struct wbcDomainInfo *i = (struct wbcDomainInfo *)ptr; 285 286 while (i->short_name != NULL) { 287 wbcFreeMemory(i->short_name); 288 wbcFreeMemory(i->dns_name); 289 i += 1; 290 } 291 } 292 293 static void wbcTranslatedNamesDestructor(void *ptr) 294 { 295 struct wbcTranslatedName *n = (struct wbcTranslatedName *)ptr; 296 297 while (n->name != NULL) { 298 free(n->name); 299 n += 1; 300 } 301 } 302 303 wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids, 304 struct wbcDomainInfo **pdomains, int *pnum_domains, 305 struct wbcTranslatedName **pnames) 306 { 307 struct winbindd_request request; 308 struct winbindd_response response; 309 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 310 int buflen, i, extra_len, num_domains, num_names; 311 char *sidlist, *p, *q, *extra_data; 312 struct wbcDomainInfo *domains = NULL; 313 struct wbcTranslatedName *names = NULL; 314 315 buflen = num_sids * (WBC_SID_STRING_BUFLEN + 1) + 1; 316 317 sidlist = (char *)malloc(buflen); 318 if (sidlist == NULL) { 319 return WBC_ERR_NO_MEMORY; 320 } 321 322 p = sidlist; 323 324 for (i=0; i<num_sids; i++) { 325 int remaining; 326 int len; 327 328 remaining = buflen - (p - sidlist); 329 330 len = wbcSidToStringBuf(&sids[i], p, remaining); 331 if (len > remaining) { 332 free(sidlist); 333 return WBC_ERR_UNKNOWN_FAILURE; 334 } 335 336 p += len; 337 *p++ = '\n'; 338 } 339 *p++ = '\0'; 340 341 ZERO_STRUCT(request); 342 ZERO_STRUCT(response); 343 344 request.extra_data.data = sidlist; 345 request.extra_len = p - sidlist; 346 347 wbc_status = wbcRequestResponse(WINBINDD_LOOKUPSIDS, 348 &request, &response); 349 free(sidlist); 350 if (!WBC_ERROR_IS_OK(wbc_status)) { 351 return wbc_status; 352 } 353 354 extra_len = response.length - sizeof(struct winbindd_response); 355 extra_data = (char *)response.extra_data.data; 356 357 if ((extra_len <= 0) || (extra_data[extra_len-1] != '\0')) { 358 goto wbc_err_invalid; 359 } 360 361 p = extra_data; 362 363 num_domains = strtoul(p, &q, 10); 364 if (*q != '\n') { 365 goto wbc_err_invalid; 366 } 367 p = q+1; 368 369 domains = (struct wbcDomainInfo *)wbcAllocateMemory( 370 num_domains+1, sizeof(struct wbcDomainInfo), 371 wbcDomainInfosDestructor); 372 if (domains == NULL) { 373 wbc_status = WBC_ERR_NO_MEMORY; 374 goto fail; 375 } 376 377 for (i=0; i<num_domains; i++) { 378 379 q = strchr(p, ' '); 380 if (q == NULL) { 381 goto wbc_err_invalid; 382 } 383 *q = '\0'; 384 wbc_status = wbcStringToSid(p, &domains[i].sid); 385 if (!WBC_ERROR_IS_OK(wbc_status)) { 386 goto fail; 387 } 388 p = q+1; 389 390 q = strchr(p, '\n'); 391 if (q == NULL) { 392 goto wbc_err_invalid; 393 } 394 *q = '\0'; 395 domains[i].short_name = wbcStrDup(p); 396 if (domains[i].short_name == NULL) { 397 wbc_status = WBC_ERR_NO_MEMORY; 398 goto fail; 399 } 400 p = q+1; 401 } 402 403 num_names = strtoul(p, &q, 10); 404 if (*q != '\n') { 405 goto wbc_err_invalid; 406 } 407 p = q+1; 408 409 if (num_names != num_sids) { 410 goto wbc_err_invalid; 411 } 412 413 names = (struct wbcTranslatedName *)wbcAllocateMemory( 414 num_names+1, sizeof(struct wbcTranslatedName), 415 wbcTranslatedNamesDestructor); 416 if (names == NULL) { 417 wbc_status = WBC_ERR_NO_MEMORY; 418 goto fail; 419 } 420 421 for (i=0; i<num_names; i++) { 422 423 names[i].domain_index = strtoul(p, &q, 10); 424 if (*q != ' ') { 425 goto wbc_err_invalid; 426 } 427 p = q+1; 428 429 names[i].type = strtoul(p, &q, 10); 430 if (*q != ' ') { 431 goto wbc_err_invalid; 432 } 433 p = q+1; 434 435 q = strchr(p, '\n'); 436 if (q == NULL) { 437 goto wbc_err_invalid; 438 } 439 *q = '\0'; 440 names[i].name = wbcStrDup(p); 441 if (names[i].name == NULL) { 442 wbc_status = WBC_ERR_NO_MEMORY; 443 goto fail; 444 } 445 p = q+1; 446 } 447 if (*p != '\0') { 448 goto wbc_err_invalid; 449 } 450 451 *pdomains = domains; 452 *pnames = names; 453 winbindd_free_response(&response); 454 return WBC_ERR_SUCCESS; 455 456 wbc_err_invalid: 457 wbc_status = WBC_ERR_INVALID_RESPONSE; 458 fail: 459 winbindd_free_response(&response); 460 wbcFreeMemory(domains); 461 wbcFreeMemory(names); 281 462 return wbc_status; 282 463 } … … 296 477 struct winbindd_request request; 297 478 struct winbindd_response response; 298 char *sid_string = NULL;299 479 char *domain_name = NULL; 300 480 const char **names = NULL; … … 312 492 } 313 493 314 wbc_status = wbcSidToString(dom_sid, &sid_string); 315 BAIL_ON_WBC_ERROR(wbc_status); 316 317 strncpy(request.data.sid, sid_string, sizeof(request.data.sid)-1); 318 wbcFreeMemory(sid_string); 494 wbcSidToStringBuf(dom_sid, request.data.sid, sizeof(request.data.sid)); 319 495 320 496 /* Even if all the Rids were of maximum 32bit values, … … 325 501 ridbuf_size = (sizeof(char)*11) * num_rids + 1; 326 502 327 ridlist = talloc_zero_array(NULL, char,ridbuf_size);503 ridlist = (char *)malloc(ridbuf_size); 328 504 BAIL_ON_PTR_ERROR(ridlist, wbc_status); 329 505 330 506 len = 0; 331 for (i=0; i<num_rids && (len-1)>0; i++) { 332 char ridstr[12]; 333 334 len = strlen(ridlist); 335 p = ridlist + len; 336 337 snprintf( ridstr, sizeof(ridstr)-1, "%u\n", rids[i]); 338 strncat(p, ridstr, ridbuf_size-len-1); 339 } 507 for (i=0; i<num_rids; i++) { 508 len += snprintf(ridlist + len, ridbuf_size - len, "%u\n", 509 rids[i]); 510 } 511 ridlist[len] = '\0'; 512 len += 1; 340 513 341 514 request.extra_data.data = ridlist; 342 request.extra_len = strlen(ridlist)+1;515 request.extra_len = len; 343 516 344 517 wbc_status = wbcRequestResponse(WINBINDD_LOOKUPRIDS, 345 518 &request, 346 519 &response); 347 talloc_free(ridlist);520 free(ridlist); 348 521 BAIL_ON_WBC_ERROR(wbc_status); 349 522 350 domain_name = talloc_strdup(NULL,response.data.domain_name);523 domain_name = wbcStrDup(response.data.domain_name); 351 524 BAIL_ON_PTR_ERROR(domain_name, wbc_status); 352 525 353 names = talloc_array(NULL, const char*,num_rids);526 names = wbcAllocateStringArray(num_rids); 354 527 BAIL_ON_PTR_ERROR(names, wbc_status); 355 528 356 types = talloc_array(NULL, enum wbcSidType, num_rids); 529 types = (enum wbcSidType *)wbcAllocateMemory( 530 num_rids, sizeof(enum wbcSidType), NULL); 357 531 BAIL_ON_PTR_ERROR(types, wbc_status); 358 532 … … 364 538 if (*p == '\0') { 365 539 wbc_status = WBC_ERR_INVALID_RESPONSE; 366 BAIL_ON_WBC_ERROR(wbc_status);540 goto done; 367 541 } 368 542 … … 371 545 if (*q != ' ') { 372 546 wbc_status = WBC_ERR_INVALID_RESPONSE; 373 BAIL_ON_WBC_ERROR(wbc_status);547 goto done; 374 548 } 375 549 … … 378 552 if ((q = strchr(p, '\n')) == NULL) { 379 553 wbc_status = WBC_ERR_INVALID_RESPONSE; 380 BAIL_ON_WBC_ERROR(wbc_status);554 goto done; 381 555 } 382 556 383 557 *q = '\0'; 384 558 385 names[i] = talloc_strdup(names,p);559 names[i] = strdup(p); 386 560 BAIL_ON_PTR_ERROR(names[i], wbc_status); 387 561 … … 391 565 if (*p != '\0') { 392 566 wbc_status = WBC_ERR_INVALID_RESPONSE; 393 BAIL_ON_WBC_ERROR(wbc_status);567 goto done; 394 568 } 395 569 … … 397 571 398 572 done: 399 if (response.extra_data.data) { 400 free(response.extra_data.data); 401 } 573 winbindd_free_response(&response); 402 574 403 575 if (WBC_ERROR_IS_OK(wbc_status)) { … … 407 579 } 408 580 else { 409 if (domain_name) 410 talloc_free(domain_name); 411 if (names) 412 talloc_free(names); 413 if (types) 414 talloc_free(types); 581 wbcFreeMemory(domain_name); 582 wbcFreeMemory(names); 583 wbcFreeMemory(types); 415 584 } 416 585 … … 428 597 struct winbindd_request request; 429 598 struct winbindd_response response; 430 char *sid_string = NULL;431 599 struct wbcDomainSid *sids = NULL; 432 600 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 443 611 } 444 612 445 wbc_status = wbcSidToString(user_sid, &sid_string); 446 BAIL_ON_WBC_ERROR(wbc_status); 447 448 strncpy(request.data.sid, sid_string, sizeof(request.data.sid)-1); 449 wbcFreeMemory(sid_string); 613 wbcSidToStringBuf(user_sid, request.data.sid, sizeof(request.data.sid)); 450 614 451 615 if (domain_groups_only) { … … 466 630 } 467 631 468 sids = talloc_array(NULL, struct wbcDomainSid, 469 response.data.num_entries); 632 sids = (struct wbcDomainSid *)wbcAllocateMemory( 633 response.data.num_entries, sizeof(struct wbcDomainSid), 634 NULL); 470 635 BAIL_ON_PTR_ERROR(sids, wbc_status); 471 636 … … 487 652 488 653 done: 489 if (response.extra_data.data) { 490 free(response.extra_data.data); 491 } 654 winbindd_free_response(&response); 492 655 if (sids) { 493 talloc_free(sids);656 wbcFreeMemory(sids); 494 657 } 495 658 … … 519 682 struct winbindd_request request; 520 683 struct winbindd_response response; 521 char *sid_string = NULL;522 ssize_t sid_len;523 684 ssize_t extra_data_len = 0; 524 685 char * extra_data = NULL; … … 535 696 if (!dom_sid) { 536 697 wbc_status = WBC_ERR_INVALID_PARAM; 537 BAIL_ON_WBC_ERROR(wbc_status); 538 } 539 540 wbc_status = wbcSidToString(dom_sid, &sid_string); 541 BAIL_ON_WBC_ERROR(wbc_status); 542 543 strncpy(request.data.sid, sid_string, sizeof(request.data.sid)-1); 544 wbcFreeMemory(sid_string); 545 sid_string = NULL; 546 547 /* Lets assume each sid is around 54 characters 548 * S-1-5-AAAAAAAAAAA-BBBBBBBBBBB-CCCCCCCCCCC-DDDDDDDDDDD\n */ 549 buflen = 54 * num_sids; 550 extra_data = talloc_array(NULL, char, buflen); 698 goto done; 699 } 700 701 wbcSidToStringBuf(dom_sid, request.data.sid, sizeof(request.data.sid)); 702 703 /* Lets assume each sid is around 57 characters 704 * S-1-5-21-AAAAAAAAAAA-BBBBBBBBBBB-CCCCCCCCCCC-DDDDDDDDDDD\n */ 705 buflen = 57 * num_sids; 706 extra_data = (char *)malloc(buflen); 551 707 if (!extra_data) { 552 708 wbc_status = WBC_ERR_NO_MEMORY; 553 BAIL_ON_WBC_ERROR(wbc_status);709 goto done; 554 710 } 555 711 556 712 /* Build the sid list */ 557 713 for (i=0; i<num_sids; i++) { 558 if (sid_string) { 559 wbcFreeMemory(sid_string); 560 sid_string = NULL; 561 } 562 wbc_status = wbcSidToString(&sids[i], &sid_string); 563 BAIL_ON_WBC_ERROR(wbc_status); 564 565 sid_len = strlen(sid_string); 714 char sid_str[WBC_SID_STRING_BUFLEN]; 715 size_t sid_len; 716 717 sid_len = wbcSidToStringBuf(&sids[i], sid_str, sizeof(sid_str)); 566 718 567 719 if (buflen < extra_data_len + sid_len + 2) { 568 720 buflen *= 2; 569 extra_data = talloc_realloc(NULL, extra_data, 570 char, buflen); 721 extra_data = (char *)realloc(extra_data, buflen); 571 722 if (!extra_data) { 572 723 wbc_status = WBC_ERR_NO_MEMORY; … … 575 726 } 576 727 577 strncpy(&extra_data[extra_data_len], sid_str ing,728 strncpy(&extra_data[extra_data_len], sid_str, 578 729 buflen - extra_data_len); 579 730 extra_data_len += sid_len; … … 581 732 extra_data[extra_data_len] = '\0'; 582 733 } 734 extra_data_len += 1; 583 735 584 736 request.extra_data.data = extra_data; … … 593 745 !response.extra_data.data) { 594 746 wbc_status = WBC_ERR_INVALID_RESPONSE; 595 BAIL_ON_WBC_ERROR(wbc_status);596 } 597 598 rids = talloc_array(NULL, uint32_t,599 response.data.num_entries);747 goto done; 748 } 749 750 rids = (uint32_t *)wbcAllocateMemory(response.data.num_entries, 751 sizeof(uint32_t), NULL); 600 752 BAIL_ON_PTR_ERROR(sids, wbc_status); 601 753 … … 619 771 620 772 done: 621 if (sid_string) { 622 wbcFreeMemory(sid_string); 623 } 624 if (extra_data) { 625 talloc_free(extra_data); 626 } 627 if (response.extra_data.data) { 628 free(response.extra_data.data); 629 } 630 if (rids) { 631 talloc_free(rids); 632 } 633 773 free(extra_data); 774 winbindd_free_response(&response); 775 wbcFreeMemory(rids); 634 776 return wbc_status; 635 777 } … … 663 805 BAIL_ON_WBC_ERROR(wbc_status); 664 806 807 users = wbcAllocateStringArray(response.data.num_entries); 808 if (users == NULL) { 809 return WBC_ERR_NO_MEMORY; 810 } 811 665 812 /* Look through extra data */ 666 813 667 814 next = (const char *)response.extra_data.data; 668 815 while (next) { 669 const char **tmp; 670 const char *current = next; 671 char *k = strchr(next, ','); 816 const char *current; 817 char *k; 818 819 if (num_users >= response.data.num_entries) { 820 wbc_status = WBC_ERR_INVALID_RESPONSE; 821 goto done; 822 } 823 824 current = next; 825 k = strchr(next, ','); 826 672 827 if (k) { 673 828 k[0] = '\0'; … … 677 832 } 678 833 679 tmp = talloc_realloc(NULL, users, 680 const char *, 681 num_users+1); 682 BAIL_ON_PTR_ERROR(tmp, wbc_status); 683 users = tmp; 684 685 users[num_users] = talloc_strdup(users, current); 834 users[num_users] = strdup(current); 686 835 BAIL_ON_PTR_ERROR(users[num_users], wbc_status); 687 688 num_users++; 689 } 690 691 *_num_users = num_users; 836 num_users += 1; 837 } 838 if (num_users != response.data.num_entries) { 839 wbc_status = WBC_ERR_INVALID_RESPONSE; 840 goto done; 841 } 842 843 *_num_users = response.data.num_entries; 692 844 *_users = users; 693 845 users = NULL; … … 695 847 696 848 done: 697 if (response.extra_data.data) { 698 free(response.extra_data.data); 699 } 700 if (users) { 701 talloc_free(users); 702 } 849 winbindd_free_response(&response); 850 wbcFreeMemory(users); 703 851 return wbc_status; 704 852 } … … 731 879 BAIL_ON_WBC_ERROR(wbc_status); 732 880 881 groups = wbcAllocateStringArray(response.data.num_entries); 882 if (groups == NULL) { 883 return WBC_ERR_NO_MEMORY; 884 } 885 733 886 /* Look through extra data */ 734 887 735 888 next = (const char *)response.extra_data.data; 736 889 while (next) { 737 const char **tmp; 738 const char *current = next; 739 char *k = strchr(next, ','); 890 const char *current; 891 char *k; 892 893 if (num_groups >= response.data.num_entries) { 894 wbc_status = WBC_ERR_INVALID_RESPONSE; 895 goto done; 896 } 897 898 current = next; 899 k = strchr(next, ','); 900 740 901 if (k) { 741 902 k[0] = '\0'; … … 745 906 } 746 907 747 tmp = talloc_realloc(NULL, groups, 748 const char *, 749 num_groups+1); 750 BAIL_ON_PTR_ERROR(tmp, wbc_status); 751 groups = tmp; 752 753 groups[num_groups] = talloc_strdup(groups, current); 908 groups[num_groups] = strdup(current); 754 909 BAIL_ON_PTR_ERROR(groups[num_groups], wbc_status); 755 756 num_groups++; 757 } 758 759 *_num_groups = num_groups; 910 num_groups += 1; 911 } 912 if (num_groups != response.data.num_entries) { 913 wbc_status = WBC_ERR_INVALID_RESPONSE; 914 goto done; 915 } 916 917 *_num_groups = response.data.num_entries; 760 918 *_groups = groups; 761 919 groups = NULL; … … 763 921 764 922 done: 765 if (response.extra_data.data) { 766 free(response.extra_data.data); 767 } 768 if (groups) { 769 talloc_free(groups); 770 } 923 winbindd_free_response(&response); 924 wbcFreeMemory(groups); 771 925 return wbc_status; 772 926 } … … 797 951 wbcFreeMemory(name); 798 952 799 name = talloc_strdup(NULL, pwd->pw_gecos); 953 name = wbcStrDup(pwd->pw_gecos); 954 wbcFreeMemory(pwd); 800 955 BAIL_ON_PTR_ERROR(name, wbc_status); 801 956 } -
trunk/server/nsswitch/libwbclient/wbc_util.c
r414 r745 2 2 Unix SMB/CIFS implementation. 3 3 4 Winbind client API4 Winbind client asynchronous API, utility functions 5 5 6 6 Copyright (C) Gerald (Jerry) Carter 2007-2008 … … 25 25 #include "replace.h" 26 26 #include "libwbclient.h" 27 28 27 #include "../winbind_client.h" 29 28 30 29 /** @brief Ping winbindd to see if the daemon is running … … 32 31 * @return #wbcErr 33 32 **/ 34 35 33 wbcErr wbcPing(void) 36 34 { … … 45 43 return wbcRequestResponse(WINBINDD_PING, &request, &response); 46 44 } 45 46 static void wbcInterfaceDetailsDestructor(void *ptr) 47 { 48 struct wbcInterfaceDetails *i = (struct wbcInterfaceDetails *)ptr; 49 free(i->winbind_version); 50 free(i->netbios_name); 51 free(i->netbios_domain); 52 free(i->dns_domain); 53 } 54 55 /** 56 * @brief Query useful information about the winbind service 57 * 58 * @param *_details pointer to hold the struct wbcInterfaceDetails 59 * 60 * @return #wbcErr 61 */ 47 62 48 63 wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details) … … 59 74 ZERO_STRUCT(response); 60 75 61 info = talloc(NULL, struct wbcInterfaceDetails); 76 info = (struct wbcInterfaceDetails *)wbcAllocateMemory( 77 1, sizeof(struct wbcInterfaceDetails), 78 wbcInterfaceDetailsDestructor); 62 79 BAIL_ON_PTR_ERROR(info, wbc_status); 63 80 … … 71 88 BAIL_ON_WBC_ERROR(wbc_status); 72 89 73 info->winbind_version = talloc_strdup(info, 74 response.data.info.samba_version); 90 info->winbind_version = strdup(response.data.info.samba_version); 75 91 BAIL_ON_PTR_ERROR(info->winbind_version, wbc_status); 76 92 info->winbind_separator = response.data.info.winbind_separator; … … 80 96 BAIL_ON_WBC_ERROR(wbc_status); 81 97 82 info->netbios_name = talloc_strdup(info, 83 response.data.netbios_name); 98 info->netbios_name = strdup(response.data.netbios_name); 84 99 BAIL_ON_PTR_ERROR(info->netbios_name, wbc_status); 85 100 … … 88 103 BAIL_ON_WBC_ERROR(wbc_status); 89 104 90 info->netbios_domain = talloc_strdup(info, 91 response.data.domain_name); 105 info->netbios_domain = strdup(response.data.domain_name); 92 106 BAIL_ON_PTR_ERROR(info->netbios_domain, wbc_status); 93 107 … … 102 116 103 117 if (domain) { 104 info->dns_domain = talloc_strdup(info, 105 domain->dns_name); 118 info->dns_domain = strdup(domain->dns_name); 106 119 wbcFreeMemory(domain); 107 120 BAIL_ON_PTR_ERROR(info->dns_domain, wbc_status); … … 116 129 117 130 done: 118 talloc_free(info); 119 return wbc_status; 120 } 121 122 123 /* Lookup the current status of a trusted domain */ 131 wbcFreeMemory(info); 132 return wbc_status; 133 } 134 135 static void wbcDomainInfoDestructor(void *ptr) 136 { 137 struct wbcDomainInfo *i = (struct wbcDomainInfo *)ptr; 138 free(i->short_name); 139 free(i->dns_name); 140 } 141 142 /** @brief Lookup the current status of a trusted domain, sync wrapper 143 * 144 * @param domain Domain to query 145 * @param *dinfo Pointer to returned struct wbcDomainInfo 146 * 147 * @return #wbcErr 148 */ 149 124 150 wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo) 125 151 { … … 147 173 BAIL_ON_WBC_ERROR(wbc_status); 148 174 149 info = talloc(NULL, struct wbcDomainInfo); 175 info = (struct wbcDomainInfo *)wbcAllocateMemory( 176 1, sizeof(struct wbcDomainInfo), wbcDomainInfoDestructor); 150 177 BAIL_ON_PTR_ERROR(info, wbc_status); 151 178 152 info->short_name = talloc_strdup(info, 153 response.data.domain_info.name); 179 info->short_name = strdup(response.data.domain_info.name); 154 180 BAIL_ON_PTR_ERROR(info->short_name, wbc_status); 155 181 156 info->dns_name = talloc_strdup(info, 157 response.data.domain_info.alt_name); 182 info->dns_name = strdup(response.data.domain_info.alt_name); 158 183 BAIL_ON_PTR_ERROR(info->dns_name, wbc_status); 159 184 … … 170 195 171 196 *dinfo = info; 197 info = NULL; 172 198 173 199 wbc_status = WBC_ERR_SUCCESS; 174 200 175 201 done: 176 if (!WBC_ERROR_IS_OK(wbc_status)) { 177 talloc_free(info); 178 } 179 180 return wbc_status; 181 } 182 202 wbcFreeMemory(info); 203 return wbc_status; 204 } 205 206 /* Get the list of current DCs */ 207 wbcErr wbcDcInfo(const char *domain, size_t *num_dcs, 208 const char ***dc_names, const char ***dc_ips) 209 { 210 struct winbindd_request request; 211 struct winbindd_response response; 212 const char **names = NULL; 213 const char **ips = NULL; 214 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 215 size_t extra_len; 216 int i; 217 char *p; 218 219 /* Initialise request */ 220 221 ZERO_STRUCT(request); 222 ZERO_STRUCT(response); 223 224 if (domain != NULL) { 225 strncpy(request.domain_name, domain, 226 sizeof(request.domain_name) - 1); 227 } 228 229 wbc_status = wbcRequestResponse(WINBINDD_DC_INFO, 230 &request, &response); 231 BAIL_ON_WBC_ERROR(wbc_status); 232 233 names = wbcAllocateStringArray(response.data.num_entries); 234 BAIL_ON_PTR_ERROR(names, wbc_status); 235 236 ips = wbcAllocateStringArray(response.data.num_entries); 237 BAIL_ON_PTR_ERROR(ips, wbc_status); 238 239 wbc_status = WBC_ERR_INVALID_RESPONSE; 240 241 p = (char *)response.extra_data.data; 242 243 if (response.length < (sizeof(struct winbindd_response)+1)) { 244 goto done; 245 } 246 247 extra_len = response.length - sizeof(struct winbindd_response); 248 249 if (p[extra_len-1] != '\0') { 250 goto done; 251 } 252 253 for (i=0; i<response.data.num_entries; i++) { 254 char *q; 255 256 q = strchr(p, '\n'); 257 if (q == NULL) { 258 goto done; 259 } 260 names[i] = strndup(p, q-p); 261 BAIL_ON_PTR_ERROR(names[i], wbc_status); 262 p = q+1; 263 264 q = strchr(p, '\n'); 265 if (q == NULL) { 266 goto done; 267 } 268 ips[i] = strndup(p, q-p); 269 BAIL_ON_PTR_ERROR(ips[i], wbc_status); 270 p = q+1; 271 } 272 if (p[0] != '\0') { 273 goto done; 274 } 275 276 wbc_status = WBC_ERR_SUCCESS; 277 done: 278 if (response.extra_data.data) 279 free(response.extra_data.data); 280 281 if (WBC_ERROR_IS_OK(wbc_status)) { 282 *num_dcs = response.data.num_entries; 283 *dc_names = names; 284 names = NULL; 285 *dc_ips = ips; 286 ips = NULL; 287 } 288 wbcFreeMemory(names); 289 wbcFreeMemory(ips); 290 return wbc_status; 291 } 183 292 184 293 /* Resolve a NetbiosName via WINS */ … … 205 314 /* Display response */ 206 315 207 ipaddr = talloc_strdup(NULL,response.data.winsresp);316 ipaddr = wbcStrDup(response.data.winsresp); 208 317 BAIL_ON_PTR_ERROR(ipaddr, wbc_status); 209 318 … … 238 347 /* Display response */ 239 348 240 name_str = talloc_strdup(NULL,response.data.winsresp);349 name_str = wbcStrDup(response.data.winsresp); 241 350 BAIL_ON_PTR_ERROR(name_str, wbc_status); 242 351 … … 251 360 */ 252 361 253 static wbcErr process_domain_info_string(TALLOC_CTX *ctx, 254 struct wbcDomainInfo *info, 362 static wbcErr process_domain_info_string(struct wbcDomainInfo *info, 255 363 char *info_string) 256 364 { … … 258 366 char *r = NULL; 259 367 char *s = NULL; 260 261 if (!info || !info_string) {262 wbc_status = WBC_ERR_INVALID_PARAM;263 BAIL_ON_WBC_ERROR(wbc_status);264 }265 266 ZERO_STRUCTP(info);267 368 268 369 r = info_string; … … 276 377 s++; 277 378 278 info->short_name = talloc_strdup(ctx,r);379 info->short_name = strdup(r); 279 380 BAIL_ON_PTR_ERROR(info->short_name, wbc_status); 280 381 … … 289 390 s++; 290 391 291 info->dns_name = talloc_strdup(ctx,r);392 info->dns_name = strdup(r); 292 393 BAIL_ON_PTR_ERROR(info->dns_name, wbc_status); 293 394 … … 382 483 } 383 484 485 static void wbcDomainInfoListDestructor(void *ptr) 486 { 487 struct wbcDomainInfo *i = (struct wbcDomainInfo *)ptr; 488 489 while (i->short_name != NULL) { 490 free(i->short_name); 491 free(i->dns_name); 492 i += 1; 493 } 494 } 495 384 496 /* Enumerate the domain trusts known by Winbind */ 385 497 wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains) … … 388 500 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 389 501 char *p = NULL; 390 char *q = NULL;391 502 char *extra_data = NULL; 392 int count = 0;393 503 struct wbcDomainInfo *d_list = NULL; 394 504 int i = 0; … … 418 528 } 419 529 420 /* Count number of domains */ 421 422 count = 0; 423 while (p) { 424 count++; 425 426 if ((q = strchr(p, '\n')) != NULL) 427 q++; 428 p = q; 429 } 430 431 d_list = talloc_array(NULL, struct wbcDomainInfo, count); 530 d_list = (struct wbcDomainInfo *)wbcAllocateMemory( 531 response.data.num_entries + 1,sizeof(struct wbcDomainInfo), 532 wbcDomainInfoListDestructor); 432 533 BAIL_ON_PTR_ERROR(d_list, wbc_status); 433 534 … … 439 540 /* Outer loop processes the list of domain information */ 440 541 441 for (i=0; i< count&& p; i++) {542 for (i=0; i<response.data.num_entries && p; i++) { 442 543 char *next = strchr(p, '\n'); 443 544 … … 447 548 } 448 549 449 wbc_status = process_domain_info_string( d_list,&d_list[i], p);550 wbc_status = process_domain_info_string(&d_list[i], p); 450 551 BAIL_ON_WBC_ERROR(wbc_status); 451 552 … … 454 555 455 556 *domains = d_list; 557 d_list = NULL; 456 558 *num_domains = i; 457 559 458 560 done: 459 if (!WBC_ERROR_IS_OK(wbc_status)) { 460 if (d_list) 461 talloc_free(d_list); 462 if (extra_data) 463 free(extra_data); 464 } 465 466 return wbc_status; 561 winbindd_free_response(&response); 562 wbcFreeMemory(d_list); 563 free(extra_data); 564 return wbc_status; 565 } 566 567 static void wbcDomainControllerInfoDestructor(void *ptr) 568 { 569 struct wbcDomainControllerInfo *i = 570 (struct wbcDomainControllerInfo *)ptr; 571 free(i->dc_name); 467 572 } 468 573 … … 492 597 request.flags = flags; 493 598 494 dc = talloc(NULL, struct wbcDomainControllerInfo); 599 dc = (struct wbcDomainControllerInfo *)wbcAllocateMemory( 600 1, sizeof(struct wbcDomainControllerInfo), 601 wbcDomainControllerInfoDestructor); 495 602 BAIL_ON_PTR_ERROR(dc, wbc_status); 496 603 … … 502 609 BAIL_ON_WBC_ERROR(wbc_status); 503 610 504 dc->dc_name = talloc_strdup(dc,response.data.dsgetdcname.dc_unc);611 dc->dc_name = strdup(response.data.dsgetdcname.dc_unc); 505 612 BAIL_ON_PTR_ERROR(dc->dc_name, wbc_status); 506 613 507 614 *dc_info = dc; 615 dc = NULL; 508 616 509 617 done: 510 if (!WBC_ERROR_IS_OK(wbc_status)) { 511 talloc_free(dc); 512 } 513 514 return wbc_status; 515 } 516 517 static wbcErr wbc_create_domain_controller_info_ex(TALLOC_CTX *mem_ctx, 518 const struct winbindd_response *resp, 618 wbcFreeMemory(dc); 619 return wbc_status; 620 } 621 622 static void wbcDomainControllerInfoExDestructor(void *ptr) 623 { 624 struct wbcDomainControllerInfoEx *i = 625 (struct wbcDomainControllerInfoEx *)ptr; 626 free((char *)(i->dc_unc)); 627 free((char *)(i->dc_address)); 628 free((char *)(i->domain_guid)); 629 free((char *)(i->domain_name)); 630 free((char *)(i->forest_name)); 631 free((char *)(i->dc_site_name)); 632 free((char *)(i->client_site_name)); 633 } 634 635 static wbcErr wbc_create_domain_controller_info_ex(const struct winbindd_response *resp, 519 636 struct wbcDomainControllerInfoEx **_i) 520 637 { … … 523 640 struct wbcGuid guid; 524 641 525 i = talloc(mem_ctx, struct wbcDomainControllerInfoEx); 642 i = (struct wbcDomainControllerInfoEx *)wbcAllocateMemory( 643 1, sizeof(struct wbcDomainControllerInfoEx), 644 wbcDomainControllerInfoExDestructor); 526 645 BAIL_ON_PTR_ERROR(i, wbc_status); 527 646 528 i->dc_unc = talloc_strdup(i,resp->data.dsgetdcname.dc_unc);647 i->dc_unc = strdup(resp->data.dsgetdcname.dc_unc); 529 648 BAIL_ON_PTR_ERROR(i->dc_unc, wbc_status); 530 649 531 i->dc_address = talloc_strdup(i,resp->data.dsgetdcname.dc_address);650 i->dc_address = strdup(resp->data.dsgetdcname.dc_address); 532 651 BAIL_ON_PTR_ERROR(i->dc_address, wbc_status); 533 652 … … 536 655 wbc_status = wbcStringToGuid(resp->data.dsgetdcname.domain_guid, &guid); 537 656 if (WBC_ERROR_IS_OK(wbc_status)) { 538 i->domain_guid = talloc(i, struct wbcGuid); 657 i->domain_guid = (struct wbcGuid *)malloc( 658 sizeof(struct wbcGuid)); 539 659 BAIL_ON_PTR_ERROR(i->domain_guid, wbc_status); 540 660 541 661 *i->domain_guid = guid; 542 } else { 543 i->domain_guid = NULL; 544 } 545 546 i->domain_name = talloc_strdup(i, resp->data.dsgetdcname.domain_name); 662 } 663 664 i->domain_name = strdup(resp->data.dsgetdcname.domain_name); 547 665 BAIL_ON_PTR_ERROR(i->domain_name, wbc_status); 548 666 549 667 if (resp->data.dsgetdcname.forest_name[0] != '\0') { 550 i->forest_name = talloc_strdup(i, 551 resp->data.dsgetdcname.forest_name); 668 i->forest_name = strdup(resp->data.dsgetdcname.forest_name); 552 669 BAIL_ON_PTR_ERROR(i->forest_name, wbc_status); 553 } else {554 i->forest_name = NULL;555 670 } 556 671 … … 558 673 559 674 if (resp->data.dsgetdcname.dc_site_name[0] != '\0') { 560 i->dc_site_name = talloc_strdup(i, 561 resp->data.dsgetdcname.dc_site_name); 675 i->dc_site_name = strdup(resp->data.dsgetdcname.dc_site_name); 562 676 BAIL_ON_PTR_ERROR(i->dc_site_name, wbc_status); 563 } else {564 i->dc_site_name = NULL;565 677 } 566 678 567 679 if (resp->data.dsgetdcname.client_site_name[0] != '\0') { 568 i->client_site_name = talloc_strdup(i,680 i->client_site_name = strdup( 569 681 resp->data.dsgetdcname.client_site_name); 570 682 BAIL_ON_PTR_ERROR(i->client_site_name, wbc_status); 571 } else {572 i->client_site_name = NULL;573 683 } 574 684 … … 577 687 578 688 done: 579 talloc_free(i); 689 if (i != NULL) { 690 wbcFreeMemory(i); 691 } 580 692 return wbc_status; 581 693 } … … 632 744 633 745 if (dc_info) { 634 wbc_status = wbc_create_domain_controller_info_ex(NULL, 635 &response, 746 wbc_status = wbc_create_domain_controller_info_ex(&response, 636 747 dc_info); 637 748 BAIL_ON_WBC_ERROR(wbc_status); … … 643 754 } 644 755 756 static void wbcNamedBlobDestructor(void *ptr) 757 { 758 struct wbcNamedBlob *b = (struct wbcNamedBlob *)ptr; 759 760 while (b->name != NULL) { 761 free((char *)(b->name)); 762 free(b->blob.data); 763 b += 1; 764 } 765 } 766 645 767 /* Initialize a named blob and add to list of blobs */ 646 768 wbcErr wbcAddNamedBlob(size_t *num_blobs, 647 struct wbcNamedBlob ** blobs,769 struct wbcNamedBlob **pblobs, 648 770 const char *name, 649 771 uint32_t flags, … … 652 774 { 653 775 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 654 struct wbcNamedBlob blob; 655 656 *blobs = talloc_realloc(NULL, *blobs, struct wbcNamedBlob, 657 *(num_blobs)+1); 658 BAIL_ON_PTR_ERROR(*blobs, wbc_status); 659 660 blob.name = talloc_strdup(*blobs, name); 661 BAIL_ON_PTR_ERROR(blob.name, wbc_status); 662 blob.flags = flags; 663 blob.blob.length = length; 664 blob.blob.data = (uint8_t *)talloc_memdup(*blobs, data, length); 665 BAIL_ON_PTR_ERROR(blob.blob.data, wbc_status); 666 667 (*(blobs))[*num_blobs] = blob; 668 *(num_blobs) += 1; 776 struct wbcNamedBlob *blobs, *blob; 777 778 if (name == NULL) { 779 return WBC_ERR_INVALID_PARAM; 780 } 781 782 /* 783 * Overallocate the b->name==NULL terminator for 784 * wbcNamedBlobDestructor 785 */ 786 blobs = (struct wbcNamedBlob *)wbcAllocateMemory( 787 *num_blobs + 2, sizeof(struct wbcNamedBlob), 788 wbcNamedBlobDestructor); 789 790 if (blobs == NULL) { 791 return WBC_ERR_NO_MEMORY; 792 } 793 794 if (*pblobs != NULL) { 795 struct wbcNamedBlob *old = *pblobs; 796 memcpy(blobs, old, sizeof(struct wbcNamedBlob) * (*num_blobs)); 797 if (*num_blobs != 0) { 798 /* end indicator for wbcNamedBlobDestructor */ 799 old[0].name = NULL; 800 } 801 wbcFreeMemory(old); 802 } 803 *pblobs = blobs; 804 805 blob = &blobs[*num_blobs]; 806 807 blob->name = strdup(name); 808 BAIL_ON_PTR_ERROR(blob->name, wbc_status); 809 blob->flags = flags; 810 811 blob->blob.length = length; 812 blob->blob.data = (uint8_t *)malloc(length); 813 BAIL_ON_PTR_ERROR(blob->blob.data, wbc_status); 814 memcpy(blob->blob.data, data, length); 815 816 *num_blobs += 1; 817 *pblobs = blobs; 818 blobs = NULL; 669 819 670 820 wbc_status = WBC_ERR_SUCCESS; 671 821 done: 672 if (!WBC_ERROR_IS_OK(wbc_status) && blobs) { 673 wbcFreeMemory(*blobs); 674 } 675 return wbc_status; 676 } 822 wbcFreeMemory(blobs); 823 return wbc_status; 824 } -
trunk/server/nsswitch/libwbclient/wbclient.c
r480 r745 24 24 25 25 #include "replace.h" 26 #include "talloc.h"27 #include "tevent.h"28 26 #include "libwbclient.h" 29 27 … … 37 35 struct winbindd_response *response); 38 36 39 /** @brief Wrapper around Winbind's send/receive API call 40 * 41 * @param cmd Winbind command operation to perform 42 * @param request Send structure 43 * @param response Receive structure 44 * 45 * @return #wbcErr 46 **/ 47 48 /********************************************************************** 37 /* 49 38 result == NSS_STATUS_UNAVAIL: winbind not around 50 39 result == NSS_STATUS_NOTFOUND: winbind around, but domain missing … … 57 46 58 47 --Volker 59 * *********************************************************************/48 */ 60 49 61 50 static wbcErr wbcRequestResponseInt( … … 92 81 } 93 82 83 /** 84 * @brief Wrapper around Winbind's send/receive API call 85 * 86 * @param cmd Winbind command operation to perform 87 * @param request Send structure 88 * @param response Receive structure 89 * 90 * @return #wbcErr 91 */ 94 92 wbcErr wbcRequestResponse(int cmd, 95 93 struct winbindd_request *request, … … 150 148 } 151 149 150 #define WBC_MAGIC (0x7a2b0e1e) 151 #define WBC_MAGIC_FREE (0x875634fe) 152 153 struct wbcMemPrefix { 154 uint32_t magic; 155 void (*destructor)(void *ptr); 156 }; 157 158 static size_t wbcPrefixLen(void) 159 { 160 size_t result = sizeof(struct wbcMemPrefix); 161 return (result + 15) & ~15; 162 } 163 164 static struct wbcMemPrefix *wbcMemToPrefix(void *ptr) 165 { 166 return (struct wbcMemPrefix *)(((char *)ptr) - wbcPrefixLen()); 167 } 168 169 void *wbcAllocateMemory(size_t nelem, size_t elsize, 170 void (*destructor)(void *ptr)) 171 { 172 struct wbcMemPrefix *result; 173 174 if (nelem >= (2<<24)/elsize) { 175 /* basic protection against integer wrap */ 176 return NULL; 177 } 178 179 result = (struct wbcMemPrefix *)calloc( 180 1, nelem*elsize + wbcPrefixLen()); 181 if (result == NULL) { 182 return NULL; 183 } 184 result->magic = WBC_MAGIC; 185 result->destructor = destructor; 186 return ((char *)result) + wbcPrefixLen(); 187 } 188 152 189 /* Free library allocated memory */ 153 190 void wbcFreeMemory(void *p) 154 191 { 155 if (p) 156 talloc_free(p); 157 192 struct wbcMemPrefix *wbcMem; 193 194 if (p == NULL) { 195 return; 196 } 197 wbcMem = wbcMemToPrefix(p); 198 if (wbcMem->magic != WBC_MAGIC) { 199 return; 200 } 201 202 /* paranoid check to ensure we don't double free */ 203 wbcMem->magic = WBC_MAGIC_FREE; 204 205 if (wbcMem->destructor != NULL) { 206 wbcMem->destructor(p); 207 } 208 free(wbcMem); 158 209 return; 159 210 } 160 211 212 char *wbcStrDup(const char *str) 213 { 214 char *result; 215 size_t len; 216 217 len = strlen(str); 218 result = (char *)wbcAllocateMemory(len+1, sizeof(char), NULL); 219 if (result == NULL) { 220 return NULL; 221 } 222 memcpy(result, str, len+1); 223 return result; 224 } 225 226 static void wbcStringArrayDestructor(void *ptr) 227 { 228 char **p = (char **)ptr; 229 while (*p != NULL) { 230 free(*p); 231 p += 1; 232 } 233 } 234 235 const char **wbcAllocateStringArray(int num_strings) 236 { 237 return (const char **)wbcAllocateMemory( 238 num_strings + 1, sizeof(const char *), 239 wbcStringArrayDestructor); 240 } 241 161 242 wbcErr wbcLibraryDetails(struct wbcLibraryDetails **_details) 162 243 { 163 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;164 244 struct wbcLibraryDetails *info; 165 245 166 info = talloc(NULL, struct wbcLibraryDetails); 167 BAIL_ON_PTR_ERROR(info, wbc_status); 246 info = (struct wbcLibraryDetails *)wbcAllocateMemory( 247 1, sizeof(struct wbcLibraryDetails), NULL); 248 249 if (info == NULL) { 250 return WBC_ERR_NO_MEMORY; 251 } 168 252 169 253 info->major_version = WBCLIENT_MAJOR_VERSION; 170 254 info->minor_version = WBCLIENT_MINOR_VERSION; 171 info->vendor_version = talloc_strdup(info, 172 WBCLIENT_VENDOR_VERSION); 173 BAIL_ON_PTR_ERROR(info->vendor_version, wbc_status); 255 info->vendor_version = WBCLIENT_VENDOR_VERSION; 174 256 175 257 *_details = info; 176 info = NULL; 177 178 wbc_status = WBC_ERR_SUCCESS; 179 180 done: 181 talloc_free(info); 182 return wbc_status; 183 } 258 return WBC_ERR_SUCCESS; 259 } -
trunk/server/nsswitch/libwbclient/wbclient.h
r414 r745 66 66 * 0.4: Added wbcSidTypeString() 67 67 * 0.5: Added wbcChangeTrustCredentials() 68 * 0.6: Made struct wbcInterfaceDetails char* members non-const 69 * 0.7: Added wbcSidToStringBuf() 70 * 0.8: Added wbcSidsToUnixIds() and wbcLookupSids() 68 71 **/ 69 72 #define WBCLIENT_MAJOR_VERSION 0 70 #define WBCLIENT_MINOR_VERSION 573 #define WBCLIENT_MINOR_VERSION 8 71 74 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient" 72 75 struct wbcLibraryDetails { … … 82 85 struct wbcInterfaceDetails { 83 86 uint32_t interface_version; 84 c onst char *winbind_version;87 char *winbind_version; 85 88 char winbind_separator; 86 c onst char *netbios_name;87 c onst char *netbios_domain;88 c onst char *dns_domain;89 char *netbios_name; 90 char *netbios_domain; 91 char *dns_domain; 89 92 }; 90 93 … … 191 194 #define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002 192 195 #define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003 193 194 196 195 197 /** … … 430 432 431 433 enum wbcPasswordChangeRejectReason { 432 WBC_PWD_CHANGE_REJECT_OTHER=0, 433 WBC_PWD_CHANGE_REJECT_TOO_SHORT=1, 434 WBC_PWD_CHANGE_REJECT_IN_HISTORY=2, 435 WBC_PWD_CHANGE_REJECT_COMPLEXITY=5 436 }; 434 WBC_PWD_CHANGE_NO_ERROR=0, 435 WBC_PWD_CHANGE_PASSWORD_TOO_SHORT=1, 436 WBC_PWD_CHANGE_PWD_IN_HISTORY=2, 437 WBC_PWD_CHANGE_USERNAME_IN_PASSWORD=3, 438 WBC_PWD_CHANGE_FULLNAME_IN_PASSWORD=4, 439 WBC_PWD_CHANGE_NOT_COMPLEX=5, 440 WBC_PWD_CHANGE_MACHINE_NOT_DEFAULT=6, 441 WBC_PWD_CHANGE_FAILED_BY_FILTER=7, 442 WBC_PWD_CHANGE_PASSWORD_TOO_LONG=8 443 }; 444 445 /* Note: this defines exist for compatibility reasons with existing code */ 446 #define WBC_PWD_CHANGE_REJECT_OTHER WBC_PWD_CHANGE_NO_ERROR 447 #define WBC_PWD_CHANGE_REJECT_TOO_SHORT WBC_PWD_CHANGE_PASSWORD_TOO_SHORT 448 #define WBC_PWD_CHANGE_REJECT_IN_HISTORY WBC_PWD_CHANGE_PWD_IN_HISTORY 449 #define WBC_PWD_CHANGE_REJECT_COMPLEXITY WBC_PWD_CHANGE_NOT_COMPLEX 437 450 438 451 /** … … 519 532 const char* wbcSidTypeString(enum wbcSidType type); 520 533 534 #define WBC_SID_STRING_BUFLEN (15*11+25) 535 536 /* 537 * @brief Print a sid into a buffer 538 * 539 * @param sid Binary Security Identifier 540 * @param buf Target buffer 541 * @param buflen Target buffer length 542 * 543 * @return Resulting string length. 544 */ 545 int wbcSidToStringBuf(const struct wbcDomainSid *sid, char *buf, int buflen); 546 521 547 /** 522 548 * @brief Convert a binary SID to a character string … … 611 637 char **name, 612 638 enum wbcSidType *name_type); 639 640 struct wbcTranslatedName { 641 enum wbcSidType type; 642 char *name; 643 int domain_index; 644 }; 645 646 wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids, 647 struct wbcDomainInfo **domains, int *num_domains, 648 struct wbcTranslatedName **names); 613 649 614 650 /** … … 758 794 struct wbcDomainSid *sid); 759 795 796 enum wbcIdType { 797 WBC_ID_TYPE_NOT_SPECIFIED, 798 WBC_ID_TYPE_UID, 799 WBC_ID_TYPE_GID 800 }; 801 802 union wbcUnixIdContainer { 803 uid_t uid; 804 gid_t gid; 805 }; 806 807 struct wbcUnixId { 808 enum wbcIdType type; 809 union wbcUnixIdContainer id; 810 }; 811 812 /** 813 * @brief Convert a list of sids to unix ids 814 * 815 * @param sids Pointer to an array of SIDs to convert 816 * @param num_sids Number of SIDs 817 * @param ids Preallocated output array for translated IDs 818 * 819 * @return #wbcErr 820 * 821 **/ 822 wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids, 823 struct wbcUnixId *ids); 824 760 825 /** 761 826 * @brief Obtain a new uid from Winbind … … 783 848 * 784 849 * @return #wbcErr 850 * 851 * @deprecated This method is not impemented any more and should 852 * be removed in the next major version change. 785 853 **/ 786 854 wbcErr wbcSetUidMapping(uid_t uid, const struct wbcDomainSid *sid); … … 793 861 * 794 862 * @return #wbcErr 863 * 864 * @deprecated This method is not impemented any more and should 865 * be removed in the next major version change. 795 866 **/ 796 867 wbcErr wbcSetGidMapping(gid_t gid, const struct wbcDomainSid *sid); … … 803 874 * 804 875 * @return #wbcErr 876 * 877 * @deprecated This method is not impemented any more and should 878 * be removed in the next major version change. 805 879 **/ 806 880 wbcErr wbcRemoveUidMapping(uid_t uid, const struct wbcDomainSid *sid); … … 813 887 * 814 888 * @return #wbcErr 889 * 890 * @deprecated This method is not impemented any more and should 891 * be removed in the next major version change. 815 892 **/ 816 893 wbcErr wbcRemoveGidMapping(gid_t gid, const struct wbcDomainSid *sid); … … 822 899 * 823 900 * @return #wbcErr 901 * 902 * @deprecated This method is not impemented any more and should 903 * be removed in the next major version change. 824 904 **/ 825 905 wbcErr wbcSetUidHwm(uid_t uid_hwm); … … 831 911 * 832 912 * @return #wbcErr 913 * 914 * @deprecated This method is not impemented any more and should 915 * be removed in the next major version change. 833 916 **/ 834 917 wbcErr wbcSetGidHwm(gid_t gid_hwm); … … 971 1054 * @brief Lookup the current status of a trusted domain 972 1055 * 973 * @param domain Domain to query 974 * @param *info Pointer to returned domain_info struct 1056 * @param domain The domain to query 1057 * 1058 * @param dinfo A pointer to store the returned domain_info struct. 975 1059 * 976 1060 * @return #wbcErr 977 1061 **/ 978 1062 wbcErr wbcDomainInfo(const char *domain, 979 struct wbcDomainInfo **info); 1063 struct wbcDomainInfo **dinfo); 1064 1065 /** 1066 * @brief Lookup the currently contacted DCs 1067 * 1068 * @param domain The domain to query 1069 * 1070 * @param num_dcs Number of DCs currently known 1071 * @param dc_names Names of the currently known DCs 1072 * @param dc_ips IP addresses of the currently known DCs 1073 * 1074 * @return #wbcErr 1075 **/ 1076 wbcErr wbcDcInfo(const char *domain, size_t *num_dcs, 1077 const char ***dc_names, const char ***dc_ips); 980 1078 981 1079 /** -
trunk/server/nsswitch/libwbclient/wbclient_internal.h
r480 r745 33 33 struct winbindd_response *response); 34 34 35 void *wbcAllocateMemory(size_t nelem, size_t elsize, 36 void (*destructor)(void *ptr)); 37 38 char *wbcStrDup(const char *str); 39 const char **wbcAllocateStringArray(int num_strings); 40 35 41 #endif /* _WBCLIENT_INTERNAL_H */
Note:
See TracChangeset
for help on using the changeset viewer.