Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/nsswitch
Files:
11 added
1 deleted
29 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/nsswitch/libwbclient/tests/wbclient.c

    r740 r988  
    2323#include "lib/util/data_blob.h"
    2424#include "lib/util/time.h"
     25#include "libcli/resolve/resolve.h"
    2526#include "nsswitch/libwbclient/wbclient.h"
    2627#include "torture/smbtorture.h"
     
    2930#include "lib/util/charset/charset.h"
    3031#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"
    3334#include "lib/crypto/arcfour.h"
     35#include "auth/credentials/credentials.h"
     36#include "lib/cmdline/popt_common.h"
    3437
    3538#define WBC_ERROR_EQUAL(x,y) (x == y)
    3639
    37 #define torture_assert_wbc_equal(torture_ctx, got, expected, cmt) \
     40#define torture_assert_wbc_equal(torture_ctx, got, expected, cmt, cmt_arg)      \
    3841        do { wbcErr __got = got, __expected = expected; \
    3942        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); \
    4144                return false; \
    4245        } \
    4346        } while (0)
    4447
    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)
    4750
    4851static bool test_wbc_ping(struct torture_context *tctx)
    4952{
    5053        torture_assert_wbc_ok(tctx, wbcPing(),
    51                 "wbcPing failed");
     54                "%s", "wbcPing failed");
    5255
    5356        return true;
     
    5659static bool test_wbc_pingdc(struct torture_context *tctx)
    5760{
    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");
    6065        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
     85static 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);
    62114
    63115        return true;
     
    69121
    70122        torture_assert_wbc_ok(tctx, wbcLibraryDetails(&details),
    71                 "wbcLibraryDetails failed");
     123                "%s", "wbcLibraryDetails failed");
    72124        torture_assert(tctx, details,
    73125                "wbcLibraryDetails returned NULL pointer");
     
    83135
    84136        torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
    85                 "wbcInterfaceDetails failed");
     137                "%s", "wbcInterfaceDetails failed");
    86138        torture_assert(tctx, details,
    87                 "wbcInterfaceDetails returned NULL pointer");
     139                       "wbcInterfaceDetails returned NULL pointer");
    88140
    89141        wbcFreeMemory(details);
     
    113165                                 "SID_UNKNOWN", "SID_UNKNOWN failed");
    114166        torture_assert_str_equal(tctx, wbcSidTypeString(WBC_SID_NAME_COMPUTER),
    115                                  "SID_COMPUTER", "SID_COMPUTER failed");
     167                                 "SID_COMPUTER",  "SID_COMPUTER failed");
    116168        return true;
    117169}
     
    124176
    125177        torture_assert_wbc_ok(tctx, wbcStringToSid(sid_string, &sid),
    126                 "wbcStringToSid failed");
     178                              "wbcStringToSid of %s failed", sid_string);
    127179        torture_assert_wbc_ok(tctx, wbcSidToString(&sid, &sid_string2),
    128                 "wbcSidToString failed");
     180                              "wbcSidToString of %s failed", sid_string);
    129181        torture_assert_str_equal(tctx, sid_string, sid_string2,
    130182                "sid strings differ");
     
    141193
    142194        torture_assert_wbc_ok(tctx, wbcStringToGuid(guid_string, &guid),
    143                 "wbcStringToGuid failed");
     195                              "wbcStringToGuid of %s failed", guid_string);
    144196        torture_assert_wbc_ok(tctx, wbcGuidToString(&guid, &guid_string2),
    145                 "wbcGuidToString failed");
     197                              "wbcGuidToString of %s failed", guid_string);
    146198        torture_assert_str_equal(tctx, guid_string, guid_string2,
    147                 "guid strings differ");
     199                                 "guid strings differ");
    148200        wbcFreeMemory(guid_string2);
    149201
     
    157209
    158210        torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
    159                 "wbcInterfaceDetails failed");
     211                "%s", "wbcInterfaceDetails failed");
    160212        torture_assert_wbc_ok(
    161213                tctx, wbcDomainInfo(details->netbios_domain, &info),
    162                 "wbcDomainInfo failed");
     214                "%s", "wbcDomainInfo failed");
    163215        wbcFreeMemory(details);
    164216
     
    179231
    180232        torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
    181                 "wbcInterfaceDetails failed");
     233                "%s", "wbcInterfaceDetails failed");
    182234
    183235        domain_name = talloc_strdup(tctx, details->netbios_domain);
     
    185237
    186238        torture_assert_wbc_ok(tctx, wbcListUsers(domain_name, &num_users, &users),
    187                 "wbcListUsers failed");
     239                "%s", "wbcListUsers failed");
    188240        torture_assert(tctx, !(num_users > 0 && !users),
    189241                "wbcListUsers returned invalid results");
     
    195247                char *domain;
    196248                char *name;
     249                char *sid_string;
    197250                uint32_t num_sids;
    198251
    199252                torture_assert_wbc_ok(tctx, wbcLookupName(domain_name, users[i], &sid, &name_type),
    200                         "wbcLookupName failed");
     253                                      "wbcLookupName of %s failed", users[i]);
    201254                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);
    203257                torture_assert_wbc_ok(tctx, wbcLookupSid(&sid, &domain, &name, &name_type),
    204                         "wbcLookupSid failed");
     258                                      "wbcLookupSid of %s failed", sid_string);
    205259                torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_USER,
    206                         "wbcLookupSid expected WBC_SID_NAME_USER");
     260                                         "wbcLookupSid of expected WBC_SID_NAME_USER");
    207261                torture_assert(tctx, name,
    208262                        "wbcLookupSid returned no name");
     
    210264                wbcFreeMemory(name);
    211265                torture_assert_wbc_ok(tctx, wbcLookupUserSids(&sid, true, &num_sids, &sids),
    212                         "wbcLookupUserSids failed");
     266                        "wbcLookupUserSids of %s failed", sid_string);
    213267                torture_assert_wbc_ok(
    214268                        tctx, wbcGetDisplayName(&sid, &domain, &name,
    215269                                                &name_type),
    216                         "wbcGetDisplayName failed");
     270                        "wbcGetDisplayName of %s failed", sid_string);
    217271                wbcFreeMemory(domain);
    218272                wbcFreeMemory(name);
    219273                wbcFreeMemory(sids);
     274                wbcFreeMemory(sid_string);
    220275        }
    221276        wbcFreeMemory(users);
     
    233288
    234289        torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
    235                 "wbcInterfaceDetails failed");
     290                              "%s", "wbcInterfaceDetails failed");
    236291
    237292        domain_name = talloc_strdup(tctx, details->netbios_domain);
     
    239294
    240295        torture_assert_wbc_ok(tctx, wbcListGroups(domain_name, &num_groups, &groups),
    241                 "wbcListGroups failed");
     296                              "wbcListGroups in %s failed", domain_name);
    242297        torture_assert(tctx, !(num_groups > 0 && !groups),
    243                 "wbcListGroups returned invalid results");
     298                       "wbcListGroups returned invalid results");
    244299
    245300        for (i=0; i < MIN(num_groups,100); i++) {
     
    249304                char *domain;
    250305                char *name;
     306                char *sid_string;
    251307
    252308                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);
    254311                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);
    256314                torture_assert(tctx, name,
    257315                        "wbcLookupSid returned no name");
     
    269327
    270328        torture_assert_wbc_ok(tctx, wbcListTrusts(&domains, &num_domains),
    271                 "wbcListTrusts failed");
     329                              "%s", "wbcListTrusts failed");
    272330        torture_assert(tctx, !(num_domains > 0 && !domains),
    273331                "wbcListTrusts returned invalid results");
     
    283341                */
    284342                torture_assert_wbc_ok(tctx, wbcCheckTrustCredentials(domains[i].short_name, &error),
    285                         "wbcCheckTrustCredentials failed");
     343                                      "%s", "wbcCheckTrustCredentials failed");
    286344                /*
    287345                torture_assert_wbc_ok(tctx, wbcLookupName(domains[i].short_name, NULL, &sid, &name_type),
     
    309367
    310368        torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
    311                 "wbcInterfaceDetails failed");
     369                "%s", "wbcInterfaceDetails failed");
    312370
    313371        domain_name = talloc_strdup(tctx, details->netbios_domain);
     
    315373
    316374        torture_assert_wbc_ok(tctx, wbcLookupDomainController(domain_name, 0, &dc_info),
    317                 "wbcLookupDomainController failed");
     375                              "wbcLookupDomainController for %s failed", domain_name);
    318376        wbcFreeMemory(dc_info);
    319377
     
    328386
    329387        torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
    330                 "wbcInterfaceDetails failed");
     388                "%s", "wbcInterfaceDetails failed");
    331389
    332390        domain_name = talloc_strdup(tctx, details->netbios_domain);
     
    334392
    335393        torture_assert_wbc_ok(tctx, wbcLookupDomainControllerEx(domain_name, NULL, NULL, 0, &dc_info),
    336                 "wbcLookupDomainControllerEx failed");
     394                "wbcLookupDomainControllerEx for %s failed", domain_name);
    337395        wbcFreeMemory(dc_info);
    338396
     
    348406        name = torture_setting_string(tctx, "host", NULL);
    349407
     408        torture_comment(tctx, "test-WinsByName: host='%s'\n", name);
     409
    350410        ret = wbcResolveWinsByName(name, &ip);
    351411
    352412        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);
    354414        } else {
    355                 torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByName failed");
     415                torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByName for %s failed", name);
    356416        }
    357417
     
    362422{
    363423        const char *ip;
     424        const char *host;
     425        struct nbt_name nbt_name;
    364426        char *name;
    365427        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);
    368443
    369444        ret = wbcResolveWinsByIP(ip, &name);
    370445
    371         torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByIP failed");
     446        torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByIP for %s failed", ip);
    372447
    373448        wbcFreeMemory(name);
     
    388463        ret = wbcLookupRids(&builtin, 2, rids, &domain_name, &names,
    389464                            &types);
    390         torture_assert_wbc_ok(tctx, ret, "wbcLookupRids failed");
     465        torture_assert_wbc_ok(tctx, ret, "%s", "wbcLookupRids for 544 and 545 failed");
    391466
    392467        torture_assert_str_equal(
     
    396471                tctx, names[1], "Users", "S-1-5-32-545 not mapped to 'Users'");
    397472
    398         wbcFreeMemory((char *)domain_name);
     473        wbcFreeMemory(discard_const_p(char ,domain_name));
    399474        wbcFreeMemory(names);
    400475        wbcFreeMemory(types);
     
    414489
    415490        torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
    416                 "wbcInterfaceDetails failed");
     491                              "%s", "wbcInterfaceDetails failed");
    417492        torture_assert_wbc_ok(
    418493                tctx, wbcDomainInfo(details->netbios_domain, &info),
    419                 "wbcDomainInfo failed");
     494                "wbcDomainInfo of %s failed", details->netbios_domain);
    420495        wbcFreeMemory(details);
    421496
     
    428503        torture_assert_wbc_ok(
    429504                tctx, wbcStringToSid("S-1-5-32", &builtin),
    430                 "wbcStringToSid failed");
     505                "wbcStringToSid of %s failed", "S-1-5-32");
    431506
    432507        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");
    434509
    435510        wbcFreeMemory(rids);
     
    446521        wbcErr ret;
    447522
    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));
    451527
    452528        ZERO_STRUCT(params);
    453         params.account_name             = getenv("USERNAME");
     529        params.account_name             = cli_credentials_get_username(cmdline_credentials);
    454530        params.level                    = WBC_AUTH_USER_LEVEL_PLAIN;
    455531        params.password.plaintext       = correct_password;
     
    457533        ret = wbcAuthenticateUserEx(&params, &info, &error);
    458534        torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
    459                                  "wbcAuthenticateUserEx failed");
     535                                 "wbcAuthenticateUserEx of %s failed", params.account_name);
    460536        wbcFreeMemory(info);
    461537        info = NULL;
     
    467543        ret = wbcAuthenticateUserEx(&params, &info, &error);
    468544        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);
    471547        wbcFreeMemory(info);
    472548        info = NULL;
     
    480556static bool test_wbc_authenticate_user(struct torture_context *tctx)
    481557{
    482         return test_wbc_authenticate_user_int(tctx, getenv("PASSWORD"));
     558        return test_wbc_authenticate_user_int(tctx, cli_credentials_get_password(cmdline_credentials));
    483559}
    484560
     
    486562{
    487563        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%$";
    490566
    491567        struct samr_CryptPassword new_nt_password;
     
    551627
    552628        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);
    555631
    556632        ret = wbcChangeUserPasswordEx(&params, NULL, NULL, NULL);
    557633        torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
    558                                  "wbcChangeUserPassword failed");
    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)) {
    561637                return false;
    562638        }
    563639
    564         ret = wbcChangeUserPassword(getenv("USERNAME"), "Koo8irei",
    565                                     getenv("PASSWORD"));
    566         torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
    567                                  "wbcChangeUserPassword failed");
    568 
    569         return test_wbc_authenticate_user_int(tctx, getenv("PASSWORD"));
     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));
    570646}
    571647
     
    586662        ret = wbcLogonUser(&params, &info, &error, &policy);
    587663        torture_assert_wbc_equal(tctx, ret, WBC_ERR_INVALID_PARAM,
    588                                  "wbcLogonUser succeeded where it should "
     664                                 "%s", "wbcLogonUser succeeded for NULL where it should "
    589665                                 "have failed");
    590666
    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);
    593669
    594670        ret = wbcAddNamedBlob(&params.num_blobs, &params.blobs,
    595671                              "foo", 0, discard_const_p(uint8_t, "bar"), 4);
    596672        torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
    597                                  "wbcAddNamedBlob failed");
     673                                 "%s", "wbcAddNamedBlob failed");
    598674
    599675        ret = wbcLogonUser(&params, &info, &error, &policy);
    600676        torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
    601                                  "wbcLogonUser failed");
     677                                 "wbcLogonUser for %s failed", params.username);
    602678        wbcFreeMemory(info); info = NULL;
    603679        wbcFreeMemory(error); error = NULL;
     
    608684        ret = wbcLogonUser(&params, &info, &error, &policy);
    609685        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);
    612688        wbcFreeMemory(info); info = NULL;
    613689        wbcFreeMemory(error); error = NULL;
     
    619695                              strlen("S-1-2-3-4")+1);
    620696        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);
    623699        ret = wbcLogonUser(&params, &info, &error, &policy);
    624700        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);
    627703        wbcFreeMemory(info); info = NULL;
    628704        wbcFreeMemory(error); error = NULL;
     
    633709        ret = wbcInterfaceDetails(&iface);
    634710        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,
    638714                            &sidtype);
    639715        wbcFreeMemory(iface);
    640716        torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
    641                                  "wbcLookupName failed");
     717                                 "wbcLookupName for %s failed", cli_credentials_get_username(cmdline_credentials));
    642718
    643719        ret = wbcSidToString(&sid, &sidstr);
    644720        torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
    645                                  "wbcSidToString failed");
     721                                 "%s", "wbcSidToString failed");
    646722
    647723        ret = wbcAddNamedBlob(&params.num_blobs, &params.blobs,
     
    649725                              (uint8_t *)sidstr, strlen(sidstr)+1);
    650726        torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
    651                                  "wbcAddNamedBlob failed");
     727                                 "%s", "wbcAddNamedBlob failed");
    652728        wbcFreeMemory(sidstr);
    653         params.password = getenv("PASSWORD");
     729        params.password = cli_credentials_get_password(cmdline_credentials);
    654730        ret = wbcLogonUser(&params, &info, &error, &policy);
    655731        torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
    656                                  "wbcLogonUser failed");
     732                                 "wbcLogonUser for %s failed", params.username);
    657733        wbcFreeMemory(info); info = NULL;
    658734        wbcFreeMemory(error); error = NULL;
     
    670746        gid_t *groups;
    671747
    672         ret = wbcGetGroups(getenv("USERNAME"), &num_groups, &groups);
    673         torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
    674                                  "wbcGetGroups failed");
     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));
    675751        wbcFreeMemory(groups);
    676752        return true;
     
    683759        torture_suite_add_simple_test(suite, "wbcPing", test_wbc_ping);
    684760        torture_suite_add_simple_test(suite, "wbcPingDc", test_wbc_pingdc);
     761        torture_suite_add_simple_test(suite, "wbcPingDc2", test_wbc_pingdc2);
    685762        torture_suite_add_simple_test(suite, "wbcLibraryDetails", test_wbc_library_details);
    686763        torture_suite_add_simple_test(suite, "wbcInterfaceDetails", test_wbc_interface_details);
  • vendor/current/nsswitch/libwbclient/wbc_err_internal.h

    r414 r988  
    3030                        goto done;              \
    3131                }                               \
    32         } while(0);
     32        } while(0)
    3333
    3434#define BAIL_ON_PTR_ERROR(x, status)                    \
     
    4040                        status = WBC_ERR_SUCCESS;       \
    4141                }                                       \
    42         } while (0);
     42        } while (0)
    4343
    4444
  • vendor/current/nsswitch/libwbclient/wbc_idmap.c

    r740 r988  
    2727
    2828/* Convert a Windows SID to a Unix uid, allocating an uid if needed */
    29 wbcErr wbcSidToUid(const struct wbcDomainSid *sid, uid_t *puid)
     29wbcErr wbcCtxSidToUid(struct wbcContext *ctx, const struct wbcDomainSid *sid,
     30                      uid_t *puid)
    3031{
    3132        struct winbindd_request request;
     
    4748        /* Make request */
    4849
    49         wbc_status = wbcRequestResponse(WINBINDD_SID_TO_UID,
     50        wbc_status = wbcRequestResponse(ctx, WINBINDD_SID_TO_UID,
    5051                                        &request,
    5152                                        &response);
     
    5859 done:
    5960        return wbc_status;
     61}
     62
     63wbcErr wbcSidToUid(const struct wbcDomainSid *sid, uid_t *puid)
     64{
     65        return wbcCtxSidToUid(NULL, sid, puid);
    6066}
    6167
     
    6874
    6975/* Convert a Unix uid to a Windows SID, allocating a SID if needed */
    70 wbcErr wbcUidToSid(uid_t uid, struct wbcDomainSid *sid)
     76wbcErr wbcCtxUidToSid(struct wbcContext *ctx, uid_t uid,
     77                      struct wbcDomainSid *sid)
    7178{
    7279        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    8895        /* Make request */
    8996
    90         wbc_status = wbcRequestResponse(WINBINDD_UID_TO_SID,
     97        wbc_status = wbcRequestResponse(ctx, WINBINDD_UID_TO_SID,
    9198                                        &request,
    9299                                        &response);
     
    98105done:
    99106        return wbc_status;
     107}
     108
     109wbcErr wbcUidToSid(uid_t uid, struct wbcDomainSid *sid)
     110{
     111        return wbcCtxUidToSid(NULL, uid, sid);
    100112}
    101113
     
    116128 **/
    117129
    118 wbcErr wbcSidToGid(const struct wbcDomainSid *sid, gid_t *pgid)
     130wbcErr wbcCtxSidToGid(struct wbcContext *ctx, const struct wbcDomainSid *sid,
     131                      gid_t *pgid)
    119132{
    120133        struct winbindd_request request;
     
    136149        /* Make request */
    137150
    138         wbc_status = wbcRequestResponse(WINBINDD_SID_TO_GID,
     151        wbc_status = wbcRequestResponse(ctx, WINBINDD_SID_TO_GID,
    139152                                        &request,
    140153                                        &response);
     
    149162}
    150163
     164wbcErr wbcSidToGid(const struct wbcDomainSid *sid, gid_t *pgid)
     165{
     166        return wbcCtxSidToGid(NULL, sid, pgid);
     167}
    151168
    152169/* Convert a Windows SID to a Unix gid if there already is a mapping */
     
    160177
    161178/* Convert a Unix gid to a Windows SID, allocating a SID if needed */
    162 wbcErr wbcGidToSid(gid_t gid, struct wbcDomainSid *sid)
     179wbcErr wbcCtxGidToSid(struct wbcContext *ctx, gid_t gid,
     180                      struct wbcDomainSid *sid)
    163181{
    164182        struct winbindd_request request;
     
    180198        /* Make request */
    181199
    182         wbc_status = wbcRequestResponse(WINBINDD_GID_TO_SID,
     200        wbc_status = wbcRequestResponse(ctx, WINBINDD_GID_TO_SID,
    183201                                        &request,
    184202                                        &response);
     
    190208done:
    191209        return wbc_status;
     210}
     211
     212wbcErr wbcGidToSid(gid_t gid, struct wbcDomainSid *sid)
     213{
     214        return wbcCtxGidToSid(NULL, gid, sid);
    192215}
    193216
     
    200223
    201224/* Obtain a new uid from Winbind */
    202 wbcErr wbcAllocateUid(uid_t *puid)
     225wbcErr wbcCtxAllocateUid(struct wbcContext *ctx, uid_t *puid)
    203226{
    204227        struct winbindd_request request;
     
    216239        /* Make request */
    217240
    218         wbc_status = wbcRequestResponsePriv(WINBINDD_ALLOCATE_UID,
     241        wbc_status = wbcRequestResponsePriv(ctx, WINBINDD_ALLOCATE_UID,
    219242                                            &request, &response);
    220243        BAIL_ON_WBC_ERROR(wbc_status);
     
    229252}
    230253
     254wbcErr wbcAllocateUid(uid_t *puid)
     255{
     256        return wbcCtxAllocateUid(NULL, puid);
     257}
     258
    231259/* Obtain a new gid from Winbind */
    232 wbcErr wbcAllocateGid(gid_t *pgid)
     260wbcErr wbcCtxAllocateGid(struct wbcContext *ctx, gid_t *pgid)
    233261{
    234262        struct winbindd_request request;
     
    246274        /* Make request */
    247275
    248         wbc_status = wbcRequestResponsePriv(WINBINDD_ALLOCATE_GID,
     276        wbc_status = wbcRequestResponsePriv(ctx, WINBINDD_ALLOCATE_GID,
    249277                                            &request, &response);
    250278        BAIL_ON_WBC_ERROR(wbc_status);
     
    257285 done:
    258286        return wbc_status;
     287}
     288
     289wbcErr wbcAllocateGid(gid_t *pgid)
     290{
     291        return wbcCtxAllocateGid(NULL, pgid);
    259292}
    260293
     
    300333
    301334/* Convert a list of SIDs */
    302 wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids,
    303                         struct wbcUnixId *ids)
     335wbcErr wbcCtxSidsToUnixIds(struct wbcContext *ctx,
     336                           const struct wbcDomainSid *sids,
     337                           uint32_t num_sids, struct wbcUnixId *ids)
    304338{
    305339        struct winbindd_request request;
     
    342376        request.extra_len = p - sidlist;
    343377
    344         wbc_status = wbcRequestResponse(WINBINDD_SIDS_TO_XIDS,
     378        wbc_status = wbcRequestResponse(ctx, WINBINDD_SIDS_TO_XIDS,
    345379                                        &request, &response);
    346380        free(sidlist);
     
    371405                        id->id.gid = strtoul(p+1, &q, 10);
    372406                        break;
     407                case 'B':
     408                        id->type = WBC_ID_TYPE_BOTH;
     409                        id->id.uid = strtoul(p+1, &q, 10);
     410                        break;
    373411                default:
    374412                        id->type = WBC_ID_TYPE_NOT_SPECIFIED;
    375                         q = p;
     413                        q = strchr(p, '\n');
    376414                        break;
    377415                };
    378                 if (q[0] != '\n') {
     416                if (q == NULL || q[0] != '\n') {
    379417                        goto wbc_err_invalid;
    380418                }
     
    390428        return wbc_status;
    391429}
     430
     431wbcErr 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  
    2929
    3030/* Authenticate a username/password pair */
    31 wbcErr wbcAuthenticateUser(const char *username,
    32                            const char *password)
     31wbcErr wbcCtxAuthenticateUser(struct wbcContext *ctx,
     32                              const char *username, const char *password)
    3333{
    3434        wbcErr wbc_status = WBC_ERR_SUCCESS;
     
    4141        params.password.plaintext       = password;
    4242
    43         wbc_status = wbcAuthenticateUserEx(&params, NULL, NULL);
     43        wbc_status = wbcCtxAuthenticateUserEx(ctx, &params, NULL, NULL);
    4444        BAIL_ON_WBC_ERROR(wbc_status);
    4545
    4646done:
    4747        return wbc_status;
     48}
     49
     50wbcErr wbcAuthenticateUser(const char *username, const char *password)
     51{
     52        return wbcCtxAuthenticateUser(NULL, username, password);
    4853}
    4954
     
    343348
    344349/* Authenticate with more detailed information */
    345 wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
    346                              struct wbcAuthUserInfo **info,
    347                              struct wbcAuthErrorInfo **error)
     350wbcErr wbcCtxAuthenticateUserEx(struct wbcContext *ctx,
     351                                const struct wbcAuthUserParams *params,
     352                                struct wbcAuthUserInfo **info,
     353                                struct wbcAuthErrorInfo **error)
    348354{
    349355        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    364370        }
    365371
    366         if (!params->account_name) {
     372        if (params->level != WBC_AUTH_USER_LEVEL_PAC && !params->account_name) {
    367373                wbc_status = WBC_ERR_INVALID_PARAM;
    368374                BAIL_ON_WBC_ERROR(wbc_status);
     
    389395                        ZERO_STRUCT(sep_response);
    390396
    391                         wbc_status = wbcRequestResponse(WINBINDD_INFO,
     397                        wbc_status = wbcRequestResponse(ctx, WINBINDD_INFO,
    392398                                                        NULL, &sep_response);
    393399                        BAIL_ON_WBC_ERROR(wbc_status);
     
    491497                }
    492498                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
    493513        default:
    494514                break;
     
    505525
    506526        if (cmd == WINBINDD_PAM_AUTH_CRAP) {
    507                 wbc_status = wbcRequestResponsePriv(cmd, &request, &response);
     527                wbc_status = wbcRequestResponsePriv(ctx, cmd,
     528                                                    &request, &response);
    508529        } else {
    509                 wbc_status = wbcRequestResponse(cmd, &request, &response);
     530                wbc_status = wbcRequestResponse(ctx, cmd,
     531                                                &request, &response);
    510532        }
    511533        if (response.data.auth.nt_status != 0) {
     
    534556}
    535557
     558wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
     559                             struct wbcAuthUserInfo **info,
     560                             struct wbcAuthErrorInfo **error)
     561{
     562        return wbcCtxAuthenticateUserEx(NULL, params, info, error);
     563}
     564
    536565/* Trigger a verification of the trust credentials of a specific domain */
    537 wbcErr wbcCheckTrustCredentials(const char *domain,
    538                                 struct wbcAuthErrorInfo **error)
     566wbcErr wbcCtxCheckTrustCredentials(struct wbcContext *ctx, const char *domain,
     567                                   struct wbcAuthErrorInfo **error)
    539568{
    540569        struct winbindd_request request;
     
    552581        /* Send request */
    553582
    554         wbc_status = wbcRequestResponsePriv(WINBINDD_CHECK_MACHACC,
     583        wbc_status = wbcRequestResponsePriv(ctx, WINBINDD_CHECK_MACHACC,
    555584                                            &request, &response);
    556585        if (response.data.auth.nt_status != 0) {
     
    570599}
    571600
     601wbcErr wbcCheckTrustCredentials(const char *domain,
     602                                struct wbcAuthErrorInfo **error)
     603{
     604        return wbcCtxCheckTrustCredentials(NULL, domain, error);
     605}
     606
    572607/* Trigger a change of the trust credentials for a specific domain */
    573 wbcErr wbcChangeTrustCredentials(const char *domain,
    574                                  struct wbcAuthErrorInfo **error)
     608wbcErr wbcCtxChangeTrustCredentials(struct wbcContext *ctx, const char *domain,
     609                                    struct wbcAuthErrorInfo **error)
    575610{
    576611        struct winbindd_request request;
     
    588623        /* Send request */
    589624
    590         wbc_status = wbcRequestResponsePriv(WINBINDD_CHANGE_MACHACC,
    591                                         &request, &response);
     625        wbc_status = wbcRequestResponsePriv(ctx, WINBINDD_CHANGE_MACHACC,
     626                                            &request, &response);
    592627        if (response.data.auth.nt_status != 0) {
    593628                if (error) {
     
    606641}
    607642
     643wbcErr wbcChangeTrustCredentials(const char *domain,
     644                                 struct wbcAuthErrorInfo **error)
     645{
     646        return wbcCtxChangeTrustCredentials(NULL, domain, error);
     647}
     648
    608649/*
    609650 * Trigger a no-op NETLOGON call. Lightweight version of
    610651 * wbcCheckTrustCredentials
    611652 */
     653wbcErr wbcCtxPingDc(struct wbcContext *ctx, const char *domain,
     654                    struct wbcAuthErrorInfo **error)
     655{
     656        return wbcCtxPingDc2(ctx, domain, error, NULL);
     657}
     658
    612659wbcErr 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 */
     668wbcErr wbcCtxPingDc2(struct wbcContext *ctx, const char *domain,
     669                     struct wbcAuthErrorInfo **error, char **dcname)
    613670{
    614671        struct winbindd_request request;
     
    616673        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
    617674
    618         if (domain) {
    619                 /*
    620                  * the current protocol doesn't support
    621                  * specifying a domain
    622                  */
    623                 wbc_status = WBC_ERR_NOT_IMPLEMENTED;
    624                 BAIL_ON_WBC_ERROR(wbc_status);
    625         }
    626 
    627675        ZERO_STRUCT(request);
    628676        ZERO_STRUCT(response);
    629677
     678        if (domain) {
     679                strncpy(request.domain_name, domain,
     680                        sizeof(request.domain_name)-1);
     681        }
     682
    630683        /* Send request */
    631684
    632         wbc_status = wbcRequestResponse(WINBINDD_PING_DC,
     685        wbc_status = wbcRequestResponse(ctx, WINBINDD_PING_DC,
    633686                                        &request,
    634687                                        &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
    635699        if (response.data.auth.nt_status != 0) {
    636700                if (error) {
     
    649713}
    650714
     715wbcErr wbcPingDc2(const char *domain, struct wbcAuthErrorInfo **error,
     716                  char **dcname)
     717{
     718        return wbcCtxPingDc2(NULL, domain, error, dcname);
     719}
     720
    651721/* Trigger an extended logoff notification to Winbind for a specific user */
    652 wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params,
    653                        struct wbcAuthErrorInfo **error)
     722wbcErr wbcCtxLogoffUserEx(struct wbcContext *ctx,
     723                          const struct wbcLogoffUserParams *params,
     724                          struct wbcAuthErrorInfo **error)
    654725{
    655726        struct winbindd_request request;
     
    714785        /* Send request */
    715786
    716         wbc_status = wbcRequestResponse(WINBINDD_PAM_LOGOFF,
     787        wbc_status = wbcRequestResponse(ctx, WINBINDD_PAM_LOGOFF,
    717788                                        &request,
    718789                                        &response);
     
    735806}
    736807
     808wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params,
     809                       struct wbcAuthErrorInfo **error)
     810{
     811        return wbcCtxLogoffUserEx(NULL, params, error);
     812}
     813
    737814/* Trigger a logoff notification to Winbind for a specific user */
     815wbcErr 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
    738854wbcErr wbcLogoffUser(const char *username,
    739855                     uid_t uid,
    740856                     const char *ccfilename)
    741857{
    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);
    775859}
    776860
    777861/* 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)
     862wbcErr wbcCtxChangeUserPasswordEx(struct wbcContext *ctx,
     863                        const struct wbcChangePasswordParams *params,
     864                        struct wbcAuthErrorInfo **error,
     865                        enum wbcPasswordChangeRejectReason *reject_reason,
     866                        struct wbcUserPasswordPolicyInfo **policy)
    782867{
    783868        struct winbindd_request request;
     
    9381023        /* Send request */
    9391024
    940         wbc_status = wbcRequestResponse(cmd,
     1025        wbc_status = wbcRequestResponse(ctx, cmd,
    9411026                                        &request,
    9421027                                        &response);
     
    9731058}
    9741059
     1060wbcErr 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
    9751069/* Change a password for a user */
    976 wbcErr wbcChangeUserPassword(const char *username,
    977                              const char *old_password,
    978                              const char *new_password)
     1070wbcErr wbcCtxChangeUserPassword(struct wbcContext *ctx,
     1071                                const char *username,
     1072                                const char *old_password,
     1073                                const char *new_password)
    9791074{
    9801075        wbcErr wbc_status = WBC_ERR_SUCCESS;
     
    9881083        params.new_password.plaintext   = new_password;
    9891084
    990         wbc_status = wbcChangeUserPasswordEx(&params,
    991                                              NULL,
    992                                              NULL,
    993                                              NULL);
     1085        wbc_status = wbcCtxChangeUserPasswordEx(ctx, &params,
     1086                                                NULL,
     1087                                                NULL,
     1088                                                NULL);
    9941089        BAIL_ON_WBC_ERROR(wbc_status);
    9951090
     
    9981093}
    9991094
     1095wbcErr 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
    10001103/* Logon a User */
    1001 wbcErr wbcLogonUser(const struct wbcLogonUserParams *params,
    1002                     struct wbcLogonUserInfo **info,
    1003                     struct wbcAuthErrorInfo **error,
    1004                     struct wbcUserPasswordPolicyInfo **policy)
     1104wbcErr wbcCtxLogonUser(struct wbcContext *ctx,
     1105                       const struct wbcLogonUserParams *params,
     1106                       struct wbcLogonUserInfo **info,
     1107                       struct wbcAuthErrorInfo **error,
     1108                       struct wbcUserPasswordPolicyInfo **policy)
    10051109{
    10061110        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    11041208        }
    11051209
    1106         wbc_status = wbcRequestResponse(WINBINDD_PAM_AUTH,
     1210        wbc_status = wbcRequestResponse(ctx, WINBINDD_PAM_AUTH,
    11071211                                        &request,
    11081212                                        &response);
     
    11381242}
    11391243
     1244wbcErr 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
    11401252static void wbcCredentialCacheInfoDestructor(void *ptr)
    11411253{
     
    11461258
    11471259/* Authenticate a user with cached credentials */
    1148 wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params,
    1149                           struct wbcCredentialCacheInfo **info,
    1150                           struct wbcAuthErrorInfo **error)
     1260wbcErr wbcCtxCredentialCache(struct wbcContext *ctx,
     1261                             struct wbcCredentialCacheParams *params,
     1262                             struct wbcCredentialCacheInfo **info,
     1263                             struct wbcAuthErrorInfo **error)
    11511264{
    11521265        wbcErr status = WBC_ERR_UNKNOWN_FAILURE;
     
    11611274        ZERO_STRUCT(response);
    11621275
    1163         if (info != NULL) {
    1164                 *info = NULL;
    1165         }
     1276        *info = NULL;
     1277
    11661278        if (error != NULL) {
    11671279                *error = NULL;
     
    11741286        }
    11751287
     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 = &params->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 = &params->blobs[i];
     1313                        continue;
     1314                }
     1315        }
     1316
    11761317        if (params->domain_name != NULL) {
    1177                 status = wbcRequestResponse(WINBINDD_INFO, NULL, &response);
     1318                status = wbcRequestResponse(ctx, WINBINDD_INFO,
     1319                                            NULL, &response);
    11781320                if (!WBC_ERROR_IS_OK(status)) {
    11791321                        goto fail;
     
    11911333        request.data.ccache_ntlm_auth.uid = getuid();
    11921334
    1193         for (i=0; i<params->num_blobs; i++) {
    1194                 if (strcasecmp(params->blobs[i].name, "initial_blob") == 0) {
    1195                         initial_blob = &params->blobs[i];
    1196                         break;
    1197                 }
    1198                 if (strcasecmp(params->blobs[i].name, "challenge_blob") == 0) {
    1199                         challenge_blob = &params->blobs[i];
    1200                         break;
    1201                 }
    1202         }
    1203 
    12041335        request.data.ccache_ntlm_auth.initial_blob_len = 0;
    12051336        request.data.ccache_ntlm_auth.challenge_blob_len = 0;
     
    12351366        }
    12361367
    1237         status = wbcRequestResponse(WINBINDD_CCACHE_NTLMAUTH, &request,
    1238                                     &response);
     1368        status = wbcRequestResponse(ctx, WINBINDD_CCACHE_NTLMAUTH,
     1369                                    &request, &response);
    12391370        if (!WBC_ERROR_IS_OK(status)) {
    12401371                goto fail;
     
    12641395                goto fail;
    12651396        }
     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        }
    12661406
    12671407        *info = result;
     
    12751415}
    12761416
     1417wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params,
     1418                          struct wbcCredentialCacheInfo **info,
     1419                          struct wbcAuthErrorInfo **error)
     1420{
     1421        return wbcCtxCredentialCache(NULL, params, info, error);
     1422}
     1423
    12771424/* Authenticate a user with cached credentials */
    1278 wbcErr wbcCredentialSave(const char *user, const char *password)
     1425wbcErr wbcCtxCredentialSave(struct wbcContext *ctx,
     1426                            const char *user, const char *password)
    12791427{
    12801428        struct winbindd_request request;
     
    12901438        request.data.ccache_save.uid = getuid();
    12911439
    1292         return wbcRequestResponse(WINBINDD_CCACHE_SAVE, &request, &response);
    1293 }
     1440        return wbcRequestResponse(ctx, WINBINDD_CCACHE_SAVE, &request, &response);
     1441}
     1442
     1443wbcErr wbcCredentialSave(const char *user, const char *password)
     1444{
     1445        return wbcCtxCredentialSave(NULL, user, password);
     1446}
  • vendor/current/nsswitch/libwbclient/wbc_pwd.c

    r740 r988  
    55
    66   Copyright (C) Gerald (Jerry) Carter 2007
     7   Copyright (C) Matthew Newton 2015
    78
    89
     
    168169
    169170/* Fill in a struct passwd* for a domain user based on username */
    170 wbcErr wbcGetpwnam(const char *name, struct passwd **pwd)
     171wbcErr wbcCtxGetpwnam(struct wbcContext *ctx,
     172                      const char *name, struct passwd **pwd)
    171173{
    172174        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    188190        strncpy(request.data.username, name, sizeof(request.data.username)-1);
    189191
    190         wbc_status = wbcRequestResponse(WINBINDD_GETPWNAM,
     192        wbc_status = wbcRequestResponse(ctx, WINBINDD_GETPWNAM,
    191193                                        &request,
    192194                                        &response);
     
    200202}
    201203
     204wbcErr wbcGetpwnam(const char *name, struct passwd **pwd)
     205{
     206        return wbcCtxGetpwnam(NULL, name, pwd);
     207}
     208
    202209/* Fill in a struct passwd* for a domain user based on uid */
    203 wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd)
     210wbcErr wbcCtxGetpwuid(struct wbcContext *ctx, uid_t uid, struct passwd **pwd)
    204211{
    205212        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    219226        request.data.uid = uid;
    220227
    221         wbc_status = wbcRequestResponse(WINBINDD_GETPWUID,
     228        wbc_status = wbcRequestResponse(ctx, WINBINDD_GETPWUID,
    222229                                        &request,
    223230                                        &response);
     
    231238}
    232239
     240wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd)
     241{
     242        return wbcCtxGetpwuid(NULL, uid, pwd);
     243}
     244
    233245/* Fill in a struct passwd* for a domain user based on sid */
    234 wbcErr wbcGetpwsid(struct wbcDomainSid *sid, struct passwd **pwd)
     246wbcErr wbcCtxGetpwsid(struct wbcContext *ctx,
     247                      struct wbcDomainSid *sid, struct passwd **pwd)
    235248{
    236249        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    250263        wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid));
    251264
    252         wbc_status = wbcRequestResponse(WINBINDD_GETPWSID,
     265        wbc_status = wbcRequestResponse(ctx, WINBINDD_GETPWSID,
    253266                                        &request,
    254267                                        &response);
     
    262275}
    263276
     277wbcErr wbcGetpwsid(struct wbcDomainSid *sid, struct passwd **pwd)
     278{
     279        return wbcCtxGetpwsid(NULL, sid, pwd);
     280}
     281
    264282/* Fill in a struct passwd* for a domain user based on username */
    265 wbcErr wbcGetgrnam(const char *name, struct group **grp)
     283wbcErr wbcCtxGetgrnam(struct wbcContext *ctx,
     284                      const char *name, struct group **grp)
    266285{
    267286        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    283302        strncpy(request.data.groupname, name, sizeof(request.data.groupname)-1);
    284303
    285         wbc_status = wbcRequestResponse(WINBINDD_GETGRNAM,
     304        wbc_status = wbcRequestResponse(ctx, WINBINDD_GETGRNAM,
    286305                                        &request,
    287306                                        &response);
     
    298317}
    299318
     319wbcErr wbcGetgrnam(const char *name, struct group **grp)
     320{
     321        return wbcCtxGetgrnam(NULL, name, grp);
     322}
     323
    300324/* Fill in a struct passwd* for a domain user based on uid */
    301 wbcErr wbcGetgrgid(gid_t gid, struct group **grp)
     325wbcErr wbcCtxGetgrgid(struct wbcContext *ctx, gid_t gid, struct group **grp)
    302326{
    303327        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    317341        request.data.gid = gid;
    318342
    319         wbc_status = wbcRequestResponse(WINBINDD_GETGRGID,
     343        wbc_status = wbcRequestResponse(ctx, WINBINDD_GETGRGID,
    320344                                        &request,
    321345                                        &response);
     
    332356}
    333357
    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;
     358wbcErr wbcGetgrgid(gid_t gid, struct group **grp)
     359{
     360        return wbcCtxGetgrgid(NULL, gid, grp);
     361}
    343362
    344363/** @brief Winbindd response containing the passwd structs
     
    348367
    349368/* Reset the passwd iterator */
     369wbcErr 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
    350392wbcErr wbcSetpwent(void)
    351393{
    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 */
     398wbcErr 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;
    356408                winbindd_free_response(&pw_response);
    357409        }
    358410
    359         ZERO_STRUCT(pw_response);
    360 
    361         wbc_status = wbcRequestResponse(WINBINDD_SETPWENT,
     411        wbc_status = wbcRequestResponse(ctx, WINBINDD_ENDPWENT,
    362412                                        NULL, NULL);
    363413        BAIL_ON_WBC_ERROR(wbc_status);
     
    367417}
    368418
    369 /* Close the passwd iterator */
    370419wbcErr wbcEndpwent(void)
    371420{
    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);
    385422}
    386423
    387424/* Return the next struct passwd* entry from the pwent iterator */
     425wbcErr 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
     456return_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
     466done:
     467        return wbc_status;
     468}
     469
    388470wbcErr wbcGetpwent(struct passwd **pwd)
    389471{
    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}
    438474
    439475/** @brief Winbindd response containing the group structs
     
    443479
    444480/* Reset the group iterator */
     481wbcErr 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
    445504wbcErr wbcSetgrent(void)
    446505{
    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 */
     510wbcErr 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;
    451520                winbindd_free_response(&gr_response);
    452521        }
    453522
    454         ZERO_STRUCT(gr_response);
    455 
    456         wbc_status = wbcRequestResponse(WINBINDD_SETGRENT,
     523        wbc_status = wbcRequestResponse(ctx, WINBINDD_ENDGRENT,
    457524                                        NULL, NULL);
    458525        BAIL_ON_WBC_ERROR(wbc_status);
     
    462529}
    463530
    464 /* Close the group iterator */
    465531wbcErr wbcEndgrent(void)
    466532{
    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);
    480534}
    481535
    482536/* Return the next struct group* entry from the pwent iterator */
    483 wbcErr wbcGetgrent(struct group **grp)
     537wbcErr wbcCtxGetgrent(struct wbcContext *ctx, struct group **grp)
    484538{
    485539        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    488542        uint32_t mem_ofs;
    489543
     544        if (!ctx) {
     545                ctx = wbcGetGlobalCtx();
     546        }
     547
    490548        /* 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) {
    492550                goto return_result;
    493551        }
     
    495553        /* Otherwise, query winbindd for some entries. */
    496554
    497         gr_cache_idx = 0;
     555        ctx->gr_cache_idx = 0;
    498556
    499557        winbindd_free_response(&gr_response);
     
    502560        request.data.num_entries = MAX_GETGRENT_GROUPS;
    503561
    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;
    510568
    511569return_result:
     
    513571        wb_gr = (struct winbindd_gr *) gr_response.extra_data.data;
    514572
    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],
    519577                                ((char *)gr_response.extra_data.data)+mem_ofs);
    520578
    521579        BAIL_ON_PTR_ERROR(*grp, wbc_status);
    522580
    523         gr_cache_idx++;
     581        ctx->gr_cache_idx++;
    524582
    525583done:
     
    527585}
    528586
     587wbcErr wbcGetgrent(struct group **grp)
     588{
     589        return wbcCtxGetgrent(NULL, grp);
     590}
     591
    529592/* Return the next struct group* entry from the pwent iterator */
    530 wbcErr wbcGetgrlist(struct group **grp)
     593wbcErr wbcCtxGetgrlist(struct wbcContext *ctx, struct group **grp)
    531594{
    532595        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    534597        struct winbindd_gr *wb_gr;
    535598
     599        if (!ctx) {
     600                ctx = wbcGetGlobalCtx();
     601        }
     602
    536603        /* 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) {
    538605                goto return_result;
    539606        }
     
    541608        /* Otherwise, query winbindd for some entries. */
    542609
    543         gr_cache_idx = 0;
     610        ctx->gr_cache_idx = 0;
    544611
    545612        winbindd_free_response(&gr_response);
     
    549616        request.data.num_entries = MAX_GETGRENT_GROUPS;
    550617
    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;
    557624
    558625return_result:
     
    560627        wb_gr = (struct winbindd_gr *) gr_response.extra_data.data;
    561628
    562         *grp = copy_group_entry(&wb_gr[gr_cache_idx], NULL);
     629        *grp = copy_group_entry(&wb_gr[ctx->gr_cache_idx], NULL);
    563630
    564631        BAIL_ON_PTR_ERROR(*grp, wbc_status);
    565632
    566         gr_cache_idx++;
     633        ctx->gr_cache_idx++;
    567634
    568635done:
     
    570637}
    571638
     639wbcErr wbcGetgrlist(struct group **grp)
     640{
     641        return wbcCtxGetgrlist(NULL, grp);
     642}
     643
    572644/* 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)
     645wbcErr wbcCtxGetGroups(struct wbcContext *ctx, const char *account,
     646                       uint32_t *num_groups, gid_t **_groups)
    576647{
    577648        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    595666        strncpy(request.data.username, account, sizeof(request.data.username)-1);
    596667
    597         wbc_status = wbcRequestResponse(WINBINDD_GETGROUPS,
     668        wbc_status = wbcRequestResponse(ctx, WINBINDD_GETGROUPS,
    598669                                        &request,
    599670                                        &response);
     
    619690        return wbc_status;
    620691}
     692
     693wbcErr 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  
    3333int wbcSidToStringBuf(const struct wbcDomainSid *sid, char *buf, int buflen)
    3434{
    35         uint32_t id_auth;
     35        uint64_t id_auth;
    3636        int i, ofs;
    3737
     
    4141        }
    4242
    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        }
    5558
    5659        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]);
    5962        }
    6063        return ofs;
     
    8992}
    9093
     94#define AUTHORITY_MASK  (~(0xffffffffffffULL))
     95
    9196/* Convert a character string to a binary SID */
    9297wbcErr wbcStringToSid(const char *str,
     
    95100        const char *p;
    96101        char *q;
    97         uint32_t x;
     102        uint64_t x;
    98103        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
    99104
     
    116121
    117122        p = str+2;
    118         x = (uint32_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!='-') {
    120125                wbc_status = WBC_ERR_INVALID_SID;
    121126                BAIL_ON_WBC_ERROR(wbc_status);
     
    123128        sid->sid_rev_num = (uint8_t)x;
    124129
    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         */
    128135        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)) {
    131138                wbc_status = WBC_ERR_INVALID_SID;
    132139                BAIL_ON_WBC_ERROR(wbc_status);
    133140        }
    134         sid->id_auth[5] = (x & 0x000000ff);
    135         sid->id_auth[4] = (x & 0x0000ff00) >> 8;
    136         sid->id_auth[3] = (x & 0x00ff0000) >> 16;
    137         sid->id_auth[2] = (x & 0xff000000) >> 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;
    140147
    141148        /* now read the the subauthorities */
    142 
    143149        p = q +1;
    144150        sid->num_auths = 0;
    145151        while (sid->num_auths < WBC_MAXSUBAUTHS) {
    146                 x=(uint32_t)strtoul(p, &q, 10);
     152                x = strtoull(p, &q, 10);
    147153                if (p == q)
    148154                        break;
    149                 if (q == NULL) {
     155                if (x > UINT32_MAX) {
    150156                        wbc_status = WBC_ERR_INVALID_SID;
    151157                        BAIL_ON_WBC_ERROR(wbc_status);
     
    175181
    176182/* Convert a domain and name to SID */
     183wbcErr 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
    177226wbcErr wbcLookupName(const char *domain,
    178227                     const char *name,
     
    180229                     enum wbcSidType *name_type)
    181230{
    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);
    217232}
    218233
    219234
    220235/* 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)
     236wbcErr wbcCtxLookupSid(struct wbcContext *ctx,
     237                       const struct wbcDomainSid *sid,
     238                       char **pdomain,
     239                       char **pname,
     240                       enum wbcSidType *pname_type)
    225241{
    226242        struct winbindd_request request;
     
    242258        /* Make request */
    243259
    244         wbc_status = wbcRequestResponse(WINBINDD_LOOKUPSID, &request,
     260        wbc_status = wbcRequestResponse(ctx, WINBINDD_LOOKUPSID,
     261                                        &request,
    245262                                        &response);
    246263        if (!WBC_ERROR_IS_OK(wbc_status)) {
     
    280297}
    281298
     299wbcErr 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
    282307static void wbcDomainInfosDestructor(void *ptr)
    283308{
     
    296321
    297322        while (n->name != NULL) {
    298                 free(n->name);
     323                wbcFreeMemory(n->name);
    299324                n += 1;
    300325        }
    301326}
    302327
    303 wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids,
    304                      struct wbcDomainInfo **pdomains, int *pnum_domains,
    305                      struct wbcTranslatedName **pnames)
     328wbcErr wbcCtxLookupSids(struct wbcContext *ctx,
     329                        const struct wbcDomainSid *sids, int num_sids,
     330                        struct wbcDomainInfo **pdomains, int *pnum_domains,
     331                        struct wbcTranslatedName **pnames)
    306332{
    307333        struct winbindd_request request;
     
    345371        request.extra_len = p - sidlist;
    346372
    347         wbc_status = wbcRequestResponse(WINBINDD_LOOKUPSIDS,
     373        wbc_status = wbcRequestResponse(ctx, WINBINDD_LOOKUPSIDS,
    348374                                        &request, &response);
    349375        free(sidlist);
     
    470496}
    471497
     498wbcErr 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
    472506/* Translate a collection of RIDs within a domain to names */
    473507
    474 wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
     508wbcErr wbcCtxLookupRids(struct wbcContext *ctx, struct wbcDomainSid *dom_sid,
    475509                     int num_rids,
    476510                     uint32_t *rids,
     
    522556        request.extra_len = len;
    523557
    524         wbc_status = wbcRequestResponse(WINBINDD_LOOKUPRIDS,
     558        wbc_status = wbcRequestResponse(ctx, WINBINDD_LOOKUPRIDS,
    525559                                        &request,
    526560                                        &response);
     
    594628}
    595629
     630wbcErr 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
    596641/* 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)
     642wbcErr wbcCtxLookupUserSids(struct wbcContext *ctx,
     643                            const struct wbcDomainSid *user_sid,
     644                            bool domain_groups_only,
     645                            uint32_t *num_sids,
     646                            struct wbcDomainSid **_sids)
    601647{
    602648        uint32_t i;
     
    626672        }
    627673
    628         wbc_status = wbcRequestResponse(cmd,
     674        wbc_status = wbcRequestResponse(ctx, cmd,
    629675                                        &request,
    630676                                        &response);
     
    667713}
    668714
     715wbcErr 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
    669724static inline
    670725wbcErr _sid_to_rid(struct wbcDomainSid *sid, uint32_t *rid)
     
    679734
    680735/* 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)
     736wbcErr 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)
    686742{
    687743        uint32_t i;
     
    744800        request.extra_len = extra_data_len;
    745801
    746         wbc_status = wbcRequestResponse(WINBINDD_GETSIDALIASES,
     802        wbc_status = wbcRequestResponse(ctx, WINBINDD_GETSIDALIASES,
    747803                                        &request,
    748804                                        &response);
     
    784840}
    785841
     842wbcErr 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
    786852
    787853/* Lists Users */
    788 wbcErr wbcListUsers(const char *domain_name,
    789                     uint32_t *_num_users,
    790                     const char ***_users)
     854wbcErr wbcCtxListUsers(struct wbcContext *ctx,
     855                       const char *domain_name,
     856                       uint32_t *_num_users,
     857                       const char ***_users)
    791858{
    792859        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    807874        }
    808875
    809         wbc_status = wbcRequestResponse(WINBINDD_LIST_USERS,
     876        wbc_status = wbcRequestResponse(ctx, WINBINDD_LIST_USERS,
    810877                                        &request,
    811878                                        &response);
     
    859926}
    860927
     928wbcErr 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
    861935/* Lists Groups */
    862 wbcErr wbcListGroups(const char *domain_name,
    863                      uint32_t *_num_groups,
    864                      const char ***_groups)
     936wbcErr wbcCtxListGroups(struct wbcContext *ctx,
     937                        const char *domain_name,
     938                        uint32_t *_num_groups,
     939                        const char ***_groups)
    865940{
    866941        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    881956        }
    882957
    883         wbc_status = wbcRequestResponse(WINBINDD_LIST_GROUPS,
     958        wbc_status = wbcRequestResponse(ctx, WINBINDD_LIST_GROUPS,
    884959                                        &request,
    885960                                        &response);
     
    9331008}
    9341009
    935 wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid,
    936                          char **pdomain,
    937                          char **pfullname,
    938                          enum wbcSidType *pname_type)
     1010wbcErr 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
     1017wbcErr wbcCtxGetDisplayName(struct wbcContext *ctx,
     1018                            const struct wbcDomainSid *sid,
     1019                            char **pdomain,
     1020                            char **pfullname,
     1021                            enum wbcSidType *pname_type)
    9391022{
    9401023        wbcErr wbc_status;
     
    9431026        enum wbcSidType name_type;
    9441027
    945         wbc_status = wbcLookupSid(sid, &domain, &name, &name_type);
     1028        wbc_status = wbcCtxLookupSid(ctx, sid, &domain, &name, &name_type);
    9461029        BAIL_ON_WBC_ERROR(wbc_status);
    9471030
     
    9501033                struct passwd *pwd;
    9511034
    952                 wbc_status = wbcSidToUid(sid, &uid);
    953                 BAIL_ON_WBC_ERROR(wbc_status);
    954 
    955                 wbc_status = wbcGetpwuid(uid, &pwd);
     1035                wbc_status = wbcCtxSidToUid(ctx, sid, &uid);
     1036                BAIL_ON_WBC_ERROR(wbc_status);
     1037
     1038                wbc_status = wbcCtxGetpwuid(ctx, uid, &pwd);
    9561039                BAIL_ON_WBC_ERROR(wbc_status);
    9571040
     
    9761059
    9771060        return wbc_status;
     1061}
     1062
     1063wbcErr 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);
    9781069}
    9791070
  • vendor/current/nsswitch/libwbclient/wbc_util.c

    r740 r988  
    2929/** @brief Ping winbindd to see if the daemon is running
    3030 *
     31 * @param *ctx       wbclient Context
     32 *
    3133 * @return #wbcErr
    3234 **/
    33 wbcErr wbcPing(void)
     35wbcErr wbcCtxPing(struct wbcContext *ctx)
    3436{
    3537        struct winbindd_request request;
     
    4143        ZERO_STRUCT(response);
    4244
    43         return wbcRequestResponse(WINBINDD_PING, &request, &response);
     45        return wbcRequestResponse(ctx, WINBINDD_PING, &request, &response);
     46}
     47
     48wbcErr wbcPing(void)
     49{
     50        return wbcCtxPing(NULL);
    4451}
    4552
     
    6168 */
    6269
    63 wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
     70wbcErr wbcCtxInterfaceDetails(struct wbcContext *ctx,
     71                              struct wbcInterfaceDetails **_details)
    6472{
    6573        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    8088
    8189        /* first the interface version */
    82         wbc_status = wbcRequestResponse(WINBINDD_INTERFACE_VERSION, NULL, &response);
     90        wbc_status = wbcRequestResponse(ctx, WINBINDD_INTERFACE_VERSION,
     91                                        NULL, &response);
    8392        BAIL_ON_WBC_ERROR(wbc_status);
    8493        info->interface_version = response.data.interface_version;
    8594
    8695        /* 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);
    8897        BAIL_ON_WBC_ERROR(wbc_status);
    8998
     
    93102
    94103        /* 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);
    96106        BAIL_ON_WBC_ERROR(wbc_status);
    97107
     
    100110
    101111        /* 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);
    103114        BAIL_ON_WBC_ERROR(wbc_status);
    104115
     
    106117        BAIL_ON_PTR_ERROR(info->netbios_domain, wbc_status);
    107118
    108         wbc_status = wbcDomainInfo(info->netbios_domain, &domain);
     119        wbc_status = wbcCtxDomainInfo(ctx, info->netbios_domain, &domain);
    109120        if (wbc_status == WBC_ERR_DOMAIN_NOT_FOUND) {
    110121                /* maybe it's a standalone server */
     
    131142        wbcFreeMemory(info);
    132143        return wbc_status;
     144}
     145
     146wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
     147{
     148        return wbcCtxInterfaceDetails(NULL, _details);
    133149}
    134150
     
    148164 */
    149165
    150 wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
     166wbcErr wbcCtxDomainInfo(struct wbcContext *ctx,
     167                        const char *domain,
     168                        struct wbcDomainInfo **dinfo)
    151169{
    152170        struct winbindd_request request;
     
    168186                sizeof(request.domain_name)-1);
    169187
    170         wbc_status = wbcRequestResponse(WINBINDD_DOMAIN_INFO,
     188        wbc_status = wbcRequestResponse(ctx, WINBINDD_DOMAIN_INFO,
    171189                                        &request,
    172190                                        &response);
     
    204222}
    205223
     224wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
     225{
     226        return wbcCtxDomainInfo(NULL, domain, dinfo);
     227}
     228
    206229/* 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)
     230wbcErr wbcCtxDcInfo(struct wbcContext *ctx,
     231                    const char *domain, size_t *num_dcs,
     232                    const char ***dc_names, const char ***dc_ips)
    209233{
    210234        struct winbindd_request request;
     
    227251        }
    228252
    229         wbc_status = wbcRequestResponse(WINBINDD_DC_INFO,
     253        wbc_status = wbcRequestResponse(ctx, WINBINDD_DC_INFO,
    230254                                        &request, &response);
    231255        BAIL_ON_WBC_ERROR(wbc_status);
     
    291315}
    292316
     317wbcErr 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
    293323/* Resolve a NetbiosName via WINS */
    294 wbcErr wbcResolveWinsByName(const char *name, char **ip)
     324wbcErr wbcCtxResolveWinsByName(struct wbcContext *ctx,
     325                               const char *name, char **ip)
    295326{
    296327        struct winbindd_request request;
     
    307338                sizeof(request.data.winsreq)-1);
    308339
    309         wbc_status = wbcRequestResponse(WINBINDD_WINS_BYNAME,
     340        wbc_status = wbcRequestResponse(ctx, WINBINDD_WINS_BYNAME,
    310341                                        &request,
    311342                                        &response);
     
    324355}
    325356
     357wbcErr wbcResolveWinsByName(const char *name, char **ip)
     358{
     359        return wbcCtxResolveWinsByName(NULL, name, ip);
     360}
     361
    326362/* Resolve an IP address via WINS into a NetbiosName */
    327 wbcErr wbcResolveWinsByIP(const char *ip, char **name)
     363wbcErr wbcCtxResolveWinsByIP(struct wbcContext *ctx,
     364                             const char *ip, char **name)
    328365{
    329366        struct winbindd_request request;
     
    340377                sizeof(request.data.winsreq)-1);
    341378
    342         wbc_status = wbcRequestResponse(WINBINDD_WINS_BYIP,
     379        wbc_status = wbcRequestResponse(ctx, WINBINDD_WINS_BYIP,
    343380                                        &request,
    344381                                        &response);
     
    355392 done:
    356393        return wbc_status;
     394}
     395
     396wbcErr wbcResolveWinsByIP(const char *ip, char **name)
     397{
     398        return wbcCtxResolveWinsByIP(NULL, ip, name);
    357399}
    358400
     
    467509
    468510        /* Online/Offline status */
    469 
    470511        r = s;
    471         if (r == NULL) {
    472                 wbc_status = WBC_ERR_INVALID_RESPONSE;
    473                 BAIL_ON_WBC_ERROR(wbc_status);
    474         }
    475512        if ( strcmp(r, "Offline") == 0) {
    476513                info->domain_flags |= WBC_DOMINFO_DOMAIN_OFFLINE;
     
    495532
    496533/* Enumerate the domain trusts known by Winbind */
    497 wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains)
     534wbcErr wbcCtxListTrusts(struct wbcContext *ctx,
     535                        struct wbcDomainInfo **domains, size_t *num_domains)
    498536{
    499537        struct winbindd_response response;
     
    511549        /* Send request */
    512550
    513         wbc_status = wbcRequestResponse(WINBINDD_LIST_TRUSTDOM,
     551        wbc_status = wbcRequestResponse(ctx, WINBINDD_LIST_TRUSTDOM,
    514552                                        NULL,
    515553                                        &response);
     
    565603}
    566604
     605wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains)
     606{
     607        return wbcCtxListTrusts(NULL, domains, num_domains);
     608}
     609
    567610static void wbcDomainControllerInfoDestructor(void *ptr)
    568611{
     
    573616
    574617/* Enumerate the domain trusts known by Winbind */
    575 wbcErr wbcLookupDomainController(const char *domain,
    576                                  uint32_t flags,
    577                                 struct wbcDomainControllerInfo **dc_info)
     618wbcErr wbcCtxLookupDomainController(struct wbcContext *ctx,
     619                                    const char *domain, uint32_t flags,
     620                                    struct wbcDomainControllerInfo **dc_info)
    578621{
    579622        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
     
    604647        /* Send request */
    605648
    606         wbc_status = wbcRequestResponse(WINBINDD_DSGETDCNAME,
     649        wbc_status = wbcRequestResponse(ctx, WINBINDD_DSGETDCNAME,
    607650                                        &request,
    608651                                        &response);
     
    620663}
    621664
     665wbcErr wbcLookupDomainController(const char *domain, uint32_t flags,
     666                                 struct wbcDomainControllerInfo **dc_info)
     667{
     668        return wbcCtxLookupDomainController(NULL, domain, flags, dc_info);
     669}
     670
    622671static void wbcDomainControllerInfoExDestructor(void *ptr)
    623672{
    624673        struct wbcDomainControllerInfoEx *i =
    625674                (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));
    633682}
    634683
     
    694743
    695744/* Get extended domain controller information */
     745wbcErr 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;
     802done:
     803        return wbc_status;
     804}
     805
    696806wbcErr wbcLookupDomainControllerEx(const char *domain,
    697807                                   struct wbcGuid *guid,
     
    700810                                   struct wbcDomainControllerInfoEx **dc_info)
    701811{
    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);
    754814}
    755815
     
    759819
    760820        while (b->name != NULL) {
    761                 free((char *)(b->name));
     821                free(discard_const_p(char, b->name));
    762822                free(b->blob.data);
    763823                b += 1;
  • vendor/current/nsswitch/libwbclient/wbclient.c

    r740 r988  
    55
    66   Copyright (C) Gerald (Jerry) Carter 2007
     7   Copyright (C) Matthew Newton 2015
    78
    89
     
    2829/* From wb_common.c */
    2930
    30 NSS_STATUS winbindd_request_response(int req_type,
     31struct winbindd_context;
     32
     33NSS_STATUS winbindd_request_response(struct winbindd_context *wbctx,
     34                                     int req_type,
    3135                                     struct winbindd_request *request,
    3236                                     struct winbindd_response *response);
    33 NSS_STATUS winbindd_priv_request_response(int req_type,
     37NSS_STATUS winbindd_priv_request_response(struct winbindd_context *wbctx,
     38                                          int req_type,
    3439                                          struct winbindd_request *request,
    3540                                          struct winbindd_response *response);
     41struct winbindd_context *winbindd_ctx_create(void);
     42void winbindd_ctx_free(struct winbindd_context *ctx);
     43
     44/* Global context used for non-Ctx functions */
     45
     46static 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};
    3653
    3754/*
     
    4966
    5067static wbcErr wbcRequestResponseInt(
     68        struct winbindd_context *wbctx,
    5169        int cmd,
    5270        struct winbindd_request *request,
    5371        struct winbindd_response *response,
    54         NSS_STATUS (*fn)(int req_type,
     72        NSS_STATUS (*fn)(struct winbindd_context *wbctx, int req_type,
    5573                         struct winbindd_request *request,
    5674                         struct winbindd_response *response))
     
    6179        /* for some calls the request and/or response can be NULL */
    6280
    63         nss_status = fn(cmd, request, response);
     81        nss_status = fn(wbctx, cmd, request, response);
    6482
    6583        switch (nss_status) {
     
    84102 * @brief Wrapper around Winbind's send/receive API call
    85103 *
     104 * @param ctx       Context
    86105 * @param cmd       Winbind command operation to perform
    87106 * @param request   Send structure
     
    90109 * @return #wbcErr
    91110 */
    92 wbcErr wbcRequestResponse(int cmd,
     111wbcErr wbcRequestResponse(struct wbcContext *ctx, int cmd,
    93112                          struct winbindd_request *request,
    94113                          struct winbindd_response *response)
    95114{
    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,
    97122                                     winbindd_request_response);
    98123}
    99124
    100 wbcErr wbcRequestResponsePriv(int cmd,
     125wbcErr wbcRequestResponsePriv(struct wbcContext *ctx, int cmd,
    101126                              struct winbindd_request *request,
    102127                              struct winbindd_response *response)
    103128{
    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,
    105136                                     winbindd_priv_request_response);
    106137}
     
    258289        return WBC_ERR_SUCCESS;
    259290}
     291
     292/* Context handling functions */
     293
     294static void wbcContextDestructor(void *ptr)
     295{
     296        struct wbcContext *ctx = (struct wbcContext *)ptr;
     297
     298        winbindd_ctx_free(ctx->winbindd_ctx);
     299}
     300
     301struct 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
     325void wbcCtxFree(struct wbcContext *ctx)
     326{
     327        wbcFreeMemory(ctx);
     328}
     329
     330struct wbcContext *wbcGetGlobalCtx(void)
     331{
     332        return &wbcGlobalCtx;
     333}
  • vendor/current/nsswitch/libwbclient/wbclient.h

    r740 r988  
    66   Copyright (C) Gerald (Jerry) Carter 2007
    77   Copyright (C) Volker Lendecke 2009
     8   Copyright (C) Matthew Newton 2015
    89
    910   This library is free software; you can redistribute it and/or
     
    6970 *  0.7: Added wbcSidToStringBuf()
    7071 *  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
    7176 **/
    7277#define WBCLIENT_MAJOR_VERSION 0
    73 #define WBCLIENT_MINOR_VERSION 8
     78#define WBCLIENT_MINOR_VERSION 12
    7479#define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
    7580struct wbcLibraryDetails {
     
    9196        char *dns_domain;
    9297};
     98
     99/**
     100 *  @brief Library context data
     101 *
     102 **/
     103
     104struct wbcContext;
    93105
    94106/*
     
    196208
    197209/**
     210 * @brief Generic Blob
     211 **/
     212
     213struct wbcBlob {
     214        uint8_t *data;
     215        size_t length;
     216};
     217
     218/**
     219 * @brief Named Blob
     220 **/
     221
     222struct wbcNamedBlob {
     223        const char *name;
     224        uint32_t flags;
     225        struct wbcBlob blob;
     226};
     227
     228/**
    198229 * @brief Auth User Parameters
    199230 **/
     
    211242                WBC_AUTH_USER_LEVEL_PLAIN = 1,
    212243                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
    214246        } level;
    215247        union {
     
    226258                        uint8_t *lm_data;
    227259                } response;
     260                struct wbcBlob pac;
    228261        } password;
    229 };
    230 
    231 /**
    232  * @brief Generic Blob
    233  **/
    234 
    235 struct wbcBlob {
    236         uint8_t *data;
    237         size_t length;
    238 };
    239 
    240 /**
    241  * @brief Named Blob
    242  **/
    243 
    244 struct wbcNamedBlob {
    245         const char *name;
    246         uint32_t flags;
    247         struct wbcBlob blob;
    248262};
    249263
     
    519533
    520534
     535/**********************************************************
     536 * Context Management
     537 **********************************************************/
     538
     539/**
     540 * @brief Create a new wbcContext context
     541 *
     542 * @return wbcContext
     543 **/
     544struct wbcContext *wbcCtxCreate(void);
     545
     546/**
     547 * @brief Free a library context
     548 *
     549 * @param ctx           wbcContext to free
     550 *
     551 * @return void
     552 **/
     553void wbcCtxFree(struct wbcContext *ctx);
     554
     555
     556
    521557/*
    522558 * Utility functions for dealing with SIDs
     
    596632 * @brief Ping winbindd to see if the daemon is running
    597633 *
     634 * @param *ctx        wbclient Context
     635 *
     636 * @return #wbcErr
     637 **/
     638wbcErr wbcCtxPing(struct wbcContext *ctx);
     639
     640/**
     641 * @brief Ping winbindd to see if the daemon is running
     642 *
    598643 * @return #wbcErr
    599644 **/
     
    602647wbcErr wbcLibraryDetails(struct wbcLibraryDetails **details);
    603648
     649wbcErr wbcCtxInterfaceDetails(struct wbcContext *ctx,
     650                              struct wbcInterfaceDetails **details);
    604651wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details);
    605652
     
    611658 * @brief Convert a domain and name to SID
    612659 *
     660 * @param *ctx        wbclient Context
    613661 * @param dom_name    Domain name (possibly "")
    614662 * @param name        User or group name
     
    618666 * @return #wbcErr
    619667 **/
     668wbcErr 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 **/
    620684wbcErr wbcLookupName(const char *dom_name,
    621685                     const char *name,
     
    626690 * @brief Convert a SID to a domain and name
    627691 *
    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 **/
     700wbcErr 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
    629710 * @param domain     Resolved Domain name (possibly "")
    630711 * @param name       Resolved User or group name
     
    644725};
    645726
     727wbcErr wbcCtxLookupSids(struct wbcContext *ctx,
     728                        const struct wbcDomainSid *sids, int num_sids,
     729                        struct wbcDomainInfo **domains, int *num_domains,
     730                        struct wbcTranslatedName **names);
     731
    646732wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids,
    647733                     struct wbcDomainInfo **domains, int *num_domains,
    648734                     struct wbcTranslatedName **names);
     735
     736/**
     737 * @brief Translate a collection of RIDs within a domain to names
     738 */
     739wbcErr 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);
    649746
    650747/**
     
    661758 * @brief Get the groups a user belongs to
    662759 **/
     760wbcErr 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 **/
    663769wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid,
    664770                         bool domain_groups_only,
    665771                         uint32_t *num_sids,
    666772                         struct wbcDomainSid **sids);
     773
     774/*
     775 * @brief Get alias membership for sids
     776 **/
     777wbcErr 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);
    667783
    668784/*
     
    678794 * @brief Lists Users
    679795 **/
     796wbcErr 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 **/
    680804wbcErr wbcListUsers(const char *domain_name,
    681805                    uint32_t *num_users,
     
    685809 * @brief Lists Groups
    686810 **/
     811wbcErr 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 **/
    687819wbcErr wbcListGroups(const char *domain_name,
    688820                     uint32_t *num_groups,
    689821                     const char ***groups);
     822
     823wbcErr wbcCtxGetDisplayName(struct wbcContext *ctx,
     824                            const struct wbcDomainSid *sid,
     825                            char **pdomain,
     826                            char **pfullname,
     827                            enum wbcSidType *pname_type);
    690828
    691829wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid,
     
    701839 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
    702840 *
     841 * @param *ctx        wbclient Context
    703842 * @param *sid        Pointer to the domain SID to be resolved
    704843 * @param *puid       Pointer to the resolved uid_t value
     
    707846 *
    708847 **/
     848wbcErr 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 **/
    709861wbcErr wbcSidToUid(const struct wbcDomainSid *sid,
    710862                   uid_t *puid);
     
    725877 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
    726878 *
     879 * @param *ctx        wbclient Context
    727880 * @param uid         Unix uid to be resolved
    728881 * @param *sid        Pointer to the resolved domain SID
     
    731884 *
    732885 **/
     886wbcErr 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 **/
    733898wbcErr wbcUidToSid(uid_t uid,
    734899                   struct wbcDomainSid *sid);
     
    749914 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
    750915 *
     916 * @param *ctx        wbclient Context
    751917 * @param *sid        Pointer to the domain SID to be resolved
    752918 * @param *pgid       Pointer to the resolved gid_t value
     
    755921 *
    756922 **/
     923wbcErr 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 **/
    757936wbcErr wbcSidToGid(const struct wbcDomainSid *sid,
    758937                   gid_t *pgid);
     
    769948wbcErr wbcQuerySidToGid(const struct wbcDomainSid *sid,
    770949                        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 **/
     961wbcErr wbcCtxGidToSid(struct wbcContext *ctx, gid_t gid,
     962                   struct wbcDomainSid *sid);
    771963
    772964/**
     
    797989        WBC_ID_TYPE_NOT_SPECIFIED,
    798990        WBC_ID_TYPE_UID,
    799         WBC_ID_TYPE_GID
     991        WBC_ID_TYPE_GID,
     992        WBC_ID_TYPE_BOTH
    800993};
    801994
     
    8131006 * @brief Convert a list of sids to unix ids
    8141007 *
     1008 * @param *ctx        wbclient Context
    8151009 * @param sids        Pointer to an array of SIDs to convert
    8161010 * @param num_sids    Number of SIDs
     
    8201014 *
    8211015 **/
     1016wbcErr 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 **/
    8221030wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids,
    8231031                        struct wbcUnixId *ids);
     
    8261034 * @brief Obtain a new uid from Winbind
    8271035 *
    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 **/
     1041wbcErr 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
    8291047 *
    8301048 * @return #wbcErr
     
    8351053 * @brief Obtain a new gid from Winbind
    8361054 *
    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 **/
     1060wbcErr 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
    8381066 *
    8391067 * @return #wbcErr
     
    8451073 *
    8461074 * @param uid       Uid of the desired mapping.
    847  * @param *sid      Pointer to the sid of the diresired mapping.
     1075 * @param *sid      Pointer to the sid of the desired mapping.
    8481076 *
    8491077 * @return #wbcErr
     
    8581086 *
    8591087 * @param gid       Gid of the desired mapping.
    860  * @param *sid      Pointer to the sid of the diresired mapping.
     1088 * @param *sid      Pointer to the sid of the desired mapping.
    8611089 *
    8621090 * @return #wbcErr
     
    9251153 *   on username
    9261154 *
     1155 * @param *ctx      wbclient Context
    9271156 * @param *name     Username to lookup
    9281157 * @param **pwd     Pointer to resulting struct passwd* from the query.
     
    9301159 * @return #wbcErr
    9311160 **/
     1161wbcErr 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 **/
    9321173wbcErr wbcGetpwnam(const char *name, struct passwd **pwd);
    9331174
     
    9361177 *   on uid
    9371178 *
     1179 * @param *ctx      wbclient Context
    9381180 * @param uid       Uid to lookup
    9391181 * @param **pwd     Pointer to resulting struct passwd* from the query.
     
    9411183 * @return #wbcErr
    9421184 **/
     1185wbcErr 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 **/
    9431197wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd);
    9441198
     
    9471201 *   on sid
    9481202 *
     1203 * @param *ctx         wbclient Context
    9491204 * @param sid       Sid to lookup
    9501205 * @param **pwd     Pointer to resulting struct passwd* from the query.
     
    9521207 * @return #wbcErr
    9531208 **/
     1209wbcErr 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 **/
    9541221wbcErr wbcGetpwsid(struct wbcDomainSid * sid, struct passwd **pwd);
    9551222
     
    9581225 *   on username
    9591226 *
     1227 * @param *ctx      wbclient Context
    9601228 * @param *name     Username to lookup
    9611229 * @param **grp     Pointer to resulting struct group* from the query.
     
    9631231 * @return #wbcErr
    9641232 **/
     1233wbcErr 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 **/
    9651245wbcErr wbcGetgrnam(const char *name, struct group **grp);
    9661246
     
    9691249 *   on uid
    9701250 *
     1251 * @param *ctx      wbclient Context
    9711252 * @param gid       Uid to lookup
    9721253 * @param **grp     Pointer to resulting struct group* from the query.
     
    9741255 * @return #wbcErr
    9751256 **/
     1257wbcErr 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 **/
    9761269wbcErr wbcGetgrgid(gid_t gid, struct group **grp);
    9771270
     
    9791272 * @brief Reset the passwd iterator
    9801273 *
     1274 * @param *ctx      wbclient Context
     1275 *
     1276 * @return #wbcErr
     1277 **/
     1278wbcErr wbcCtxSetpwent(struct wbcContext *ctx);
     1279
     1280/**
     1281 * @brief Reset the passwd iterator
     1282 *
    9811283 * @return #wbcErr
    9821284 **/
     
    9861288 * @brief Close the passwd iterator
    9871289 *
     1290 * @param *ctx      wbclient Context
     1291 *
     1292 * @return #wbcErr
     1293 **/
     1294wbcErr wbcCtxEndpwent(struct wbcContext *ctx);
     1295
     1296/**
     1297 * @brief Close the passwd iterator
     1298 *
    9881299 * @return #wbcErr
    9891300 **/
     
    9931304 * @brief Return the next struct passwd* entry from the pwent iterator
    9941305 *
    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 **/
     1311wbcErr 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.
    9961317 *
    9971318 * @return #wbcErr
     
    10021323 * @brief Reset the group iterator
    10031324 *
     1325 * @param *ctx      wbclient Context
     1326 *
     1327 * @return #wbcErr
     1328 **/
     1329wbcErr wbcCtxSetgrent(struct wbcContext *ctx);
     1330
     1331/**
     1332 * @brief Reset the group iterator
     1333 *
    10041334 * @return #wbcErr
    10051335 **/
     
    10091339 * @brief Close the group iterator
    10101340 *
     1341 * @param *ctx      wbclient Context
     1342 *
     1343 * @return #wbcErr
     1344 **/
     1345wbcErr wbcCtxEndgrent(struct wbcContext *ctx);
     1346
     1347/**
     1348 * @brief Close the group iterator
     1349 *
    10111350 * @return #wbcErr
    10121351 **/
     
    10161355 * @brief Return the next struct group* entry from the pwent iterator
    10171356 *
    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 **/
     1362wbcErr 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.
    10191368 *
    10201369 * @return #wbcErr
     
    10271376 * This is similar to #wbcGetgrent, just that the member list is empty
    10281377 *
    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 **/
     1383wbcErr 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.
    10301391 *
    10311392 * @return #wbcErr
     
    10361397 * @brief Return the unix group array belonging to the given user
    10371398 *
     1399 * @param *ctx           wbclient Context
    10381400 * @param *account       The given user name
    10391401 * @param *num_groups    Number of elements returned in the groups array
     
    10421404 * @return #wbcErr
    10431405 **/
     1406wbcErr 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 **/
    10441420wbcErr wbcGetGroups(const char *account,
    10451421                    uint32_t *num_groups,
     
    10541430 * @brief Lookup the current status of a trusted domain
    10551431 *
    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 **/
     1439wbcErr 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
    10571447 *
    10581448 * @param dinfo          A pointer to store the returned domain_info struct.
     
    10661456 * @brief Lookup the currently contacted DCs
    10671457 *
     1458 * @param *ctx          wbclient Context
    10681459 * @param domain        The domain to query
    10691460 *
     
    10741465 * @return #wbcErr
    10751466 **/
     1467wbcErr 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 **/
    10761482wbcErr wbcDcInfo(const char *domain, size_t *num_dcs,
    10771483                 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 **/
     1494wbcErr wbcCtxListTrusts(struct wbcContext *ctx,
     1495                        struct wbcDomainInfo **domains,
     1496                        size_t *num_domains);
    10781497
    10791498/**
     
    11131532 * @brief Enumerate the domain trusts known by Winbind
    11141533 *
     1534 * @param *ctx          wbclient Context
    11151535 * @param domain        Name of the domain to query for a DC
    11161536 * @param flags         Bit flags used to control the domain location query
     
    11191539 * @return #wbcErr
    11201540 **/
     1541wbcErr 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 **/
    11211555wbcErr wbcLookupDomainController(const char *domain,
    11221556                                 uint32_t flags,
     
    11261560 * @brief Get extended domain controller information
    11271561 *
     1562 * @param *ctx          wbclient Context
    11281563 * @param domain        Name of the domain to query for a DC
    11291564 * @param guid          Guid of the domain to query for a DC
     
    11341569 * @return #wbcErr
    11351570 **/
     1571wbcErr 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 **/
    11361589wbcErr wbcLookupDomainControllerEx(const char *domain,
    11371590                                   struct wbcGuid *guid,
     
    11471600 * @brief Authenticate a username/password pair
    11481601 *
     1602 * @param *ctx         wbclient Context
    11491603 * @param username     Name of user to authenticate
    11501604 * @param password     Clear text password os user
     
    11521606 * @return #wbcErr
    11531607 **/
     1608wbcErr 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 **/
    11541620wbcErr wbcAuthenticateUser(const char *username,
    11551621                           const char *password);
     
    11581624 * @brief Authenticate with more detailed information
    11591625 *
     1626 * @param *ctx         wbclient Context
    11601627 * @param params       Input parameters, WBC_AUTH_USER_LEVEL_HASH
    11611628 *                     is not supported yet
     
    11651632 * @return #wbcErr
    11661633 **/
     1634wbcErr 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 **/
    11671649wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
    11681650                             struct wbcAuthUserInfo **info,
     
    11721654 * @brief Logon a User
    11731655 *
     1656 * @param[in]  *ctx        wbclient Context
    11741657 * @param[in]  params      Pointer to a wbcLogonUserParams structure
    11751658 * @param[out] info        Pointer to a pointer to a wbcLogonUserInfo structure
     
    11791662 * @return #wbcErr
    11801663 **/
     1664wbcErr 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 **/
    11811680wbcErr wbcLogonUser(const struct wbcLogonUserParams *params,
    11821681                    struct wbcLogonUserInfo **info,
     
    11871686 * @brief Trigger a logoff notification to Winbind for a specific user
    11881687 *
     1688 * @param *ctx        wbclient Context
    11891689 * @param username    Name of user to remove from Winbind's list of
    11901690 *                    logged on users.
     
    11951695 * @return #wbcErr
    11961696 **/
     1697wbcErr 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 **/
    11971712wbcErr wbcLogoffUser(const char *username,
    11981713                     uid_t uid,
     
    12021717 * @brief Trigger an extended logoff notification to Winbind for a specific user
    12031718 *
     1719 * @param *ctx        wbclient Context
    12041720 * @param params      A wbcLogoffUserParams structure
    12051721 * @param error       User output details on error
     
    12071723 * @return #wbcErr
    12081724 **/
     1725wbcErr 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 **/
    12091737wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params,
    12101738                       struct wbcAuthErrorInfo **error);
     
    12131741 * @brief Change a password for a user
    12141742 *
     1743 * @param *ctx          wbclient Context
    12151744 * @param username      Name of user to authenticate
    12161745 * @param old_password  Old clear text password of user
     
    12191748 * @return #wbcErr
    12201749 **/
     1750wbcErr 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 **/
    12211764wbcErr wbcChangeUserPassword(const char *username,
    12221765                             const char *old_password,
     
    12271770 *   failure
    12281771 *
     1772 * @param *ctx                  wbclient Context
    12291773 * @param params                Input parameters
    12301774 * @param error                 User output details on WBC_ERR_PWD_CHANGE_FAILED
     
    12341778 * @return #wbcErr
    12351779 **/
     1780wbcErr 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 **/
    12361797wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params,
    12371798                               struct wbcAuthErrorInfo **error,
     
    12421803 * @brief Authenticate a user with cached credentials
    12431804 *
     1805 * @param *ctx       wbclient Context
    12441806 * @param *params    Pointer to a wbcCredentialCacheParams structure
    12451807 * @param **info     Pointer to a pointer to a wbcCredentialCacheInfo structure
     
    12481810 * @return #wbcErr
    12491811 **/
     1812wbcErr 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 **/
    12501826wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params,
    12511827                          struct wbcCredentialCacheInfo **info,
     
    12551831 * @brief Save a password with winbind for doing wbcCredentialCache() later
    12561832 *
     1833 * @param *ctx       wbclient Context
     1834 * @param *user      Username
     1835 * @param *password  Password
     1836 *
     1837 * @return #wbcErr
     1838 **/
     1839wbcErr 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 *
    12571845 * @param *user      Username
    12581846 * @param *password  Password
     
    12691857 * @brief Resolve a NetbiosName via WINS
    12701858 *
     1859 * @param *ctx         wbclient Context
    12711860 * @param name         Name to resolve
    12721861 * @param *ip          Pointer to the ip address string
     
    12741863 * @return #wbcErr
    12751864 **/
     1865wbcErr 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 **/
    12761876wbcErr wbcResolveWinsByName(const char *name, char **ip);
    12771877
     
    12791879 * @brief Resolve an IP address via WINS into a NetbiosName
    12801880 *
    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 **/
     1888wbcErr 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
    12831896 *
    12841897 * @return #wbcErr
     
    12941907 * @brief Trigger a verification of the trust credentials of a specific domain
    12951908 *
     1909 * @param *ctx         wbclient Context
    12961910 * @param *domain      The name of the domain.
    12971911 * @param error        Output details on WBC_ERR_AUTH_ERROR
     
    12991913 * @return #wbcErr
    13001914 **/
     1915wbcErr 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 **/
    13011926wbcErr wbcCheckTrustCredentials(const char *domain,
    13021927                                struct wbcAuthErrorInfo **error);
     
    13051930 * @brief Trigger a change of the trust credentials for a specific domain
    13061931 *
     1932 * @param *ctx         wbclient Context
    13071933 * @param *domain      The name of the domain.
    13081934 * @param error        Output details on WBC_ERR_AUTH_ERROR
     
    13101936 * @return #wbcErr
    13111937 **/
     1938wbcErr 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 **/
    13121949wbcErr wbcChangeTrustCredentials(const char *domain,
    13131950                                 struct wbcAuthErrorInfo **error);
     
    13171954 *        version of wbcCheckTrustCredentials
    13181955 *
     1956 * @param *ctx         wbclient Context
    13191957 * @param *domain      The name of the domain, only NULL for the default domain is
    13201958 *                     supported yet. Other values than NULL will result in
     
    13241962 * @return #wbcErr
    13251963 **/
     1964wbcErr 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 **/
    13261978wbcErr 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 **/
     1993wbcErr 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 **/
     2009wbcErr wbcPingDc2(const char *domain, struct wbcAuthErrorInfo **error,
     2010                  char **dcname);
    13272011
    13282012/**********************************************************
  • vendor/current/nsswitch/libwbclient/wbclient_internal.h

    r740 r988  
    2323#define _WBCLIENT_INTERNAL_H
    2424
     25struct 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
    2533/* Private functions */
    2634
    27 wbcErr wbcRequestResponse(int cmd,
     35wbcErr wbcRequestResponse(struct wbcContext *ctx, int cmd,
    2836                          struct winbindd_request *request,
    2937                          struct winbindd_response *response);
    3038
    31 wbcErr wbcRequestResponsePriv(int cmd,
     39wbcErr wbcRequestResponsePriv(struct wbcContext *ctx, int cmd,
    3240                              struct winbindd_request *request,
    3341                              struct winbindd_response *response);
     
    3846char *wbcStrDup(const char *str);
    3947const char **wbcAllocateStringArray(int num_strings);
     48struct wbcContext *wbcGetGlobalCtx(void);
    4049
    4150#endif      /* _WBCLIENT_INTERNAL_H */
  • vendor/current/nsswitch/nsstest.c

    r740 r988  
    371371        NSS_STATUS status;
    372372
    373         groups = (gid_t *)malloc(size);
     373        groups = (gid_t *)malloc(sizeof(gid_t) * size);
     374        if (groups == NULL) {
     375                printf("Unable to allocate memory for groups\n");
     376                return;
     377        }
    374378        groups[0] = gid;
    375379
     
    452456        if (pwd || last_error != NSS_STATUS_NOTFOUND) {
    453457                total_errors++;
    454                 printf("ERROR Non existant user gave error %d\n", last_error);
     458                printf("ERROR Non existent user gave error %d\n", last_error);
    455459        }
    456460
     
    458462        if (pwd || last_error != NSS_STATUS_NOTFOUND) {
    459463                total_errors++;
    460                 printf("ERROR Non existant uid gave error %d\n", last_error);
     464                printf("ERROR Non existent uid gave error %d\n", last_error);
    461465        }
    462466
     
    464468        if (grp || last_error != NSS_STATUS_NOTFOUND) {
    465469                total_errors++;
    466                 printf("ERROR Non existant group gave error %d\n", last_error);
     470                printf("ERROR Non existent group gave error %d\n", last_error);
    467471        }
    468472
     
    470474        if (grp || last_error != NSS_STATUS_NOTFOUND) {
    471475                total_errors++;
    472                 printf("ERROR Non existant gid gave error %d\n", last_error);
     476                printf("ERROR Non existent gid gave error %d\n", last_error);
    473477        }
    474478}
  • vendor/current/nsswitch/pam_winbind.c

    r860 r988  
    1212
    1313#include "pam_winbind.h"
    14 #define CONST_DISCARD(type,ptr) ((type)(void *)ptr)
    15 
     14
     15enum pam_winbind_request_type
     16{
     17        PAM_WINBIND_AUTHENTICATE,
     18        PAM_WINBIND_SETCRED,
     19        PAM_WINBIND_ACCT_MGMT,
     20        PAM_WINBIND_OPEN_SESSION,
     21        PAM_WINBIND_CLOSE_SESSION,
     22        PAM_WINBIND_CHAUTHTOK,
     23        PAM_WINBIND_CLEANUP
     24};
    1625
    1726static int wbc_error_to_pam_error(wbcErr status)
     
    141150        do { \
    142151                _pam_log_debug(ctx, LOG_DEBUG, "[pamh: %p] LEAVE: " \
    143                                function " returning %d (%s)", ctx->pamh, retval, \
     152                               function " returning %d (%s)", ctx ? ctx->pamh : NULL, retval, \
    144153                               _pam_error_code_str(retval)); \
    145154                _pam_log_state(ctx); \
     
    164173#endif
    165174
    166 
    167 /*
    168  * Work around the pam API that has functions with void ** as parameters
    169  * These lead to strict aliasing warnings with gcc.
    170  */
    171 static int _pam_get_item(const pam_handle_t *pamh,
    172                          int item_type,
    173                          const void *_item)
    174 {
    175         const void **item = (const void **)_item;
    176         return pam_get_item(pamh, item_type, item);
    177 }
    178 static int _pam_get_data(const pam_handle_t *pamh,
    179                          const char *module_data_name,
    180                          const void *_data)
    181 {
    182         const void **data = (const void **)_data;
    183         return pam_get_data(pamh, module_data_name, data);
    184 }
    185175
    186176/* some syslogging */
     
    203193        const char *service;
    204194
    205         _pam_get_item(pamh, PAM_SERVICE, &service);
     195        pam_get_item(pamh, PAM_SERVICE, (const void **) &service);
    206196
    207197        format2 = (char *)malloc(strlen(MODULE_NAME)+strlen(format)+strlen(service)+5);
     
    281271        va_list args;
    282272
    283         if (!_pam_log_is_debug_enabled(r->ctrl)) {
     273        if (!r || !_pam_log_is_debug_enabled(r->ctrl)) {
    284274                return;
    285275        }
     
    350340        _pam_log_state_datum(ctx, item_type, #item_type, \
    351341                             _LOG_PASSWORD_AS_STRING)
     342/*
     343 * wrapper to preserve old behaviour of iniparser which ignored
     344 * key values that had no value assigned like
     345 *    key =
     346 * for a key like above newer iniparser will return a zero-length
     347 * string, previously iniparser would return NULL
     348 *
     349 * JRA: For compatibility, tiniparser behaves like iniparser.
     350 */
     351static const char *tiniparser_getstring_nonempty(struct tiniparser_dictionary *d,
     352                        const char *key,
     353                        const char *def)
     354{
     355        const char *ret = tiniparser_getstring(d, key, def);
     356        if (ret && strlen(ret) == 0) {
     357                ret = NULL;
     358        }
     359        return ret;
     360}
    352361
    353362static void _pam_log_state(struct pwb_context *ctx)
    354363{
    355         if (!_pam_log_is_debug_state_enabled(ctx->ctrl)) {
     364        if (!ctx || !_pam_log_is_debug_state_enabled(ctx->ctrl)) {
    356365                return;
    357366        }
     
    389398                      int argc,
    390399                      const char **argv,
    391                       dictionary **result_d)
     400                      enum pam_winbind_request_type type,
     401                      struct tiniparser_dictionary **result_d)
    392402{
    393403        int ctrl = 0;
     
    395405        int i;
    396406        const char **v;
    397         dictionary *d = NULL;
     407        struct tiniparser_dictionary *d = NULL;
    398408
    399409        if (flags & PAM_SILENT) {
     
    413423        }
    414424
    415         d = iniparser_load(CONST_DISCARD(char *, config_file));
     425        d = tiniparser_load(config_file);
    416426        if (d == NULL) {
    417427                goto config_from_pam;
    418428        }
    419429
    420         if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:debug"), false)) {
     430        if (tiniparser_getboolean(d, "global:debug", false)) {
    421431                ctrl |= WINBIND_DEBUG_ARG;
    422432        }
    423433
    424         if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:debug_state"), false)) {
     434        if (tiniparser_getboolean(d, "global:debug_state", false)) {
    425435                ctrl |= WINBIND_DEBUG_STATE;
    426436        }
    427437
    428         if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:cached_login"), false)) {
     438        if (tiniparser_getboolean(d, "global:cached_login", false)) {
    429439                ctrl |= WINBIND_CACHED_LOGIN;
    430440        }
    431441
    432         if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:krb5_auth"), false)) {
     442        if (tiniparser_getboolean(d, "global:krb5_auth", false)) {
    433443                ctrl |= WINBIND_KRB5_AUTH;
    434444        }
    435445
    436         if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:silent"), false)) {
     446        if (tiniparser_getboolean(d, "global:silent", false)) {
    437447                ctrl |= WINBIND_SILENT;
    438448        }
    439449
    440         if (iniparser_getstring(d, CONST_DISCARD(char *, "global:krb5_ccache_type"), NULL) != NULL) {
     450        if (tiniparser_getstring_nonempty(d, "global:krb5_ccache_type", NULL) != NULL) {
    441451                ctrl |= WINBIND_KRB5_CCACHE_TYPE;
    442452        }
    443453
    444         if ((iniparser_getstring(d, CONST_DISCARD(char *, "global:require-membership-of"), NULL)
     454        if ((tiniparser_getstring_nonempty(d, "global:require-membership-of", NULL)
    445455             != NULL) ||
    446             (iniparser_getstring(d, CONST_DISCARD(char *, "global:require_membership_of"), NULL)
     456            (tiniparser_getstring_nonempty(d, "global:require_membership_of", NULL)
    447457             != NULL)) {
    448458                ctrl |= WINBIND_REQUIRED_MEMBERSHIP;
    449459        }
    450460
    451         if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:try_first_pass"), false)) {
     461        if (tiniparser_getboolean(d, "global:try_first_pass", false)) {
    452462                ctrl |= WINBIND_TRY_FIRST_PASS_ARG;
    453463        }
    454464
    455         if (iniparser_getint(d, CONST_DISCARD(char *, "global:warn_pwd_expire"), 0)) {
     465        if (tiniparser_getint(d, "global:warn_pwd_expire", 0)) {
    456466                ctrl |= WINBIND_WARN_PWD_EXPIRE;
    457467        }
    458468
    459         if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:mkhomedir"), false)) {
     469        if (tiniparser_getboolean(d, "global:mkhomedir", false)) {
    460470                ctrl |= WINBIND_MKHOMEDIR;
    461471        }
     
    480490                else if (!strcasecmp(*v, "unknown_ok"))
    481491                        ctrl |= WINBIND_UNKNOWN_OK_ARG;
    482                 else if (!strncasecmp(*v, "require_membership_of",
    483                                       strlen("require_membership_of")))
     492                else if ((type == PAM_WINBIND_AUTHENTICATE
     493                          || type == PAM_WINBIND_SETCRED)
     494                         && !strncasecmp(*v, "require_membership_of",
     495                                         strlen("require_membership_of")))
    484496                        ctrl |= WINBIND_REQUIRED_MEMBERSHIP;
    485                 else if (!strncasecmp(*v, "require-membership-of",
    486                                       strlen("require-membership-of")))
     497                else if ((type == PAM_WINBIND_AUTHENTICATE
     498                          || type == PAM_WINBIND_SETCRED)
     499                         && !strncasecmp(*v, "require-membership-of",
     500                                         strlen("require-membership-of")))
    487501                        ctrl |= WINBIND_REQUIRED_MEMBERSHIP;
    488502                else if (!strcasecmp(*v, "krb5_auth"))
     
    495509                else if (!strcasecmp(*v, "mkhomedir"))
    496510                        ctrl |= WINBIND_MKHOMEDIR;
    497                 else {
     511                else if (!strncasecmp(*v, "warn_pwd_expire",
     512                        strlen("warn_pwd_expire")))
     513                        ctrl |= WINBIND_WARN_PWD_EXPIRE;
     514                else if (type != PAM_WINBIND_CLEANUP) {
    498515                        __pam_log(pamh, ctrl, LOG_ERR,
    499516                                 "pam_parse: unknown option: %s", *v);
     
    507524        } else {
    508525                if (d) {
    509                         iniparser_freedict(d);
     526                        tiniparser_freedict(d);
    510527                }
    511528        }
     
    521538
    522539        if (ctx->dict) {
    523                 iniparser_freedict(ctx->dict);
     540                tiniparser_freedict(ctx->dict);
    524541        }
    525542
     
    531548                                     int argc,
    532549                                     const char **argv,
     550                                     enum pam_winbind_request_type type,
    533551                                     struct pwb_context **ctx_p)
    534552{
     
    539557#endif
    540558
    541         r = TALLOC_ZERO_P(NULL, struct pwb_context);
     559        r = talloc_zero(NULL, struct pwb_context);
    542560        if (!r) {
    543561                return PAM_BUF_ERR;
     
    550568        r->argc = argc;
    551569        r->argv = argv;
    552         r->ctrl = _pam_parse(pamh, flags, argc, argv, &r->dict);
     570        r->ctrl = _pam_parse(pamh, flags, argc, argv, type, &r->dict);
    553571        if (r->ctrl == -1) {
    554572                TALLOC_FREE(r);
     
    565583                                      int error_status)
    566584{
    567         int ctrl = _pam_parse(pamh, 0, 0, NULL, NULL);
     585        int ctrl = _pam_parse(pamh, 0, 0, NULL, PAM_WINBIND_CLEANUP, NULL);
    568586        if (_pam_log_is_debug_state_enabled(ctrl)) {
    569587                __pam_log_debug(pamh, ctrl, LOG_DEBUG,
     
    646664        struct pam_conv *conv;
    647665
    648         retval = _pam_get_item(pamh, PAM_CONV, &conv);
     666        retval = pam_get_item(pamh, PAM_CONV, (const void **) &conv);
    649667        if (retval == PAM_SUCCESS) {
    650668                retval = conv->conv(nargs,
    651                                     (const struct pam_message **)message,
     669                                    discard_const_p(const struct pam_message *, message),
    652670                                    response, conv->appdata_ptr);
    653671        }
     
    813831        struct pam_message msg, *pmsg;
    814832        struct pam_response *resp = NULL;
    815         const char *prompt;
    816833        int ret;
    817834        bool retval = false;
    818         prompt = _("Do you want to change your password now?");
    819835        pmsg = &msg;
    820836        msg.msg_style = PAM_RADIO_TYPE;
    821         msg.msg = prompt;
     837        msg.msg = _("Do you want to change your password now?");
    822838        ret = converse(ctx->pamh, 1, &pmsg, &resp);
    823839        if (resp == NULL) {
     
    10501066                               int dest_buffer_size)
    10511067{
    1052         int dest_length = strlen(dest);
    1053         int src_length = strlen(src);
    1054 
    1055         if (dest_length + src_length + 1 > dest_buffer_size) {
    1056                 return false;
    1057         }
    1058 
    1059         memcpy(dest + dest_length, src, src_length + 1);
    1060         return true;
     1068        size_t len;
     1069        len = strlcat(dest, src, dest_buffer_size);
     1070        return (len < dest_buffer_size);
    10611071}
    10621072
     
    12211231                                struct wbcLogonUserInfo *info)
    12221232{
    1223         char var[PATH_MAX];
     1233        char *var = NULL;
    12241234        int ret;
    12251235        uint32_t i;
     
    12481258                       "request returned KRB5CCNAME: %s", krb5ccname);
    12491259
    1250         if (snprintf(var, sizeof(var), "KRB5CCNAME=%s", krb5ccname) == -1) {
     1260        if (asprintf(&var, "KRB5CCNAME=%s", krb5ccname) == -1) {
    12511261                return;
    12521262        }
    12531263
    12541264        ret = pam_putenv(ctx->pamh, var);
    1255         if (ret) {
     1265        if (ret != PAM_SUCCESS) {
    12561266                _pam_log(ctx, LOG_ERR,
    12571267                         "failed to set KRB5CCNAME to %s: %s",
    12581268                         var, pam_strerror(ctx->pamh, ret));
    12591269        }
     1270        free(var);
    12601271}
    12611272
     
    13181329        ret = pam_set_data(ctx->pamh, data_name, talloc_strdup(NULL, value),
    13191330                           _pam_winbind_cleanup_func);
    1320         if (ret) {
     1331        if (ret != PAM_SUCCESS) {
    13211332                _pam_log_debug(ctx, LOG_DEBUG,
    13221333                               "Could not set data %s: %s\n",
     
    16461657
    16471658                ret = _pam_create_homedir(ctx, create_dir, mode);
    1648                 if (ret) {
     1659                if (ret != PAM_SUCCESS) {
    16491660                        return ret;
    16501661                }
     
    17711782                                             "krb5_cc_type",
    17721783                                             0,
    1773                                              (uint8_t *)cctype,
     1784                                             discard_const_p(uint8_t, cctype),
    17741785                                             strlen(cctype)+1);
    17751786                if (!WBC_ERROR_IS_OK(wbc_status)) {
     
    19521963
    19531964        params.account_name             = user;
    1954         params.level                    = WBC_AUTH_USER_LEVEL_PLAIN;
     1965        params.level                    = WBC_CHANGE_PASSWORD_LEVEL_PLAIN;
    19551966        params.old_password.plaintext   = oldpass;
    19561967        params.new_password.plaintext   = newpass;
     
    19912002
    19922003                /* FIXME: avoid to send multiple PAM messages after another */
    1993                 switch (reject_reason) {
     2004                switch ((int)reject_reason) {
    19942005                        case -1:
    19952006                                break;
     
    21292140        if (on(WINBIND_TRY_FIRST_PASS_ARG, ctrl) ||
    21302141            on(WINBIND_USE_FIRST_PASS_ARG, ctrl)) {
    2131                 retval = _pam_get_item(ctx->pamh, authtok_flag, &item);
     2142                retval = pam_get_item(ctx->pamh,
     2143                                      authtok_flag,
     2144                                      (const void **) &item);
    21322145                if (retval != PAM_SUCCESS) {
    21332146                        /* very strange. */
     
    22372250        _pam_delete(token);     /* clean it up */
    22382251        if (retval != PAM_SUCCESS ||
    2239             (retval = _pam_get_item(ctx->pamh, authtok_flag, &item)) != PAM_SUCCESS) {
     2252            (retval = pam_get_item(ctx->pamh, authtok_flag, (const void **) &item)) != PAM_SUCCESS) {
    22402253
    22412254                _pam_log(ctx, LOG_CRIT, "error manipulating password");
     
    22872300                }
    22882301
    2289                 parm_opt = iniparser_getstring(ctx->dict, key, NULL);
     2302                parm_opt = tiniparser_getstring_nonempty(ctx->dict, key, NULL);
    22902303                TALLOC_FREE(key);
    22912304
     
    23352348                }
    23362349
    2337                 parm_opt = iniparser_getint(ctx->dict, key, -1);
     2350                parm_opt = tiniparser_getint(ctx->dict, key, -1);
    23382351                TALLOC_FREE(key);
    23392352
     
    23572370        ret = get_conf_item_string(ctx, "require_membership_of",
    23582371                                   WINBIND_REQUIRED_MEMBERSHIP);
    2359         if (ret) {
     2372        if (ret != NULL) {
    23602373                return ret;
    23612374        }
     
    23702383                                  WINBIND_WARN_PWD_EXPIRE);
    23712384        /* no or broken setting */
    2372         if (ret <= 0) {
     2385        if (ret < 0) {
    23732386                return DEFAULT_DAYS_TO_WARN_BEFORE_PWD_EXPIRES;
    23742387        }
     
    24092422 *
    24102423 * @param ctx PAM winbind context.
    2411  * @param upn  USer UPN to be trabslated.
     2424 * @param upn  User UPN to be translated.
    24122425 *
    24132426 * @return converted name. NULL pointer on failure. Caller needs to free.
     
    24242437        char *name;
    24252438        char *p;
     2439        char *result;
    24262440
    24272441        /* This cannot work when the winbind separator = @ */
     
    24552469        }
    24562470
    2457         return talloc_asprintf(ctx, "%s%c%s", domain, sep, name);
     2471        result = talloc_asprintf(ctx, "%s%c%s", domain, sep, name);
     2472        wbcFreeMemory(domain);
     2473        wbcFreeMemory(name);
     2474        return result;
    24582475}
    24592476
    24602477static int _pam_delete_cred(pam_handle_t *pamh, int flags,
    2461                          int argc, const char **argv)
     2478                            int argc, enum pam_winbind_request_type type,
     2479                            const char **argv)
    24622480{
    24632481        int retval = PAM_SUCCESS;
     
    24702488        ZERO_STRUCT(logoff);
    24712489
    2472         retval = _pam_winbind_init_context(pamh, flags, argc, argv, &ctx);
    2473         if (retval) {
    2474                 goto out;
     2490        retval = _pam_winbind_init_context(pamh, flags, argc, argv, type, &ctx);
     2491        if (retval != PAM_SUCCESS) {
     2492                return retval;
    24752493        }
    24762494
     
    24862504
    24872505                retval = pam_get_user(pamh, &user, _("Username: "));
    2488                 if (retval) {
     2506                if (retval != PAM_SUCCESS) {
    24892507                        _pam_log(ctx, LOG_ERR,
    24902508                                 "could not identify user");
     
    25242542                                                     "ccfilename",
    25252543                                                     0,
    2526                                                      (uint8_t *)ccname,
     2544                                                     discard_const_p(uint8_t, ccname),
    25272545                                                     strlen(ccname)+1);
    25282546                        if (!WBC_ERROR_IS_OK(wbc_status)) {
     
    26052623        struct pwb_context *ctx = NULL;
    26062624
    2607         retval = _pam_winbind_init_context(pamh, flags, argc, argv, &ctx);
    2608         if (retval) {
    2609                 goto out;
     2625        retval = _pam_winbind_init_context(pamh, flags, argc, argv,
     2626                                           PAM_WINBIND_AUTHENTICATE, &ctx);
     2627        if (retval != PAM_SUCCESS) {
     2628                return retval;
    26102629        }
    26112630
     
    27422761        }
    27432762
    2744         if (ctx != NULL) {
    2745                 _PAM_LOG_FUNCTION_LEAVE("pam_sm_authenticate", ctx, retval);
    2746                 TALLOC_FREE(ctx);
    2747         }
     2763        _PAM_LOG_FUNCTION_LEAVE("pam_sm_authenticate", ctx, retval);
     2764
     2765        TALLOC_FREE(ctx);
    27482766
    27492767        return retval;
     
    27572775        struct pwb_context *ctx = NULL;
    27582776
    2759         ret = _pam_winbind_init_context(pamh, flags, argc, argv, &ctx);
    2760         if (ret) {
    2761                 goto out;
     2777        ret = _pam_winbind_init_context(pamh, flags, argc, argv,
     2778                                        PAM_WINBIND_SETCRED, &ctx);
     2779        if (ret != PAM_SUCCESS) {
     2780                return ret;
    27622781        }
    27632782
     
    27672786
    27682787                case PAM_DELETE_CRED:
    2769                         ret = _pam_delete_cred(pamh, flags, argc, argv);
     2788                        ret = _pam_delete_cred(pamh, flags, argc,
     2789                                               PAM_WINBIND_SETCRED, argv);
    27702790                        break;
    27712791                case PAM_REFRESH_CRED:
     
    27892809        }
    27902810
    2791  out:
    2792 
    27932811        _PAM_LOG_FUNCTION_LEAVE("pam_sm_setcred", ctx, ret);
    27942812
     
    28082826        const char *username;
    28092827        int ret = PAM_USER_UNKNOWN;
    2810         void *tmp = NULL;
     2828        const char *tmp = NULL;
    28112829        struct pwb_context *ctx = NULL;
    28122830
    2813         ret = _pam_winbind_init_context(pamh, flags, argc, argv, &ctx);
    2814         if (ret) {
    2815                 goto out;
     2831        ret = _pam_winbind_init_context(pamh, flags, argc, argv,
     2832                                        PAM_WINBIND_ACCT_MGMT, &ctx);
     2833        if (ret != PAM_SUCCESS) {
     2834                return ret;
    28162835        }
    28172836
     
    28492868                             (const void **)&tmp);
    28502869                if (tmp != NULL) {
    2851                         ret = atoi((const char *)tmp);
     2870                        ret = atoi(tmp);
    28522871                        switch (ret) {
    28532872                        case PAM_AUTHTOK_EXPIRED:
     
    29062925        struct pwb_context *ctx = NULL;
    29072926
    2908         ret = _pam_winbind_init_context(pamh, flags, argc, argv, &ctx);
    2909         if (ret) {
    2910                 goto out;
     2927        ret = _pam_winbind_init_context(pamh, flags, argc, argv,
     2928                                        PAM_WINBIND_OPEN_SESSION, &ctx);
     2929        if (ret != PAM_SUCCESS) {
     2930                return ret;
    29112931        }
    29122932
     
    29172937                ret = _pam_mkhomedir(ctx);
    29182938        }
    2919  out:
     2939
    29202940        _PAM_LOG_FUNCTION_LEAVE("pam_sm_open_session", ctx, ret);
    29212941
     
    29322952        struct pwb_context *ctx = NULL;
    29332953
    2934         ret = _pam_winbind_init_context(pamh, flags, argc, argv, &ctx);
    2935         if (ret) {
    2936                 goto out;
     2954        ret = _pam_winbind_init_context(pamh, flags, argc, argv,
     2955                                        PAM_WINBIND_CLOSE_SESSION, &ctx);
     2956        if (ret != PAM_SUCCESS) {
     2957                return ret;
    29372958        }
    29382959
    29392960        _PAM_LOG_FUNCTION_ENTER("pam_sm_close_session", ctx);
    29402961
    2941 out:
    29422962        _PAM_LOG_FUNCTION_LEAVE("pam_sm_close_session", ctx, ret);
    29432963
     
    29752995        struct passwd *pwd = NULL;
    29762996
    2977         _pam_get_data(ctx->pamh, PAM_WINBIND_NEW_AUTHTOK_REQD_DURING_AUTH,
    2978                       &new_authtok_reqd_during_auth);
     2997        pam_get_data(ctx->pamh, PAM_WINBIND_NEW_AUTHTOK_REQD_DURING_AUTH,
     2998                      (const void **) &new_authtok_reqd_during_auth);
    29792999        pam_set_data(ctx->pamh, PAM_WINBIND_NEW_AUTHTOK_REQD_DURING_AUTH,
    29803000                     NULL, NULL);
     
    30073027        /* <DO NOT free() THESE> */
    30083028        const char *user;
    3009         char *pass_old, *pass_new;
     3029        const char *pass_old;
     3030        const char *pass_new;
    30103031        /* </DO NOT free() THESE> */
    30113032
     
    30173038        struct pwb_context *ctx = NULL;
    30183039
    3019         ret = _pam_winbind_init_context(pamh, flags, argc, argv, &ctx);
    3020         if (ret) {
    3021                 goto out;
     3040        ret = _pam_winbind_init_context(pamh, flags, argc, argv,
     3041                                        PAM_WINBIND_CHAUTHTOK, &ctx);
     3042        if (ret != PAM_SUCCESS) {
     3043                return ret;
    30223044        }
    30233045
     
    30333055         */
    30343056        ret = pam_get_user(pamh, &user, _("Username: "));
    3035         if (ret) {
     3057        if (ret != PAM_SUCCESS) {
    30363058                _pam_log(ctx, LOG_ERR,
    30373059                         "password - could not identify user");
     
    31303152                 */
    31313153
    3132                 ret = _pam_get_item(pamh, PAM_OLDAUTHTOK, &pass_old);
     3154                ret = pam_get_item(pamh, PAM_OLDAUTHTOK, (const void **) &pass_old);
    31333155
    31343156                if (ret != PAM_SUCCESS) {
     
    31803202                 * rebuild the password database file.
    31813203                 */
    3182                 _pam_get_data(pamh, PAM_WINBIND_PWD_LAST_SET,
    3183                               &pwdlastset_update);
     3204                pam_get_data(pamh, PAM_WINBIND_PWD_LAST_SET,
     3205                             (const void **) &pwdlastset_update);
    31843206
    31853207                /*
     
    31943216                ret = winbind_chauthtok_request(ctx, user, pass_old,
    31953217                                                pass_new, pwdlastset_update);
    3196                 if (ret) {
     3218                if (ret != PAM_SUCCESS) {
    31973219                        pass_old = pass_new = NULL;
    31983220                        goto out;
  • vendor/current/nsswitch/pam_winbind.h

    r740 r988  
    5656#include <talloc.h>
    5757#include "libwbclient/wbclient.h"
     58#include "lib/util/tiniparser.h"
    5859
    5960#define MODULE_NAME "pam_winbind"
     
    6667#define PAM_WINBIND_CONFIG_FILE "/etc/security/pam_winbind.conf"
    6768#endif
    68 
    69 #include <iniparser.h>
    7069
    7170#ifdef HAVE_LIBINTL_H
     
    9493#endif
    9594
    96 #endif /* defined(SUNOS5) || defined(SUNOS4) || defined(HPUX) || defined(FREEBSD) || defined(AIX) */
     95#endif /* (!)LINUX */
    9796
    9897#if defined(HAVE_SECURITY_PAM_MODULES_H)
     
    213212        int argc;
    214213        const char **argv;
    215         dictionary *dict;
     214        struct tiniparser_dictionary *dict;
    216215        uint32_t ctrl;
    217216};
  • vendor/current/nsswitch/tests/test_wbinfo.sh

    r740 r988  
    1515
    1616failed=0
    17 samba4bindir="$BUILDDIR/bin"
    18 wbinfo="$VALGRIND $samba4bindir/wbinfo$EXEEXT"
     17samba4bindir="$BINDIR"
     18wbinfo="$VALGRIND $samba4bindir/wbinfo"
    1919
    2020. `dirname $0`/../../testprogs/blackbox/subunit.sh
     
    5858# Convert netbios name to IP
    5959# Does not work yet
    60 knownfail "wbinfo -N against $TARGET" $wbinfo -N $NETBIOSNAME || failed=`expr $failed + 1`
     60testit "wbinfo -N against $TARGET" $wbinfo -N $NETBIOSNAME || failed=`expr $failed + 1`
    6161# Convert IP to netbios name
    6262# Does not work yet
    63 knownfail "wbinfo -I against $TARGET" $wbinfo -I $SERVER_IP || failed=`expr $failed + 1`
     63testit "wbinfo -I against $TARGET" $wbinfo -I $SERVER_IP || failed=`expr $failed + 1`
    6464
    6565# Convert name to SID
     
    152152
    153153#didn't really work anyway
    154 knownfail "wbinfo  --trusted-domains against $TARGET" $wbinfo --trusted-domains || failed=`expr $failed + 1`
    155 knownfail "wbinfo --all-domains against $TARGET" $wbinfo --all-domains || failed=`expr $failed + 1`
     154testit "wbinfo  --trusted-domains against $TARGET" $wbinfo --trusted-domains || failed=`expr $failed + 1`
     155testit "wbinfo --all-domains against $TARGET" $wbinfo --all-domains || failed=`expr $failed + 1`
    156156
    157157testit "wbinfo --own-domain against $TARGET" $wbinfo --own-domain || failed=`expr $failed + 1`
     
    175175testit "wbinfo -i against $TARGET" $wbinfo -i "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
    176176
    177 testit "wbinfo --uid-info against $TARGET" $wbinfo --uid-info $admin_uid || failed=`expr $failed + 1`
    178 
    179177echo "test: wbinfo --group-info against $TARGET"
    180 rawgid=`$wbinfo --group-info "Domain admins" | sed 's/.*:\([0-9][0-9]*\):/\1/'`
     178gid=`$wbinfo --group-info "$DOMAIN/Domain users" | cut -d: -f3`
    181179if test x$? = x0; then
    182180        echo "success: wbinfo --group-info against $TARGET"
     
    186184fi
    187185
    188 gid=`echo $rawgid | sed 's/.*:\([0-9][0-9]*\):/\1/'`
     186test_name="wbinfo -i against $TARGET"
     187subunit_start_test "$test_name"
     188passwd_line=`$wbinfo -i "$DOMAIN/$USERNAME"`
     189if test x$? = x0; then
     190        subunit_pass_test "$test_name"
     191else
     192        subunit_fail_test "$test_name"
     193        failed=`expr $failed + 1`
     194fi
     195
     196test_name="confirm output of wbinfo -i against $TARGET"
     197subunit_start_test "$test_name"
     198
     199# The full name (GECOS) is based on name (the RDN, in this case CN)
     200# and displayName in winbindd_ads, and is based only on displayName in
     201# winbindd_msrpc and winbindd_rpc.  Allow both versions.
     202expected_line="$DOMAIN/administrator:*:$admin_uid:$gid:Administrator:/home/$DOMAIN/administrator:/bin/false"
     203expected2_line="$DOMAIN/administrator:*:$admin_uid:$gid::/home/$DOMAIN/administrator:/bin/false"
     204
     205if test x$passwd_line = x"$expected_line" -o x$passwd_line = x"$expected2_line"; then
     206        subunit_pass_test "$test_name"
     207else
     208        echo "expected '$expected_line' or '$expected2_line' got '$passwd_line'" | subunit_fail_test "$test_name"
     209        failed=`expr $failed + 1`
     210fi
     211
     212test_name="wbinfo --uid-info against $TARGET"
     213subunit_start_test "$test_name"
     214passwd_line=`$wbinfo --uid-info=$admin_uid`
     215if test x$? = x0; then
     216        subunit_pass_test "$test_name"
     217else
     218        subunit_fail_test "$test_name"
     219        failed=`expr $failed + 1`
     220fi
     221
     222test_name="confirm output of wbinfo --uid-info against $TARGET"
     223subunit_start_test "$test_name"
     224if test x$passwd_line = x"$expected_line" -o x$passwd_line = x"$expected2_line"; then
     225        subunit_pass_test "$test_name"
     226else
     227        echo "expected '$expected_line' or '$expected2_line' got '$passwd_line'" | subunit_fail_test "$test_name"
     228        failed=`expr $failed + 1`
     229fi
     230
     231testfail "wbinfo --group-info against $TARGET with $USERNAME" $wbinfo --group-info $USERNAME && failed=`expr $failed + 1`
     232
    189233testit "wbinfo --gid-info against $TARGET" $wbinfo --gid-info $gid || failed=`expr $failed + 1`
    190234
  • vendor/current/nsswitch/wb_common.c

    r860 r988  
    77   Copyright (C) Andrew Tridgell 2000
    88   Copyright (C) Andrew Bartlett 2002
     9   Copyright (C) Matthew Newton 2015
    910
    1011
     
    2728#include "winbind_client.h"
    2829
    29 /* Global variables.  These are effectively the client state information */
    30 
    31 int winbindd_fd = -1;           /* fd for winbindd socket */
    32 static int is_privileged = 0;
     30/* Global context */
     31
     32struct winbindd_context {
     33        int winbindd_fd;        /* winbind file descriptor */
     34        bool is_privileged;     /* using the privileged socket? */
     35        pid_t our_pid;          /* calling process pid */
     36};
     37
     38static struct winbindd_context wb_global_ctx = {
     39        .winbindd_fd = -1,
     40        .is_privileged = 0,
     41        .our_pid = 0
     42};
    3343
    3444/* Free a response structure */
     
    6575/* Close established socket */
    6676
    67 #if HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR
     77static void winbind_close_sock(struct winbindd_context *ctx)
     78{
     79        if (!ctx) {
     80                return;
     81        }
     82
     83        if (ctx->winbindd_fd != -1) {
     84                close(ctx->winbindd_fd);
     85                ctx->winbindd_fd = -1;
     86        }
     87}
     88
     89/* Destructor for global context to ensure fd is closed */
     90
     91#if HAVE_DESTRUCTOR_ATTRIBUTE
    6892__attribute__((destructor))
    6993#endif
    70 static void winbind_close_sock(void)
    71 {
    72         if (winbindd_fd != -1) {
    73                 close(winbindd_fd);
    74                 winbindd_fd = -1;
    75         }
     94static void winbind_destructor(void)
     95{
     96        winbind_close_sock(&wb_global_ctx);
    7697}
    7798
     
    169190}
    170191
     192/**
     193 * @internal
     194 *
     195 * @brief Check if we talk to the priviliged pipe which should be owned by root.
     196 *
     197 * This checks if we have uid_wrapper running and if this is the case it will
     198 * allow one to connect to the winbind privileged pipe even it is not owned by root.
     199 *
     200 * @param[in]  uid      The uid to check if we can safely talk to the pipe.
     201 *
     202 * @return              If we have access it returns true, else false.
     203 */
     204static bool winbind_privileged_pipe_is_root(uid_t uid)
     205{
     206        if (uid == 0) {
     207                return true;
     208        }
     209
     210        if (uid_wrapper_enabled()) {
     211                return true;
     212        }
     213
     214        return false;
     215}
     216
    171217/* Connect to winbindd socket */
    172218
     
    175221        struct sockaddr_un sunaddr;
    176222        struct stat st;
    177         char *path = NULL;
    178223        int fd;
    179224        int wait_time;
    180225        int slept;
     226        int ret;
    181227
    182228        /* Check permissions on unix socket directory */
     
    187233        }
    188234
     235        /*
     236         * This tells us that the pipe is owned by a privileged
     237         * process, as we will be sending passwords to it.
     238         */
    189239        if (!S_ISDIR(st.st_mode) ||
    190             (st.st_uid != 0 && st.st_uid != geteuid())) {
     240            !winbind_privileged_pipe_is_root(st.st_uid)) {
    191241                errno = ENOENT;
    192242                return -1;
     
    195245        /* Connect to socket */
    196246
    197         if (asprintf(&path, "%s/%s", dir, WINBINDD_SOCKET_NAME) < 0) {
    198                 return -1;
    199         }
    200 
    201         ZERO_STRUCT(sunaddr);
    202         sunaddr.sun_family = AF_UNIX;
    203         strncpy(sunaddr.sun_path, path, sizeof(sunaddr.sun_path) - 1);
     247        sunaddr = (struct sockaddr_un) { .sun_family = AF_UNIX };
     248
     249        ret = snprintf(sunaddr.sun_path, sizeof(sunaddr.sun_path),
     250                       "%s/%s", dir, WINBINDD_SOCKET_NAME);
     251        if ((ret == -1) || (ret >= sizeof(sunaddr.sun_path))) {
     252                errno = ENAMETOOLONG;
     253                return -1;
     254        }
    204255
    205256        /* If socket file doesn't exist, don't bother trying to connect
     
    207258           the winbindd daemon is not running. */
    208259
    209         if (lstat(path, &st) == -1) {
     260        if (lstat(sunaddr.sun_path, &st) == -1) {
    210261                errno = ENOENT;
    211                 SAFE_FREE(path);
    212                 return -1;
    213         }
    214 
    215         SAFE_FREE(path);
     262                return -1;
     263        }
     264
    216265        /* Check permissions on unix socket file */
    217266
     267        /*
     268         * This tells us that the pipe is owned by a privileged
     269         * process, as we will be sending passwords to it.
     270         */
    218271        if (!S_ISSOCK(st.st_mode) ||
    219             (st.st_uid != 0 && st.st_uid != geteuid())) {
     272            !winbind_privileged_pipe_is_root(st.st_uid)) {
    220273                errno = ENOENT;
    221274                return -1;
     
    237290                        wait_time += slept) {
    238291                struct pollfd pfd;
    239                 int ret;
    240292                int connect_errno = 0;
    241293                socklen_t errnosize;
     
    287339static const char *winbindd_socket_dir(void)
    288340{
    289 #ifdef SOCKET_WRAPPER
    290         const char *env_dir;
    291 
    292         env_dir = getenv(WINBINDD_SOCKET_DIR_ENVVAR);
    293         if (env_dir) {
    294                 return env_dir;
    295         }
    296 #endif
     341        if (nss_wrapper_enabled()) {
     342                const char *env_dir;
     343
     344                env_dir = getenv("SELFTEST_WINBINDD_SOCKET_DIR");
     345                if (env_dir != NULL) {
     346                        return env_dir;
     347                }
     348        }
    297349
    298350        return WINBINDD_SOCKET_DIR;
     
    301353/* Connect to winbindd socket */
    302354
    303 static int winbind_open_pipe_sock(int recursing, int need_priv)
     355static int winbind_open_pipe_sock(struct winbindd_context *ctx,
     356                                  int recursing, int need_priv)
    304357{
    305358#ifdef HAVE_UNIXSOCKET
    306         static pid_t our_pid;
    307359        struct winbindd_request request;
    308360        struct winbindd_response response;
     361
    309362        ZERO_STRUCT(request);
    310363        ZERO_STRUCT(response);
    311364
    312         if (our_pid != getpid()) {
    313                 winbind_close_sock();
    314                 our_pid = getpid();
    315         }
    316 
    317         if ((need_priv != 0) && (is_privileged == 0)) {
    318                 winbind_close_sock();
    319         }
    320 
    321         if (winbindd_fd != -1) {
    322                 return winbindd_fd;
     365        if (!ctx) {
     366                return -1;
     367        }
     368
     369        if (ctx->our_pid != getpid()) {
     370                winbind_close_sock(ctx);
     371                ctx->our_pid = getpid();
     372        }
     373
     374        if ((need_priv != 0) && (ctx->is_privileged == 0)) {
     375                winbind_close_sock(ctx);
     376        }
     377
     378        if (ctx->winbindd_fd != -1) {
     379                return ctx->winbindd_fd;
    323380        }
    324381
     
    327384        }
    328385
    329         if ((winbindd_fd = winbind_named_pipe_sock(winbindd_socket_dir())) == -1) {
    330                 return -1;
    331         }
    332 
    333         is_privileged = 0;
     386        ctx->winbindd_fd = winbind_named_pipe_sock(winbindd_socket_dir());
     387
     388        if (ctx->winbindd_fd == -1) {
     389                return -1;
     390        }
     391
     392        ctx->is_privileged = 0;
    334393
    335394        /* version-check the socket */
    336395
    337396        request.wb_flags = WBFLAG_RECURSE;
    338         if ((winbindd_request_response(WINBINDD_INTERFACE_VERSION, &request, &response) != NSS_STATUS_SUCCESS) || (response.data.interface_version != WINBIND_INTERFACE_VERSION)) {
    339                 winbind_close_sock();
     397        if ((winbindd_request_response(ctx, WINBINDD_INTERFACE_VERSION, &request,
     398                                       &response) != NSS_STATUS_SUCCESS) ||
     399            (response.data.interface_version != WINBIND_INTERFACE_VERSION)) {
     400                winbind_close_sock(ctx);
    340401                return -1;
    341402        }
     
    344405
    345406        request.wb_flags = WBFLAG_RECURSE;
    346         if (winbindd_request_response(WINBINDD_PRIV_PIPE_DIR, &request, &response) == NSS_STATUS_SUCCESS) {
     407
     408        /* Note that response needs to be initialized to avoid
     409         * crashing on clean up after WINBINDD_PRIV_PIPE_DIR call failed
     410         * as interface version (from the first request) returned as a fstring,
     411         * thus response.extra_data.data will not be NULL even though
     412         * winbindd response did not write over it due to a failure */
     413        ZERO_STRUCT(response);
     414        if (winbindd_request_response(ctx, WINBINDD_PRIV_PIPE_DIR, &request,
     415                                      &response) == NSS_STATUS_SUCCESS) {
    347416                int fd;
    348                 if ((fd = winbind_named_pipe_sock((char *)response.extra_data.data)) != -1) {
    349                         close(winbindd_fd);
    350                         winbindd_fd = fd;
    351                         is_privileged = 1;
    352                 }
    353         }
    354 
    355         if ((need_priv != 0) && (is_privileged == 0)) {
     417                fd = winbind_named_pipe_sock((char *)response.extra_data.data);
     418                if (fd != -1) {
     419                        close(ctx->winbindd_fd);
     420                        ctx->winbindd_fd = fd;
     421                        ctx->is_privileged = 1;
     422                }
     423        }
     424
     425        if ((need_priv != 0) && (ctx->is_privileged == 0)) {
    356426                return -1;
    357427        }
     
    359429        SAFE_FREE(response.extra_data.data);
    360430
    361         return winbindd_fd;
     431        return ctx->winbindd_fd;
    362432#else
    363433        return -1;
     
    367437/* Write data to winbindd socket */
    368438
    369 static int winbind_write_sock(void *buffer, int count, int recursing,
    370                               int need_priv)
    371 {
    372         int result, nwritten;
     439static int winbind_write_sock(struct winbindd_context *ctx, void *buffer,
     440                              int count, int recursing, int need_priv)
     441{
     442        int fd, result, nwritten;
    373443
    374444        /* Open connection to winbind daemon */
     
    376446 restart:
    377447
    378         if (winbind_open_pipe_sock(recursing, need_priv) == -1) {
     448        fd = winbind_open_pipe_sock(ctx, recursing, need_priv);
     449        if (fd == -1) {
    379450                errno = ENOENT;
    380451                return -1;
     
    392463                   call would not block by calling poll(). */
    393464
    394                 pfd.fd = winbindd_fd;
     465                pfd.fd = fd;
    395466                pfd.events = POLLIN|POLLOUT|POLLHUP;
    396467
    397468                ret = poll(&pfd, 1, -1);
    398469                if (ret == -1) {
    399                         winbind_close_sock();
     470                        winbind_close_sock(ctx);
    400471                        return -1;                   /* poll error */
    401472                }
     
    407478                        /* Pipe has closed on remote end */
    408479
    409                         winbind_close_sock();
     480                        winbind_close_sock(ctx);
    410481                        goto restart;
    411482                }
     
    413484                /* Do the write */
    414485
    415                 result = write(winbindd_fd,
    416                                (char *)buffer + nwritten,
     486                result = write(fd, (char *)buffer + nwritten,
    417487                               count - nwritten);
    418488
     
    421491                        /* Write failed */
    422492
    423                         winbind_close_sock();
     493                        winbind_close_sock(ctx);
    424494                        return -1;
    425495                }
     
    433503/* Read data from winbindd socket */
    434504
    435 static int winbind_read_sock(void *buffer, int count)
    436 {
     505static int winbind_read_sock(struct winbindd_context *ctx,
     506                             void *buffer, int count)
     507{
     508        int fd;
    437509        int nread = 0;
    438510        int total_time = 0;
    439511
    440         if (winbindd_fd == -1) {
     512        fd = winbind_open_pipe_sock(ctx, false, false);
     513        if (fd == -1) {
    441514                return -1;
    442515        }
     
    450523                   call would not block by calling poll(). */
    451524
    452                 pfd.fd = winbindd_fd;
     525                pfd.fd = fd;
    453526                pfd.events = POLLIN|POLLHUP;
    454527
     
    457530                ret = poll(&pfd, 1, 5000);
    458531                if (ret == -1) {
    459                         winbind_close_sock();
     532                        winbind_close_sock(ctx);
    460533                        return -1;                   /* poll error */
    461534                }
     
    463536                if (ret == 0) {
    464537                        /* Not ready for read yet... */
    465                         if (total_time >= 30) {
     538                        if (total_time >= 300) {
    466539                                /* Timeout */
    467                                 winbind_close_sock();
     540                                winbind_close_sock(ctx);
    468541                                return -1;
    469542                        }
     
    476549                        /* Do the Read */
    477550
    478                         int result = read(winbindd_fd, (char *)buffer + nread,
     551                        int result = read(fd, (char *)buffer + nread,
    479552                              count - nread);
    480553
     
    485558                                   transaction has failed half way through. */
    486559
    487                                 winbind_close_sock();
     560                                winbind_close_sock(ctx);
    488561                                return -1;
    489562                        }
     
    499572/* Read reply */
    500573
    501 static int winbindd_read_reply(struct winbindd_response *response)
     574static int winbindd_read_reply(struct winbindd_context *ctx,
     575                               struct winbindd_response *response)
    502576{
    503577        int result1, result2 = 0;
     
    509583        /* Read fixed length response */
    510584
    511         result1 = winbind_read_sock(response,
     585        result1 = winbind_read_sock(ctx, response,
    512586                                    sizeof(struct winbindd_response));
    513         if (result1 == -1) {
    514                 return -1;
    515         }
    516 
    517         if (response->length < sizeof(struct winbindd_response)) {
    518                 return -1;
    519         }
    520587
    521588        /* We actually send the pointer value of the extra_data field from
     
    525592        response->extra_data.data = NULL;
    526593
     594        if (result1 == -1) {
     595                return -1;
     596        }
     597
     598        if (response->length < sizeof(struct winbindd_response)) {
     599                return -1;
     600        }
     601
    527602        /* Read variable length response */
    528603
     
    537612                }
    538613
    539                 result2 = winbind_read_sock(response->extra_data.data,
     614                result2 = winbind_read_sock(ctx, response->extra_data.data,
    540615                                            extra_data_len);
    541616                if (result2 == -1) {
     
    554629 */
    555630
    556 NSS_STATUS winbindd_send_request(int req_type, int need_priv,
     631NSS_STATUS winbindd_send_request(struct winbindd_context *ctx,
     632                                 int req_type, int need_priv,
    557633                                 struct winbindd_request *request)
    558634{
     
    574650        winbindd_init_request(request, req_type);
    575651
    576         if (winbind_write_sock(request, sizeof(*request),
     652        if (winbind_write_sock(ctx, request, sizeof(*request),
    577653                               request->wb_flags & WBFLAG_RECURSE,
    578654                               need_priv) == -1)
     
    585661
    586662        if ((request->extra_len != 0) &&
    587             (winbind_write_sock(request->extra_data.data,
     663            (winbind_write_sock(ctx, request->extra_data.data,
    588664                                request->extra_len,
    589665                                request->wb_flags & WBFLAG_RECURSE,
     
    603679 */
    604680
    605 NSS_STATUS winbindd_get_response(struct winbindd_response *response)
     681NSS_STATUS winbindd_get_response(struct winbindd_context *ctx,
     682                                 struct winbindd_response *response)
    606683{
    607684        struct winbindd_response lresponse;
     
    615692
    616693        /* Wait for reply */
    617         if (winbindd_read_reply(response) == -1) {
     694        if (winbindd_read_reply(ctx, response) == -1) {
    618695                /* Set ENOENT for consistency.  Required by some apps */
    619696                errno = ENOENT;
     
    637714/* Handle simple types of requests */
    638715
    639 NSS_STATUS winbindd_request_response(int req_type,
    640                             struct winbindd_request *request,
    641                             struct winbindd_response *response)
     716NSS_STATUS winbindd_request_response(struct winbindd_context *ctx,
     717                                     int req_type,
     718                                     struct winbindd_request *request,
     719                                     struct winbindd_response *response)
    642720{
    643721        NSS_STATUS status = NSS_STATUS_UNAVAIL;
    644         int count = 0;
    645 
    646         while ((status == NSS_STATUS_UNAVAIL) && (count < 10)) {
    647                 status = winbindd_send_request(req_type, 0, request);
    648                 if (status != NSS_STATUS_SUCCESS)
    649                         return(status);
    650                 status = winbindd_get_response(response);
    651                 count += 1;
    652         }
     722        struct winbindd_context *wb_ctx = ctx;
     723
     724        if (ctx == NULL) {
     725                wb_ctx = &wb_global_ctx;
     726        }
     727
     728        status = winbindd_send_request(wb_ctx, req_type, 0, request);
     729        if (status != NSS_STATUS_SUCCESS)
     730                return (status);
     731        status = winbindd_get_response(wb_ctx, response);
    653732
    654733        return status;
    655734}
    656735
    657 NSS_STATUS winbindd_priv_request_response(int req_type,
     736NSS_STATUS winbindd_priv_request_response(struct winbindd_context *ctx,
     737                                          int req_type,
    658738                                          struct winbindd_request *request,
    659739                                          struct winbindd_response *response)
    660740{
    661741        NSS_STATUS status = NSS_STATUS_UNAVAIL;
    662         int count = 0;
    663 
    664         while ((status == NSS_STATUS_UNAVAIL) && (count < 10)) {
    665                 status = winbindd_send_request(req_type, 1, request);
    666                 if (status != NSS_STATUS_SUCCESS)
    667                         return(status);
    668                 status = winbindd_get_response(response);
    669                 count += 1;
    670         }
     742        struct winbindd_context *wb_ctx = ctx;
     743
     744        if (ctx == NULL) {
     745                wb_ctx = &wb_global_ctx;
     746        }
     747
     748        status = winbindd_send_request(wb_ctx, req_type, 1, request);
     749        if (status != NSS_STATUS_SUCCESS)
     750                return (status);
     751        status = winbindd_get_response(wb_ctx, response);
    671752
    672753        return status;
    673754}
     755
     756/* Create and free winbindd context */
     757
     758struct winbindd_context *winbindd_ctx_create(void)
     759{
     760        struct winbindd_context *ctx;
     761
     762        ctx = calloc(1, sizeof(struct winbindd_context));
     763
     764        if (!ctx) {
     765                return NULL;
     766        }
     767
     768        ctx->winbindd_fd = -1;
     769
     770        return ctx;
     771}
     772
     773void winbindd_ctx_free(struct winbindd_context *ctx)
     774{
     775        winbind_close_sock(ctx);
     776        free(ctx);
     777}
  • vendor/current/nsswitch/wbinfo.c

    r860 r988  
    2323
    2424#include "includes.h"
    25 #include "popt_common.h"
    2625#include "winbind_client.h"
    2726#include "libwbclient/wbclient.h"
    28 #include "lib/popt/popt.h"
    2927#include "../libcli/auth/libcli_auth.h"
    30 #if (_SAMBA_BUILD_) >= 4
    3128#include "lib/cmdline/popt_common.h"
    32 #endif
     29#include "lib/afs/afs_settoken.h"
    3330
    3431#ifdef DBGC_CLASS
     
    121118        if (!p) {
    122119                /* Maybe it was a UPN? */
    123                 if ((p = strchr(domuser, '@')) != NULL) {
     120                p = strchr(domuser, '@');
     121                if (p != NULL) {
    124122                        fstrcpy(domain, "");
    125123                        fstrcpy(user, domuser);
     
    135133        fstrcpy(domain, domuser);
    136134        domain[PTR_DIFF(p, domuser)] = 0;
    137         strupper_m(domain);
    138135
    139136        return true;
     
    243240                 pwd->pw_shell);
    244241
     242        wbcFreeMemory(pwd);
     243
    245244        return true;
    246245}
     
    520519
    521520        if (print_all) {
    522                 d_printf("%-16s%-24s%-12s%-12s%-5s%-5s\n",
     521                d_printf("%-16s%-65s%-12s%-12s%-5s%-5s\n",
    523522                         "Domain Name", "DNS Domain", "Trust Type",
    524523                         "Transitive", "In", "Out");
     
    534533                }
    535534
    536                 d_printf("%-24s", domain_list[i].dns_name);
     535                d_printf("%-65s", domain_list[i].dns_name);
    537536
    538537                switch(domain_list[i].trust_type) {
     
    690689        /* Send request */
    691690
    692         if (winbindd_request_response(WINBINDD_GETDCNAME, &request,
     691        if (winbindd_request_response(NULL, WINBINDD_GETDCNAME, &request,
    693692                                      &response) != NSS_STATUS_SUCCESS) {
    694693                d_fprintf(stderr, "Could not get dc name for %s\n",domain_name);
     
    754753
    755754        if (wbc_status == WBC_ERR_AUTH_ERROR) {
    756                 d_fprintf(stderr, "error code was %s (0x%x)\n",
    757                           error->nt_string, error->nt_status);
     755                d_fprintf(stderr, "wbcCheckTrustCredentials(%s): error code was %s (0x%x)\n",
     756                          domain_name, error->nt_string, error->nt_status);
    758757                wbcFreeMemory(error);
    759758        }
     
    813812
    814813        if (wbc_status == WBC_ERR_AUTH_ERROR) {
    815                 d_fprintf(stderr, "error code was %s (0x%x)\n",
    816                           error->nt_string, error->nt_status);
     814                d_fprintf(stderr, "wbcChangeTrustCredentials(%s): error code was %s (0x%x)\n",
     815                          domain_name, error->nt_string, error->nt_status);
    817816                wbcFreeMemory(error);
    818817        }
     
    828827/* Check DC connection */
    829828
    830 static bool wbinfo_ping_dc(void)
     829static bool wbinfo_ping_dc(const char *domain)
    831830{
    832831        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
    833832        struct wbcAuthErrorInfo *error = NULL;
    834 
    835         wbc_status = wbcPingDc(NULL, &error);
    836 
    837         d_printf("checking the NETLOGON dc connection %s\n",
     833        char *dcname = NULL;
     834
     835        const char *domain_name;
     836
     837        if (domain) {
     838                domain_name = domain;
     839        } else {
     840                domain_name = get_winbind_domain();
     841        }
     842
     843        wbc_status = wbcPingDc2(domain_name, &error, &dcname);
     844
     845        d_printf("checking the NETLOGON for domain[%s] dc connection to \"%s\" %s\n",
     846                 domain_name ? domain_name : "",
     847                 dcname ? dcname : "",
    838848                 WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
    839849
     850        wbcFreeMemory(dcname);
    840851        if (wbc_status == WBC_ERR_AUTH_ERROR) {
    841                 d_fprintf(stderr, "error code was %s (0x%x)\n",
    842                           error->nt_string, error->nt_status);
     852                d_fprintf(stderr, "wbcPingDc2(%s): error code was %s (0x%x)\n",
     853                          domain_name, error->nt_string, error->nt_status);
    843854                wbcFreeMemory(error);
     855                return false;
    844856        }
    845857        if (!WBC_ERROR_IS_OK(wbc_status)) {
     
    10201032                        d_printf("%s -> gid %d\n", sidstr, unix_ids[i].id.gid);
    10211033                        break;
     1034                case WBC_ID_TYPE_BOTH:
     1035                        d_printf("%s -> uid/gid %d\n", sidstr, unix_ids[i].id.uid);
     1036                        break;
    10221037                default:
    10231038                        d_printf("%s -> unmapped\n", sidstr);
     
    12181233        /* Display response */
    12191234
    1220         d_printf("%s%c%s %d\n",
    1221                  domain, winbind_separator(), name, type);
     1235        if (type == WBC_SID_NAME_DOMAIN) {
     1236                d_printf("%s %d\n", domain, type);
     1237        } else {
     1238                d_printf("%s%c%s %d\n",
     1239                         domain, winbind_separator(), name, type);
     1240        }
     1241
     1242        wbcFreeMemory(domain);
     1243        wbcFreeMemory(name);
    12221244
    12231245        return true;
     
    12541276        d_printf("%s%c%s %d\n",
    12551277                 domain, winbind_separator(), name, type);
     1278
     1279        wbcFreeMemory(domain);
     1280        wbcFreeMemory(name);
    12561281
    12571282        return true;
     
    13141339
    13151340        wbc_status = wbcLookupRids(&dinfo->sid, num_rids, rids,
    1316                                    (const char **)&domain_name, &names, &types);
     1341                                   &p, &names, &types);
    13171342        if (!WBC_ERROR_IS_OK(wbc_status)) {
    13181343                d_printf("winbind_lookup_rids failed: %s\n",
     
    13211346        }
    13221347
     1348        domain_name = discard_const_p(char, p);
    13231349        d_printf("Domain: %s\n", domain_name);
    13241350
     
    13951421                if (names[i].type == WBC_SID_NAME_DOMAIN) {
    13961422                        d_printf("%s -> %s %d\n", sidstr,
    1397                                 domain,
    1398                                 names[i].type);
     1423                                 domain,
     1424                                 names[i].type);
    13991425                } else {
    14001426                        d_printf("%s -> %s%c%s %d\n", sidstr,
    1401                                 domain,
    1402                                 winbind_separator(),
    1403                                 names[i].name, names[i].type);
    1404                 }
    1405         }
     1427                                 domain,
     1428                                 winbind_separator(),
     1429                                 names[i].name, names[i].type);
     1430                }
     1431        }
     1432        wbcFreeMemory(names);
     1433        wbcFreeMemory(domains);
    14061434        return true;
    14071435}
     
    14451473{
    14461474        char *prompt;
    1447         const char *ret = NULL;
     1475        char buf[1024] = {0};
     1476        int rc;
    14481477
    14491478        prompt = talloc_asprintf(mem_ctx, "Enter %s's ", username);
     
    14621491        }
    14631492
    1464         ret = getpass(prompt);
     1493        rc = samba_getpass(prompt, buf, sizeof(buf), false, false);
    14651494        TALLOC_FREE(prompt);
    1466 
    1467         return talloc_strdup(mem_ctx, ret);
     1495        if (rc < 0) {
     1496                return NULL;
     1497        }
     1498
     1499        return talloc_strdup(mem_ctx, buf);
    14681500}
    14691501
     
    15531585        if (error) {
    15541586                d_fprintf(stderr,
    1555                          "error code was %s (0x%x)\nerror message was: %s\n",
    1556                          error->nt_string,
     1587                         "wbcLogonUser(%s): error code was %s (0x%x)\n"
     1588                         "error message was: %s\n",
     1589                         params.username, error->nt_string,
    15571590                         error->nt_status,
    15581591                         error->display_string);
     
    17251758        if (wbc_status == WBC_ERR_AUTH_ERROR) {
    17261759                d_fprintf(stderr,
    1727                          "error code was %s (0x%x)\nerror message was: %s\n",
     1760                         "wbcAuthenticateUserEx(%s%c%s): error code was %s (0x%x)\n"
     1761                         "error message was: %s\n",
     1762                         name_domain,
     1763                         winbind_separator(),
     1764                         name_user,
    17281765                         err->nt_string,
    17291766                         err->nt_status,
     
    17421779/* Authenticate a user with a plaintext password */
    17431780
    1744 static bool wbinfo_pam_logon(char *username)
     1781static bool wbinfo_pam_logon(char *username, bool verbose)
    17451782{
    17461783        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
    17471784        struct wbcLogonUserParams params;
     1785        struct wbcLogonUserInfo *info = NULL;
    17481786        struct wbcAuthErrorInfo *error = NULL;
    17491787        char *s = NULL;
     
    17901828        }
    17911829
    1792         wbc_status = wbcLogonUser(&params, NULL, &error, NULL);
     1830        wbc_status = wbcLogonUser(&params, &info, &error, NULL);
     1831
     1832        if (verbose && (info != NULL)) {
     1833                struct wbcAuthUserInfo *i = info->info;
     1834                uint32_t j;
     1835
     1836                if (i->account_name != NULL) {
     1837                        d_printf("account_name: %s\n", i->account_name);
     1838                }
     1839                if (i->user_principal != NULL) {
     1840                        d_printf("user_principal: %s\n", i->user_principal);
     1841                }
     1842                if (i->full_name != NULL) {
     1843                        d_printf("full_name: %s\n", i->full_name);
     1844                }
     1845                if (i->domain_name != NULL) {
     1846                        d_printf("domain_name: %s\n", i->domain_name);
     1847                }
     1848                if (i->dns_domain_name != NULL) {
     1849                        d_printf("dns_domain_name: %s\n", i->dns_domain_name);
     1850                }
     1851                if (i->logon_server != NULL) {
     1852                        d_printf("logon_server: %s\n", i->logon_server);
     1853                }
     1854                if (i->logon_script != NULL) {
     1855                        d_printf("logon_script: %s\n", i->logon_script);
     1856                }
     1857                if (i->profile_path != NULL) {
     1858                        d_printf("profile_path: %s\n", i->profile_path);
     1859                }
     1860                if (i->home_directory != NULL) {
     1861                        d_printf("home_directory: %s\n", i->home_directory);
     1862                }
     1863                if (i->home_drive != NULL) {
     1864                        d_printf("home_drive: %s\n", i->home_drive);
     1865                }
     1866
     1867                d_printf("sids:");
     1868
     1869                for (j=0; j<i->num_sids; j++) {
     1870                        char buf[WBC_SID_STRING_BUFLEN];
     1871                        wbcSidToStringBuf(&i->sids[j].sid, buf, sizeof(buf));
     1872                        d_printf(" %s", buf);
     1873                }
     1874                d_printf("\n");
     1875
     1876                wbcFreeMemory(info);
     1877                info = NULL;
     1878        }
    17931879
    17941880        wbcFreeMemory(params.blobs);
     
    17991885        if (!WBC_ERROR_IS_OK(wbc_status) && (error != NULL)) {
    18001886                d_fprintf(stderr,
    1801                           "error code was %s (0x%x)\nerror message was: %s\n",
     1887                          "wbcLogonUser(%s): error code was %s (0x%x)\n"
     1888                          "error message was: %s\n",
     1889                          params.username,
    18021890                          error->nt_string,
    18031891                          (int)error->nt_status,
     
    18691957        } else {
    18701958                fstrcpy(request.data.auth.user, username);
    1871                 fstrcpy(request.data.auth.pass, getpass("Password: "));
     1959                (void) samba_getpass("Password: ",
     1960                                     request.data.auth.pass,
     1961                                     sizeof(request.data.auth.pass),
     1962                                     false, false);
    18721963        }
    18731964
    18741965        request.flags |= WBFLAG_PAM_AFS_TOKEN;
    18751966
    1876         result = winbindd_request_response(WINBINDD_PAM_AUTH, &request,
     1967        result = winbindd_request_response(NULL, WINBINDD_PAM_AUTH, &request,
    18771968                                           &response);
    18781969
     
    19242015        /* Send request to winbind daemon */
    19252016
    1926         /* '.' is the special sign for our own domain */
    1927         if (domain && strcmp(domain, ".") == 0) {
     2017        if (domain == NULL) {
    19282018                domain = get_winbind_domain();
     2019        } else {
     2020                /* '.' is the special sign for our own domain */
     2021                if ((domain[0] == '\0') || strcmp(domain, ".") == 0) {
     2022                        domain = get_winbind_domain();
     2023                /* '*' is the special sign for all domains */
     2024                } else if (strcmp(domain, "*") == 0) {
     2025                        domain = NULL;
     2026                }
    19292027        }
    19302028
     
    19542052        /* Send request to winbind daemon */
    19552053
    1956         /* '.' is the special sign for our own domain */
    1957         if (domain && strcmp(domain, ".") == 0) {
     2054        if (domain == NULL) {
    19582055                domain = get_winbind_domain();
     2056        } else {
     2057                /* '.' is the special sign for our own domain */
     2058                if ((domain[0] == '\0') || strcmp(domain, ".") == 0) {
     2059                        domain = get_winbind_domain();
     2060                /* '*' is the special sign for all domains */
     2061                } else if (strcmp(domain, "*") == 0) {
     2062                        domain = NULL;
     2063                }
    19592064        }
    19602065
     
    20622167        OPT_LOGOFF_USER,
    20632168        OPT_LOGOFF_UID,
    2064         OPT_LANMAN
     2169        OPT_LANMAN,
     2170        OPT_KRB5CCNAME
    20652171};
    20662172
    2067 int main(int argc, char **argv, char **envp)
     2173int main(int argc, const char **argv, char **envp)
    20682174{
    20692175        int opt;
     
    20812187        char *logoff_user = getenv("USER");
    20822188        int logoff_uid = geteuid();
     2189        const char *opt_krb5ccname = "FILE";
    20832190
    20842191        struct poptOption long_options[] = {
     
    21622269                        /* destroys wbinfo --help output */
    21632270                        /* "user%password,DOM\\user%password,user@EXAMPLE.COM,EXAMPLE.COM\\user%password" }, */
     2271                { "krb5ccname", 0, POPT_ARG_STRING, &opt_krb5ccname, OPT_KRB5CCNAME, "authenticate user using Kerberos and specific credential cache type", "krb5ccname" },
    21642272#endif
    21652273                { "separator", 0, POPT_ARG_NONE, 0, OPT_SEPARATOR, "Get the active winbind separator", NULL },
     
    21732281
    21742282        /* Samba client initialisation */
    2175         load_case_tables();
     2283        smb_init_locale();
    21762284
    21772285
    21782286        /* Parse options */
    21792287
    2180         pc = poptGetContext("wbinfo", argc, (const char **)argv,
     2288        pc = poptGetContext("wbinfo", argc, argv,
    21812289                            long_options, 0);
    21822290
     
    23822490                        break;
    23832491                case 'P':
    2384                         if (!wbinfo_ping_dc()) {
    2385                                 d_fprintf(stderr, "Could not ping our DC\n");
     2492                        if (!wbinfo_ping_dc(opt_domain_name)) {
    23862493                                goto done;
    23872494                        }
     
    25092616                        }
    25102617                case OPT_PAM_LOGON:
    2511                         if (!wbinfo_pam_logon(string_arg)) {
     2618                        if (!wbinfo_pam_logon(string_arg, verbose)) {
    25122619                                d_fprintf(stderr, "pam_logon failed for %s\n",
    25132620                                          string_arg);
     
    25322639                                                 WBFLAG_PAM_CONTACT_TRUSTDOM;
    25332640
    2534                                 if (!wbinfo_auth_krb5(string_arg, "FILE",
     2641                                if (!wbinfo_auth_krb5(string_arg, opt_krb5ccname,
    25352642                                                      flags)) {
    25362643                                        d_fprintf(stderr,
     
    25382645                                                "[%s] with Kerberos "
    25392646                                                "(ccache: %s)\n", string_arg,
    2540                                                 "FILE");
     2647                                                opt_krb5ccname);
    25412648                                        goto done;
    25422649                                }
     
    26182725                case OPT_LOGOFF_USER:
    26192726                case OPT_LOGOFF_UID:
     2727                case OPT_KRB5CCNAME:
    26202728                        break;
    26212729                default:
  • vendor/current/nsswitch/winbind_client.h

    r740 r988  
    77   Copyright (C) Andrew Tridgell 2000
    88   Copyright (C) Andrew Bartlett 2002
     9   Copyright (C) Matthew Newton 2015
    910
    1011
     
    2930#include "winbind_struct_protocol.h"
    3031
     32struct winbindd_context;
     33
     34struct winbindd_context *winbindd_ctx_create(void);
     35void winbindd_ctx_free(struct winbindd_context *ctx);
     36
    3137void winbindd_free_response(struct winbindd_response *response);
    32 NSS_STATUS winbindd_send_request(int req_type, int need_priv,
     38NSS_STATUS winbindd_send_request(struct winbindd_context *ctx,
     39                                 int req_type, int need_priv,
    3340                                 struct winbindd_request *request);
    34 NSS_STATUS winbindd_get_response(struct winbindd_response *response);
    35 NSS_STATUS winbindd_request_response(int req_type,
    36                             struct winbindd_request *request,
    37                             struct winbindd_response *response);
    38 NSS_STATUS winbindd_priv_request_response(int req_type,
     41NSS_STATUS winbindd_get_response(struct winbindd_context *ctx,
     42                                 struct winbindd_response *response);
     43NSS_STATUS winbindd_request_response(struct winbindd_context *ctx,
     44                                     int req_type,
     45                                     struct winbindd_request *request,
     46                                     struct winbindd_response *response);
     47NSS_STATUS winbindd_priv_request_response(struct winbindd_context *ctx,
     48                                          int req_type,
    3949                                          struct winbindd_request *request,
    4050                                          struct winbindd_response *response);
     51
    4152#define winbind_env_set() \
    4253        (strcmp(getenv(WINBINDD_DONT_ENV)?getenv(WINBINDD_DONT_ENV):"0","1") == 0)
  • vendor/current/nsswitch/winbind_krb5_locator.c

    r746 r988  
    143143                case AF_UNSPEC:
    144144                case AF_INET:
    145                         break;
    146145#if defined(HAVE_IPV6)
    147146                case AF_INET6:
    148                         break;
    149 #endif
     147#endif
     148                        break;
    150149                default:
    151150                        return EINVAL;
  • vendor/current/nsswitch/winbind_nss_aix.c

    r414 r988  
    280280        request.data.gid = gid;
    281281
    282         ret = winbindd_request_response(WINBINDD_GETGRGID, &request, &response);
     282        ret = winbindd_request_response(NULL, WINBINDD_GETGRGID,
     283                                        &request, &response);
    283284
    284285        logit("getgrgid ret=%d\n", ret);
     
    312313        STRCPY_RETNULL(request.data.groupname, name);
    313314
    314         ret = winbindd_request_response(WINBINDD_GETGRNAM, &request, &response);
     315        ret = winbindd_request_response(NULL, WINBINDD_GETGRNAM,
     316                                        &request, &response);
    315317
    316318        HANDLE_ERRORS(ret);
     
    371373        }
    372374
    373         ret = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response);
     375        ret = winbindd_request_response(NULL, WINBINDD_GETGROUPS,
     376                                        &request, &response);
    374377
    375378        HANDLE_ERRORS(ret);
     
    410413        request.data.uid = uid;
    411414
    412         ret = winbindd_request_response(WINBINDD_GETPWUID, &request, &response);
     415        ret = winbindd_request_response(NULL, WINBINDD_GETPWUID,
     416                                        &request, &response);
    413417
    414418        HANDLE_ERRORS(ret);
     
    443447        STRCPY_RETNULL(request.data.username, name);
    444448
    445         ret = winbindd_request_response(WINBINDD_GETPWNAM, &request, &response);
     449        ret = winbindd_request_response(NULL, WINBINDD_GETPWNAM,
     450                                        &request, &response);
    446451
    447452        HANDLE_ERRORS(ret);
     
    476481        ZERO_STRUCT(response);
    477482
    478         ret = winbindd_request_response(WINBINDD_LIST_USERS, &request, &response);
     483        ret = winbindd_request_response(NULL, WINBINDD_LIST_USERS,
     484                                        &request, &response);
    479485        if (ret != 0) {
    480486                errno = EINVAL;
     
    524530        ZERO_STRUCT(response);
    525531
    526         ret = winbindd_request_response(WINBINDD_LIST_GROUPS, &request, &response);
     532        ret = winbindd_request_response(NULL, WINBINDD_LIST_GROUPS,
     533                                        &request, &response);
    527534        if (ret != 0) {
    528535                errno = EINVAL;
     
    603610        request.data.uid = pwd->pw_uid;
    604611
    605         if (winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response) !=
     612        if (winbindd_request_response(NULL, WINBINDD_UID_TO_SID,
     613                                      &request, &response) !=
    606614            NSS_STATUS_SUCCESS) {
    607615                r.attr_flag = ENOENT;
     
    889897        }
    890898
    891         result = winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response);
     899        result = winbindd_request_response(NULL, WINBINDD_PAM_AUTH,
     900                                           &request, &response);
    892901
    893902        winbindd_free_response(&response);
     
    938947        }
    939948
    940         result = winbindd_request_response(WINBINDD_PAM_CHAUTHTOK, &request, &response);
     949        result = winbindd_request_response(NULL, WINBINDD_PAM_CHAUTHTOK,
     950                                           &request, &response);
    941951
    942952        winbindd_free_response(&response);
  • vendor/current/nsswitch/winbind_nss_config.h

    r414 r988  
    2828#endif
    2929
    30 /*
    31  * we don't need socket wrapper
    32  * nor nss wrapper here and we don't
    33  * want to depend on swrap_close()
    34  * so we better disable both
    35  */
    36 #define SOCKET_WRAPPER_NOT_REPLACE
    37 #define NSS_WRAPPER_NOT_REPLACE
    38 
    3930/* Include header files from data in config.h file */
    4031
     
    5546#define FSTRING_LEN 256
    5647typedef char fstring[FSTRING_LEN];
    57 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
     48#ifndef fstrcpy
     49#define fstrcpy(d,s) \
     50do { \
     51        const char *_fstrcpy_src = (const char *)(s); \
     52        strlcpy((d),_fstrcpy_src ? _fstrcpy_src : "",sizeof(fstring)); \
     53} while (0)
     54#endif
    5855#endif
    5956
  • vendor/current/nsswitch/winbind_nss_freebsd.c

    r597 r988  
    66
    77   Copyright (C) Aaron Collins 2003
     8   Copyright (C) Timur I. Bakeyev 2013
    89
    910   This library is free software; you can redistribute it and/or
     
    2425
    2526/* Make sure that the module gets registered needed by freebsd 5.1 */
    26 
    2727extern enum nss_status _nss_winbind_getgrent_r(struct group *, char *, size_t,
    2828    int *);
     
    3333extern enum nss_status _nss_winbind_setgrent(void);
    3434extern enum nss_status _nss_winbind_endgrent(void);
     35extern enum nss_status _nss_winbind_initgroups_dyn(char *, gid_t, long int *,
     36    long int *, gid_t **, long int , int *);
    3537
    3638extern enum nss_status _nss_winbind_getpwent_r(struct passwd *, char *, size_t,
     
    4244extern enum nss_status _nss_winbind_setpwent(void);
    4345extern enum nss_status _nss_winbind_endpwent(void);
     46ns_mtab *nss_module_register(const char *, unsigned int *, nss_module_unregister_fn *);
    4447
    4548NSS_METHOD_PROTOTYPE(__nss_compat_getgrnam_r);
     
    5457NSS_METHOD_PROTOTYPE(__nss_compat_setpwent);
    5558NSS_METHOD_PROTOTYPE(__nss_compat_endpwent);
     59NSS_METHOD_PROTOTYPE(__nss_compat_endpwent);
     60
     61NSS_METHOD_PROTOTYPE(__freebsd_getgroupmembership);
    5662
    5763static ns_mtab methods[] = {
     
    6167{ NSDB_GROUP, "setgrent",   __nss_compat_setgrent,   _nss_winbind_setgrent },
    6268{ NSDB_GROUP, "endgrent",   __nss_compat_endgrent,   _nss_winbind_endgrent },
     69{ NSDB_GROUP, "getgroupmembership", __freebsd_getgroupmembership, NULL },
    6370
    6471{ NSDB_PASSWD, "getpwnam_r", __nss_compat_getpwnam_r, _nss_winbind_getpwnam_r },
     
    7077};
    7178
     79/* Taken from libc */
     80static int
     81gr_addgid(gid_t gid, gid_t *groups, int maxgrp, int *grpcnt)
     82{
     83        int     ret, dupc;
     84
     85        /* skip duplicates */
     86        for (dupc = 0; dupc < MIN(maxgrp, *grpcnt); dupc++) {
     87                if (groups[dupc] == gid)
     88                        return 1;
     89        }
     90
     91        ret = 1;
     92        if (*grpcnt < maxgrp)                   /* add this gid */
     93                groups[*grpcnt] = gid;
     94        else
     95                ret = 0;
     96
     97        (*grpcnt)++;
     98
     99        return ret;
     100}
     101
     102/*
     103    rv = _nsdispatch(NULL, dtab, NSDB_GROUP, "getgroupmembership",
     104                    defaultsrc, uname, agroup, groups, maxgrp, grpcnt);
     105*/
     106
     107int
     108__freebsd_getgroupmembership(void *retval, void *mdata, va_list ap)
     109{
     110        const char      *uname  = va_arg(ap, const char *);
     111        gid_t            group  = va_arg(ap, gid_t);
     112        gid_t           *groups = va_arg(ap, gid_t *);
     113        int              maxgrp = va_arg(ap, int);
     114        int             *groupc = va_arg(ap, int *);
     115
     116        NSS_STATUS ret;
     117        long int lcount, lsize;
     118        int i, errnop;
     119        gid_t *tmpgroups;
     120
     121        /* Can be realloc() inside _nss_winbind_initgroups_dyn() */
     122        if ((tmpgroups=calloc(maxgrp, sizeof(gid_t))) == NULL) {
     123                errno = ENOMEM;
     124                return NS_TRYAGAIN;
     125        }
     126
     127        lcount = 0;
     128        lsize = maxgrp;
     129        /* insert primary membership(possibly already there) */
     130        gr_addgid(group, groups, maxgrp, groupc);
     131        /* Don't limit number of groups, we want to know total size */
     132        ret = _nss_winbind_initgroups_dyn(uname, group, &lcount, &lsize,
     133                &tmpgroups, 0, &errnop);
     134        if (ret == NSS_STATUS_SUCCESS) {
     135                /* lcount potentially can be bigger than maxgrp, so would groupc */
     136                for (i = 0; i < lcount; i++)
     137                         gr_addgid(tmpgroups[i], groups, maxgrp, groupc);
     138        }
     139        free(tmpgroups);
     140        /* Let following nsswitch backend(s) add more groups(?) */
     141        return NSS_STATUS_NOTFOUND;
     142}
     143
    72144ns_mtab *
    73145nss_module_register(const char *source, unsigned int *mtabsize,
  • vendor/current/nsswitch/winbind_nss_linux.c

    r740 r988  
    288288
    289289static NSS_STATUS fill_grent(struct group *result, struct winbindd_gr *gr,
    290                       char *gr_mem, char **buffer, size_t *buflen)
     290                      const char *gr_mem, char **buffer, size_t *buflen)
    291291{
    292292        char *name;
     
    323323        /* Group membership */
    324324
    325         if ((gr->num_gr_mem < 0) || !gr_mem) {
     325        if (!gr_mem) {
    326326                gr->num_gr_mem = 0;
    327327        }
     
    402402        }
    403403
    404         ret = winbindd_request_response(WINBINDD_SETPWENT, NULL, NULL);
     404        ret = winbindd_request_response(NULL, WINBINDD_SETPWENT, NULL, NULL);
    405405#ifdef DEBUG_NSS
    406406        fprintf(stderr, "[%5d]: setpwent returns %s (%d)\n", getpid(),
     
    433433        }
    434434
    435         ret = winbindd_request_response(WINBINDD_ENDPWENT, NULL, NULL);
     435        ret = winbindd_request_response(NULL, WINBINDD_ENDPWENT, NULL, NULL);
    436436#ifdef DEBUG_NSS
    437437        fprintf(stderr, "[%5d]: endpwent returns %s (%d)\n", getpid(),
     
    482482        request.data.num_entries = MAX_GETPWENT_USERS;
    483483
    484         ret = winbindd_request_response(WINBINDD_GETPWENT, &request,
     484        ret = winbindd_request_response(NULL, WINBINDD_GETPWENT, &request,
    485485                               &getpwent_response);
    486486
     
    570570                request.data.uid = uid;
    571571
    572                 ret = winbindd_request_response(WINBINDD_GETPWUID, &request, &response);
     572                ret = winbindd_request_response(NULL, WINBINDD_GETPWUID, &request, &response);
    573573
    574574                if (ret == NSS_STATUS_SUCCESS) {
     
    646646                        [sizeof(request.data.username) - 1] = '\0';
    647647
    648                 ret = winbindd_request_response(WINBINDD_GETPWNAM, &request, &response);
     648                ret = winbindd_request_response(NULL, WINBINDD_GETPWNAM, &request, &response);
    649649
    650650                if (ret == NSS_STATUS_SUCCESS) {
     
    717717        }
    718718
    719         ret = winbindd_request_response(WINBINDD_SETGRENT, NULL, NULL);
     719        ret = winbindd_request_response(NULL, WINBINDD_SETGRENT, NULL, NULL);
    720720#ifdef DEBUG_NSS
    721721        fprintf(stderr, "[%5d]: setgrent returns %s (%d)\n", getpid(),
     
    749749        }
    750750
    751         ret = winbindd_request_response(WINBINDD_ENDGRENT, NULL, NULL);
     751        ret = winbindd_request_response(NULL, WINBINDD_ENDGRENT, NULL, NULL);
    752752#ifdef DEBUG_NSS
    753753        fprintf(stderr, "[%5d]: endgrent returns %s (%d)\n", getpid(),
     
    800800        request.data.num_entries = MAX_GETGRENT_USERS;
    801801
    802         ret = winbindd_request_response(cmd, &request,
     802        ret = winbindd_request_response(NULL, cmd, &request,
    803803                               &getgrent_response);
    804804
     
    919919                        [sizeof(request.data.groupname) - 1] = '\0';
    920920
    921                 ret = winbindd_request_response(WINBINDD_GETGRNAM, &request, &response);
     921                ret = winbindd_request_response(NULL, WINBINDD_GETGRNAM,
     922                                                &request, &response);
    922923
    923924                if (ret == NSS_STATUS_SUCCESS) {
     
    997998                request.data.gid = gid;
    998999
    999                 ret = winbindd_request_response(WINBINDD_GETGRGID, &request, &response);
     1000                ret = winbindd_request_response(NULL, WINBINDD_GETGRGID,
     1001                                                &request, &response);
    10001002
    10011003                if (ret == NSS_STATUS_SUCCESS) {
     
    10701072                sizeof(request.data.username) - 1);
    10711073
    1072         ret = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response);
     1074        ret = winbindd_request_response(NULL, WINBINDD_GETGROUPS,
     1075                                        &request, &response);
    10731076
    10741077        if (ret == NSS_STATUS_SUCCESS) {
     
    10991102
    11001103                        if (gid_list[i] == group) {
     1104                                continue;
     1105                        }
     1106
     1107                        /* Skip groups without a mapping */
     1108                        if (gid_list[i] == (uid_t)-1) {
    11011109                                continue;
    11021110                        }
     
    11771185        request.data.sid[sizeof(request.data.sid) - 1] = '\0';
    11781186
    1179         ret = winbindd_request_response(WINBINDD_GETUSERSIDS, &request, &response);
     1187        ret = winbindd_request_response(NULL, WINBINDD_GETUSERSIDS,
     1188                                        &request, &response);
    11801189
    11811190        if (ret != NSS_STATUS_SUCCESS) {
     
    12291238        request.data.name.name[sizeof(request.data.name.name) - 1] = '\0';
    12301239
    1231         ret = winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response);
     1240        ret = winbindd_request_response(NULL, WINBINDD_LOOKUPNAME,
     1241                                        &request, &response);
    12321242        if (ret != NSS_STATUS_SUCCESS) {
    12331243                *errnop = errno = EINVAL;
     
    12791289        /* we need to fetch the separator first time through */
    12801290        if (!sep_char) {
    1281                 ret = winbindd_request_response(WINBINDD_INFO, &request, &response);
     1291                ret = winbindd_request_response(NULL, WINBINDD_INFO,
     1292                                                &request, &response);
    12821293                if (ret != NSS_STATUS_SUCCESS) {
    12831294                        *errnop = errno = EINVAL;
     
    12941305        request.data.sid[sizeof(request.data.sid) - 1] = '\0';
    12951306
    1296         ret = winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response);
     1307        ret = winbindd_request_response(NULL, WINBINDD_LOOKUPSID,
     1308                                        &request, &response);
    12971309        if (ret != NSS_STATUS_SUCCESS) {
    12981310                *errnop = errno = EINVAL;
     
    13501362        request.data.sid[sizeof(request.data.sid) - 1] = '\0';
    13511363
    1352         ret = winbindd_request_response(WINBINDD_SID_TO_UID, &request, &response);
     1364        ret = winbindd_request_response(NULL, WINBINDD_SID_TO_UID,
     1365                                        &request, &response);
    13531366        if (ret != NSS_STATUS_SUCCESS) {
    13541367                *errnop = errno = EINVAL;
     
    13891402        request.data.sid[sizeof(request.data.sid) - 1] = '\0';
    13901403
    1391         ret = winbindd_request_response(WINBINDD_SID_TO_GID, &request, &response);
     1404        ret = winbindd_request_response(NULL, WINBINDD_SID_TO_GID,
     1405                                        &request, &response);
    13921406        if (ret != NSS_STATUS_SUCCESS) {
    13931407                *errnop = errno = EINVAL;
     
    14281442        request.data.uid = uid;
    14291443
    1430         ret = winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response);
     1444        ret = winbindd_request_response(NULL, WINBINDD_UID_TO_SID,
     1445                                        &request, &response);
    14311446        if (ret != NSS_STATUS_SUCCESS) {
    14321447                *errnop = errno = EINVAL;
     
    14761491        request.data.gid = gid;
    14771492
    1478         ret = winbindd_request_response(WINBINDD_GID_TO_SID, &request, &response);
     1493        ret = winbindd_request_response(NULL, WINBINDD_GID_TO_SID,
     1494                                        &request, &response);
    14791495        if (ret != NSS_STATUS_SUCCESS) {
    14801496                *errnop = errno = EINVAL;
  • vendor/current/nsswitch/winbind_nss_netbsd.c

    r414 r988  
    229229        strncpy(request.data.username, uname,
    230230                                sizeof(request.data.username) - 1);
    231         i = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response);
     231        i = winbindd_request_response(NULL, WINBINDD_GETGROUPS,
     232                                      &request, &response);
    232233        if (i != NSS_STATUS_SUCCESS)
    233234                return NS_NOTFOUND;
  • vendor/current/nsswitch/winbind_nss_solaris.c

    r414 r988  
    2626
    2727#undef DEVELOPER
     28
    2829
    2930#include "winbind_client.h"
     
    3334#include <string.h>
    3435#include <pwd.h>
    35 #include "includes.h"
    3636#include <syslog.h>
     37
    3738#if !defined(HPUX)
    3839#include <sys/syslog.h>
     
    4748#else
    4849#define NSS_DEBUG(str) ;
     50#endif
     51
     52#if !defined(SMB_MALLOC_P)
     53#define SMB_MALLOC_P(type) (type *)malloc(sizeof(type))
    4954#endif
    5055
     
    255260                NSS_ARGS(args)->returnval = (void*) result;
    256261
     262        if (NSS_ARGS(args)->erange == ERANGE && ret == NSS_STATUS_TRYAGAIN)
     263                return NSS_STATUS_UNAVAIL;
     264
    257265        return ret;
    258266}
     
    273281        if(ret == NSS_STATUS_SUCCESS)
    274282                NSS_ARGS(args)->returnval = (void*) result;
     283
     284        if (NSS_ARGS(args)->erange == ERANGE && ret == NSS_STATUS_TRYAGAIN)
     285                return NSS_STATUS_UNAVAIL;
    275286
    276287        return ret;
     
    511522        request.data.winsreq[sizeof(request.data.winsreq) - 1] = '\0';
    512523
    513         if( (ret = winbindd_request_response(WINBINDD_WINS_BYNAME, &request, &response))
     524        if( (ret = winbindd_request_response(NULL, WINBINDD_WINS_BYNAME,
     525                                             &request, &response))
    514526                == NSS_STATUS_SUCCESS ) {
    515527          ret = parse_response(af, argp, &response);
     
    534546        request.data.winsreq[sizeof(request.data.winsreq) - 1] = '\0';
    535547
    536         if( (ret = winbindd_request_response(WINBINDD_WINS_BYNAME, &request, &response))
     548        if( (ret = winbindd_request_response(NULL, WINBINDD_WINS_BYNAME,
     549                                             &request, &response))
    537550                == NSS_STATUS_SUCCESS ) {
    538551          ret = parse_response(AF_INET, argp, &response);
     
    573586#endif
    574587
    575         ret = winbindd_request_response(WINBINDD_WINS_BYIP, &request, &response);
     588        ret = winbindd_request_response(NULL, WINBINDD_WINS_BYIP,
     589                                        &request, &response);
    576590
    577591        if( ret == NSS_STATUS_SUCCESS) {
  • vendor/current/nsswitch/winbind_nss_solaris.h

    r740 r988  
    2626#include <nss_dbdefs.h>
    2727#include <nsswitch.h>
     28#include "system/passwd.h"
    2829
    2930typedef nss_status_t NSS_STATUS;
  • vendor/current/nsswitch/winbind_struct_protocol.h

    r740 r988  
    2626#define WINBINDD_SOCKET_NAME "pipe"            /* Name of PF_UNIX socket */
    2727
    28 /* Let the build environment override the public winbindd socket location. This
    29  * is needed for launchd support -- jpeach.
     28/* We let the build environment set the public winbindd socket
     29 * location. Therefore we no longer set
     30 *
     31 * #define WINBINDD_SOCKET_DIR "/tmp/.winbindd"
     32 *
     33 * A number of different distributions set different paths, and so it
     34 * needs to come from configure in Samba.  External users of this header will
     35 * need to know where the path is on their system by some other
     36 * mechanism.
    3037 */
    31 #ifndef WINBINDD_SOCKET_DIR
    32 #define WINBINDD_SOCKET_DIR  "/tmp/.winbindd"  /* Name of PF_UNIX dir */
    33 #endif
    34 
    35 /*
    36  * when compiled with socket_wrapper support
    37  * the location of the WINBINDD_SOCKET_DIR
    38  * can be overwritten via an environment variable
    39  */
    40 #define WINBINDD_SOCKET_DIR_ENVVAR "WINBINDD_SOCKET_DIR"
    41 
    42 #define WINBINDD_PRIV_SOCKET_SUBDIR "winbindd_privileged" /* name of subdirectory of lp_lockdir() to hold the 'privileged' pipe */
     38
     39#define WINBINDD_PRIV_SOCKET_SUBDIR "winbindd_privileged" /* name of subdirectory of lp_lock_directory() to hold the 'privileged' pipe */
    4340#define WINBINDD_DOMAIN_ENV  "WINBINDD_DOMAIN" /* Environment variables */
    4441#define WINBINDD_DONT_ENV    "_NO_WINBINDD"
     
    206203} WINBINDD_GR;
    207204
    208 /* PAM specific request flags */
     205/* Request flags */
    209206#define WBFLAG_PAM_INFO3_NDR            0x00000001
    210207#define WBFLAG_PAM_INFO3_TEXT           0x00000002
     
    212209#define WBFLAG_PAM_LMKEY                0x00000008
    213210#define WBFLAG_PAM_CONTACT_TRUSTDOM     0x00000010
     211#define WBFLAG_QUERY_ONLY               0x00000020      /* not used */
     212#define WBFLAG_PAM_AUTH_PAC             0x00000040
    214213#define WBFLAG_PAM_UNIX_NAME            0x00000080
    215214#define WBFLAG_PAM_AFS_TOKEN            0x00000100
    216215#define WBFLAG_PAM_NT_STATUS_SQUASH     0x00000200
     216/* This is a flag that can only be sent from parent to child */
     217#define WBFLAG_IS_PRIVILEGED            0x00000400      /* not used */
     218/* Flag to say this is a winbindd internal send - don't recurse. */
     219#define WBFLAG_RECURSE                  0x00000800
    217220#define WBFLAG_PAM_KRB5                 0x00001000
    218221#define WBFLAG_PAM_FALLBACK_AFTER_KRB5  0x00002000
    219222#define WBFLAG_PAM_CACHED_LOGIN         0x00004000
    220223#define WBFLAG_PAM_GET_PWD_POLICY       0x00008000
    221 
    222 /* generic request flags */
    223 #define WBFLAG_QUERY_ONLY               0x00000020      /* not used */
    224 /* This is a flag that can only be sent from parent to child */
    225 #define WBFLAG_IS_PRIVILEGED            0x00000400      /* not used */
    226 /* Flag to say this is a winbindd internal send - don't recurse. */
    227 #define WBFLAG_RECURSE                  0x00000800
    228224/* Flag to tell winbind the NTLMv2 blob is too big for the struct and is in the
    229225 * extra_data field */
     
    491487                        uint8_t session_key[16];
    492488                        uint32_t auth_blob_len; /* blob in extra_data */
     489                        uint8_t new_spnego;
    493490                } ccache_ntlm_auth;
    494491                struct {
  • vendor/current/nsswitch/wins.c

    r740 r988  
    2121#include "includes.h"
    2222#include "nsswitch/winbind_nss.h"
     23#include "nsswitch/libwbclient/wbclient.h"
    2324
    2425#ifdef HAVE_NS_API_H
     
    3839#define INADDRSZ 4
    3940#endif
    40 
    41 static int initialised;
    4241
    4342NSS_STATUS _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he,
     
    4645                           char *buffer, size_t buflen, int *h_errnop);
    4746
    48 static void nss_wins_init(void)
    49 {
    50         initialised = 1;
    51         load_case_tables_library();
    52         lp_set_cmdline("log level", "0");
    53 
    54         TimeInit();
    55         setup_logging("nss_wins",False);
    56         lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
    57         load_interfaces();
    58 }
    59 
    60 static struct in_addr *lookup_byname_backend(const char *name, int *count)
    61 {
    62         struct ip_service *address = NULL;
    63         struct in_addr *ret = NULL;
    64         int j;
    65 
    66         if (!initialised) {
    67                 nss_wins_init();
    68         }
    69 
    70         *count = 0;
    71 
    72         /* always try with wins first */
    73         if (NT_STATUS_IS_OK(resolve_wins(name,0x00,&address,count))) {
    74                 if ( (ret = SMB_MALLOC_P(struct in_addr)) == NULL ) {
    75                         free( address );
    76                         return NULL;
    77                 }
    78                 if (address[0].ss.ss_family != AF_INET) {
    79                         free(address);
    80                         free(ret);
    81                         return NULL;
    82                 }
    83                 *ret = ((struct sockaddr_in *)(void *)&address[0].ss)
    84                         ->sin_addr;
    85                 free( address );
    86                 return ret;
    87         }
    88 
    89         /* uggh, we have to broadcast to each interface in turn */
    90         for (j=iface_count() - 1;j >= 0;j--) {
    91                 const struct in_addr *bcast = iface_n_bcast_v4(j);
    92                 struct sockaddr_storage ss;
    93                 struct sockaddr_storage *pss;
    94                 NTSTATUS status;
    95 
    96                 if (!bcast) {
    97                         continue;
    98                 }
    99                 in_addr_to_sockaddr_storage(&ss, *bcast);
    100                 status = name_query(name, 0x00, True, True, &ss,
    101                                     NULL, &pss, count, NULL);
    102                 if (NT_STATUS_IS_OK(status) && (*count > 0)) {
    103                         if ((ret = SMB_MALLOC_P(struct in_addr)) == NULL) {
    104                                 return NULL;
    105                         }
    106                         *ret = ((struct sockaddr_in *)pss)->sin_addr;
    107                         TALLOC_FREE(pss);
    108                         break;
    109                 }
    110         }
    111 
    112         return ret;
     47static char *lookup_byname_backend(const char *name)
     48{
     49        const char *p;
     50        char *ip, *ipp;
     51        size_t nbt_len;
     52        wbcErr result;
     53
     54        nbt_len = strlen(name);
     55        if (nbt_len > MAX_NETBIOSNAME_LEN - 1) {
     56                return NULL;
     57        }
     58        p = strchr(name, '.');
     59        if (p != NULL) {
     60                return NULL;
     61        }
     62
     63        result = wbcResolveWinsByName(name, &ip);
     64        if (result != WBC_ERR_SUCCESS) {
     65                return NULL;
     66        }
     67
     68        ipp = strchr(ip, '\t');
     69        if (ipp != NULL) {
     70                *ipp = '\0';
     71        }
     72
     73        return ip;
    11374}
    11475
    11576#ifdef HAVE_NS_API_H
    11677
    117 static struct node_status *lookup_byaddr_backend(char *addr, int *count)
    118 {
    119         struct sockaddr_storage ss;
    120         struct nmb_name nname;
    121         struct node_status *result;
    122         NTSTATUS status;
    123 
    124         if (!initialised) {
    125                 nss_wins_init();
    126         }
    127 
    128         make_nmb_name(&nname, "*", 0);
    129         if (!interpret_string_addr(&ss, addr, AI_NUMERICHOST)) {
    130                 return NULL;
    131         }
    132         status = node_status_query(NULL, &nname, &ss, &result, count, NULL);
    133         if (!NT_STATUS_IS_OK(status)) {
    134                 return NULL;
    135         }
    136 
    137         return result;
     78static char *lookup_byaddr_backend(const char *ip)
     79{
     80        wbcErr result;
     81        char *name = NULL;
     82
     83        result = wbcResolveWinsByIP(ip, &name);
     84        if (result != WBC_ERR_SUCCESS) {
     85                return NULL;
     86        }
     87
     88        return name;
    13889}
    13990
     
    14293int init(void)
    14394{
     95        bool ok;
     96
    14497        nsd_logprintf(NSD_LOG_MIN, "entering init (wins)\n");
    145         nss_wins_init();
     98
     99        ok = nss_wins_init();
     100        if (!ok) {
     101                return NSD_ERROR;
     102        }
     103
    146104        return NSD_OK;
    147105}
     
    152110        char *key;
    153111        char *addr;
    154         struct in_addr *ip_list;
    155         struct node_status *status;
    156112        int i, count, len, size;
    157113        char response[1024];
     
    181137         * ip_address[ ip_address]*\tname[ alias]*
    182138         */
    183         if (StrCaseCmp(map,"hosts.byaddr") == 0) {
    184                 if ( status = lookup_byaddr_backend(key, &count)) {
    185                     size = strlen(key) + 1;
    186                     if (size > len) {
    187                         talloc_free(status);
    188                         return NSD_ERROR;
    189                     }
    190                     len -= size;
    191                     strncat(response,key,size);
    192                     strncat(response,"\t",1);
    193                     for (i = 0; i < count; i++) {
    194                         /* ignore group names */
    195                         if (status[i].flags & 0x80) continue;
    196                         if (status[i].type == 0x20) {
    197                                 size = sizeof(status[i].name) + 1;
    198                                 if (size > len) {
    199                                     talloc_free(status);
    200                                     return NSD_ERROR;
    201                                 }
    202                                 len -= size;
    203                                 strncat(response, status[i].name, size);
    204                                 strncat(response, " ", 1);
    205                                 found = True;
     139        if (strcasecmp_m(map,"hosts.byaddr") == 0) {
     140                char *name;
     141
     142                name = lookup_byaddr_backend(key);
     143                if (name != NULL) {
     144                        size = strlen(key) + 1;
     145                        if (size > len) {
     146                                return NSD_ERROR;
    206147                        }
    207                     }
    208                     response[strlen(response)-1] = '\n';
    209                     talloc_free(status);
     148                        len -= size;
     149                        strncat(response,key,size);
     150                        strncat(response,"\t",1);
     151
     152                        size = strlen(name) + 1;
     153                        if (size > len) {
     154                                return NSD_ERROR;
     155                        }
     156                        len -= size;
     157                        strncat(response, name, size);
     158                        strncat(response, " ", 1);
     159                        found = True;
    210160                }
    211         } else if (StrCaseCmp(map,"hosts.byname") == 0) {
    212             if (ip_list = lookup_byname_backend(key, &count)) {
    213                 for (i = count; i ; i--) {
    214                     addr = inet_ntoa(ip_list[i-1]);
    215                     size = strlen(addr) + 1;
    216                     if (size > len) {
    217                         free(ip_list);
    218                         return NSD_ERROR;
    219                     }
    220                     len -= size;
    221                     if (i != 0)
    222                         response[strlen(response)-1] = ' ';
    223                     strncat(response,addr,size);
    224                     strncat(response,"\t",1);
     161                response[strlen(response)-1] = '\n';
     162        } else if (strcasecmp_m(map,"hosts.byname") == 0) {
     163                char *ip;
     164
     165                ip = lookup_byname_backend(key);
     166                if (ip != NULL) {
     167                        size = strlen(ip) + 1;
     168                        if (size > len) {
     169                                wbcFreeMemory(ip);
     170                                return NSD_ERROR;
     171                        }
     172                        len -= size;
     173                        strncat(response,ip,size);
     174                        strncat(response,"\t",1);
     175                        size = strlen(key) + 1;
     176                        wbcFreeMemory(ip);
     177                        if (size > len) {
     178                                return NSD_ERROR;
     179                        }
     180                        strncat(response,key,size);
     181                        strncat(response,"\n",1);
     182
     183                        found = True;
    225184                }
    226                 size = strlen(key) + 1;
    227                 if (size > len) {
    228                     free(ip_list);
    229                     return NSD_ERROR;
    230                 }
    231                 strncat(response,key,size);
    232                 strncat(response,"\n",1);
    233                 found = True;
    234                 free(ip_list);
    235             }
    236185        }
    237186
     
    252201   functions. */
    253202
    254 static char *get_static(char **buffer, size_t *buflen, int len)
     203static char *get_static(char **buffer, size_t *buflen, size_t len)
    255204{
    256205        char *result;
     
    281230{
    282231        NSS_STATUS nss_status = NSS_STATUS_SUCCESS;
    283         struct in_addr *ip_list;
    284         int i, count;
     232        char *ip;
     233        struct in_addr in;
     234        int i;
    285235        fstring name;
    286236        size_t namelen;
    287         TALLOC_CTX *frame;
     237        int rc;
    288238
    289239#if HAVE_PTHREAD
     
    291241#endif
    292242
    293         frame = talloc_stackframe();
    294 
    295243        memset(he, '\0', sizeof(*he));
    296244        fstrcpy(name, hostname);
     
    298246        /* Do lookup */
    299247
    300         ip_list = lookup_byname_backend(name, &count);
    301 
    302         if (!ip_list) {
     248        ip = lookup_byname_backend(name);
     249        if (ip == NULL) {
    303250                nss_status = NSS_STATUS_NOTFOUND;
    304251                goto out;
    305252        }
    306253
     254        rc = inet_pton(AF_INET, ip, &in);
     255        wbcFreeMemory(ip);
     256        if (rc == 0) {
     257                nss_status = NSS_STATUS_TRYAGAIN;
     258                goto out;
     259        }
     260
    307261        /* Copy h_name */
    308262
     
    310264
    311265        if ((he->h_name = get_static(&buffer, &buflen, namelen)) == NULL) {
    312                 free(ip_list);
    313266                nss_status = NSS_STATUS_TRYAGAIN;
    314267                goto out;
     
    323276
    324277        if (get_static(&buffer, &buflen, i) == NULL) {
    325                 free(ip_list);
    326278                nss_status = NSS_STATUS_TRYAGAIN;
    327279                goto out;
     
    329281
    330282        if ((he->h_addr_list = (char **)get_static(
    331                      &buffer, &buflen, (count + 1) * sizeof(char *))) == NULL) {
    332                 free(ip_list);
    333                 nss_status = NSS_STATUS_TRYAGAIN;
    334                 goto out;
    335         }
    336 
    337         for (i = 0; i < count; i++) {
    338                 if ((he->h_addr_list[i] = get_static(&buffer, &buflen,
    339                                                      INADDRSZ)) == NULL) {
    340                         free(ip_list);
    341                         nss_status = NSS_STATUS_TRYAGAIN;
    342                         goto out;
    343                 }
    344                 memcpy(he->h_addr_list[i], &ip_list[i], INADDRSZ);
    345         }
    346 
    347         he->h_addr_list[count] = NULL;
    348 
    349         free(ip_list);
     283                     &buffer, &buflen, 2 * sizeof(char *))) == NULL) {
     284                nss_status = NSS_STATUS_TRYAGAIN;
     285                goto out;
     286        }
     287
     288        if ((he->h_addr_list[0] = get_static(&buffer, &buflen,
     289                                             INADDRSZ)) == NULL) {
     290                nss_status = NSS_STATUS_TRYAGAIN;
     291                goto out;
     292        }
     293
     294        memcpy(he->h_addr_list[0], &in, INADDRSZ);
     295
     296        he->h_addr_list[1] = NULL;
    350297
    351298        /* Set h_addr_type and h_length */
     
    375322
    376323  out:
    377 
    378         TALLOC_FREE(frame);
    379324
    380325#if HAVE_PTHREAD
  • vendor/current/nsswitch/wscript_build

    r740 r988  
    11#!/usr/bin/env python
     2import Utils
     3import sys
     4host_os = sys.platform
    25
    36bld.SAMBA_LIBRARY('winbind-client',
    47        source='wb_common.c',
    58        deps='replace',
    6         cflags='-DSOCKET_WRAPPER_DISABLE=1 -DWINBINDD_SOCKET_DIR=\"%s\"' % bld.env.WINBINDD_SOCKET_DIR,
     9        cflags='-DWINBINDD_SOCKET_DIR=\"%s\"' % bld.env.WINBINDD_SOCKET_DIR,
    710        private_library=True
    811        )
     
    1013
    1114bld.SAMBA_BINARY('nsstest',
    12         source='nsstest.c',
    13         deps='replace dl'
    14         )
     15                 source='nsstest.c',
     16                 deps='replace dl',
     17                 install=False
     18                 )
    1519
     20# The nss_wrapper code relies strictly on the linux implementation and
     21# name, so compile but do not install a copy under this name.
     22bld.SAMBA_LIBRARY('nss_wrapper_winbind',
     23                  source='winbind_nss_linux.c',
     24                  deps='winbind-client',
     25                  realname='libnss_wrapper_winbind.so.2',
     26                  install=False,
     27                  vnum='2')
    1628
    17 bld.SAMBA_LIBRARY('nss_winbind',
    18         source='winbind_nss_linux.c',
    19         deps='winbind-client',
    20         realname='libnss_winbind.so.2',
    21         vnum='2')
     29# FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
     30# the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
    2231
     32if (Utils.unversioned_sys_platform() == 'linux' or (host_os.rfind('gnu') > -1)):
     33    bld.SAMBA_LIBRARY('nss_winbind',
     34              keep_underscore=True,
     35              source='winbind_nss_linux.c',
     36              deps='winbind-client',
     37              public_headers=[],
     38              public_headers_install=False,
     39              pc_files=[],
     40              vnum='2')
    2341
    24 if bld.CONFIG_SET('WITH_PAM_MODULES') or bld.CONFIG_SET('HAVE_PAM_START'):
     42    bld.SAMBA3_LIBRARY('nss_wins',
     43                       keep_underscore=True,
     44                       source='wins.c',
     45                       deps='''wbclient''',
     46                       public_headers=[],
     47                       public_headers_install=False,
     48                       pc_files=[],
     49                       vnum='2')
     50elif (host_os.rfind('freebsd') > -1):
     51        # FreeBSD winbind client is implemented as a wrapper around
     52        # the Linux version.
     53        bld.SAMBA_LIBRARY('nss_winbind',
     54                          source='winbind_nss_linux.c winbind_nss_freebsd.c',
     55                          deps='winbind-client',
     56                          realname='nss_winbind.so.1',
     57                          vnum='1')
     58
     59        bld.SAMBA3_LIBRARY('nss_wins',
     60                          source='wins.c wins_freebsd.c',
     61                          deps='''wbclient''',
     62                          realname='nss_wins.so.1',
     63                          vnum='1')
     64
     65elif (host_os.rfind('netbsd') > -1):
     66        # NetBSD winbind client is implemented as a wrapper
     67        # around the Linux version. It needs getpwent_r() to
     68        # indicate libc's use of the correct nsdispatch API.
     69
     70        if bld.CONFIG_SET("HAVE_GETPWENT_R"):
     71                bld.SAMBA_LIBRARY('nss_winbind',
     72                                  source='winbind_nss_linux.c winbind_nss_netbsd.c',
     73                                  deps='winbind-client',
     74                                  realname='libnss_winbind.so')
     75elif (host_os.rfind('irix') > -1):
     76        bld.SAMBA_LIBRARY('ns_winbind',
     77                          source='winbind_nss_irix.c',
     78                          deps='winbind-client',
     79                          realname='libns_winbind.so')
     80
     81elif Utils.unversioned_sys_platform() == 'sunos':
     82        bld.SAMBA_LIBRARY('nss_winbind',
     83                          source='winbind_nss_solaris.c winbind_nss_linux.c',
     84                          deps='winbind-client',
     85                          realname='nss_winbind.so.1',
     86                          vnum='1')
     87elif (host_os.rfind('hpux') > -1):
     88        bld.SAMBA_LIBRARY('nss_winbind',
     89                          source='winbind_nss_linux.c',
     90                          deps='winbind-client',
     91                          realname='libnss_winbind.so')
     92elif (host_os.rfind('aix') > -1):
     93        bld.SAMBA_LIBRARY('nss_winbind',
     94                          source='winbind_nss_aix.c',
     95                          deps='winbind-client',
     96                          realname='WINBIND')
     97
     98if bld.CONFIG_SET('WITH_PAM_MODULES') and bld.CONFIG_SET('HAVE_PAM_START'):
    2599        bld.SAMBA_LIBRARY('pamwinbind',
    26100                source='pam_winbind.c',
    27                 deps='intl talloc wbclient winbind-client LIBINIPARSER pam',
     101                deps='talloc wbclient winbind-client tiniparser pam samba_intl',
    28102                cflags='-DLOCALEDIR=\"%s/locale\"' % bld.env.DATADIR,
    29103                realname='pam_winbind.so',
     104                install_path='${PAMMODULESDIR}'
    30105                )
    31106
     
    33108        bld.SAMBA_LIBRARY('winbind_krb5_locator',
    34109                source='winbind_krb5_locator.c',
    35                 deps='wbclient krb5',
     110                deps='wbclient krb5 com_err',
    36111                realname='winbind_krb5_locator.so')
    37112
     
    40115        deps='talloc tevent LIBASYNC_REQ'
    41116        )
     117
     118bld.SAMBA_BINARY('wbinfo',
     119        source='wbinfo.c',
     120        deps='samba-util LIBCLI_AUTH popt POPT_SAMBA wbclient LIBAFS_SETTOKEN'
     121        )
  • vendor/current/nsswitch/wscript_configure

    r740 r988  
    55conf.CHECK_HEADERS('security/pam_appl.h security/pam_modules.h pam/pam_modules.h', together=True)
    66conf.CHECK_FUNCS_IN('pam_start', 'pam', checklibc=True, headers='security/pam_appl.h')
     7
     8# Solaris 10 does have new member in nss_XbyY_key
     9conf.CHECK_STRUCTURE_MEMBER('union nss_XbyY_key', 'ipnode.af_family',
     10                            define='HAVE_NSS_XBYY_KEY_IPNODE',
     11                            headers='nss_dbdefs.h')
     12
     13# Solaris has some extra fields in struct passwd that need to be
     14# initialised otherwise nscd crashes.
     15
     16conf.CHECK_STRUCTURE_MEMBER('struct passwd', 'pw_comment',
     17                            define='HAVE_PASSWD_PW_COMMENT',
     18                            headers='pwd.h')
     19
     20conf.CHECK_STRUCTURE_MEMBER('struct passwd', 'pw_age',
     21                            define='HAVE_PASSWD_PW_AGE',
     22                            headers='pwd.h')
Note: See TracChangeset for help on using the changeset viewer.