Changeset 988 for vendor/current/nsswitch/libwbclient
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/nsswitch/libwbclient
- Files:
-
- 7 added
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/nsswitch/libwbclient/tests/wbclient.c
r740 r988 23 23 #include "lib/util/data_blob.h" 24 24 #include "lib/util/time.h" 25 #include "libcli/resolve/resolve.h" 25 26 #include "nsswitch/libwbclient/wbclient.h" 26 27 #include "torture/smbtorture.h" … … 29 30 #include "lib/util/charset/charset.h" 30 31 #include "libcli/auth/libcli_auth.h" 31 #include " source4/param/param.h"32 #include "lib/util/ util.h"32 #include "lib/param/param.h" 33 #include "lib/util/samba_util.h" 33 34 #include "lib/crypto/arcfour.h" 35 #include "auth/credentials/credentials.h" 36 #include "lib/cmdline/popt_common.h" 34 37 35 38 #define WBC_ERROR_EQUAL(x,y) (x == y) 36 39 37 #define torture_assert_wbc_equal(torture_ctx, got, expected, cmt )\40 #define torture_assert_wbc_equal(torture_ctx, got, expected, cmt, cmt_arg) \ 38 41 do { wbcErr __got = got, __expected = expected; \ 39 42 if (!WBC_ERROR_EQUAL(__got, __expected)) { \ 40 torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", wbcErrorString(__got), wbcErrorString(__expected), cmt); \43 torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: " cmt, wbcErrorString(__got), wbcErrorString(__expected), cmt_arg); \ 41 44 return false; \ 42 45 } \ 43 46 } while (0) 44 47 45 #define torture_assert_wbc_ok(torture_ctx,expr,cmt )\46 torture_assert_wbc_equal(torture_ctx,expr,WBC_ERR_SUCCESS,cmt)48 #define torture_assert_wbc_ok(torture_ctx,expr,cmt,cmt_arg) \ 49 torture_assert_wbc_equal(torture_ctx,expr,WBC_ERR_SUCCESS,cmt,cmt_arg) 47 50 48 51 static bool test_wbc_ping(struct torture_context *tctx) 49 52 { 50 53 torture_assert_wbc_ok(tctx, wbcPing(), 51 " wbcPing failed");54 "%s", "wbcPing failed"); 52 55 53 56 return true; … … 56 59 static bool test_wbc_pingdc(struct torture_context *tctx) 57 60 { 58 torture_assert_wbc_equal(tctx, wbcPingDc("random_string", NULL), WBC_ERR_NOT_IMPLEMENTED, 59 "wbcPingDc failed"); 61 struct wbcInterfaceDetails *details; 62 63 torture_assert_wbc_equal(tctx, wbcPingDc("random_string", NULL), WBC_ERR_DOMAIN_NOT_FOUND, 64 "%s", "wbcPingDc failed"); 60 65 torture_assert_wbc_ok(tctx, wbcPingDc(NULL, NULL), 61 "wbcPingDc failed"); 66 "%s", "wbcPingDc failed"); 67 68 torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), 69 "%s", "wbcInterfaceDetails failed"); 70 torture_assert(tctx, details, 71 "wbcInterfaceDetails returned NULL pointer"); 72 torture_assert(tctx, details->netbios_domain, 73 "wbcInterfaceDetails returned NULL netbios_domain"); 74 75 torture_assert_wbc_ok(tctx, wbcPingDc(details->netbios_domain, NULL), 76 "wbcPingDc(%s) failed", details->netbios_domain); 77 78 torture_assert_wbc_ok(tctx, wbcPingDc("BUILTIN", NULL), 79 "%s", "wbcPingDc(BUILTIN) failed"); 80 81 wbcFreeMemory(details); 82 return true; 83 } 84 85 static bool test_wbc_pingdc2(struct torture_context *tctx) 86 { 87 struct wbcInterfaceDetails *details; 88 char *name = NULL; 89 90 torture_assert_wbc_equal(tctx, wbcPingDc2("random_string", NULL, &name), 91 WBC_ERR_DOMAIN_NOT_FOUND, "%s", 92 "wbcPingDc2 failed"); 93 torture_assert_wbc_ok(tctx, wbcPingDc2(NULL, NULL, &name), "%s", 94 "wbcPingDc2 failed"); 95 96 wbcFreeMemory(name); 97 98 torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), 99 "%s", "wbcInterfaceDetails failed"); 100 torture_assert(tctx, details, 101 "wbcInterfaceDetails returned NULL pointer"); 102 torture_assert(tctx, details->netbios_domain, 103 "wbcInterfaceDetails returned NULL netbios_domain"); 104 105 torture_assert_wbc_ok(tctx, wbcPingDc2(details->netbios_domain, NULL, &name), 106 "wbcPingDc2(%s) failed", details->netbios_domain); 107 wbcFreeMemory(name); 108 109 torture_assert_wbc_ok(tctx, wbcPingDc2("BUILTIN", NULL, &name), 110 "%s", "wbcPingDc2(BUILTIN) failed"); 111 wbcFreeMemory(name); 112 113 wbcFreeMemory(details); 62 114 63 115 return true; … … 69 121 70 122 torture_assert_wbc_ok(tctx, wbcLibraryDetails(&details), 71 " wbcLibraryDetails failed");123 "%s", "wbcLibraryDetails failed"); 72 124 torture_assert(tctx, details, 73 125 "wbcLibraryDetails returned NULL pointer"); … … 83 135 84 136 torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), 85 " wbcInterfaceDetails failed");137 "%s", "wbcInterfaceDetails failed"); 86 138 torture_assert(tctx, details, 87 "wbcInterfaceDetails returned NULL pointer");139 "wbcInterfaceDetails returned NULL pointer"); 88 140 89 141 wbcFreeMemory(details); … … 113 165 "SID_UNKNOWN", "SID_UNKNOWN failed"); 114 166 torture_assert_str_equal(tctx, wbcSidTypeString(WBC_SID_NAME_COMPUTER), 115 "SID_COMPUTER", "SID_COMPUTER failed");167 "SID_COMPUTER", "SID_COMPUTER failed"); 116 168 return true; 117 169 } … … 124 176 125 177 torture_assert_wbc_ok(tctx, wbcStringToSid(sid_string, &sid), 126 "wbcStringToSid failed");178 "wbcStringToSid of %s failed", sid_string); 127 179 torture_assert_wbc_ok(tctx, wbcSidToString(&sid, &sid_string2), 128 "wbcSidToString failed");180 "wbcSidToString of %s failed", sid_string); 129 181 torture_assert_str_equal(tctx, sid_string, sid_string2, 130 182 "sid strings differ"); … … 141 193 142 194 torture_assert_wbc_ok(tctx, wbcStringToGuid(guid_string, &guid), 143 "wbcStringToGuid failed");195 "wbcStringToGuid of %s failed", guid_string); 144 196 torture_assert_wbc_ok(tctx, wbcGuidToString(&guid, &guid_string2), 145 "wbcGuidToString failed");197 "wbcGuidToString of %s failed", guid_string); 146 198 torture_assert_str_equal(tctx, guid_string, guid_string2, 147 "guid strings differ");199 "guid strings differ"); 148 200 wbcFreeMemory(guid_string2); 149 201 … … 157 209 158 210 torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), 159 " wbcInterfaceDetails failed");211 "%s", "wbcInterfaceDetails failed"); 160 212 torture_assert_wbc_ok( 161 213 tctx, wbcDomainInfo(details->netbios_domain, &info), 162 " wbcDomainInfo failed");214 "%s", "wbcDomainInfo failed"); 163 215 wbcFreeMemory(details); 164 216 … … 179 231 180 232 torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), 181 " wbcInterfaceDetails failed");233 "%s", "wbcInterfaceDetails failed"); 182 234 183 235 domain_name = talloc_strdup(tctx, details->netbios_domain); … … 185 237 186 238 torture_assert_wbc_ok(tctx, wbcListUsers(domain_name, &num_users, &users), 187 " wbcListUsers failed");239 "%s", "wbcListUsers failed"); 188 240 torture_assert(tctx, !(num_users > 0 && !users), 189 241 "wbcListUsers returned invalid results"); … … 195 247 char *domain; 196 248 char *name; 249 char *sid_string; 197 250 uint32_t num_sids; 198 251 199 252 torture_assert_wbc_ok(tctx, wbcLookupName(domain_name, users[i], &sid, &name_type), 200 "wbcLookupName failed");253 "wbcLookupName of %s failed", users[i]); 201 254 torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_USER, 202 "wbcLookupName expected WBC_SID_NAME_USER"); 255 "wbcLookupName expected WBC_SID_NAME_USER"); 256 wbcSidToString(&sid, &sid_string); 203 257 torture_assert_wbc_ok(tctx, wbcLookupSid(&sid, &domain, &name, &name_type), 204 "wbcLookupSid failed");258 "wbcLookupSid of %s failed", sid_string); 205 259 torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_USER, 206 "wbcLookupSidexpected WBC_SID_NAME_USER");260 "wbcLookupSid of expected WBC_SID_NAME_USER"); 207 261 torture_assert(tctx, name, 208 262 "wbcLookupSid returned no name"); … … 210 264 wbcFreeMemory(name); 211 265 torture_assert_wbc_ok(tctx, wbcLookupUserSids(&sid, true, &num_sids, &sids), 212 "wbcLookupUserSids failed");266 "wbcLookupUserSids of %s failed", sid_string); 213 267 torture_assert_wbc_ok( 214 268 tctx, wbcGetDisplayName(&sid, &domain, &name, 215 269 &name_type), 216 "wbcGetDisplayName failed");270 "wbcGetDisplayName of %s failed", sid_string); 217 271 wbcFreeMemory(domain); 218 272 wbcFreeMemory(name); 219 273 wbcFreeMemory(sids); 274 wbcFreeMemory(sid_string); 220 275 } 221 276 wbcFreeMemory(users); … … 233 288 234 289 torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), 235 "wbcInterfaceDetails failed");290 "%s", "wbcInterfaceDetails failed"); 236 291 237 292 domain_name = talloc_strdup(tctx, details->netbios_domain); … … 239 294 240 295 torture_assert_wbc_ok(tctx, wbcListGroups(domain_name, &num_groups, &groups), 241 "wbcListGroups failed");296 "wbcListGroups in %s failed", domain_name); 242 297 torture_assert(tctx, !(num_groups > 0 && !groups), 243 "wbcListGroups returned invalid results");298 "wbcListGroups returned invalid results"); 244 299 245 300 for (i=0; i < MIN(num_groups,100); i++) { … … 249 304 char *domain; 250 305 char *name; 306 char *sid_string; 251 307 252 308 torture_assert_wbc_ok(tctx, wbcLookupName(domain_name, groups[i], &sid, &name_type), 253 "wbcLookupName failed"); 309 "wbcLookupName for %s failed", domain_name); 310 wbcSidToString(&sid, &sid_string); 254 311 torture_assert_wbc_ok(tctx, wbcLookupSid(&sid, &domain, &name, &name_type), 255 "wbcLookupSid failed"); 312 "wbcLookupSid of %s failed", sid_string); 313 wbcFreeMemory(sid_string); 256 314 torture_assert(tctx, name, 257 315 "wbcLookupSid returned no name"); … … 269 327 270 328 torture_assert_wbc_ok(tctx, wbcListTrusts(&domains, &num_domains), 271 "wbcListTrusts failed");329 "%s", "wbcListTrusts failed"); 272 330 torture_assert(tctx, !(num_domains > 0 && !domains), 273 331 "wbcListTrusts returned invalid results"); … … 283 341 */ 284 342 torture_assert_wbc_ok(tctx, wbcCheckTrustCredentials(domains[i].short_name, &error), 285 "wbcCheckTrustCredentials failed");343 "%s", "wbcCheckTrustCredentials failed"); 286 344 /* 287 345 torture_assert_wbc_ok(tctx, wbcLookupName(domains[i].short_name, NULL, &sid, &name_type), … … 309 367 310 368 torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), 311 " wbcInterfaceDetails failed");369 "%s", "wbcInterfaceDetails failed"); 312 370 313 371 domain_name = talloc_strdup(tctx, details->netbios_domain); … … 315 373 316 374 torture_assert_wbc_ok(tctx, wbcLookupDomainController(domain_name, 0, &dc_info), 317 "wbcLookupDomainController failed");375 "wbcLookupDomainController for %s failed", domain_name); 318 376 wbcFreeMemory(dc_info); 319 377 … … 328 386 329 387 torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), 330 " wbcInterfaceDetails failed");388 "%s", "wbcInterfaceDetails failed"); 331 389 332 390 domain_name = talloc_strdup(tctx, details->netbios_domain); … … 334 392 335 393 torture_assert_wbc_ok(tctx, wbcLookupDomainControllerEx(domain_name, NULL, NULL, 0, &dc_info), 336 "wbcLookupDomainControllerEx f ailed");394 "wbcLookupDomainControllerEx for %s failed", domain_name); 337 395 wbcFreeMemory(dc_info); 338 396 … … 348 406 name = torture_setting_string(tctx, "host", NULL); 349 407 408 torture_comment(tctx, "test-WinsByName: host='%s'\n", name); 409 350 410 ret = wbcResolveWinsByName(name, &ip); 351 411 352 412 if (is_ipaddress(name)) { 353 torture_assert_wbc_equal(tctx, ret, WBC_ERR_DOMAIN_NOT_FOUND, "wbcResolveWinsByName failed");413 torture_assert_wbc_equal(tctx, ret, WBC_ERR_DOMAIN_NOT_FOUND, "wbcResolveWinsByName of %s failed", name); 354 414 } else { 355 torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByName f ailed");415 torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByName for %s failed", name); 356 416 } 357 417 … … 362 422 { 363 423 const char *ip; 424 const char *host; 425 struct nbt_name nbt_name; 364 426 char *name; 365 427 wbcErr ret; 366 367 ip = torture_setting_string(tctx, "host", NULL); 428 NTSTATUS status; 429 430 host = torture_setting_string(tctx, "host", NULL); 431 432 torture_comment(tctx, "test-WinsByIp: host='%s'\n", host); 433 434 make_nbt_name_server(&nbt_name, host); 435 436 status = resolve_name_ex(lpcfg_resolve_context(tctx->lp_ctx), 437 0, 0, &nbt_name, tctx, &ip, tctx->ev); 438 torture_assert_ntstatus_ok(tctx, status, 439 talloc_asprintf(tctx,"Failed to resolve %s: %s", 440 nbt_name.name, nt_errstr(status))); 441 442 torture_comment(tctx, "test-WinsByIp: ip='%s'\n", ip); 368 443 369 444 ret = wbcResolveWinsByIP(ip, &name); 370 445 371 torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByIP f ailed");446 torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByIP for %s failed", ip); 372 447 373 448 wbcFreeMemory(name); … … 388 463 ret = wbcLookupRids(&builtin, 2, rids, &domain_name, &names, 389 464 &types); 390 torture_assert_wbc_ok(tctx, ret, " wbcLookupRidsfailed");465 torture_assert_wbc_ok(tctx, ret, "%s", "wbcLookupRids for 544 and 545 failed"); 391 466 392 467 torture_assert_str_equal( … … 396 471 tctx, names[1], "Users", "S-1-5-32-545 not mapped to 'Users'"); 397 472 398 wbcFreeMemory( (char *)domain_name);473 wbcFreeMemory(discard_const_p(char ,domain_name)); 399 474 wbcFreeMemory(names); 400 475 wbcFreeMemory(types); … … 414 489 415 490 torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), 416 "wbcInterfaceDetails failed");491 "%s", "wbcInterfaceDetails failed"); 417 492 torture_assert_wbc_ok( 418 493 tctx, wbcDomainInfo(details->netbios_domain, &info), 419 "wbcDomainInfo failed");494 "wbcDomainInfo of %s failed", details->netbios_domain); 420 495 wbcFreeMemory(details); 421 496 … … 428 503 torture_assert_wbc_ok( 429 504 tctx, wbcStringToSid("S-1-5-32", &builtin), 430 "wbcStringToSid failed");505 "wbcStringToSid of %s failed", "S-1-5-32"); 431 506 432 507 ret = wbcGetSidAliases(&builtin, sids, 2, &rids, &num_rids); 433 torture_assert_wbc_ok(tctx, ret, " wbcGetSidAliases failed");508 torture_assert_wbc_ok(tctx, ret, "%s", "wbcGetSidAliases failed"); 434 509 435 510 wbcFreeMemory(rids); … … 446 521 wbcErr ret; 447 522 448 ret = wbcAuthenticateUser(getenv("USERNAME"), correct_password); 449 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 450 "wbcAuthenticateUser failed"); 523 ret = wbcAuthenticateUser(cli_credentials_get_username(cmdline_credentials), correct_password); 524 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 525 "wbcAuthenticateUser of %s failed", 526 cli_credentials_get_username(cmdline_credentials)); 451 527 452 528 ZERO_STRUCT(params); 453 params.account_name = getenv("USERNAME");529 params.account_name = cli_credentials_get_username(cmdline_credentials); 454 530 params.level = WBC_AUTH_USER_LEVEL_PLAIN; 455 531 params.password.plaintext = correct_password; … … 457 533 ret = wbcAuthenticateUserEx(¶ms, &info, &error); 458 534 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 459 "wbcAuthenticateUserEx failed");535 "wbcAuthenticateUserEx of %s failed", params.account_name); 460 536 wbcFreeMemory(info); 461 537 info = NULL; … … 467 543 ret = wbcAuthenticateUserEx(¶ms, &info, &error); 468 544 torture_assert_wbc_equal(tctx, ret, WBC_ERR_AUTH_ERROR, 469 "wbcAuthenticateUserEx succeeded where it "470 "should have failed" );545 "wbcAuthenticateUserEx for %s succeeded where it " 546 "should have failed", params.account_name); 471 547 wbcFreeMemory(info); 472 548 info = NULL; … … 480 556 static bool test_wbc_authenticate_user(struct torture_context *tctx) 481 557 { 482 return test_wbc_authenticate_user_int(tctx, getenv("PASSWORD"));558 return test_wbc_authenticate_user_int(tctx, cli_credentials_get_password(cmdline_credentials)); 483 559 } 484 560 … … 486 562 { 487 563 wbcErr ret; 488 const char *oldpass = getenv("PASSWORD");489 const char *newpass = "Koo8irei ";564 const char *oldpass = cli_credentials_get_password(cmdline_credentials); 565 const char *newpass = "Koo8irei%$"; 490 566 491 567 struct samr_CryptPassword new_nt_password; … … 551 627 552 628 params.level = WBC_CHANGE_PASSWORD_LEVEL_RESPONSE; 553 params.account_name = getenv("USERNAME");554 params.domain_name = "SAMBA-TEST";629 params.account_name = cli_credentials_get_username(cmdline_credentials); 630 params.domain_name = cli_credentials_get_domain(cmdline_credentials); 555 631 556 632 ret = wbcChangeUserPasswordEx(¶ms, NULL, NULL, NULL); 557 633 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 558 "wbcChangeUserPassword f ailed");559 560 if (!test_wbc_authenticate_user_int(tctx, "Koo8irei")) {634 "wbcChangeUserPassword for %s failed", params.account_name); 635 636 if (!test_wbc_authenticate_user_int(tctx, newpass)) { 561 637 return false; 562 638 } 563 639 564 ret = wbcChangeUserPassword( getenv("USERNAME"), "Koo8irei",565 getenv("PASSWORD"));566 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 567 "wbcChangeUserPassword f ailed");568 569 return test_wbc_authenticate_user_int(tctx, getenv("PASSWORD"));640 ret = wbcChangeUserPassword(cli_credentials_get_username(cmdline_credentials), newpass, 641 cli_credentials_get_password(cmdline_credentials)); 642 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 643 "wbcChangeUserPassword for %s failed", params.account_name); 644 645 return test_wbc_authenticate_user_int(tctx, cli_credentials_get_password(cmdline_credentials)); 570 646 } 571 647 … … 586 662 ret = wbcLogonUser(¶ms, &info, &error, &policy); 587 663 torture_assert_wbc_equal(tctx, ret, WBC_ERR_INVALID_PARAM, 588 " wbcLogonUser succeededwhere it should "664 "%s", "wbcLogonUser succeeded for NULL where it should " 589 665 "have failed"); 590 666 591 params.username = getenv("USERNAME");592 params.password = getenv("PASSWORD");667 params.username = cli_credentials_get_username(cmdline_credentials); 668 params.password = cli_credentials_get_password(cmdline_credentials); 593 669 594 670 ret = wbcAddNamedBlob(¶ms.num_blobs, ¶ms.blobs, 595 671 "foo", 0, discard_const_p(uint8_t, "bar"), 4); 596 672 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 597 " wbcAddNamedBlob failed");673 "%s", "wbcAddNamedBlob failed"); 598 674 599 675 ret = wbcLogonUser(¶ms, &info, &error, &policy); 600 676 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 601 "wbcLogonUser f ailed");677 "wbcLogonUser for %s failed", params.username); 602 678 wbcFreeMemory(info); info = NULL; 603 679 wbcFreeMemory(error); error = NULL; … … 608 684 ret = wbcLogonUser(¶ms, &info, &error, &policy); 609 685 torture_assert_wbc_equal(tctx, ret, WBC_ERR_AUTH_ERROR, 610 "wbcLogonUser should have failed with "611 "WBC_ERR_AUTH_ERROR" );686 "wbcLogonUser for %s should have failed with " 687 "WBC_ERR_AUTH_ERROR", params.username); 612 688 wbcFreeMemory(info); info = NULL; 613 689 wbcFreeMemory(error); error = NULL; … … 619 695 strlen("S-1-2-3-4")+1); 620 696 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 621 " wbcAddNamedBlob failed");622 params.password = getenv("PASSWORD");697 "%s", "wbcAddNamedBlob failed"); 698 params.password = cli_credentials_get_password(cmdline_credentials); 623 699 ret = wbcLogonUser(¶ms, &info, &error, &policy); 624 700 torture_assert_wbc_equal(tctx, ret, WBC_ERR_AUTH_ERROR, 625 "wbcLogonUser should have failed with "626 "WBC_ERR_AUTH_ERROR" );701 "wbcLogonUser for %s should have failed with " 702 "WBC_ERR_AUTH_ERROR", params.username); 627 703 wbcFreeMemory(info); info = NULL; 628 704 wbcFreeMemory(error); error = NULL; … … 633 709 ret = wbcInterfaceDetails(&iface); 634 710 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 635 " wbcInterfaceDetails failed");636 637 ret = wbcLookupName(iface->netbios_domain, getenv("USERNAME"), &sid,711 "%s", "wbcInterfaceDetails failed"); 712 713 ret = wbcLookupName(iface->netbios_domain, cli_credentials_get_username(cmdline_credentials), &sid, 638 714 &sidtype); 639 715 wbcFreeMemory(iface); 640 716 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 641 "wbcLookupName f ailed");717 "wbcLookupName for %s failed", cli_credentials_get_username(cmdline_credentials)); 642 718 643 719 ret = wbcSidToString(&sid, &sidstr); 644 720 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 645 " wbcSidToString failed");721 "%s", "wbcSidToString failed"); 646 722 647 723 ret = wbcAddNamedBlob(¶ms.num_blobs, ¶ms.blobs, … … 649 725 (uint8_t *)sidstr, strlen(sidstr)+1); 650 726 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 651 " wbcAddNamedBlob failed");727 "%s", "wbcAddNamedBlob failed"); 652 728 wbcFreeMemory(sidstr); 653 params.password = getenv("PASSWORD");729 params.password = cli_credentials_get_password(cmdline_credentials); 654 730 ret = wbcLogonUser(¶ms, &info, &error, &policy); 655 731 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 656 "wbcLogonUser f ailed");732 "wbcLogonUser for %s failed", params.username); 657 733 wbcFreeMemory(info); info = NULL; 658 734 wbcFreeMemory(error); error = NULL; … … 670 746 gid_t *groups; 671 747 672 ret = wbcGetGroups( getenv("USERNAME"), &num_groups, &groups);673 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 674 "wbcGetGroups f ailed");748 ret = wbcGetGroups(cli_credentials_get_username(cmdline_credentials), &num_groups, &groups); 749 torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, 750 "wbcGetGroups for %s failed", cli_credentials_get_username(cmdline_credentials)); 675 751 wbcFreeMemory(groups); 676 752 return true; … … 683 759 torture_suite_add_simple_test(suite, "wbcPing", test_wbc_ping); 684 760 torture_suite_add_simple_test(suite, "wbcPingDc", test_wbc_pingdc); 761 torture_suite_add_simple_test(suite, "wbcPingDc2", test_wbc_pingdc2); 685 762 torture_suite_add_simple_test(suite, "wbcLibraryDetails", test_wbc_library_details); 686 763 torture_suite_add_simple_test(suite, "wbcInterfaceDetails", test_wbc_interface_details); -
vendor/current/nsswitch/libwbclient/wbc_err_internal.h
r414 r988 30 30 goto done; \ 31 31 } \ 32 } while(0) ;32 } while(0) 33 33 34 34 #define BAIL_ON_PTR_ERROR(x, status) \ … … 40 40 status = WBC_ERR_SUCCESS; \ 41 41 } \ 42 } while (0) ;42 } while (0) 43 43 44 44 -
vendor/current/nsswitch/libwbclient/wbc_idmap.c
r740 r988 27 27 28 28 /* Convert a Windows SID to a Unix uid, allocating an uid if needed */ 29 wbcErr wbcSidToUid(const struct wbcDomainSid *sid, uid_t *puid) 29 wbcErr wbcCtxSidToUid(struct wbcContext *ctx, const struct wbcDomainSid *sid, 30 uid_t *puid) 30 31 { 31 32 struct winbindd_request request; … … 47 48 /* Make request */ 48 49 49 wbc_status = wbcRequestResponse( WINBINDD_SID_TO_UID,50 wbc_status = wbcRequestResponse(ctx, WINBINDD_SID_TO_UID, 50 51 &request, 51 52 &response); … … 58 59 done: 59 60 return wbc_status; 61 } 62 63 wbcErr wbcSidToUid(const struct wbcDomainSid *sid, uid_t *puid) 64 { 65 return wbcCtxSidToUid(NULL, sid, puid); 60 66 } 61 67 … … 68 74 69 75 /* Convert a Unix uid to a Windows SID, allocating a SID if needed */ 70 wbcErr wbcUidToSid(uid_t uid, struct wbcDomainSid *sid) 76 wbcErr wbcCtxUidToSid(struct wbcContext *ctx, uid_t uid, 77 struct wbcDomainSid *sid) 71 78 { 72 79 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 88 95 /* Make request */ 89 96 90 wbc_status = wbcRequestResponse( WINBINDD_UID_TO_SID,97 wbc_status = wbcRequestResponse(ctx, WINBINDD_UID_TO_SID, 91 98 &request, 92 99 &response); … … 98 105 done: 99 106 return wbc_status; 107 } 108 109 wbcErr wbcUidToSid(uid_t uid, struct wbcDomainSid *sid) 110 { 111 return wbcCtxUidToSid(NULL, uid, sid); 100 112 } 101 113 … … 116 128 **/ 117 129 118 wbcErr wbcSidToGid(const struct wbcDomainSid *sid, gid_t *pgid) 130 wbcErr wbcCtxSidToGid(struct wbcContext *ctx, const struct wbcDomainSid *sid, 131 gid_t *pgid) 119 132 { 120 133 struct winbindd_request request; … … 136 149 /* Make request */ 137 150 138 wbc_status = wbcRequestResponse( WINBINDD_SID_TO_GID,151 wbc_status = wbcRequestResponse(ctx, WINBINDD_SID_TO_GID, 139 152 &request, 140 153 &response); … … 149 162 } 150 163 164 wbcErr wbcSidToGid(const struct wbcDomainSid *sid, gid_t *pgid) 165 { 166 return wbcCtxSidToGid(NULL, sid, pgid); 167 } 151 168 152 169 /* Convert a Windows SID to a Unix gid if there already is a mapping */ … … 160 177 161 178 /* Convert a Unix gid to a Windows SID, allocating a SID if needed */ 162 wbcErr wbcGidToSid(gid_t gid, struct wbcDomainSid *sid) 179 wbcErr wbcCtxGidToSid(struct wbcContext *ctx, gid_t gid, 180 struct wbcDomainSid *sid) 163 181 { 164 182 struct winbindd_request request; … … 180 198 /* Make request */ 181 199 182 wbc_status = wbcRequestResponse( WINBINDD_GID_TO_SID,200 wbc_status = wbcRequestResponse(ctx, WINBINDD_GID_TO_SID, 183 201 &request, 184 202 &response); … … 190 208 done: 191 209 return wbc_status; 210 } 211 212 wbcErr wbcGidToSid(gid_t gid, struct wbcDomainSid *sid) 213 { 214 return wbcCtxGidToSid(NULL, gid, sid); 192 215 } 193 216 … … 200 223 201 224 /* Obtain a new uid from Winbind */ 202 wbcErr wbc AllocateUid(uid_t *puid)225 wbcErr wbcCtxAllocateUid(struct wbcContext *ctx, uid_t *puid) 203 226 { 204 227 struct winbindd_request request; … … 216 239 /* Make request */ 217 240 218 wbc_status = wbcRequestResponsePriv( WINBINDD_ALLOCATE_UID,241 wbc_status = wbcRequestResponsePriv(ctx, WINBINDD_ALLOCATE_UID, 219 242 &request, &response); 220 243 BAIL_ON_WBC_ERROR(wbc_status); … … 229 252 } 230 253 254 wbcErr wbcAllocateUid(uid_t *puid) 255 { 256 return wbcCtxAllocateUid(NULL, puid); 257 } 258 231 259 /* Obtain a new gid from Winbind */ 232 wbcErr wbc AllocateGid(gid_t *pgid)260 wbcErr wbcCtxAllocateGid(struct wbcContext *ctx, gid_t *pgid) 233 261 { 234 262 struct winbindd_request request; … … 246 274 /* Make request */ 247 275 248 wbc_status = wbcRequestResponsePriv( WINBINDD_ALLOCATE_GID,276 wbc_status = wbcRequestResponsePriv(ctx, WINBINDD_ALLOCATE_GID, 249 277 &request, &response); 250 278 BAIL_ON_WBC_ERROR(wbc_status); … … 257 285 done: 258 286 return wbc_status; 287 } 288 289 wbcErr wbcAllocateGid(gid_t *pgid) 290 { 291 return wbcCtxAllocateGid(NULL, pgid); 259 292 } 260 293 … … 300 333 301 334 /* Convert a list of SIDs */ 302 wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids, 303 struct wbcUnixId *ids) 335 wbcErr wbcCtxSidsToUnixIds(struct wbcContext *ctx, 336 const struct wbcDomainSid *sids, 337 uint32_t num_sids, struct wbcUnixId *ids) 304 338 { 305 339 struct winbindd_request request; … … 342 376 request.extra_len = p - sidlist; 343 377 344 wbc_status = wbcRequestResponse( WINBINDD_SIDS_TO_XIDS,378 wbc_status = wbcRequestResponse(ctx, WINBINDD_SIDS_TO_XIDS, 345 379 &request, &response); 346 380 free(sidlist); … … 371 405 id->id.gid = strtoul(p+1, &q, 10); 372 406 break; 407 case 'B': 408 id->type = WBC_ID_TYPE_BOTH; 409 id->id.uid = strtoul(p+1, &q, 10); 410 break; 373 411 default: 374 412 id->type = WBC_ID_TYPE_NOT_SPECIFIED; 375 q = p;413 q = strchr(p, '\n'); 376 414 break; 377 415 }; 378 if (q [0] != '\n') {416 if (q == NULL || q[0] != '\n') { 379 417 goto wbc_err_invalid; 380 418 } … … 390 428 return wbc_status; 391 429 } 430 431 wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids, 432 struct wbcUnixId *ids) 433 { 434 return wbcCtxSidsToUnixIds(NULL, sids, num_sids, ids); 435 } -
vendor/current/nsswitch/libwbclient/wbc_pam.c
r740 r988 29 29 30 30 /* Authenticate a username/password pair */ 31 wbcErr wbc AuthenticateUser(const char *username,32 const char *password)31 wbcErr wbcCtxAuthenticateUser(struct wbcContext *ctx, 32 const char *username, const char *password) 33 33 { 34 34 wbcErr wbc_status = WBC_ERR_SUCCESS; … … 41 41 params.password.plaintext = password; 42 42 43 wbc_status = wbc AuthenticateUserEx(¶ms, NULL, NULL);43 wbc_status = wbcCtxAuthenticateUserEx(ctx, ¶ms, NULL, NULL); 44 44 BAIL_ON_WBC_ERROR(wbc_status); 45 45 46 46 done: 47 47 return wbc_status; 48 } 49 50 wbcErr wbcAuthenticateUser(const char *username, const char *password) 51 { 52 return wbcCtxAuthenticateUser(NULL, username, password); 48 53 } 49 54 … … 343 348 344 349 /* Authenticate with more detailed information */ 345 wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, 346 struct wbcAuthUserInfo **info, 347 struct wbcAuthErrorInfo **error) 350 wbcErr wbcCtxAuthenticateUserEx(struct wbcContext *ctx, 351 const struct wbcAuthUserParams *params, 352 struct wbcAuthUserInfo **info, 353 struct wbcAuthErrorInfo **error) 348 354 { 349 355 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 364 370 } 365 371 366 if ( !params->account_name) {372 if (params->level != WBC_AUTH_USER_LEVEL_PAC && !params->account_name) { 367 373 wbc_status = WBC_ERR_INVALID_PARAM; 368 374 BAIL_ON_WBC_ERROR(wbc_status); … … 389 395 ZERO_STRUCT(sep_response); 390 396 391 wbc_status = wbcRequestResponse( WINBINDD_INFO,397 wbc_status = wbcRequestResponse(ctx, WINBINDD_INFO, 392 398 NULL, &sep_response); 393 399 BAIL_ON_WBC_ERROR(wbc_status); … … 491 497 } 492 498 break; 499 500 case WBC_AUTH_USER_LEVEL_PAC: 501 cmd = WINBINDD_PAM_AUTH_CRAP; 502 request.flags = WBFLAG_PAM_AUTH_PAC | WBFLAG_PAM_INFO3_TEXT; 503 request.extra_data.data = malloc(params->password.pac.length); 504 if (request.extra_data.data == NULL) { 505 wbc_status = WBC_ERR_NO_MEMORY; 506 BAIL_ON_WBC_ERROR(wbc_status); 507 } 508 memcpy(request.extra_data.data, params->password.pac.data, 509 params->password.pac.length); 510 request.extra_len = params->password.pac.length; 511 break; 512 493 513 default: 494 514 break; … … 505 525 506 526 if (cmd == WINBINDD_PAM_AUTH_CRAP) { 507 wbc_status = wbcRequestResponsePriv(cmd, &request, &response); 527 wbc_status = wbcRequestResponsePriv(ctx, cmd, 528 &request, &response); 508 529 } else { 509 wbc_status = wbcRequestResponse(cmd, &request, &response); 530 wbc_status = wbcRequestResponse(ctx, cmd, 531 &request, &response); 510 532 } 511 533 if (response.data.auth.nt_status != 0) { … … 534 556 } 535 557 558 wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, 559 struct wbcAuthUserInfo **info, 560 struct wbcAuthErrorInfo **error) 561 { 562 return wbcCtxAuthenticateUserEx(NULL, params, info, error); 563 } 564 536 565 /* Trigger a verification of the trust credentials of a specific domain */ 537 wbcErr wbcC heckTrustCredentials(const char *domain,538 struct wbcAuthErrorInfo **error)566 wbcErr wbcCtxCheckTrustCredentials(struct wbcContext *ctx, const char *domain, 567 struct wbcAuthErrorInfo **error) 539 568 { 540 569 struct winbindd_request request; … … 552 581 /* Send request */ 553 582 554 wbc_status = wbcRequestResponsePriv( WINBINDD_CHECK_MACHACC,583 wbc_status = wbcRequestResponsePriv(ctx, WINBINDD_CHECK_MACHACC, 555 584 &request, &response); 556 585 if (response.data.auth.nt_status != 0) { … … 570 599 } 571 600 601 wbcErr wbcCheckTrustCredentials(const char *domain, 602 struct wbcAuthErrorInfo **error) 603 { 604 return wbcCtxCheckTrustCredentials(NULL, domain, error); 605 } 606 572 607 /* Trigger a change of the trust credentials for a specific domain */ 573 wbcErr wbcC hangeTrustCredentials(const char *domain,574 struct wbcAuthErrorInfo **error)608 wbcErr wbcCtxChangeTrustCredentials(struct wbcContext *ctx, const char *domain, 609 struct wbcAuthErrorInfo **error) 575 610 { 576 611 struct winbindd_request request; … … 588 623 /* Send request */ 589 624 590 wbc_status = wbcRequestResponsePriv( WINBINDD_CHANGE_MACHACC,591 &request, &response);625 wbc_status = wbcRequestResponsePriv(ctx, WINBINDD_CHANGE_MACHACC, 626 &request, &response); 592 627 if (response.data.auth.nt_status != 0) { 593 628 if (error) { … … 606 641 } 607 642 643 wbcErr wbcChangeTrustCredentials(const char *domain, 644 struct wbcAuthErrorInfo **error) 645 { 646 return wbcCtxChangeTrustCredentials(NULL, domain, error); 647 } 648 608 649 /* 609 650 * Trigger a no-op NETLOGON call. Lightweight version of 610 651 * wbcCheckTrustCredentials 611 652 */ 653 wbcErr wbcCtxPingDc(struct wbcContext *ctx, const char *domain, 654 struct wbcAuthErrorInfo **error) 655 { 656 return wbcCtxPingDc2(ctx, domain, error, NULL); 657 } 658 612 659 wbcErr wbcPingDc(const char *domain, struct wbcAuthErrorInfo **error) 660 { 661 return wbcPingDc2(domain, error, NULL); 662 } 663 664 /* 665 * Trigger a no-op NETLOGON call. Lightweight version of 666 * wbcCheckTrustCredentials, optionally return attempted DC 667 */ 668 wbcErr wbcCtxPingDc2(struct wbcContext *ctx, const char *domain, 669 struct wbcAuthErrorInfo **error, char **dcname) 613 670 { 614 671 struct winbindd_request request; … … 616 673 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 617 674 618 if (domain) {619 /*620 * the current protocol doesn't support621 * specifying a domain622 */623 wbc_status = WBC_ERR_NOT_IMPLEMENTED;624 BAIL_ON_WBC_ERROR(wbc_status);625 }626 627 675 ZERO_STRUCT(request); 628 676 ZERO_STRUCT(response); 629 677 678 if (domain) { 679 strncpy(request.domain_name, domain, 680 sizeof(request.domain_name)-1); 681 } 682 630 683 /* Send request */ 631 684 632 wbc_status = wbcRequestResponse( WINBINDD_PING_DC,685 wbc_status = wbcRequestResponse(ctx, WINBINDD_PING_DC, 633 686 &request, 634 687 &response); 688 689 if (dcname && response.extra_data.data) { 690 size_t len; 691 692 len = response.length - sizeof(struct winbindd_response); 693 *dcname = wbcAllocateMemory(1, len, NULL); 694 BAIL_ON_PTR_ERROR(*dcname, wbc_status); 695 696 strlcpy(*dcname, response.extra_data.data, len); 697 } 698 635 699 if (response.data.auth.nt_status != 0) { 636 700 if (error) { … … 649 713 } 650 714 715 wbcErr wbcPingDc2(const char *domain, struct wbcAuthErrorInfo **error, 716 char **dcname) 717 { 718 return wbcCtxPingDc2(NULL, domain, error, dcname); 719 } 720 651 721 /* Trigger an extended logoff notification to Winbind for a specific user */ 652 wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params, 653 struct wbcAuthErrorInfo **error) 722 wbcErr wbcCtxLogoffUserEx(struct wbcContext *ctx, 723 const struct wbcLogoffUserParams *params, 724 struct wbcAuthErrorInfo **error) 654 725 { 655 726 struct winbindd_request request; … … 714 785 /* Send request */ 715 786 716 wbc_status = wbcRequestResponse( WINBINDD_PAM_LOGOFF,787 wbc_status = wbcRequestResponse(ctx, WINBINDD_PAM_LOGOFF, 717 788 &request, 718 789 &response); … … 735 806 } 736 807 808 wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params, 809 struct wbcAuthErrorInfo **error) 810 { 811 return wbcCtxLogoffUserEx(NULL, params, error); 812 } 813 737 814 /* Trigger a logoff notification to Winbind for a specific user */ 815 wbcErr wbcCtxLogoffUser(struct wbcContext *ctx, 816 const char *username, uid_t uid, 817 const char *ccfilename) 818 { 819 struct winbindd_request request; 820 struct winbindd_response response; 821 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 822 823 /* validate input */ 824 825 if (!username) { 826 wbc_status = WBC_ERR_INVALID_PARAM; 827 BAIL_ON_WBC_ERROR(wbc_status); 828 } 829 830 ZERO_STRUCT(request); 831 ZERO_STRUCT(response); 832 833 strncpy(request.data.logoff.user, username, 834 sizeof(request.data.logoff.user)-1); 835 request.data.logoff.uid = uid; 836 837 if (ccfilename) { 838 strncpy(request.data.logoff.krb5ccname, ccfilename, 839 sizeof(request.data.logoff.krb5ccname)-1); 840 } 841 842 /* Send request */ 843 844 wbc_status = wbcRequestResponse(ctx, WINBINDD_PAM_LOGOFF, 845 &request, 846 &response); 847 848 /* Take the response above and return it to the caller */ 849 850 done: 851 return wbc_status; 852 } 853 738 854 wbcErr wbcLogoffUser(const char *username, 739 855 uid_t uid, 740 856 const char *ccfilename) 741 857 { 742 struct winbindd_request request; 743 struct winbindd_response response; 744 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 745 746 /* validate input */ 747 748 if (!username) { 749 wbc_status = WBC_ERR_INVALID_PARAM; 750 BAIL_ON_WBC_ERROR(wbc_status); 751 } 752 753 ZERO_STRUCT(request); 754 ZERO_STRUCT(response); 755 756 strncpy(request.data.logoff.user, username, 757 sizeof(request.data.logoff.user)-1); 758 request.data.logoff.uid = uid; 759 760 if (ccfilename) { 761 strncpy(request.data.logoff.krb5ccname, ccfilename, 762 sizeof(request.data.logoff.krb5ccname)-1); 763 } 764 765 /* Send request */ 766 767 wbc_status = wbcRequestResponse(WINBINDD_PAM_LOGOFF, 768 &request, 769 &response); 770 771 /* Take the response above and return it to the caller */ 772 773 done: 774 return wbc_status; 858 return wbcCtxLogoffUser(NULL, username, uid, ccfilename); 775 859 } 776 860 777 861 /* Change a password for a user with more detailed information upon failure */ 778 wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params, 779 struct wbcAuthErrorInfo **error, 780 enum wbcPasswordChangeRejectReason *reject_reason, 781 struct wbcUserPasswordPolicyInfo **policy) 862 wbcErr wbcCtxChangeUserPasswordEx(struct wbcContext *ctx, 863 const struct wbcChangePasswordParams *params, 864 struct wbcAuthErrorInfo **error, 865 enum wbcPasswordChangeRejectReason *reject_reason, 866 struct wbcUserPasswordPolicyInfo **policy) 782 867 { 783 868 struct winbindd_request request; … … 938 1023 /* Send request */ 939 1024 940 wbc_status = wbcRequestResponse(c md,1025 wbc_status = wbcRequestResponse(ctx, cmd, 941 1026 &request, 942 1027 &response); … … 973 1058 } 974 1059 1060 wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params, 1061 struct wbcAuthErrorInfo **error, 1062 enum wbcPasswordChangeRejectReason *reject_reason, 1063 struct wbcUserPasswordPolicyInfo **policy) 1064 { 1065 return wbcCtxChangeUserPasswordEx(NULL, params, error, 1066 reject_reason, policy); 1067 } 1068 975 1069 /* Change a password for a user */ 976 wbcErr wbcChangeUserPassword(const char *username, 977 const char *old_password, 978 const char *new_password) 1070 wbcErr wbcCtxChangeUserPassword(struct wbcContext *ctx, 1071 const char *username, 1072 const char *old_password, 1073 const char *new_password) 979 1074 { 980 1075 wbcErr wbc_status = WBC_ERR_SUCCESS; … … 988 1083 params.new_password.plaintext = new_password; 989 1084 990 wbc_status = wbcC hangeUserPasswordEx(¶ms,991 992 993 1085 wbc_status = wbcCtxChangeUserPasswordEx(ctx, ¶ms, 1086 NULL, 1087 NULL, 1088 NULL); 994 1089 BAIL_ON_WBC_ERROR(wbc_status); 995 1090 … … 998 1093 } 999 1094 1095 wbcErr wbcChangeUserPassword(const char *username, 1096 const char *old_password, 1097 const char *new_password) 1098 { 1099 return wbcCtxChangeUserPassword(NULL, username, 1100 old_password, new_password); 1101 } 1102 1000 1103 /* Logon a User */ 1001 wbcErr wbcLogonUser(const struct wbcLogonUserParams *params, 1002 struct wbcLogonUserInfo **info, 1003 struct wbcAuthErrorInfo **error, 1004 struct wbcUserPasswordPolicyInfo **policy) 1104 wbcErr wbcCtxLogonUser(struct wbcContext *ctx, 1105 const struct wbcLogonUserParams *params, 1106 struct wbcLogonUserInfo **info, 1107 struct wbcAuthErrorInfo **error, 1108 struct wbcUserPasswordPolicyInfo **policy) 1005 1109 { 1006 1110 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 1104 1208 } 1105 1209 1106 wbc_status = wbcRequestResponse( WINBINDD_PAM_AUTH,1210 wbc_status = wbcRequestResponse(ctx, WINBINDD_PAM_AUTH, 1107 1211 &request, 1108 1212 &response); … … 1138 1242 } 1139 1243 1244 wbcErr wbcLogonUser(const struct wbcLogonUserParams *params, 1245 struct wbcLogonUserInfo **info, 1246 struct wbcAuthErrorInfo **error, 1247 struct wbcUserPasswordPolicyInfo **policy) 1248 { 1249 return wbcCtxLogonUser(NULL, params, info, error, policy); 1250 } 1251 1140 1252 static void wbcCredentialCacheInfoDestructor(void *ptr) 1141 1253 { … … 1146 1258 1147 1259 /* Authenticate a user with cached credentials */ 1148 wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params, 1149 struct wbcCredentialCacheInfo **info, 1150 struct wbcAuthErrorInfo **error) 1260 wbcErr wbcCtxCredentialCache(struct wbcContext *ctx, 1261 struct wbcCredentialCacheParams *params, 1262 struct wbcCredentialCacheInfo **info, 1263 struct wbcAuthErrorInfo **error) 1151 1264 { 1152 1265 wbcErr status = WBC_ERR_UNKNOWN_FAILURE; … … 1161 1274 ZERO_STRUCT(response); 1162 1275 1163 if (info != NULL) { 1164 *info = NULL; 1165 } 1276 *info = NULL; 1277 1166 1278 if (error != NULL) { 1167 1279 *error = NULL; … … 1174 1286 } 1175 1287 1288 for (i=0; i<params->num_blobs; i++) { 1289 /* 1290 * Older callers may used to provide the NEGOTIATE request 1291 * as "initial_blob", but it was completely ignored by winbindd. 1292 * 1293 * So we keep ignoring it. 1294 * 1295 * A new callers that is capable to support "new_spnego", 1296 * will provide the NEGOTIATE request as "negotiate_blob" 1297 * instead. 1298 */ 1299 if (strcasecmp(params->blobs[i].name, "negotiate_blob") == 0) { 1300 if (initial_blob != NULL) { 1301 status = WBC_ERR_INVALID_PARAM; 1302 goto fail; 1303 } 1304 initial_blob = ¶ms->blobs[i]; 1305 continue; 1306 } 1307 if (strcasecmp(params->blobs[i].name, "challenge_blob") == 0) { 1308 if (challenge_blob != NULL) { 1309 status = WBC_ERR_INVALID_PARAM; 1310 goto fail; 1311 } 1312 challenge_blob = ¶ms->blobs[i]; 1313 continue; 1314 } 1315 } 1316 1176 1317 if (params->domain_name != NULL) { 1177 status = wbcRequestResponse(WINBINDD_INFO, NULL, &response); 1318 status = wbcRequestResponse(ctx, WINBINDD_INFO, 1319 NULL, &response); 1178 1320 if (!WBC_ERROR_IS_OK(status)) { 1179 1321 goto fail; … … 1191 1333 request.data.ccache_ntlm_auth.uid = getuid(); 1192 1334 1193 for (i=0; i<params->num_blobs; i++) {1194 if (strcasecmp(params->blobs[i].name, "initial_blob") == 0) {1195 initial_blob = ¶ms->blobs[i];1196 break;1197 }1198 if (strcasecmp(params->blobs[i].name, "challenge_blob") == 0) {1199 challenge_blob = ¶ms->blobs[i];1200 break;1201 }1202 }1203 1204 1335 request.data.ccache_ntlm_auth.initial_blob_len = 0; 1205 1336 request.data.ccache_ntlm_auth.challenge_blob_len = 0; … … 1235 1366 } 1236 1367 1237 status = wbcRequestResponse( WINBINDD_CCACHE_NTLMAUTH, &request,1238 &re sponse);1368 status = wbcRequestResponse(ctx, WINBINDD_CCACHE_NTLMAUTH, 1369 &request, &response); 1239 1370 if (!WBC_ERROR_IS_OK(status)) { 1240 1371 goto fail; … … 1264 1395 goto fail; 1265 1396 } 1397 if (response.data.ccache_ntlm_auth.new_spnego) { 1398 status = wbcAddNamedBlob( 1399 &result->num_blobs, &result->blobs, "new_spnego", 0, 1400 &response.data.ccache_ntlm_auth.new_spnego, 1401 sizeof(response.data.ccache_ntlm_auth.new_spnego)); 1402 if (!WBC_ERROR_IS_OK(status)) { 1403 goto fail; 1404 } 1405 } 1266 1406 1267 1407 *info = result; … … 1275 1415 } 1276 1416 1417 wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params, 1418 struct wbcCredentialCacheInfo **info, 1419 struct wbcAuthErrorInfo **error) 1420 { 1421 return wbcCtxCredentialCache(NULL, params, info, error); 1422 } 1423 1277 1424 /* Authenticate a user with cached credentials */ 1278 wbcErr wbcCredentialSave(const char *user, const char *password) 1425 wbcErr wbcCtxCredentialSave(struct wbcContext *ctx, 1426 const char *user, const char *password) 1279 1427 { 1280 1428 struct winbindd_request request; … … 1290 1438 request.data.ccache_save.uid = getuid(); 1291 1439 1292 return wbcRequestResponse(WINBINDD_CCACHE_SAVE, &request, &response); 1293 } 1440 return wbcRequestResponse(ctx, WINBINDD_CCACHE_SAVE, &request, &response); 1441 } 1442 1443 wbcErr wbcCredentialSave(const char *user, const char *password) 1444 { 1445 return wbcCtxCredentialSave(NULL, user, password); 1446 } -
vendor/current/nsswitch/libwbclient/wbc_pwd.c
r740 r988 5 5 6 6 Copyright (C) Gerald (Jerry) Carter 2007 7 Copyright (C) Matthew Newton 2015 7 8 8 9 … … 168 169 169 170 /* Fill in a struct passwd* for a domain user based on username */ 170 wbcErr wbcGetpwnam(const char *name, struct passwd **pwd) 171 wbcErr wbcCtxGetpwnam(struct wbcContext *ctx, 172 const char *name, struct passwd **pwd) 171 173 { 172 174 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 188 190 strncpy(request.data.username, name, sizeof(request.data.username)-1); 189 191 190 wbc_status = wbcRequestResponse( WINBINDD_GETPWNAM,192 wbc_status = wbcRequestResponse(ctx, WINBINDD_GETPWNAM, 191 193 &request, 192 194 &response); … … 200 202 } 201 203 204 wbcErr wbcGetpwnam(const char *name, struct passwd **pwd) 205 { 206 return wbcCtxGetpwnam(NULL, name, pwd); 207 } 208 202 209 /* Fill in a struct passwd* for a domain user based on uid */ 203 wbcErr wbc Getpwuid(uid_t uid, struct passwd **pwd)210 wbcErr wbcCtxGetpwuid(struct wbcContext *ctx, uid_t uid, struct passwd **pwd) 204 211 { 205 212 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 219 226 request.data.uid = uid; 220 227 221 wbc_status = wbcRequestResponse( WINBINDD_GETPWUID,228 wbc_status = wbcRequestResponse(ctx, WINBINDD_GETPWUID, 222 229 &request, 223 230 &response); … … 231 238 } 232 239 240 wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd) 241 { 242 return wbcCtxGetpwuid(NULL, uid, pwd); 243 } 244 233 245 /* Fill in a struct passwd* for a domain user based on sid */ 234 wbcErr wbcGetpwsid(struct wbcDomainSid *sid, struct passwd **pwd) 246 wbcErr wbcCtxGetpwsid(struct wbcContext *ctx, 247 struct wbcDomainSid *sid, struct passwd **pwd) 235 248 { 236 249 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 250 263 wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid)); 251 264 252 wbc_status = wbcRequestResponse( WINBINDD_GETPWSID,265 wbc_status = wbcRequestResponse(ctx, WINBINDD_GETPWSID, 253 266 &request, 254 267 &response); … … 262 275 } 263 276 277 wbcErr wbcGetpwsid(struct wbcDomainSid *sid, struct passwd **pwd) 278 { 279 return wbcCtxGetpwsid(NULL, sid, pwd); 280 } 281 264 282 /* Fill in a struct passwd* for a domain user based on username */ 265 wbcErr wbcGetgrnam(const char *name, struct group **grp) 283 wbcErr wbcCtxGetgrnam(struct wbcContext *ctx, 284 const char *name, struct group **grp) 266 285 { 267 286 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 283 302 strncpy(request.data.groupname, name, sizeof(request.data.groupname)-1); 284 303 285 wbc_status = wbcRequestResponse( WINBINDD_GETGRNAM,304 wbc_status = wbcRequestResponse(ctx, WINBINDD_GETGRNAM, 286 305 &request, 287 306 &response); … … 298 317 } 299 318 319 wbcErr wbcGetgrnam(const char *name, struct group **grp) 320 { 321 return wbcCtxGetgrnam(NULL, name, grp); 322 } 323 300 324 /* Fill in a struct passwd* for a domain user based on uid */ 301 wbcErr wbc Getgrgid(gid_t gid, struct group **grp)325 wbcErr wbcCtxGetgrgid(struct wbcContext *ctx, gid_t gid, struct group **grp) 302 326 { 303 327 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 317 341 request.data.gid = gid; 318 342 319 wbc_status = wbcRequestResponse( WINBINDD_GETGRGID,343 wbc_status = wbcRequestResponse(ctx, WINBINDD_GETGRGID, 320 344 &request, 321 345 &response); … … 332 356 } 333 357 334 /** @brief Number of cached passwd structs 335 * 336 */ 337 static uint32_t pw_cache_size; 338 339 /** @brief Position of the pwent context 340 * 341 */ 342 static uint32_t pw_cache_idx; 358 wbcErr wbcGetgrgid(gid_t gid, struct group **grp) 359 { 360 return wbcCtxGetgrgid(NULL, gid, grp); 361 } 343 362 344 363 /** @brief Winbindd response containing the passwd structs … … 348 367 349 368 /* Reset the passwd iterator */ 369 wbcErr wbcCtxSetpwent(struct wbcContext *ctx) 370 { 371 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 372 373 if (!ctx) { 374 ctx = wbcGetGlobalCtx(); 375 } 376 377 if (ctx->pw_cache_size > 0) { 378 ctx->pw_cache_idx = ctx->pw_cache_size = 0; 379 winbindd_free_response(&pw_response); 380 } 381 382 ZERO_STRUCT(pw_response); 383 384 wbc_status = wbcRequestResponse(ctx, WINBINDD_SETPWENT, 385 NULL, NULL); 386 BAIL_ON_WBC_ERROR(wbc_status); 387 388 done: 389 return wbc_status; 390 } 391 350 392 wbcErr wbcSetpwent(void) 351 393 { 352 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 353 354 if (pw_cache_size > 0) { 355 pw_cache_idx = pw_cache_size = 0; 394 return wbcCtxSetpwent(NULL); 395 } 396 397 /* Close the passwd iterator */ 398 wbcErr wbcCtxEndpwent(struct wbcContext *ctx) 399 { 400 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 401 402 if (!ctx) { 403 ctx = wbcGetGlobalCtx(); 404 } 405 406 if (ctx->pw_cache_size > 0) { 407 ctx->pw_cache_idx = ctx->pw_cache_size = 0; 356 408 winbindd_free_response(&pw_response); 357 409 } 358 410 359 ZERO_STRUCT(pw_response); 360 361 wbc_status = wbcRequestResponse(WINBINDD_SETPWENT, 411 wbc_status = wbcRequestResponse(ctx, WINBINDD_ENDPWENT, 362 412 NULL, NULL); 363 413 BAIL_ON_WBC_ERROR(wbc_status); … … 367 417 } 368 418 369 /* Close the passwd iterator */370 419 wbcErr wbcEndpwent(void) 371 420 { 372 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 373 374 if (pw_cache_size > 0) { 375 pw_cache_idx = pw_cache_size = 0; 376 winbindd_free_response(&pw_response); 377 } 378 379 wbc_status = wbcRequestResponse(WINBINDD_ENDPWENT, 380 NULL, NULL); 381 BAIL_ON_WBC_ERROR(wbc_status); 382 383 done: 384 return wbc_status; 421 return wbcCtxEndpwent(NULL); 385 422 } 386 423 387 424 /* Return the next struct passwd* entry from the pwent iterator */ 425 wbcErr wbcCtxGetpwent(struct wbcContext *ctx, struct passwd **pwd) 426 { 427 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 428 struct winbindd_request request; 429 struct winbindd_pw *wb_pw; 430 431 if (!ctx) { 432 ctx = wbcGetGlobalCtx(); 433 } 434 435 /* If there's a cached result, return that. */ 436 if (ctx->pw_cache_idx < ctx->pw_cache_size) { 437 goto return_result; 438 } 439 440 /* Otherwise, query winbindd for some entries. */ 441 442 ctx->pw_cache_idx = 0; 443 444 winbindd_free_response(&pw_response); 445 446 ZERO_STRUCT(request); 447 request.data.num_entries = MAX_GETPWENT_USERS; 448 449 wbc_status = wbcRequestResponse(ctx, WINBINDD_GETPWENT, &request, 450 &pw_response); 451 452 BAIL_ON_WBC_ERROR(wbc_status); 453 454 ctx->pw_cache_size = pw_response.data.num_entries; 455 456 return_result: 457 458 wb_pw = (struct winbindd_pw *) pw_response.extra_data.data; 459 460 *pwd = copy_passwd_entry(&wb_pw[ctx->pw_cache_idx]); 461 462 BAIL_ON_PTR_ERROR(*pwd, wbc_status); 463 464 ctx->pw_cache_idx++; 465 466 done: 467 return wbc_status; 468 } 469 388 470 wbcErr wbcGetpwent(struct passwd **pwd) 389 471 { 390 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 391 struct winbindd_request request; 392 struct winbindd_pw *wb_pw; 393 394 /* If there's a cached result, return that. */ 395 if (pw_cache_idx < pw_cache_size) { 396 goto return_result; 397 } 398 399 /* Otherwise, query winbindd for some entries. */ 400 401 pw_cache_idx = 0; 402 403 winbindd_free_response(&pw_response); 404 405 ZERO_STRUCT(request); 406 request.data.num_entries = MAX_GETPWENT_USERS; 407 408 wbc_status = wbcRequestResponse(WINBINDD_GETPWENT, &request, 409 &pw_response); 410 411 BAIL_ON_WBC_ERROR(wbc_status); 412 413 pw_cache_size = pw_response.data.num_entries; 414 415 return_result: 416 417 wb_pw = (struct winbindd_pw *) pw_response.extra_data.data; 418 419 *pwd = copy_passwd_entry(&wb_pw[pw_cache_idx]); 420 421 BAIL_ON_PTR_ERROR(*pwd, wbc_status); 422 423 pw_cache_idx++; 424 425 done: 426 return wbc_status; 427 } 428 429 /** @brief Number of cached group structs 430 * 431 */ 432 static uint32_t gr_cache_size; 433 434 /** @brief Position of the grent context 435 * 436 */ 437 static uint32_t gr_cache_idx; 472 return wbcCtxGetpwent(NULL, pwd); 473 } 438 474 439 475 /** @brief Winbindd response containing the group structs … … 443 479 444 480 /* Reset the group iterator */ 481 wbcErr wbcCtxSetgrent(struct wbcContext *ctx) 482 { 483 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 484 485 if (!ctx) { 486 ctx = wbcGetGlobalCtx(); 487 } 488 489 if (ctx->gr_cache_size > 0) { 490 ctx->gr_cache_idx = ctx->gr_cache_size = 0; 491 winbindd_free_response(&gr_response); 492 } 493 494 ZERO_STRUCT(gr_response); 495 496 wbc_status = wbcRequestResponse(ctx, WINBINDD_SETGRENT, 497 NULL, NULL); 498 BAIL_ON_WBC_ERROR(wbc_status); 499 500 done: 501 return wbc_status; 502 } 503 445 504 wbcErr wbcSetgrent(void) 446 505 { 447 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 448 449 if (gr_cache_size > 0) { 450 gr_cache_idx = gr_cache_size = 0; 506 return wbcCtxSetgrent(NULL); 507 } 508 509 /* Close the group iterator */ 510 wbcErr wbcCtxEndgrent(struct wbcContext *ctx) 511 { 512 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 513 514 if (!ctx) { 515 ctx = wbcGetGlobalCtx(); 516 } 517 518 if (ctx->gr_cache_size > 0) { 519 ctx->gr_cache_idx = ctx->gr_cache_size = 0; 451 520 winbindd_free_response(&gr_response); 452 521 } 453 522 454 ZERO_STRUCT(gr_response); 455 456 wbc_status = wbcRequestResponse(WINBINDD_SETGRENT, 523 wbc_status = wbcRequestResponse(ctx, WINBINDD_ENDGRENT, 457 524 NULL, NULL); 458 525 BAIL_ON_WBC_ERROR(wbc_status); … … 462 529 } 463 530 464 /* Close the group iterator */465 531 wbcErr wbcEndgrent(void) 466 532 { 467 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 468 469 if (gr_cache_size > 0) { 470 gr_cache_idx = gr_cache_size = 0; 471 winbindd_free_response(&gr_response); 472 } 473 474 wbc_status = wbcRequestResponse(WINBINDD_ENDGRENT, 475 NULL, NULL); 476 BAIL_ON_WBC_ERROR(wbc_status); 477 478 done: 479 return wbc_status; 533 return wbcCtxEndgrent(NULL); 480 534 } 481 535 482 536 /* Return the next struct group* entry from the pwent iterator */ 483 wbcErr wbc Getgrent(struct group **grp)537 wbcErr wbcCtxGetgrent(struct wbcContext *ctx, struct group **grp) 484 538 { 485 539 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 488 542 uint32_t mem_ofs; 489 543 544 if (!ctx) { 545 ctx = wbcGetGlobalCtx(); 546 } 547 490 548 /* If there's a cached result, return that. */ 491 if ( gr_cache_idx <gr_cache_size) {549 if (ctx->gr_cache_idx < ctx->gr_cache_size) { 492 550 goto return_result; 493 551 } … … 495 553 /* Otherwise, query winbindd for some entries. */ 496 554 497 gr_cache_idx = 0;555 ctx->gr_cache_idx = 0; 498 556 499 557 winbindd_free_response(&gr_response); … … 502 560 request.data.num_entries = MAX_GETGRENT_GROUPS; 503 561 504 wbc_status = wbcRequestResponse( WINBINDD_GETGRENT, &request,505 & gr_response);506 507 BAIL_ON_WBC_ERROR(wbc_status); 508 509 gr_cache_size = gr_response.data.num_entries;562 wbc_status = wbcRequestResponse(ctx, WINBINDD_GETGRENT, 563 &request, &gr_response); 564 565 BAIL_ON_WBC_ERROR(wbc_status); 566 567 ctx->gr_cache_size = gr_response.data.num_entries; 510 568 511 569 return_result: … … 513 571 wb_gr = (struct winbindd_gr *) gr_response.extra_data.data; 514 572 515 mem_ofs = wb_gr[ gr_cache_idx].gr_mem_ofs +516 gr_cache_size * sizeof(struct winbindd_gr);517 518 *grp = copy_group_entry(&wb_gr[ gr_cache_idx],573 mem_ofs = wb_gr[ctx->gr_cache_idx].gr_mem_ofs + 574 ctx->gr_cache_size * sizeof(struct winbindd_gr); 575 576 *grp = copy_group_entry(&wb_gr[ctx->gr_cache_idx], 519 577 ((char *)gr_response.extra_data.data)+mem_ofs); 520 578 521 579 BAIL_ON_PTR_ERROR(*grp, wbc_status); 522 580 523 gr_cache_idx++;581 ctx->gr_cache_idx++; 524 582 525 583 done: … … 527 585 } 528 586 587 wbcErr wbcGetgrent(struct group **grp) 588 { 589 return wbcCtxGetgrent(NULL, grp); 590 } 591 529 592 /* Return the next struct group* entry from the pwent iterator */ 530 wbcErr wbc Getgrlist(struct group **grp)593 wbcErr wbcCtxGetgrlist(struct wbcContext *ctx, struct group **grp) 531 594 { 532 595 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 534 597 struct winbindd_gr *wb_gr; 535 598 599 if (!ctx) { 600 ctx = wbcGetGlobalCtx(); 601 } 602 536 603 /* If there's a cached result, return that. */ 537 if ( gr_cache_idx <gr_cache_size) {604 if (ctx->gr_cache_idx < ctx->gr_cache_size) { 538 605 goto return_result; 539 606 } … … 541 608 /* Otherwise, query winbindd for some entries. */ 542 609 543 gr_cache_idx = 0;610 ctx->gr_cache_idx = 0; 544 611 545 612 winbindd_free_response(&gr_response); … … 549 616 request.data.num_entries = MAX_GETGRENT_GROUPS; 550 617 551 wbc_status = wbcRequestResponse( WINBINDD_GETGRLST, &request,552 & gr_response);553 554 BAIL_ON_WBC_ERROR(wbc_status); 555 556 gr_cache_size = gr_response.data.num_entries;618 wbc_status = wbcRequestResponse(ctx, WINBINDD_GETGRLST, 619 &request, &gr_response); 620 621 BAIL_ON_WBC_ERROR(wbc_status); 622 623 ctx->gr_cache_size = gr_response.data.num_entries; 557 624 558 625 return_result: … … 560 627 wb_gr = (struct winbindd_gr *) gr_response.extra_data.data; 561 628 562 *grp = copy_group_entry(&wb_gr[ gr_cache_idx], NULL);629 *grp = copy_group_entry(&wb_gr[ctx->gr_cache_idx], NULL); 563 630 564 631 BAIL_ON_PTR_ERROR(*grp, wbc_status); 565 632 566 gr_cache_idx++;633 ctx->gr_cache_idx++; 567 634 568 635 done: … … 570 637 } 571 638 639 wbcErr wbcGetgrlist(struct group **grp) 640 { 641 return wbcCtxGetgrlist(NULL, grp); 642 } 643 572 644 /* Return the unix group array belonging to the given user */ 573 wbcErr wbcGetGroups(const char *account, 574 uint32_t *num_groups, 575 gid_t **_groups) 645 wbcErr wbcCtxGetGroups(struct wbcContext *ctx, const char *account, 646 uint32_t *num_groups, gid_t **_groups) 576 647 { 577 648 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 595 666 strncpy(request.data.username, account, sizeof(request.data.username)-1); 596 667 597 wbc_status = wbcRequestResponse( WINBINDD_GETGROUPS,668 wbc_status = wbcRequestResponse(ctx, WINBINDD_GETGROUPS, 598 669 &request, 599 670 &response); … … 619 690 return wbc_status; 620 691 } 692 693 wbcErr wbcGetGroups(const char *account, uint32_t *num_groups, gid_t **_groups) 694 { 695 return wbcCtxGetGroups(NULL, account, num_groups, _groups); 696 } -
vendor/current/nsswitch/libwbclient/wbc_sid.c
r860 r988 33 33 int wbcSidToStringBuf(const struct wbcDomainSid *sid, char *buf, int buflen) 34 34 { 35 uint 32_t id_auth;35 uint64_t id_auth; 36 36 int i, ofs; 37 37 … … 41 41 } 42 42 43 /* 44 * BIG NOTE: this function only does SIDS where the identauth is not 45 * >= ^32 in a range of 2^48. 46 */ 47 48 id_auth = sid->id_auth[5] + 49 (sid->id_auth[4] << 8) + 50 (sid->id_auth[3] << 16) + 51 (sid->id_auth[2] << 24); 52 53 ofs = snprintf(buf, buflen, "S-%u-%lu", 54 (unsigned int)sid->sid_rev_num, (unsigned long)id_auth); 43 id_auth = (uint64_t)sid->id_auth[5] + 44 ((uint64_t)sid->id_auth[4] << 8) + 45 ((uint64_t)sid->id_auth[3] << 16) + 46 ((uint64_t)sid->id_auth[2] << 24) + 47 ((uint64_t)sid->id_auth[1] << 32) + 48 ((uint64_t)sid->id_auth[0] << 40); 49 50 ofs = snprintf(buf, buflen, "S-%hhu-", (unsigned char)sid->sid_rev_num); 51 if (id_auth >= UINT32_MAX) { 52 ofs += snprintf(buf + ofs, MAX(buflen - ofs, 0), "0x%llx", 53 (unsigned long long)id_auth); 54 } else { 55 ofs += snprintf(buf + ofs, MAX(buflen - ofs, 0), "%llu", 56 (unsigned long long)id_auth); 57 } 55 58 56 59 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]);60 ofs += snprintf(buf + ofs, MAX(buflen - ofs, 0), "-%u", 61 (unsigned int)sid->sub_auths[i]); 59 62 } 60 63 return ofs; … … 89 92 } 90 93 94 #define AUTHORITY_MASK (~(0xffffffffffffULL)) 95 91 96 /* Convert a character string to a binary SID */ 92 97 wbcErr wbcStringToSid(const char *str, … … 95 100 const char *p; 96 101 char *q; 97 uint 32_t x;102 uint64_t x; 98 103 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 99 104 … … 116 121 117 122 p = str+2; 118 x = (uint 32_t)strtol(p, &q, 10);119 if (x==0 || !q || *q!='-') {123 x = (uint64_t)strtoul(p, &q, 10); 124 if (x==0 || x > UINT8_MAX || !q || *q!='-') { 120 125 wbc_status = WBC_ERR_INVALID_SID; 121 126 BAIL_ON_WBC_ERROR(wbc_status); … … 123 128 sid->sid_rev_num = (uint8_t)x; 124 129 125 /* Next the Identifier Authority. This is stored in big-endian 126 in a 6 byte array. */ 127 130 /* 131 * Next the Identifier Authority. This is stored big-endian in a 132 * 6 byte array. If the authority value is >= UINT_MAX, then it should 133 * be expressed as a hex value, according to MS-DTYP. 134 */ 128 135 p = q+1; 129 x = (uint32_t)strtol(p, &q, 10);130 if (!q || *q!='-' ) {136 x = strtoull(p, &q, 0); 137 if (!q || *q!='-' || (x & AUTHORITY_MASK)) { 131 138 wbc_status = WBC_ERR_INVALID_SID; 132 139 BAIL_ON_WBC_ERROR(wbc_status); 133 140 } 134 sid->id_auth[5] = (x & 0x000000 ff);135 sid->id_auth[4] = (x & 0x0000 ff00) >> 8;136 sid->id_auth[3] = (x & 0x00 ff0000) >> 16;137 sid->id_auth[2] = (x & 0x ff000000) >> 24;138 sid->id_auth[1] = 0;139 sid->id_auth[0] = 0;141 sid->id_auth[5] = (x & 0x0000000000ffULL); 142 sid->id_auth[4] = (x & 0x00000000ff00ULL) >> 8; 143 sid->id_auth[3] = (x & 0x000000ff0000ULL) >> 16; 144 sid->id_auth[2] = (x & 0x0000ff000000ULL) >> 24; 145 sid->id_auth[1] = (x & 0x00ff00000000ULL) >> 32; 146 sid->id_auth[0] = (x & 0xff0000000000ULL) >> 40; 140 147 141 148 /* now read the the subauthorities */ 142 143 149 p = q +1; 144 150 sid->num_auths = 0; 145 151 while (sid->num_auths < WBC_MAXSUBAUTHS) { 146 x =(uint32_t)strtoul(p, &q, 10);152 x = strtoull(p, &q, 10); 147 153 if (p == q) 148 154 break; 149 if ( q == NULL) {155 if (x > UINT32_MAX) { 150 156 wbc_status = WBC_ERR_INVALID_SID; 151 157 BAIL_ON_WBC_ERROR(wbc_status); … … 175 181 176 182 /* Convert a domain and name to SID */ 183 wbcErr wbcCtxLookupName(struct wbcContext *ctx, 184 const char *domain, 185 const char *name, 186 struct wbcDomainSid *sid, 187 enum wbcSidType *name_type) 188 { 189 struct winbindd_request request; 190 struct winbindd_response response; 191 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 192 193 if (!sid || !name_type) { 194 wbc_status = WBC_ERR_INVALID_PARAM; 195 BAIL_ON_WBC_ERROR(wbc_status); 196 } 197 198 /* Initialize request */ 199 200 ZERO_STRUCT(request); 201 ZERO_STRUCT(response); 202 203 /* dst is already null terminated from the memset above */ 204 205 strncpy(request.data.name.dom_name, domain, 206 sizeof(request.data.name.dom_name)-1); 207 strncpy(request.data.name.name, name, 208 sizeof(request.data.name.name)-1); 209 210 wbc_status = wbcRequestResponse(ctx, WINBINDD_LOOKUPNAME, 211 &request, 212 &response); 213 BAIL_ON_WBC_ERROR(wbc_status); 214 215 wbc_status = wbcStringToSid(response.data.sid.sid, sid); 216 BAIL_ON_WBC_ERROR(wbc_status); 217 218 *name_type = (enum wbcSidType)response.data.sid.type; 219 220 wbc_status = WBC_ERR_SUCCESS; 221 222 done: 223 return wbc_status; 224 } 225 177 226 wbcErr wbcLookupName(const char *domain, 178 227 const char *name, … … 180 229 enum wbcSidType *name_type) 181 230 { 182 struct winbindd_request request; 183 struct winbindd_response response; 184 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 185 186 if (!sid || !name_type) { 187 wbc_status = WBC_ERR_INVALID_PARAM; 188 BAIL_ON_WBC_ERROR(wbc_status); 189 } 190 191 /* Initialize request */ 192 193 ZERO_STRUCT(request); 194 ZERO_STRUCT(response); 195 196 /* dst is already null terminated from the memset above */ 197 198 strncpy(request.data.name.dom_name, domain, 199 sizeof(request.data.name.dom_name)-1); 200 strncpy(request.data.name.name, name, 201 sizeof(request.data.name.name)-1); 202 203 wbc_status = wbcRequestResponse(WINBINDD_LOOKUPNAME, 204 &request, 205 &response); 206 BAIL_ON_WBC_ERROR(wbc_status); 207 208 wbc_status = wbcStringToSid(response.data.sid.sid, sid); 209 BAIL_ON_WBC_ERROR(wbc_status); 210 211 *name_type = (enum wbcSidType)response.data.sid.type; 212 213 wbc_status = WBC_ERR_SUCCESS; 214 215 done: 216 return wbc_status; 231 return wbcCtxLookupName(NULL, domain, name, sid, name_type); 217 232 } 218 233 219 234 220 235 /* Convert a SID to a domain and name */ 221 wbcErr wbcLookupSid(const struct wbcDomainSid *sid, 222 char **pdomain, 223 char **pname, 224 enum wbcSidType *pname_type) 236 wbcErr wbcCtxLookupSid(struct wbcContext *ctx, 237 const struct wbcDomainSid *sid, 238 char **pdomain, 239 char **pname, 240 enum wbcSidType *pname_type) 225 241 { 226 242 struct winbindd_request request; … … 242 258 /* Make request */ 243 259 244 wbc_status = wbcRequestResponse(WINBINDD_LOOKUPSID, &request, 260 wbc_status = wbcRequestResponse(ctx, WINBINDD_LOOKUPSID, 261 &request, 245 262 &response); 246 263 if (!WBC_ERROR_IS_OK(wbc_status)) { … … 280 297 } 281 298 299 wbcErr wbcLookupSid(const struct wbcDomainSid *sid, 300 char **pdomain, 301 char **pname, 302 enum wbcSidType *pname_type) 303 { 304 return wbcCtxLookupSid(NULL, sid, pdomain, pname, pname_type); 305 } 306 282 307 static void wbcDomainInfosDestructor(void *ptr) 283 308 { … … 296 321 297 322 while (n->name != NULL) { 298 free(n->name);323 wbcFreeMemory(n->name); 299 324 n += 1; 300 325 } 301 326 } 302 327 303 wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids, 304 struct wbcDomainInfo **pdomains, int *pnum_domains, 305 struct wbcTranslatedName **pnames) 328 wbcErr wbcCtxLookupSids(struct wbcContext *ctx, 329 const struct wbcDomainSid *sids, int num_sids, 330 struct wbcDomainInfo **pdomains, int *pnum_domains, 331 struct wbcTranslatedName **pnames) 306 332 { 307 333 struct winbindd_request request; … … 345 371 request.extra_len = p - sidlist; 346 372 347 wbc_status = wbcRequestResponse( WINBINDD_LOOKUPSIDS,373 wbc_status = wbcRequestResponse(ctx, WINBINDD_LOOKUPSIDS, 348 374 &request, &response); 349 375 free(sidlist); … … 470 496 } 471 497 498 wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids, 499 struct wbcDomainInfo **pdomains, int *pnum_domains, 500 struct wbcTranslatedName **pnames) 501 { 502 return wbcCtxLookupSids(NULL, sids, num_sids, pdomains, 503 pnum_domains, pnames); 504 } 505 472 506 /* Translate a collection of RIDs within a domain to names */ 473 507 474 wbcErr wbc LookupRids(struct wbcDomainSid *dom_sid,508 wbcErr wbcCtxLookupRids(struct wbcContext *ctx, struct wbcDomainSid *dom_sid, 475 509 int num_rids, 476 510 uint32_t *rids, … … 522 556 request.extra_len = len; 523 557 524 wbc_status = wbcRequestResponse( WINBINDD_LOOKUPRIDS,558 wbc_status = wbcRequestResponse(ctx, WINBINDD_LOOKUPRIDS, 525 559 &request, 526 560 &response); … … 594 628 } 595 629 630 wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid, 631 int num_rids, 632 uint32_t *rids, 633 const char **pp_domain_name, 634 const char ***pnames, 635 enum wbcSidType **ptypes) 636 { 637 return wbcCtxLookupRids(NULL, dom_sid, num_rids, rids, 638 pp_domain_name, pnames, ptypes); 639 } 640 596 641 /* Get the groups a user belongs to */ 597 wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid, 598 bool domain_groups_only, 599 uint32_t *num_sids, 600 struct wbcDomainSid **_sids) 642 wbcErr wbcCtxLookupUserSids(struct wbcContext *ctx, 643 const struct wbcDomainSid *user_sid, 644 bool domain_groups_only, 645 uint32_t *num_sids, 646 struct wbcDomainSid **_sids) 601 647 { 602 648 uint32_t i; … … 626 672 } 627 673 628 wbc_status = wbcRequestResponse(c md,674 wbc_status = wbcRequestResponse(ctx, cmd, 629 675 &request, 630 676 &response); … … 667 713 } 668 714 715 wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid, 716 bool domain_groups_only, 717 uint32_t *num_sids, 718 struct wbcDomainSid **_sids) 719 { 720 return wbcCtxLookupUserSids(NULL, user_sid, domain_groups_only, 721 num_sids, _sids); 722 } 723 669 724 static inline 670 725 wbcErr _sid_to_rid(struct wbcDomainSid *sid, uint32_t *rid) … … 679 734 680 735 /* Get alias membership for sids */ 681 wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid, 682 struct wbcDomainSid *sids, 683 uint32_t num_sids, 684 uint32_t **alias_rids, 685 uint32_t *num_alias_rids) 736 wbcErr wbcCtxGetSidAliases(struct wbcContext *ctx, 737 const struct wbcDomainSid *dom_sid, 738 struct wbcDomainSid *sids, 739 uint32_t num_sids, 740 uint32_t **alias_rids, 741 uint32_t *num_alias_rids) 686 742 { 687 743 uint32_t i; … … 744 800 request.extra_len = extra_data_len; 745 801 746 wbc_status = wbcRequestResponse( WINBINDD_GETSIDALIASES,802 wbc_status = wbcRequestResponse(ctx, WINBINDD_GETSIDALIASES, 747 803 &request, 748 804 &response); … … 784 840 } 785 841 842 wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid, 843 struct wbcDomainSid *sids, 844 uint32_t num_sids, 845 uint32_t **alias_rids, 846 uint32_t *num_alias_rids) 847 { 848 return wbcCtxGetSidAliases(NULL, dom_sid, sids, num_sids, 849 alias_rids, num_alias_rids); 850 } 851 786 852 787 853 /* Lists Users */ 788 wbcErr wbcListUsers(const char *domain_name, 789 uint32_t *_num_users, 790 const char ***_users) 854 wbcErr wbcCtxListUsers(struct wbcContext *ctx, 855 const char *domain_name, 856 uint32_t *_num_users, 857 const char ***_users) 791 858 { 792 859 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 807 874 } 808 875 809 wbc_status = wbcRequestResponse( WINBINDD_LIST_USERS,876 wbc_status = wbcRequestResponse(ctx, WINBINDD_LIST_USERS, 810 877 &request, 811 878 &response); … … 859 926 } 860 927 928 wbcErr wbcListUsers(const char *domain_name, 929 uint32_t *_num_users, 930 const char ***_users) 931 { 932 return wbcCtxListUsers(NULL, domain_name, _num_users, _users); 933 } 934 861 935 /* Lists Groups */ 862 wbcErr wbcListGroups(const char *domain_name, 863 uint32_t *_num_groups, 864 const char ***_groups) 936 wbcErr wbcCtxListGroups(struct wbcContext *ctx, 937 const char *domain_name, 938 uint32_t *_num_groups, 939 const char ***_groups) 865 940 { 866 941 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 881 956 } 882 957 883 wbc_status = wbcRequestResponse( WINBINDD_LIST_GROUPS,958 wbc_status = wbcRequestResponse(ctx, WINBINDD_LIST_GROUPS, 884 959 &request, 885 960 &response); … … 933 1008 } 934 1009 935 wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid, 936 char **pdomain, 937 char **pfullname, 938 enum wbcSidType *pname_type) 1010 wbcErr wbcListGroups(const char *domain_name, 1011 uint32_t *_num_groups, 1012 const char ***_groups) 1013 { 1014 return wbcCtxListGroups(NULL, domain_name, _num_groups, _groups); 1015 } 1016 1017 wbcErr wbcCtxGetDisplayName(struct wbcContext *ctx, 1018 const struct wbcDomainSid *sid, 1019 char **pdomain, 1020 char **pfullname, 1021 enum wbcSidType *pname_type) 939 1022 { 940 1023 wbcErr wbc_status; … … 943 1026 enum wbcSidType name_type; 944 1027 945 wbc_status = wbc LookupSid(sid, &domain, &name, &name_type);1028 wbc_status = wbcCtxLookupSid(ctx, sid, &domain, &name, &name_type); 946 1029 BAIL_ON_WBC_ERROR(wbc_status); 947 1030 … … 950 1033 struct passwd *pwd; 951 1034 952 wbc_status = wbc SidToUid(sid, &uid);953 BAIL_ON_WBC_ERROR(wbc_status); 954 955 wbc_status = wbc Getpwuid(uid, &pwd);1035 wbc_status = wbcCtxSidToUid(ctx, sid, &uid); 1036 BAIL_ON_WBC_ERROR(wbc_status); 1037 1038 wbc_status = wbcCtxGetpwuid(ctx, uid, &pwd); 956 1039 BAIL_ON_WBC_ERROR(wbc_status); 957 1040 … … 976 1059 977 1060 return wbc_status; 1061 } 1062 1063 wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid, 1064 char **pdomain, 1065 char **pfullname, 1066 enum wbcSidType *pname_type) 1067 { 1068 return wbcCtxGetDisplayName(NULL, sid, pdomain, pfullname, pname_type); 978 1069 } 979 1070 -
vendor/current/nsswitch/libwbclient/wbc_util.c
r740 r988 29 29 /** @brief Ping winbindd to see if the daemon is running 30 30 * 31 * @param *ctx wbclient Context 32 * 31 33 * @return #wbcErr 32 34 **/ 33 wbcErr wbc Ping(void)35 wbcErr wbcCtxPing(struct wbcContext *ctx) 34 36 { 35 37 struct winbindd_request request; … … 41 43 ZERO_STRUCT(response); 42 44 43 return wbcRequestResponse(WINBINDD_PING, &request, &response); 45 return wbcRequestResponse(ctx, WINBINDD_PING, &request, &response); 46 } 47 48 wbcErr wbcPing(void) 49 { 50 return wbcCtxPing(NULL); 44 51 } 45 52 … … 61 68 */ 62 69 63 wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details) 70 wbcErr wbcCtxInterfaceDetails(struct wbcContext *ctx, 71 struct wbcInterfaceDetails **_details) 64 72 { 65 73 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 80 88 81 89 /* first the interface version */ 82 wbc_status = wbcRequestResponse(WINBINDD_INTERFACE_VERSION, NULL, &response); 90 wbc_status = wbcRequestResponse(ctx, WINBINDD_INTERFACE_VERSION, 91 NULL, &response); 83 92 BAIL_ON_WBC_ERROR(wbc_status); 84 93 info->interface_version = response.data.interface_version; 85 94 86 95 /* then the samba version and the winbind separator */ 87 wbc_status = wbcRequestResponse( WINBINDD_INFO, NULL, &response);96 wbc_status = wbcRequestResponse(ctx, WINBINDD_INFO, NULL, &response); 88 97 BAIL_ON_WBC_ERROR(wbc_status); 89 98 … … 93 102 94 103 /* then the local netbios name */ 95 wbc_status = wbcRequestResponse(WINBINDD_NETBIOS_NAME, NULL, &response); 104 wbc_status = wbcRequestResponse(ctx, WINBINDD_NETBIOS_NAME, 105 NULL, &response); 96 106 BAIL_ON_WBC_ERROR(wbc_status); 97 107 … … 100 110 101 111 /* then the local workgroup name */ 102 wbc_status = wbcRequestResponse(WINBINDD_DOMAIN_NAME, NULL, &response); 112 wbc_status = wbcRequestResponse(ctx, WINBINDD_DOMAIN_NAME, 113 NULL, &response); 103 114 BAIL_ON_WBC_ERROR(wbc_status); 104 115 … … 106 117 BAIL_ON_PTR_ERROR(info->netbios_domain, wbc_status); 107 118 108 wbc_status = wbc DomainInfo(info->netbios_domain, &domain);119 wbc_status = wbcCtxDomainInfo(ctx, info->netbios_domain, &domain); 109 120 if (wbc_status == WBC_ERR_DOMAIN_NOT_FOUND) { 110 121 /* maybe it's a standalone server */ … … 131 142 wbcFreeMemory(info); 132 143 return wbc_status; 144 } 145 146 wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details) 147 { 148 return wbcCtxInterfaceDetails(NULL, _details); 133 149 } 134 150 … … 148 164 */ 149 165 150 wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo) 166 wbcErr wbcCtxDomainInfo(struct wbcContext *ctx, 167 const char *domain, 168 struct wbcDomainInfo **dinfo) 151 169 { 152 170 struct winbindd_request request; … … 168 186 sizeof(request.domain_name)-1); 169 187 170 wbc_status = wbcRequestResponse( WINBINDD_DOMAIN_INFO,188 wbc_status = wbcRequestResponse(ctx, WINBINDD_DOMAIN_INFO, 171 189 &request, 172 190 &response); … … 204 222 } 205 223 224 wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo) 225 { 226 return wbcCtxDomainInfo(NULL, domain, dinfo); 227 } 228 206 229 /* 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) 230 wbcErr wbcCtxDcInfo(struct wbcContext *ctx, 231 const char *domain, size_t *num_dcs, 232 const char ***dc_names, const char ***dc_ips) 209 233 { 210 234 struct winbindd_request request; … … 227 251 } 228 252 229 wbc_status = wbcRequestResponse( WINBINDD_DC_INFO,253 wbc_status = wbcRequestResponse(ctx, WINBINDD_DC_INFO, 230 254 &request, &response); 231 255 BAIL_ON_WBC_ERROR(wbc_status); … … 291 315 } 292 316 317 wbcErr wbcDcInfo(const char *domain, size_t *num_dcs, 318 const char ***dc_names, const char ***dc_ips) 319 { 320 return wbcCtxDcInfo(NULL, domain, num_dcs, dc_names, dc_ips); 321 } 322 293 323 /* Resolve a NetbiosName via WINS */ 294 wbcErr wbcResolveWinsByName(const char *name, char **ip) 324 wbcErr wbcCtxResolveWinsByName(struct wbcContext *ctx, 325 const char *name, char **ip) 295 326 { 296 327 struct winbindd_request request; … … 307 338 sizeof(request.data.winsreq)-1); 308 339 309 wbc_status = wbcRequestResponse( WINBINDD_WINS_BYNAME,340 wbc_status = wbcRequestResponse(ctx, WINBINDD_WINS_BYNAME, 310 341 &request, 311 342 &response); … … 324 355 } 325 356 357 wbcErr wbcResolveWinsByName(const char *name, char **ip) 358 { 359 return wbcCtxResolveWinsByName(NULL, name, ip); 360 } 361 326 362 /* Resolve an IP address via WINS into a NetbiosName */ 327 wbcErr wbcResolveWinsByIP(const char *ip, char **name) 363 wbcErr wbcCtxResolveWinsByIP(struct wbcContext *ctx, 364 const char *ip, char **name) 328 365 { 329 366 struct winbindd_request request; … … 340 377 sizeof(request.data.winsreq)-1); 341 378 342 wbc_status = wbcRequestResponse( WINBINDD_WINS_BYIP,379 wbc_status = wbcRequestResponse(ctx, WINBINDD_WINS_BYIP, 343 380 &request, 344 381 &response); … … 355 392 done: 356 393 return wbc_status; 394 } 395 396 wbcErr wbcResolveWinsByIP(const char *ip, char **name) 397 { 398 return wbcCtxResolveWinsByIP(NULL, ip, name); 357 399 } 358 400 … … 467 509 468 510 /* Online/Offline status */ 469 470 511 r = s; 471 if (r == NULL) {472 wbc_status = WBC_ERR_INVALID_RESPONSE;473 BAIL_ON_WBC_ERROR(wbc_status);474 }475 512 if ( strcmp(r, "Offline") == 0) { 476 513 info->domain_flags |= WBC_DOMINFO_DOMAIN_OFFLINE; … … 495 532 496 533 /* Enumerate the domain trusts known by Winbind */ 497 wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains) 534 wbcErr wbcCtxListTrusts(struct wbcContext *ctx, 535 struct wbcDomainInfo **domains, size_t *num_domains) 498 536 { 499 537 struct winbindd_response response; … … 511 549 /* Send request */ 512 550 513 wbc_status = wbcRequestResponse( WINBINDD_LIST_TRUSTDOM,551 wbc_status = wbcRequestResponse(ctx, WINBINDD_LIST_TRUSTDOM, 514 552 NULL, 515 553 &response); … … 565 603 } 566 604 605 wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains) 606 { 607 return wbcCtxListTrusts(NULL, domains, num_domains); 608 } 609 567 610 static void wbcDomainControllerInfoDestructor(void *ptr) 568 611 { … … 573 616 574 617 /* Enumerate the domain trusts known by Winbind */ 575 wbcErr wbc LookupDomainController(const char *domain,576 uint32_t flags,577 struct wbcDomainControllerInfo **dc_info)618 wbcErr wbcCtxLookupDomainController(struct wbcContext *ctx, 619 const char *domain, uint32_t flags, 620 struct wbcDomainControllerInfo **dc_info) 578 621 { 579 622 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 604 647 /* Send request */ 605 648 606 wbc_status = wbcRequestResponse( WINBINDD_DSGETDCNAME,649 wbc_status = wbcRequestResponse(ctx, WINBINDD_DSGETDCNAME, 607 650 &request, 608 651 &response); … … 620 663 } 621 664 665 wbcErr wbcLookupDomainController(const char *domain, uint32_t flags, 666 struct wbcDomainControllerInfo **dc_info) 667 { 668 return wbcCtxLookupDomainController(NULL, domain, flags, dc_info); 669 } 670 622 671 static void wbcDomainControllerInfoExDestructor(void *ptr) 623 672 { 624 673 struct wbcDomainControllerInfoEx *i = 625 674 (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));675 free(discard_const_p(char, i->dc_unc)); 676 free(discard_const_p(char, i->dc_address)); 677 free(discard_const_p(char, i->domain_guid)); 678 free(discard_const_p(char, i->domain_name)); 679 free(discard_const_p(char, i->forest_name)); 680 free(discard_const_p(char, i->dc_site_name)); 681 free(discard_const_p(char, i->client_site_name)); 633 682 } 634 683 … … 694 743 695 744 /* Get extended domain controller information */ 745 wbcErr wbcCtxLookupDomainControllerEx(struct wbcContext *ctx, 746 const char *domain, 747 struct wbcGuid *guid, 748 const char *site, 749 uint32_t flags, 750 struct wbcDomainControllerInfoEx **dc_info) 751 { 752 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 753 struct winbindd_request request; 754 struct winbindd_response response; 755 756 /* validate input params */ 757 758 if (!domain || !dc_info) { 759 wbc_status = WBC_ERR_INVALID_PARAM; 760 BAIL_ON_WBC_ERROR(wbc_status); 761 } 762 763 ZERO_STRUCT(request); 764 ZERO_STRUCT(response); 765 766 request.data.dsgetdcname.flags = flags; 767 768 strncpy(request.data.dsgetdcname.domain_name, domain, 769 sizeof(request.data.dsgetdcname.domain_name)-1); 770 771 if (site) { 772 strncpy(request.data.dsgetdcname.site_name, site, 773 sizeof(request.data.dsgetdcname.site_name)-1); 774 } 775 776 if (guid) { 777 char *str = NULL; 778 779 wbc_status = wbcGuidToString(guid, &str); 780 BAIL_ON_WBC_ERROR(wbc_status); 781 782 strncpy(request.data.dsgetdcname.domain_guid, str, 783 sizeof(request.data.dsgetdcname.domain_guid)-1); 784 785 wbcFreeMemory(str); 786 } 787 788 /* Send request */ 789 790 wbc_status = wbcRequestResponse(ctx, WINBINDD_DSGETDCNAME, 791 &request, 792 &response); 793 BAIL_ON_WBC_ERROR(wbc_status); 794 795 if (dc_info) { 796 wbc_status = wbc_create_domain_controller_info_ex(&response, 797 dc_info); 798 BAIL_ON_WBC_ERROR(wbc_status); 799 } 800 801 wbc_status = WBC_ERR_SUCCESS; 802 done: 803 return wbc_status; 804 } 805 696 806 wbcErr wbcLookupDomainControllerEx(const char *domain, 697 807 struct wbcGuid *guid, … … 700 810 struct wbcDomainControllerInfoEx **dc_info) 701 811 { 702 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; 703 struct winbindd_request request; 704 struct winbindd_response response; 705 706 /* validate input params */ 707 708 if (!domain || !dc_info) { 709 wbc_status = WBC_ERR_INVALID_PARAM; 710 BAIL_ON_WBC_ERROR(wbc_status); 711 } 712 713 ZERO_STRUCT(request); 714 ZERO_STRUCT(response); 715 716 request.data.dsgetdcname.flags = flags; 717 718 strncpy(request.data.dsgetdcname.domain_name, domain, 719 sizeof(request.data.dsgetdcname.domain_name)-1); 720 721 if (site) { 722 strncpy(request.data.dsgetdcname.site_name, site, 723 sizeof(request.data.dsgetdcname.site_name)-1); 724 } 725 726 if (guid) { 727 char *str = NULL; 728 729 wbc_status = wbcGuidToString(guid, &str); 730 BAIL_ON_WBC_ERROR(wbc_status); 731 732 strncpy(request.data.dsgetdcname.domain_guid, str, 733 sizeof(request.data.dsgetdcname.domain_guid)-1); 734 735 wbcFreeMemory(str); 736 } 737 738 /* Send request */ 739 740 wbc_status = wbcRequestResponse(WINBINDD_DSGETDCNAME, 741 &request, 742 &response); 743 BAIL_ON_WBC_ERROR(wbc_status); 744 745 if (dc_info) { 746 wbc_status = wbc_create_domain_controller_info_ex(&response, 747 dc_info); 748 BAIL_ON_WBC_ERROR(wbc_status); 749 } 750 751 wbc_status = WBC_ERR_SUCCESS; 752 done: 753 return wbc_status; 812 return wbcCtxLookupDomainControllerEx(NULL, domain, guid, site, 813 flags, dc_info); 754 814 } 755 815 … … 759 819 760 820 while (b->name != NULL) { 761 free( (char *)(b->name));821 free(discard_const_p(char, b->name)); 762 822 free(b->blob.data); 763 823 b += 1; -
vendor/current/nsswitch/libwbclient/wbclient.c
r740 r988 5 5 6 6 Copyright (C) Gerald (Jerry) Carter 2007 7 Copyright (C) Matthew Newton 2015 7 8 8 9 … … 28 29 /* From wb_common.c */ 29 30 30 NSS_STATUS winbindd_request_response(int req_type, 31 struct winbindd_context; 32 33 NSS_STATUS winbindd_request_response(struct winbindd_context *wbctx, 34 int req_type, 31 35 struct winbindd_request *request, 32 36 struct winbindd_response *response); 33 NSS_STATUS winbindd_priv_request_response(int req_type, 37 NSS_STATUS winbindd_priv_request_response(struct winbindd_context *wbctx, 38 int req_type, 34 39 struct winbindd_request *request, 35 40 struct winbindd_response *response); 41 struct winbindd_context *winbindd_ctx_create(void); 42 void winbindd_ctx_free(struct winbindd_context *ctx); 43 44 /* Global context used for non-Ctx functions */ 45 46 static struct wbcContext wbcGlobalCtx = { 47 .winbindd_ctx = NULL, 48 .pw_cache_size = 0, 49 .pw_cache_idx = 0, 50 .gr_cache_size = 0, 51 .gr_cache_idx = 0 52 }; 36 53 37 54 /* … … 49 66 50 67 static wbcErr wbcRequestResponseInt( 68 struct winbindd_context *wbctx, 51 69 int cmd, 52 70 struct winbindd_request *request, 53 71 struct winbindd_response *response, 54 NSS_STATUS (*fn)( int req_type,72 NSS_STATUS (*fn)(struct winbindd_context *wbctx, int req_type, 55 73 struct winbindd_request *request, 56 74 struct winbindd_response *response)) … … 61 79 /* for some calls the request and/or response can be NULL */ 62 80 63 nss_status = fn( cmd, request, response);81 nss_status = fn(wbctx, cmd, request, response); 64 82 65 83 switch (nss_status) { … … 84 102 * @brief Wrapper around Winbind's send/receive API call 85 103 * 104 * @param ctx Context 86 105 * @param cmd Winbind command operation to perform 87 106 * @param request Send structure … … 90 109 * @return #wbcErr 91 110 */ 92 wbcErr wbcRequestResponse( int cmd,111 wbcErr wbcRequestResponse(struct wbcContext *ctx, int cmd, 93 112 struct winbindd_request *request, 94 113 struct winbindd_response *response) 95 114 { 96 return wbcRequestResponseInt(cmd, request, response, 115 struct winbindd_context *wbctx = NULL; 116 117 if (ctx) { 118 wbctx = ctx->winbindd_ctx; 119 } 120 121 return wbcRequestResponseInt(wbctx, cmd, request, response, 97 122 winbindd_request_response); 98 123 } 99 124 100 wbcErr wbcRequestResponsePriv( int cmd,125 wbcErr wbcRequestResponsePriv(struct wbcContext *ctx, int cmd, 101 126 struct winbindd_request *request, 102 127 struct winbindd_response *response) 103 128 { 104 return wbcRequestResponseInt(cmd, request, response, 129 struct winbindd_context *wbctx = NULL; 130 131 if (ctx) { 132 wbctx = ctx->winbindd_ctx; 133 } 134 135 return wbcRequestResponseInt(wbctx, cmd, request, response, 105 136 winbindd_priv_request_response); 106 137 } … … 258 289 return WBC_ERR_SUCCESS; 259 290 } 291 292 /* Context handling functions */ 293 294 static void wbcContextDestructor(void *ptr) 295 { 296 struct wbcContext *ctx = (struct wbcContext *)ptr; 297 298 winbindd_ctx_free(ctx->winbindd_ctx); 299 } 300 301 struct wbcContext *wbcCtxCreate(void) 302 { 303 struct wbcContext *ctx; 304 struct winbindd_context *wbctx; 305 306 ctx = (struct wbcContext *)wbcAllocateMemory( 307 1, sizeof(struct wbcContext), wbcContextDestructor); 308 309 if (!ctx) { 310 return NULL; 311 } 312 313 wbctx = winbindd_ctx_create(); 314 315 if (!wbctx) { 316 wbcFreeMemory(ctx); 317 return NULL; 318 } 319 320 ctx->winbindd_ctx = wbctx; 321 322 return ctx; 323 } 324 325 void wbcCtxFree(struct wbcContext *ctx) 326 { 327 wbcFreeMemory(ctx); 328 } 329 330 struct wbcContext *wbcGetGlobalCtx(void) 331 { 332 return &wbcGlobalCtx; 333 } -
vendor/current/nsswitch/libwbclient/wbclient.h
r740 r988 6 6 Copyright (C) Gerald (Jerry) Carter 2007 7 7 Copyright (C) Volker Lendecke 2009 8 Copyright (C) Matthew Newton 2015 8 9 9 10 This library is free software; you can redistribute it and/or … … 69 70 * 0.7: Added wbcSidToStringBuf() 70 71 * 0.8: Added wbcSidsToUnixIds() and wbcLookupSids() 72 * 0.9: Added support for WBC_ID_TYPE_BOTH 73 * 0.10: Added wbcPingDc2() 74 * 0.11: Extended wbcAuthenticateUserEx to provide PAC parsing 75 * 0.12: Added wbcCtxCreate and friends 71 76 **/ 72 77 #define WBCLIENT_MAJOR_VERSION 0 73 #define WBCLIENT_MINOR_VERSION 878 #define WBCLIENT_MINOR_VERSION 12 74 79 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient" 75 80 struct wbcLibraryDetails { … … 91 96 char *dns_domain; 92 97 }; 98 99 /** 100 * @brief Library context data 101 * 102 **/ 103 104 struct wbcContext; 93 105 94 106 /* … … 196 208 197 209 /** 210 * @brief Generic Blob 211 **/ 212 213 struct wbcBlob { 214 uint8_t *data; 215 size_t length; 216 }; 217 218 /** 219 * @brief Named Blob 220 **/ 221 222 struct wbcNamedBlob { 223 const char *name; 224 uint32_t flags; 225 struct wbcBlob blob; 226 }; 227 228 /** 198 229 * @brief Auth User Parameters 199 230 **/ … … 211 242 WBC_AUTH_USER_LEVEL_PLAIN = 1, 212 243 WBC_AUTH_USER_LEVEL_HASH = 2, 213 WBC_AUTH_USER_LEVEL_RESPONSE = 3 244 WBC_AUTH_USER_LEVEL_RESPONSE = 3, 245 WBC_AUTH_USER_LEVEL_PAC = 4 214 246 } level; 215 247 union { … … 226 258 uint8_t *lm_data; 227 259 } response; 260 struct wbcBlob pac; 228 261 } password; 229 };230 231 /**232 * @brief Generic Blob233 **/234 235 struct wbcBlob {236 uint8_t *data;237 size_t length;238 };239 240 /**241 * @brief Named Blob242 **/243 244 struct wbcNamedBlob {245 const char *name;246 uint32_t flags;247 struct wbcBlob blob;248 262 }; 249 263 … … 519 533 520 534 535 /********************************************************** 536 * Context Management 537 **********************************************************/ 538 539 /** 540 * @brief Create a new wbcContext context 541 * 542 * @return wbcContext 543 **/ 544 struct wbcContext *wbcCtxCreate(void); 545 546 /** 547 * @brief Free a library context 548 * 549 * @param ctx wbcContext to free 550 * 551 * @return void 552 **/ 553 void wbcCtxFree(struct wbcContext *ctx); 554 555 556 521 557 /* 522 558 * Utility functions for dealing with SIDs … … 596 632 * @brief Ping winbindd to see if the daemon is running 597 633 * 634 * @param *ctx wbclient Context 635 * 636 * @return #wbcErr 637 **/ 638 wbcErr wbcCtxPing(struct wbcContext *ctx); 639 640 /** 641 * @brief Ping winbindd to see if the daemon is running 642 * 598 643 * @return #wbcErr 599 644 **/ … … 602 647 wbcErr wbcLibraryDetails(struct wbcLibraryDetails **details); 603 648 649 wbcErr wbcCtxInterfaceDetails(struct wbcContext *ctx, 650 struct wbcInterfaceDetails **details); 604 651 wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details); 605 652 … … 611 658 * @brief Convert a domain and name to SID 612 659 * 660 * @param *ctx wbclient Context 613 661 * @param dom_name Domain name (possibly "") 614 662 * @param name User or group name … … 618 666 * @return #wbcErr 619 667 **/ 668 wbcErr wbcCtxLookupName(struct wbcContext *ctx, 669 const char *dom_name, 670 const char *name, 671 struct wbcDomainSid *sid, 672 enum wbcSidType *name_type); 673 674 /** 675 * @brief Convert a domain and name to SID 676 * 677 * @param dom_name Domain name (possibly "") 678 * @param name User or group name 679 * @param *sid Pointer to the resolved domain SID 680 * @param *name_type Pointer to the SID type 681 * 682 * @return #wbcErr 683 **/ 620 684 wbcErr wbcLookupName(const char *dom_name, 621 685 const char *name, … … 626 690 * @brief Convert a SID to a domain and name 627 691 * 628 * @param *sid Pointer to the domain SID to be resolved 692 * @param *ctx wbclient Context 693 * @param *sid Pointer to the domain SID to be resolved 694 * @param domain Resolved Domain name (possibly "") 695 * @param name Resolved User or group name 696 * @param *name_type Pointer to the resolved SID type 697 * 698 * @return #wbcErr 699 **/ 700 wbcErr wbcCtxLookupSid(struct wbcContext *ctx, 701 const struct wbcDomainSid *sid, 702 char **domain, 703 char **name, 704 enum wbcSidType *name_type); 705 706 /** 707 * @brief Convert a SID to a domain and name 708 * 709 * @param *sid Pointer to the domain SID to be resolved 629 710 * @param domain Resolved Domain name (possibly "") 630 711 * @param name Resolved User or group name … … 644 725 }; 645 726 727 wbcErr wbcCtxLookupSids(struct wbcContext *ctx, 728 const struct wbcDomainSid *sids, int num_sids, 729 struct wbcDomainInfo **domains, int *num_domains, 730 struct wbcTranslatedName **names); 731 646 732 wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids, 647 733 struct wbcDomainInfo **domains, int *num_domains, 648 734 struct wbcTranslatedName **names); 735 736 /** 737 * @brief Translate a collection of RIDs within a domain to names 738 */ 739 wbcErr wbcCtxLookupRids(struct wbcContext *ctx, 740 struct wbcDomainSid *dom_sid, 741 int num_rids, 742 uint32_t *rids, 743 const char **domain_name, 744 const char ***names, 745 enum wbcSidType **types); 649 746 650 747 /** … … 661 758 * @brief Get the groups a user belongs to 662 759 **/ 760 wbcErr wbcCtxLookupUserSids(struct wbcContext *ctx, 761 const struct wbcDomainSid *user_sid, 762 bool domain_groups_only, 763 uint32_t *num_sids, 764 struct wbcDomainSid **sids); 765 766 /* 767 * @brief Get the groups a user belongs to 768 **/ 663 769 wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid, 664 770 bool domain_groups_only, 665 771 uint32_t *num_sids, 666 772 struct wbcDomainSid **sids); 773 774 /* 775 * @brief Get alias membership for sids 776 **/ 777 wbcErr wbcCtxGetSidAliases(struct wbcContext *ctx, 778 const struct wbcDomainSid *dom_sid, 779 struct wbcDomainSid *sids, 780 uint32_t num_sids, 781 uint32_t **alias_rids, 782 uint32_t *num_alias_rids); 667 783 668 784 /* … … 678 794 * @brief Lists Users 679 795 **/ 796 wbcErr wbcCtxListUsers(struct wbcContext *ctx, 797 const char *domain_name, 798 uint32_t *num_users, 799 const char ***users); 800 801 /** 802 * @brief Lists Users 803 **/ 680 804 wbcErr wbcListUsers(const char *domain_name, 681 805 uint32_t *num_users, … … 685 809 * @brief Lists Groups 686 810 **/ 811 wbcErr wbcCtxListGroups(struct wbcContext *ctx, 812 const char *domain_name, 813 uint32_t *num_groups, 814 const char ***groups); 815 816 /** 817 * @brief Lists Groups 818 **/ 687 819 wbcErr wbcListGroups(const char *domain_name, 688 820 uint32_t *num_groups, 689 821 const char ***groups); 822 823 wbcErr wbcCtxGetDisplayName(struct wbcContext *ctx, 824 const struct wbcDomainSid *sid, 825 char **pdomain, 826 char **pfullname, 827 enum wbcSidType *pname_type); 690 828 691 829 wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid, … … 701 839 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed 702 840 * 841 * @param *ctx wbclient Context 703 842 * @param *sid Pointer to the domain SID to be resolved 704 843 * @param *puid Pointer to the resolved uid_t value … … 707 846 * 708 847 **/ 848 wbcErr wbcCtxSidToUid(struct wbcContext *ctx, 849 const struct wbcDomainSid *sid, 850 uid_t *puid); 851 852 /** 853 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed 854 * 855 * @param *sid Pointer to the domain SID to be resolved 856 * @param *puid Pointer to the resolved uid_t value 857 * 858 * @return #wbcErr 859 * 860 **/ 709 861 wbcErr wbcSidToUid(const struct wbcDomainSid *sid, 710 862 uid_t *puid); … … 725 877 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed 726 878 * 879 * @param *ctx wbclient Context 727 880 * @param uid Unix uid to be resolved 728 881 * @param *sid Pointer to the resolved domain SID … … 731 884 * 732 885 **/ 886 wbcErr wbcCtxUidToSid(struct wbcContext *ctx, uid_t uid, 887 struct wbcDomainSid *sid); 888 889 /** 890 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed 891 * 892 * @param uid Unix uid to be resolved 893 * @param *sid Pointer to the resolved domain SID 894 * 895 * @return #wbcErr 896 * 897 **/ 733 898 wbcErr wbcUidToSid(uid_t uid, 734 899 struct wbcDomainSid *sid); … … 749 914 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed 750 915 * 916 * @param *ctx wbclient Context 751 917 * @param *sid Pointer to the domain SID to be resolved 752 918 * @param *pgid Pointer to the resolved gid_t value … … 755 921 * 756 922 **/ 923 wbcErr wbcCtxSidToGid(struct wbcContext *ctx, 924 const struct wbcDomainSid *sid, 925 gid_t *pgid); 926 927 /** 928 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed 929 * 930 * @param *sid Pointer to the domain SID to be resolved 931 * @param *pgid Pointer to the resolved gid_t value 932 * 933 * @return #wbcErr 934 * 935 **/ 757 936 wbcErr wbcSidToGid(const struct wbcDomainSid *sid, 758 937 gid_t *pgid); … … 769 948 wbcErr wbcQuerySidToGid(const struct wbcDomainSid *sid, 770 949 gid_t *pgid); 950 951 /** 952 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed 953 * 954 * @param *ctx wbclient Context 955 * @param gid Unix gid to be resolved 956 * @param *sid Pointer to the resolved domain SID 957 * 958 * @return #wbcErr 959 * 960 **/ 961 wbcErr wbcCtxGidToSid(struct wbcContext *ctx, gid_t gid, 962 struct wbcDomainSid *sid); 771 963 772 964 /** … … 797 989 WBC_ID_TYPE_NOT_SPECIFIED, 798 990 WBC_ID_TYPE_UID, 799 WBC_ID_TYPE_GID 991 WBC_ID_TYPE_GID, 992 WBC_ID_TYPE_BOTH 800 993 }; 801 994 … … 813 1006 * @brief Convert a list of sids to unix ids 814 1007 * 1008 * @param *ctx wbclient Context 815 1009 * @param sids Pointer to an array of SIDs to convert 816 1010 * @param num_sids Number of SIDs … … 820 1014 * 821 1015 **/ 1016 wbcErr wbcCtxSidsToUnixIds(struct wbcContext *ctx, 1017 const struct wbcDomainSid *sids, uint32_t num_sids, 1018 struct wbcUnixId *ids); 1019 1020 /** 1021 * @brief Convert a list of sids to unix ids 1022 * 1023 * @param sids Pointer to an array of SIDs to convert 1024 * @param num_sids Number of SIDs 1025 * @param ids Preallocated output array for translated IDs 1026 * 1027 * @return #wbcErr 1028 * 1029 **/ 822 1030 wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids, 823 1031 struct wbcUnixId *ids); … … 826 1034 * @brief Obtain a new uid from Winbind 827 1035 * 828 * @param *puid *pointer to the allocated uid 1036 * @param *ctx wbclient Context 1037 * @param *puid Pointer to the allocated uid 1038 * 1039 * @return #wbcErr 1040 **/ 1041 wbcErr wbcCtxAllocateUid(struct wbcContext *ctx, uid_t *puid); 1042 1043 /** 1044 * @brief Obtain a new uid from Winbind 1045 * 1046 * @param *puid Pointer to the allocated uid 829 1047 * 830 1048 * @return #wbcErr … … 835 1053 * @brief Obtain a new gid from Winbind 836 1054 * 837 * @param *pgid Pointer to the allocated gid 1055 * @param *ctx wbclient Context 1056 * @param *pgid Pointer to the allocated gid 1057 * 1058 * @return #wbcErr 1059 **/ 1060 wbcErr wbcCtxAllocateGid(struct wbcContext *ctx, gid_t *pgid); 1061 1062 /** 1063 * @brief Obtain a new gid from Winbind 1064 * 1065 * @param *pgid Pointer to the allocated gid 838 1066 * 839 1067 * @return #wbcErr … … 845 1073 * 846 1074 * @param uid Uid of the desired mapping. 847 * @param *sid Pointer to the sid of the d iresired mapping.1075 * @param *sid Pointer to the sid of the desired mapping. 848 1076 * 849 1077 * @return #wbcErr … … 858 1086 * 859 1087 * @param gid Gid of the desired mapping. 860 * @param *sid Pointer to the sid of the d iresired mapping.1088 * @param *sid Pointer to the sid of the desired mapping. 861 1089 * 862 1090 * @return #wbcErr … … 925 1153 * on username 926 1154 * 1155 * @param *ctx wbclient Context 927 1156 * @param *name Username to lookup 928 1157 * @param **pwd Pointer to resulting struct passwd* from the query. … … 930 1159 * @return #wbcErr 931 1160 **/ 1161 wbcErr wbcCtxGetpwnam(struct wbcContext *ctx, 1162 const char *name, struct passwd **pwd); 1163 1164 /** 1165 * @brief Fill in a struct passwd* for a domain user based 1166 * on username 1167 * 1168 * @param *name Username to lookup 1169 * @param **pwd Pointer to resulting struct passwd* from the query. 1170 * 1171 * @return #wbcErr 1172 **/ 932 1173 wbcErr wbcGetpwnam(const char *name, struct passwd **pwd); 933 1174 … … 936 1177 * on uid 937 1178 * 1179 * @param *ctx wbclient Context 938 1180 * @param uid Uid to lookup 939 1181 * @param **pwd Pointer to resulting struct passwd* from the query. … … 941 1183 * @return #wbcErr 942 1184 **/ 1185 wbcErr wbcCtxGetpwuid(struct wbcContext *ctx, 1186 uid_t uid, struct passwd **pwd); 1187 1188 /** 1189 * @brief Fill in a struct passwd* for a domain user based 1190 * on uid 1191 * 1192 * @param uid Uid to lookup 1193 * @param **pwd Pointer to resulting struct passwd* from the query. 1194 * 1195 * @return #wbcErr 1196 **/ 943 1197 wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd); 944 1198 … … 947 1201 * on sid 948 1202 * 1203 * @param *ctx wbclient Context 949 1204 * @param sid Sid to lookup 950 1205 * @param **pwd Pointer to resulting struct passwd* from the query. … … 952 1207 * @return #wbcErr 953 1208 **/ 1209 wbcErr wbcCtxGetpwsid(struct wbcContext *ctx, 1210 struct wbcDomainSid * sid, struct passwd **pwd); 1211 1212 /** 1213 * @brief Fill in a struct passwd* for a domain user based 1214 * on sid 1215 * 1216 * @param sid Sid to lookup 1217 * @param **pwd Pointer to resulting struct passwd* from the query. 1218 * 1219 * @return #wbcErr 1220 **/ 954 1221 wbcErr wbcGetpwsid(struct wbcDomainSid * sid, struct passwd **pwd); 955 1222 … … 958 1225 * on username 959 1226 * 1227 * @param *ctx wbclient Context 960 1228 * @param *name Username to lookup 961 1229 * @param **grp Pointer to resulting struct group* from the query. … … 963 1231 * @return #wbcErr 964 1232 **/ 1233 wbcErr wbcCtxGetgrnam(struct wbcContext *ctx, 1234 const char *name, struct group **grp); 1235 1236 /** 1237 * @brief Fill in a struct passwd* for a domain user based 1238 * on username 1239 * 1240 * @param *name Username to lookup 1241 * @param **grp Pointer to resulting struct group* from the query. 1242 * 1243 * @return #wbcErr 1244 **/ 965 1245 wbcErr wbcGetgrnam(const char *name, struct group **grp); 966 1246 … … 969 1249 * on uid 970 1250 * 1251 * @param *ctx wbclient Context 971 1252 * @param gid Uid to lookup 972 1253 * @param **grp Pointer to resulting struct group* from the query. … … 974 1255 * @return #wbcErr 975 1256 **/ 1257 wbcErr wbcCtxGetgrgid(struct wbcContext *ctx, 1258 gid_t gid, struct group **grp); 1259 1260 /** 1261 * @brief Fill in a struct passwd* for a domain user based 1262 * on uid 1263 * 1264 * @param gid Uid to lookup 1265 * @param **grp Pointer to resulting struct group* from the query. 1266 * 1267 * @return #wbcErr 1268 **/ 976 1269 wbcErr wbcGetgrgid(gid_t gid, struct group **grp); 977 1270 … … 979 1272 * @brief Reset the passwd iterator 980 1273 * 1274 * @param *ctx wbclient Context 1275 * 1276 * @return #wbcErr 1277 **/ 1278 wbcErr wbcCtxSetpwent(struct wbcContext *ctx); 1279 1280 /** 1281 * @brief Reset the passwd iterator 1282 * 981 1283 * @return #wbcErr 982 1284 **/ … … 986 1288 * @brief Close the passwd iterator 987 1289 * 1290 * @param *ctx wbclient Context 1291 * 1292 * @return #wbcErr 1293 **/ 1294 wbcErr wbcCtxEndpwent(struct wbcContext *ctx); 1295 1296 /** 1297 * @brief Close the passwd iterator 1298 * 988 1299 * @return #wbcErr 989 1300 **/ … … 993 1304 * @brief Return the next struct passwd* entry from the pwent iterator 994 1305 * 995 * @param **pwd Pointer to resulting struct passwd* from the query. 1306 * @param *ctx wbclient Context 1307 * @param **pwd Pointer to resulting struct passwd* from the query. 1308 * 1309 * @return #wbcErr 1310 **/ 1311 wbcErr wbcCtxGetpwent(struct wbcContext *ctx, struct passwd **pwd); 1312 1313 /** 1314 * @brief Return the next struct passwd* entry from the pwent iterator 1315 * 1316 * @param **pwd Pointer to resulting struct passwd* from the query. 996 1317 * 997 1318 * @return #wbcErr … … 1002 1323 * @brief Reset the group iterator 1003 1324 * 1325 * @param *ctx wbclient Context 1326 * 1327 * @return #wbcErr 1328 **/ 1329 wbcErr wbcCtxSetgrent(struct wbcContext *ctx); 1330 1331 /** 1332 * @brief Reset the group iterator 1333 * 1004 1334 * @return #wbcErr 1005 1335 **/ … … 1009 1339 * @brief Close the group iterator 1010 1340 * 1341 * @param *ctx wbclient Context 1342 * 1343 * @return #wbcErr 1344 **/ 1345 wbcErr wbcCtxEndgrent(struct wbcContext *ctx); 1346 1347 /** 1348 * @brief Close the group iterator 1349 * 1011 1350 * @return #wbcErr 1012 1351 **/ … … 1016 1355 * @brief Return the next struct group* entry from the pwent iterator 1017 1356 * 1018 * @param **grp Pointer to resulting struct group* from the query. 1357 * @param *ctx wbclient Context 1358 * @param **grp Pointer to resulting struct group* from the query. 1359 * 1360 * @return #wbcErr 1361 **/ 1362 wbcErr wbcCtxGetgrent(struct wbcContext *ctx, struct group **grp); 1363 1364 /** 1365 * @brief Return the next struct group* entry from the pwent iterator 1366 * 1367 * @param **grp Pointer to resulting struct group* from the query. 1019 1368 * 1020 1369 * @return #wbcErr … … 1027 1376 * This is similar to #wbcGetgrent, just that the member list is empty 1028 1377 * 1029 * @param **grp Pointer to resulting struct group* from the query. 1378 * @param *ctx wbclient Context 1379 * @param **grp Pointer to resulting struct group* from the query. 1380 * 1381 * @return #wbcErr 1382 **/ 1383 wbcErr wbcCtxGetgrlist(struct wbcContext *ctx, struct group **grp); 1384 1385 /** 1386 * @brief Return the next struct group* entry from the pwent iterator 1387 * 1388 * This is similar to #wbcGetgrent, just that the member list is empty 1389 * 1390 * @param **grp Pointer to resulting struct group* from the query. 1030 1391 * 1031 1392 * @return #wbcErr … … 1036 1397 * @brief Return the unix group array belonging to the given user 1037 1398 * 1399 * @param *ctx wbclient Context 1038 1400 * @param *account The given user name 1039 1401 * @param *num_groups Number of elements returned in the groups array … … 1042 1404 * @return #wbcErr 1043 1405 **/ 1406 wbcErr wbcCtxGetGroups(struct wbcContext *ctx, 1407 const char *account, 1408 uint32_t *num_groups, 1409 gid_t **_groups); 1410 1411 /** 1412 * @brief Return the unix group array belonging to the given user 1413 * 1414 * @param *account The given user name 1415 * @param *num_groups Number of elements returned in the groups array 1416 * @param **_groups Pointer to resulting gid_t array. 1417 * 1418 * @return #wbcErr 1419 **/ 1044 1420 wbcErr wbcGetGroups(const char *account, 1045 1421 uint32_t *num_groups, … … 1054 1430 * @brief Lookup the current status of a trusted domain 1055 1431 * 1056 * @param domain The domain to query 1432 * @param *ctx wbclient Context 1433 * @param domain The domain to query 1434 * 1435 * @param dinfo A pointer to store the returned domain_info struct. 1436 * 1437 * @return #wbcErr 1438 **/ 1439 wbcErr wbcCtxDomainInfo(struct wbcContext *ctx, 1440 const char *domain, 1441 struct wbcDomainInfo **dinfo); 1442 1443 /** 1444 * @brief Lookup the current status of a trusted domain 1445 * 1446 * @param domain The domain to query 1057 1447 * 1058 1448 * @param dinfo A pointer to store the returned domain_info struct. … … 1066 1456 * @brief Lookup the currently contacted DCs 1067 1457 * 1458 * @param *ctx wbclient Context 1068 1459 * @param domain The domain to query 1069 1460 * … … 1074 1465 * @return #wbcErr 1075 1466 **/ 1467 wbcErr wbcCtxDcInfo(struct wbcContext *ctx, 1468 const char *domain, size_t *num_dcs, 1469 const char ***dc_names, const char ***dc_ips); 1470 1471 /** 1472 * @brief Lookup the currently contacted DCs 1473 * 1474 * @param domain The domain to query 1475 * 1476 * @param num_dcs Number of DCs currently known 1477 * @param dc_names Names of the currently known DCs 1478 * @param dc_ips IP addresses of the currently known DCs 1479 * 1480 * @return #wbcErr 1481 **/ 1076 1482 wbcErr wbcDcInfo(const char *domain, size_t *num_dcs, 1077 1483 const char ***dc_names, const char ***dc_ips); 1484 1485 /** 1486 * @brief Enumerate the domain trusts known by Winbind 1487 * 1488 * @param *ctx wbclient Context 1489 * @param **domains Pointer to the allocated domain list array 1490 * @param *num_domains Pointer to number of domains returned 1491 * 1492 * @return #wbcErr 1493 **/ 1494 wbcErr wbcCtxListTrusts(struct wbcContext *ctx, 1495 struct wbcDomainInfo **domains, 1496 size_t *num_domains); 1078 1497 1079 1498 /** … … 1113 1532 * @brief Enumerate the domain trusts known by Winbind 1114 1533 * 1534 * @param *ctx wbclient Context 1115 1535 * @param domain Name of the domain to query for a DC 1116 1536 * @param flags Bit flags used to control the domain location query … … 1119 1539 * @return #wbcErr 1120 1540 **/ 1541 wbcErr wbcCtxLookupDomainController(struct wbcContext *ctx, 1542 const char *domain, 1543 uint32_t flags, 1544 struct wbcDomainControllerInfo **dc_info); 1545 1546 /** 1547 * @brief Enumerate the domain trusts known by Winbind 1548 * 1549 * @param domain Name of the domain to query for a DC 1550 * @param flags Bit flags used to control the domain location query 1551 * @param *dc_info Pointer to the returned domain controller information 1552 * 1553 * @return #wbcErr 1554 **/ 1121 1555 wbcErr wbcLookupDomainController(const char *domain, 1122 1556 uint32_t flags, … … 1126 1560 * @brief Get extended domain controller information 1127 1561 * 1562 * @param *ctx wbclient Context 1128 1563 * @param domain Name of the domain to query for a DC 1129 1564 * @param guid Guid of the domain to query for a DC … … 1134 1569 * @return #wbcErr 1135 1570 **/ 1571 wbcErr wbcCtxLookupDomainControllerEx(struct wbcContext *ctx, 1572 const char *domain, 1573 struct wbcGuid *guid, 1574 const char *site, 1575 uint32_t flags, 1576 struct wbcDomainControllerInfoEx **dc_info); 1577 1578 /** 1579 * @brief Get extended domain controller information 1580 * 1581 * @param domain Name of the domain to query for a DC 1582 * @param guid Guid of the domain to query for a DC 1583 * @param site Site of the domain to query for a DC 1584 * @param flags Bit flags used to control the domain location query 1585 * @param *dc_info Pointer to the returned extended domain controller information 1586 * 1587 * @return #wbcErr 1588 **/ 1136 1589 wbcErr wbcLookupDomainControllerEx(const char *domain, 1137 1590 struct wbcGuid *guid, … … 1147 1600 * @brief Authenticate a username/password pair 1148 1601 * 1602 * @param *ctx wbclient Context 1149 1603 * @param username Name of user to authenticate 1150 1604 * @param password Clear text password os user … … 1152 1606 * @return #wbcErr 1153 1607 **/ 1608 wbcErr wbcCtxAuthenticateUser(struct wbcContext *ctx, 1609 const char *username, 1610 const char *password); 1611 1612 /** 1613 * @brief Authenticate a username/password pair 1614 * 1615 * @param username Name of user to authenticate 1616 * @param password Clear text password os user 1617 * 1618 * @return #wbcErr 1619 **/ 1154 1620 wbcErr wbcAuthenticateUser(const char *username, 1155 1621 const char *password); … … 1158 1624 * @brief Authenticate with more detailed information 1159 1625 * 1626 * @param *ctx wbclient Context 1160 1627 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH 1161 1628 * is not supported yet … … 1165 1632 * @return #wbcErr 1166 1633 **/ 1634 wbcErr wbcCtxAuthenticateUserEx(struct wbcContext *ctx, 1635 const struct wbcAuthUserParams *params, 1636 struct wbcAuthUserInfo **info, 1637 struct wbcAuthErrorInfo **error); 1638 1639 /** 1640 * @brief Authenticate with more detailed information 1641 * 1642 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH 1643 * is not supported yet 1644 * @param info Output details on WBC_ERR_SUCCESS 1645 * @param error Output details on WBC_ERR_AUTH_ERROR 1646 * 1647 * @return #wbcErr 1648 **/ 1167 1649 wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, 1168 1650 struct wbcAuthUserInfo **info, … … 1172 1654 * @brief Logon a User 1173 1655 * 1656 * @param[in] *ctx wbclient Context 1174 1657 * @param[in] params Pointer to a wbcLogonUserParams structure 1175 1658 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure … … 1179 1662 * @return #wbcErr 1180 1663 **/ 1664 wbcErr wbcCtxLogonUser(struct wbcContext *ctx, 1665 const struct wbcLogonUserParams *params, 1666 struct wbcLogonUserInfo **info, 1667 struct wbcAuthErrorInfo **error, 1668 struct wbcUserPasswordPolicyInfo **policy); 1669 1670 /** 1671 * @brief Logon a User 1672 * 1673 * @param[in] params Pointer to a wbcLogonUserParams structure 1674 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure 1675 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure 1676 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure 1677 * 1678 * @return #wbcErr 1679 **/ 1181 1680 wbcErr wbcLogonUser(const struct wbcLogonUserParams *params, 1182 1681 struct wbcLogonUserInfo **info, … … 1187 1686 * @brief Trigger a logoff notification to Winbind for a specific user 1188 1687 * 1688 * @param *ctx wbclient Context 1189 1689 * @param username Name of user to remove from Winbind's list of 1190 1690 * logged on users. … … 1195 1695 * @return #wbcErr 1196 1696 **/ 1697 wbcErr wbcCtxLogoffUser(struct wbcContext *ctx, 1698 const char *username, uid_t uid, 1699 const char *ccfilename); 1700 1701 /** 1702 * @brief Trigger a logoff notification to Winbind for a specific user 1703 * 1704 * @param username Name of user to remove from Winbind's list of 1705 * logged on users. 1706 * @param uid Uid assigned to the username 1707 * @param ccfilename Absolute path to the Krb5 credentials cache to 1708 * be removed 1709 * 1710 * @return #wbcErr 1711 **/ 1197 1712 wbcErr wbcLogoffUser(const char *username, 1198 1713 uid_t uid, … … 1202 1717 * @brief Trigger an extended logoff notification to Winbind for a specific user 1203 1718 * 1719 * @param *ctx wbclient Context 1204 1720 * @param params A wbcLogoffUserParams structure 1205 1721 * @param error User output details on error … … 1207 1723 * @return #wbcErr 1208 1724 **/ 1725 wbcErr wbcCtxLogoffUserEx(struct wbcContext *ctx, 1726 const struct wbcLogoffUserParams *params, 1727 struct wbcAuthErrorInfo **error); 1728 1729 /** 1730 * @brief Trigger an extended logoff notification to Winbind for a specific user 1731 * 1732 * @param params A wbcLogoffUserParams structure 1733 * @param error User output details on error 1734 * 1735 * @return #wbcErr 1736 **/ 1209 1737 wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params, 1210 1738 struct wbcAuthErrorInfo **error); … … 1213 1741 * @brief Change a password for a user 1214 1742 * 1743 * @param *ctx wbclient Context 1215 1744 * @param username Name of user to authenticate 1216 1745 * @param old_password Old clear text password of user … … 1219 1748 * @return #wbcErr 1220 1749 **/ 1750 wbcErr wbcCtxChangeUserPassword(struct wbcContext *ctx, 1751 const char *username, 1752 const char *old_password, 1753 const char *new_password); 1754 1755 /** 1756 * @brief Change a password for a user 1757 * 1758 * @param username Name of user to authenticate 1759 * @param old_password Old clear text password of user 1760 * @param new_password New clear text password of user 1761 * 1762 * @return #wbcErr 1763 **/ 1221 1764 wbcErr wbcChangeUserPassword(const char *username, 1222 1765 const char *old_password, … … 1227 1770 * failure 1228 1771 * 1772 * @param *ctx wbclient Context 1229 1773 * @param params Input parameters 1230 1774 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED … … 1234 1778 * @return #wbcErr 1235 1779 **/ 1780 wbcErr wbcCtxChangeUserPasswordEx(struct wbcContext *ctx, 1781 const struct wbcChangePasswordParams *params, 1782 struct wbcAuthErrorInfo **error, 1783 enum wbcPasswordChangeRejectReason *reject_reason, 1784 struct wbcUserPasswordPolicyInfo **policy); 1785 1786 /** 1787 * @brief Change a password for a user with more detailed information upon 1788 * failure 1789 * 1790 * @param params Input parameters 1791 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED 1792 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED 1793 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED 1794 * 1795 * @return #wbcErr 1796 **/ 1236 1797 wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params, 1237 1798 struct wbcAuthErrorInfo **error, … … 1242 1803 * @brief Authenticate a user with cached credentials 1243 1804 * 1805 * @param *ctx wbclient Context 1244 1806 * @param *params Pointer to a wbcCredentialCacheParams structure 1245 1807 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure … … 1248 1810 * @return #wbcErr 1249 1811 **/ 1812 wbcErr wbcCtxCredentialCache(struct wbcContext *ctx, 1813 struct wbcCredentialCacheParams *params, 1814 struct wbcCredentialCacheInfo **info, 1815 struct wbcAuthErrorInfo **error); 1816 1817 /** 1818 * @brief Authenticate a user with cached credentials 1819 * 1820 * @param *params Pointer to a wbcCredentialCacheParams structure 1821 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure 1822 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure 1823 * 1824 * @return #wbcErr 1825 **/ 1250 1826 wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params, 1251 1827 struct wbcCredentialCacheInfo **info, … … 1255 1831 * @brief Save a password with winbind for doing wbcCredentialCache() later 1256 1832 * 1833 * @param *ctx wbclient Context 1834 * @param *user Username 1835 * @param *password Password 1836 * 1837 * @return #wbcErr 1838 **/ 1839 wbcErr wbcCtxCredentialSave(struct wbcContext *ctx, 1840 const char *user, const char *password); 1841 1842 /** 1843 * @brief Save a password with winbind for doing wbcCredentialCache() later 1844 * 1257 1845 * @param *user Username 1258 1846 * @param *password Password … … 1269 1857 * @brief Resolve a NetbiosName via WINS 1270 1858 * 1859 * @param *ctx wbclient Context 1271 1860 * @param name Name to resolve 1272 1861 * @param *ip Pointer to the ip address string … … 1274 1863 * @return #wbcErr 1275 1864 **/ 1865 wbcErr wbcCtxResolveWinsByName(struct wbcContext *ctx, 1866 const char *name, char **ip); 1867 1868 /** 1869 * @brief Resolve a NetbiosName via WINS 1870 * 1871 * @param name Name to resolve 1872 * @param *ip Pointer to the ip address string 1873 * 1874 * @return #wbcErr 1875 **/ 1276 1876 wbcErr wbcResolveWinsByName(const char *name, char **ip); 1277 1877 … … 1279 1879 * @brief Resolve an IP address via WINS into a NetbiosName 1280 1880 * 1281 * @param ip The ip address string 1282 * @param *name Pointer to the name 1881 * @param *ctx wbclient Context 1882 * @param ip The ip address string 1883 * @param *name Pointer to the name 1884 * 1885 * @return #wbcErr 1886 * 1887 **/ 1888 wbcErr wbcCtxResolveWinsByIP(struct wbcContext *ctx, 1889 const char *ip, char **name); 1890 1891 /** 1892 * @brief Resolve an IP address via WINS into a NetbiosName 1893 * 1894 * @param ip The ip address string 1895 * @param *name Pointer to the name 1283 1896 * 1284 1897 * @return #wbcErr … … 1294 1907 * @brief Trigger a verification of the trust credentials of a specific domain 1295 1908 * 1909 * @param *ctx wbclient Context 1296 1910 * @param *domain The name of the domain. 1297 1911 * @param error Output details on WBC_ERR_AUTH_ERROR … … 1299 1913 * @return #wbcErr 1300 1914 **/ 1915 wbcErr wbcCtxCheckTrustCredentials(struct wbcContext *ctx, const char *domain, 1916 struct wbcAuthErrorInfo **error); 1917 1918 /** 1919 * @brief Trigger a verification of the trust credentials of a specific domain 1920 * 1921 * @param *domain The name of the domain. 1922 * @param error Output details on WBC_ERR_AUTH_ERROR 1923 * 1924 * @return #wbcErr 1925 **/ 1301 1926 wbcErr wbcCheckTrustCredentials(const char *domain, 1302 1927 struct wbcAuthErrorInfo **error); … … 1305 1930 * @brief Trigger a change of the trust credentials for a specific domain 1306 1931 * 1932 * @param *ctx wbclient Context 1307 1933 * @param *domain The name of the domain. 1308 1934 * @param error Output details on WBC_ERR_AUTH_ERROR … … 1310 1936 * @return #wbcErr 1311 1937 **/ 1938 wbcErr wbcCtxChangeTrustCredentials(struct wbcContext *ctx, const char *domain, 1939 struct wbcAuthErrorInfo **error); 1940 1941 /** 1942 * @brief Trigger a change of the trust credentials for a specific domain 1943 * 1944 * @param *domain The name of the domain. 1945 * @param error Output details on WBC_ERR_AUTH_ERROR 1946 * 1947 * @return #wbcErr 1948 **/ 1312 1949 wbcErr wbcChangeTrustCredentials(const char *domain, 1313 1950 struct wbcAuthErrorInfo **error); … … 1317 1954 * version of wbcCheckTrustCredentials 1318 1955 * 1956 * @param *ctx wbclient Context 1319 1957 * @param *domain The name of the domain, only NULL for the default domain is 1320 1958 * supported yet. Other values than NULL will result in … … 1324 1962 * @return #wbcErr 1325 1963 **/ 1964 wbcErr wbcCtxPingDc(struct wbcContext *ctx, const char *domain, 1965 struct wbcAuthErrorInfo **error); 1966 1967 /** 1968 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost 1969 * version of wbcCheckTrustCredentials 1970 * 1971 * @param *domain The name of the domain, only NULL for the default domain is 1972 * supported yet. Other values than NULL will result in 1973 * WBC_ERR_NOT_IMPLEMENTED. 1974 * @param error Output details on WBC_ERR_AUTH_ERROR 1975 * 1976 * @return #wbcErr 1977 **/ 1326 1978 wbcErr wbcPingDc(const char *domain, struct wbcAuthErrorInfo **error); 1979 1980 /** 1981 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost 1982 * version of wbcCheckTrustCredentials 1983 * 1984 * @param *ctx wbclient Context 1985 * @param *domain The name of the domain, only NULL for the default domain is 1986 * supported yet. Other values than NULL will result in 1987 * WBC_ERR_NOT_IMPLEMENTED. 1988 * @param error Output details on WBC_ERR_AUTH_ERROR 1989 * @param dcname DC that was attempted to ping 1990 * 1991 * @return #wbcErr 1992 **/ 1993 wbcErr wbcCtxPingDc2(struct wbcContext *ctx, const char *domain, 1994 struct wbcAuthErrorInfo **error, 1995 char **dcname); 1996 1997 /** 1998 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost 1999 * version of wbcCheckTrustCredentials 2000 * 2001 * @param *domain The name of the domain, only NULL for the default domain is 2002 * supported yet. Other values than NULL will result in 2003 * WBC_ERR_NOT_IMPLEMENTED. 2004 * @param error Output details on WBC_ERR_AUTH_ERROR 2005 * @param dcname DC that was attempted to ping 2006 * 2007 * @return #wbcErr 2008 **/ 2009 wbcErr wbcPingDc2(const char *domain, struct wbcAuthErrorInfo **error, 2010 char **dcname); 1327 2011 1328 2012 /********************************************************** -
vendor/current/nsswitch/libwbclient/wbclient_internal.h
r740 r988 23 23 #define _WBCLIENT_INTERNAL_H 24 24 25 struct wbcContext { 26 struct winbindd_context *winbindd_ctx; 27 uint32_t pw_cache_size; /* Number of cached passwd structs */ 28 uint32_t pw_cache_idx; /* Position of the pwent context */ 29 uint32_t gr_cache_size; /* Number of cached group structs */ 30 uint32_t gr_cache_idx; /* Position of the grent context */ 31 }; 32 25 33 /* Private functions */ 26 34 27 wbcErr wbcRequestResponse( int cmd,35 wbcErr wbcRequestResponse(struct wbcContext *ctx, int cmd, 28 36 struct winbindd_request *request, 29 37 struct winbindd_response *response); 30 38 31 wbcErr wbcRequestResponsePriv( int cmd,39 wbcErr wbcRequestResponsePriv(struct wbcContext *ctx, int cmd, 32 40 struct winbindd_request *request, 33 41 struct winbindd_response *response); … … 38 46 char *wbcStrDup(const char *str); 39 47 const char **wbcAllocateStringArray(int num_strings); 48 struct wbcContext *wbcGetGlobalCtx(void); 40 49 41 50 #endif /* _WBCLIENT_INTERNAL_H */
Note:
See TracChangeset
for help on using the changeset viewer.