>From c6af870b81526ce7f1d391be02b869464b915332 Mon Sep 17 00:00:00 2001 From: Matthew Newton Date: Sat, 21 Feb 2015 22:30:11 +0000 Subject: [PATCH 5/6] Add context versions of wbclient functions To make the libwbclient library thread-safe, all functions that call through to wb_common winbindd_request_response need to have context that they can use. This commit adds all the necessary functions. Signed-off-by: Matthew Newton --- nsswitch/libwbclient/wbc_idmap.c | 70 ++++++++++--- nsswitch/libwbclient/wbc_pam.c | 198 ++++++++++++++++++++++++++---------- nsswitch/libwbclient/wbc_pwd.c | 127 +++++++++++++++++------ nsswitch/libwbclient/wbc_sid.c | 169 ++++++++++++++++++++++-------- nsswitch/libwbclient/wbc_util.c | 123 ++++++++++++++++------ nsswitch/libwbclient/wbclient.h | 209 ++++++++++++++++++++++++++++++++++++-- 6 files changed, 720 insertions(+), 176 deletions(-) diff --git a/nsswitch/libwbclient/wbc_idmap.c b/nsswitch/libwbclient/wbc_idmap.c index 04e7d02..3e8366a 100644 --- a/nsswitch/libwbclient/wbc_idmap.c +++ b/nsswitch/libwbclient/wbc_idmap.c @@ -26,7 +26,8 @@ #include "../winbind_client.h" /* Convert a Windows SID to a Unix uid, allocating an uid if needed */ -wbcErr wbcSidToUid(const struct wbcDomainSid *sid, uid_t *puid) +wbcErr wbcCtxSidToUid(struct wbcContext *ctx, const struct wbcDomainSid *sid, + uid_t *puid) { struct winbindd_request request; struct winbindd_response response; @@ -46,7 +47,7 @@ wbcErr wbcSidToUid(const struct wbcDomainSid *sid, uid_t *puid) /* Make request */ - wbc_status = wbcRequestResponse(WINBINDD_SID_TO_UID, + wbc_status = wbcRequestResponse(ctx, WINBINDD_SID_TO_UID, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -59,6 +60,11 @@ wbcErr wbcSidToUid(const struct wbcDomainSid *sid, uid_t *puid) return wbc_status; } +wbcErr wbcSidToUid(const struct wbcDomainSid *sid, uid_t *puid) +{ + return wbcCtxSidToUid(NULL, sid, puid); +} + /* Convert a Windows SID to a Unix uid if there already is a mapping */ wbcErr wbcQuerySidToUid(const struct wbcDomainSid *sid, uid_t *puid) @@ -67,7 +73,8 @@ wbcErr wbcQuerySidToUid(const struct wbcDomainSid *sid, } /* Convert a Unix uid to a Windows SID, allocating a SID if needed */ -wbcErr wbcUidToSid(uid_t uid, struct wbcDomainSid *sid) +wbcErr wbcCtxUidToSid(struct wbcContext *ctx, uid_t uid, + struct wbcDomainSid *sid) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -87,7 +94,7 @@ wbcErr wbcUidToSid(uid_t uid, struct wbcDomainSid *sid) /* Make request */ - wbc_status = wbcRequestResponse(WINBINDD_UID_TO_SID, + wbc_status = wbcRequestResponse(ctx, WINBINDD_UID_TO_SID, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -99,6 +106,11 @@ done: return wbc_status; } +wbcErr wbcUidToSid(uid_t uid, struct wbcDomainSid *sid) +{ + return wbcCtxUidToSid(NULL, uid, sid); +} + /* Convert a Unix uid to a Windows SID if there already is a mapping */ wbcErr wbcQueryUidToSid(uid_t uid, struct wbcDomainSid *sid) @@ -115,7 +127,8 @@ wbcErr wbcQueryUidToSid(uid_t uid, * **/ -wbcErr wbcSidToGid(const struct wbcDomainSid *sid, gid_t *pgid) +wbcErr wbcCtxSidToGid(struct wbcContext *ctx, const struct wbcDomainSid *sid, + gid_t *pgid) { struct winbindd_request request; struct winbindd_response response; @@ -135,7 +148,7 @@ wbcErr wbcSidToGid(const struct wbcDomainSid *sid, gid_t *pgid) /* Make request */ - wbc_status = wbcRequestResponse(WINBINDD_SID_TO_GID, + wbc_status = wbcRequestResponse(ctx, WINBINDD_SID_TO_GID, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -148,6 +161,10 @@ wbcErr wbcSidToGid(const struct wbcDomainSid *sid, gid_t *pgid) return wbc_status; } +wbcErr wbcSidToGid(const struct wbcDomainSid *sid, gid_t *pgid) +{ + return wbcCtxSidToGid(NULL, sid, pgid); +} /* Convert a Windows SID to a Unix gid if there already is a mapping */ @@ -159,7 +176,8 @@ wbcErr wbcQuerySidToGid(const struct wbcDomainSid *sid, /* Convert a Unix gid to a Windows SID, allocating a SID if needed */ -wbcErr wbcGidToSid(gid_t gid, struct wbcDomainSid *sid) +wbcErr wbcCtxGidToSid(struct wbcContext *ctx, gid_t gid, + struct wbcDomainSid *sid) { struct winbindd_request request; struct winbindd_response response; @@ -179,7 +197,7 @@ wbcErr wbcGidToSid(gid_t gid, struct wbcDomainSid *sid) /* Make request */ - wbc_status = wbcRequestResponse(WINBINDD_GID_TO_SID, + wbc_status = wbcRequestResponse(ctx, WINBINDD_GID_TO_SID, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -191,6 +209,11 @@ done: return wbc_status; } +wbcErr wbcGidToSid(gid_t gid, struct wbcDomainSid *sid) +{ + return wbcCtxGidToSid(NULL, gid, sid); +} + /* Convert a Unix gid to a Windows SID if there already is a mapping */ wbcErr wbcQueryGidToSid(gid_t gid, struct wbcDomainSid *sid) @@ -199,7 +222,7 @@ wbcErr wbcQueryGidToSid(gid_t gid, } /* Obtain a new uid from Winbind */ -wbcErr wbcAllocateUid(uid_t *puid) +wbcErr wbcCtxAllocateUid(struct wbcContext *ctx, uid_t *puid) { struct winbindd_request request; struct winbindd_response response; @@ -215,7 +238,7 @@ wbcErr wbcAllocateUid(uid_t *puid) /* Make request */ - wbc_status = wbcRequestResponsePriv(WINBINDD_ALLOCATE_UID, + wbc_status = wbcRequestResponsePriv(ctx, WINBINDD_ALLOCATE_UID, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -228,8 +251,13 @@ wbcErr wbcAllocateUid(uid_t *puid) return wbc_status; } +wbcErr wbcAllocateUid(uid_t *puid) +{ + return wbcCtxAllocateUid(NULL, puid); +} + /* Obtain a new gid from Winbind */ -wbcErr wbcAllocateGid(gid_t *pgid) +wbcErr wbcCtxAllocateGid(struct wbcContext *ctx, gid_t *pgid) { struct winbindd_request request; struct winbindd_response response; @@ -245,7 +273,7 @@ wbcErr wbcAllocateGid(gid_t *pgid) /* Make request */ - wbc_status = wbcRequestResponsePriv(WINBINDD_ALLOCATE_GID, + wbc_status = wbcRequestResponsePriv(ctx, WINBINDD_ALLOCATE_GID, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -258,6 +286,11 @@ wbcErr wbcAllocateGid(gid_t *pgid) return wbc_status; } +wbcErr wbcAllocateGid(gid_t *pgid) +{ + return wbcCtxAllocateGid(NULL, pgid); +} + /* we can't include smb.h here... */ #define _ID_TYPE_UID 1 #define _ID_TYPE_GID 2 @@ -299,8 +332,9 @@ wbcErr wbcSetGidHwm(gid_t gid_hwm) } /* Convert a list of SIDs */ -wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids, - struct wbcUnixId *ids) +wbcErr wbcCtxSidsToUnixIds(struct wbcContext *ctx, + const struct wbcDomainSid *sids, + uint32_t num_sids, struct wbcUnixId *ids) { struct winbindd_request request; struct winbindd_response response; @@ -341,7 +375,7 @@ wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids, request.extra_data.data = sidlist; request.extra_len = p - sidlist; - wbc_status = wbcRequestResponse(WINBINDD_SIDS_TO_XIDS, + wbc_status = wbcRequestResponse(ctx, WINBINDD_SIDS_TO_XIDS, &request, &response); free(sidlist); if (!WBC_ERROR_IS_OK(wbc_status)) { @@ -393,3 +427,9 @@ done: winbindd_free_response(&response); return wbc_status; } + +wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids, + struct wbcUnixId *ids) +{ + return wbcCtxSidsToUnixIds(NULL, sids, num_sids, ids); +} diff --git a/nsswitch/libwbclient/wbc_pam.c b/nsswitch/libwbclient/wbc_pam.c index 11b59f6..3d402dd 100644 --- a/nsswitch/libwbclient/wbc_pam.c +++ b/nsswitch/libwbclient/wbc_pam.c @@ -28,8 +28,8 @@ #include "../winbind_client.h" /* Authenticate a username/password pair */ -wbcErr wbcAuthenticateUser(const char *username, - const char *password) +wbcErr wbcCtxAuthenticateUser(struct wbcContext *ctx, + const char *username, const char *password) { wbcErr wbc_status = WBC_ERR_SUCCESS; struct wbcAuthUserParams params; @@ -40,13 +40,18 @@ wbcErr wbcAuthenticateUser(const char *username, params.level = WBC_AUTH_USER_LEVEL_PLAIN; params.password.plaintext = password; - wbc_status = wbcAuthenticateUserEx(¶ms, NULL, NULL); + wbc_status = wbcCtxAuthenticateUserEx(ctx, ¶ms, NULL, NULL); BAIL_ON_WBC_ERROR(wbc_status); done: return wbc_status; } +wbcErr wbcAuthenticateUser(const char *username, const char *password) +{ + return wbcCtxAuthenticateUser(NULL, username, password); +} + static bool sid_attr_compose(struct wbcSidWithAttr *s, const struct wbcDomainSid *d, uint32_t rid, uint32_t attr) @@ -342,9 +347,10 @@ done: /* Authenticate with more detailed information */ -wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, - struct wbcAuthUserInfo **info, - struct wbcAuthErrorInfo **error) +wbcErr wbcCtxAuthenticateUserEx(struct wbcContext *ctx, + const struct wbcAuthUserParams *params, + struct wbcAuthUserInfo **info, + struct wbcAuthErrorInfo **error) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; int cmd = 0; @@ -388,7 +394,7 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, ZERO_STRUCT(sep_response); - wbc_status = wbcRequestResponse(WINBINDD_INFO, + wbc_status = wbcRequestResponse(ctx, WINBINDD_INFO, NULL, &sep_response); BAIL_ON_WBC_ERROR(wbc_status); @@ -518,9 +524,11 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, } if (cmd == WINBINDD_PAM_AUTH_CRAP) { - wbc_status = wbcRequestResponsePriv(cmd, &request, &response); + wbc_status = wbcRequestResponsePriv(ctx, cmd, + &request, &response); } else { - wbc_status = wbcRequestResponse(cmd, &request, &response); + wbc_status = wbcRequestResponse(ctx, cmd, + &request, &response); } if (response.data.auth.nt_status != 0) { if (error) { @@ -545,11 +553,18 @@ done: free(request.extra_data.data); return wbc_status; +} + +wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, + struct wbcAuthUserInfo **info, + struct wbcAuthErrorInfo **error) +{ + return wbcCtxAuthenticateUserEx(NULL, params, info, error); } /* Trigger a verification of the trust credentials of a specific domain */ -wbcErr wbcCheckTrustCredentials(const char *domain, - struct wbcAuthErrorInfo **error) +wbcErr wbcCtxCheckTrustCredentials(struct wbcContext *ctx, const char *domain, + struct wbcAuthErrorInfo **error) { struct winbindd_request request; struct winbindd_response response; @@ -565,7 +580,7 @@ wbcErr wbcCheckTrustCredentials(const char *domain, /* Send request */ - wbc_status = wbcRequestResponsePriv(WINBINDD_CHECK_MACHACC, + wbc_status = wbcRequestResponsePriv(ctx, WINBINDD_CHECK_MACHACC, &request, &response); if (response.data.auth.nt_status != 0) { if (error) { @@ -583,9 +598,15 @@ wbcErr wbcCheckTrustCredentials(const char *domain, return wbc_status; } +wbcErr wbcCheckTrustCredentials(const char *domain, + struct wbcAuthErrorInfo **error) +{ + return wbcCtxCheckTrustCredentials(NULL, domain, error); +} + /* Trigger a change of the trust credentials for a specific domain */ -wbcErr wbcChangeTrustCredentials(const char *domain, - struct wbcAuthErrorInfo **error) +wbcErr wbcCtxChangeTrustCredentials(struct wbcContext *ctx, const char *domain, + struct wbcAuthErrorInfo **error) { struct winbindd_request request; struct winbindd_response response; @@ -601,8 +622,8 @@ wbcErr wbcChangeTrustCredentials(const char *domain, /* Send request */ - wbc_status = wbcRequestResponsePriv(WINBINDD_CHANGE_MACHACC, - &request, &response); + wbc_status = wbcRequestResponsePriv(ctx, WINBINDD_CHANGE_MACHACC, + &request, &response); if (response.data.auth.nt_status != 0) { if (error) { wbc_status = wbc_create_error_info(&response, @@ -619,10 +640,22 @@ wbcErr wbcChangeTrustCredentials(const char *domain, return wbc_status; } +wbcErr wbcChangeTrustCredentials(const char *domain, + struct wbcAuthErrorInfo **error) +{ + return wbcCtxChangeTrustCredentials(NULL, domain, error); +} + /* * Trigger a no-op NETLOGON call. Lightweight version of * wbcCheckTrustCredentials */ +wbcErr wbcCtxPingDc(struct wbcContext *ctx, const char *domain, + struct wbcAuthErrorInfo **error) +{ + return wbcCtxPingDc2(ctx, domain, error, NULL); +} + wbcErr wbcPingDc(const char *domain, struct wbcAuthErrorInfo **error) { return wbcPingDc2(domain, error, NULL); @@ -632,8 +665,8 @@ wbcErr wbcPingDc(const char *domain, struct wbcAuthErrorInfo **error) * Trigger a no-op NETLOGON call. Lightweight version of * wbcCheckTrustCredentials, optionally return attempted DC */ -wbcErr wbcPingDc2(const char *domain, struct wbcAuthErrorInfo **error, - char **dcname) +wbcErr wbcCtxPingDc2(struct wbcContext *ctx, const char *domain, + struct wbcAuthErrorInfo **error, char **dcname) { struct winbindd_request request; struct winbindd_response response; @@ -653,7 +686,7 @@ wbcErr wbcPingDc2(const char *domain, struct wbcAuthErrorInfo **error, /* Send request */ - wbc_status = wbcRequestResponse(WINBINDD_PING_DC, + wbc_status = wbcRequestResponse(ctx, WINBINDD_PING_DC, &request, &response); @@ -683,9 +716,16 @@ wbcErr wbcPingDc2(const char *domain, struct wbcAuthErrorInfo **error, return wbc_status; } +wbcErr wbcPingDc2(const char *domain, struct wbcAuthErrorInfo **error, + char **dcname) +{ + return wbcCtxPingDc2(NULL, domain, error, dcname); +} + /* Trigger an extended logoff notification to Winbind for a specific user */ -wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params, - struct wbcAuthErrorInfo **error) +wbcErr wbcCtxLogoffUserEx(struct wbcContext *ctx, + const struct wbcLogoffUserParams *params, + struct wbcAuthErrorInfo **error) { struct winbindd_request request; struct winbindd_response response; @@ -748,7 +788,7 @@ wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params, /* Send request */ - wbc_status = wbcRequestResponse(WINBINDD_PAM_LOGOFF, + wbc_status = wbcRequestResponse(ctx, WINBINDD_PAM_LOGOFF, &request, &response); @@ -769,10 +809,16 @@ wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params, return wbc_status; } +wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params, + struct wbcAuthErrorInfo **error) +{ + return wbcCtxLogoffUserEx(NULL, params, error); +} + /* Trigger a logoff notification to Winbind for a specific user */ -wbcErr wbcLogoffUser(const char *username, - uid_t uid, - const char *ccfilename) +wbcErr wbcCtxLogoffUser(struct wbcContext *ctx, + const char *username, uid_t uid, + const char *ccfilename) { struct winbindd_request request; struct winbindd_response response; @@ -799,7 +845,7 @@ wbcErr wbcLogoffUser(const char *username, /* Send request */ - wbc_status = wbcRequestResponse(WINBINDD_PAM_LOGOFF, + wbc_status = wbcRequestResponse(ctx, WINBINDD_PAM_LOGOFF, &request, &response); @@ -809,11 +855,19 @@ wbcErr wbcLogoffUser(const char *username, return wbc_status; } +wbcErr wbcLogoffUser(const char *username, + uid_t uid, + const char *ccfilename) +{ + return wbcCtxLogoffUser(NULL, username, uid, ccfilename); +} + /* Change a password for a user with more detailed information upon failure */ -wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params, - struct wbcAuthErrorInfo **error, - enum wbcPasswordChangeRejectReason *reject_reason, - struct wbcUserPasswordPolicyInfo **policy) +wbcErr wbcCtxChangeUserPasswordEx(struct wbcContext *ctx, + const struct wbcChangePasswordParams *params, + struct wbcAuthErrorInfo **error, + enum wbcPasswordChangeRejectReason *reject_reason, + struct wbcUserPasswordPolicyInfo **policy) { struct winbindd_request request; struct winbindd_response response; @@ -972,7 +1026,7 @@ wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params, /* Send request */ - wbc_status = wbcRequestResponse(cmd, + wbc_status = wbcRequestResponse(ctx, cmd, &request, &response); if (WBC_ERROR_IS_OK(wbc_status)) { @@ -1007,10 +1061,20 @@ wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params, return wbc_status; } +wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params, + struct wbcAuthErrorInfo **error, + enum wbcPasswordChangeRejectReason *reject_reason, + struct wbcUserPasswordPolicyInfo **policy) +{ + return wbcCtxChangeUserPasswordEx(NULL, params, error, + reject_reason, policy); +} + /* Change a password for a user */ -wbcErr wbcChangeUserPassword(const char *username, - const char *old_password, - const char *new_password) +wbcErr wbcCtxChangeUserPassword(struct wbcContext *ctx, + const char *username, + const char *old_password, + const char *new_password) { wbcErr wbc_status = WBC_ERR_SUCCESS; struct wbcChangePasswordParams params; @@ -1022,21 +1086,30 @@ wbcErr wbcChangeUserPassword(const char *username, params.old_password.plaintext = old_password; params.new_password.plaintext = new_password; - wbc_status = wbcChangeUserPasswordEx(¶ms, - NULL, - NULL, - NULL); + wbc_status = wbcCtxChangeUserPasswordEx(ctx, ¶ms, + NULL, + NULL, + NULL); BAIL_ON_WBC_ERROR(wbc_status); done: return wbc_status; } +wbcErr wbcChangeUserPassword(const char *username, + const char *old_password, + const char *new_password) +{ + return wbcCtxChangeUserPassword(NULL, username, + old_password, new_password); +} + /* Logon a User */ -wbcErr wbcLogonUser(const struct wbcLogonUserParams *params, - struct wbcLogonUserInfo **info, - struct wbcAuthErrorInfo **error, - struct wbcUserPasswordPolicyInfo **policy) +wbcErr wbcCtxLogonUser(struct wbcContext *ctx, + const struct wbcLogonUserParams *params, + struct wbcLogonUserInfo **info, + struct wbcAuthErrorInfo **error, + struct wbcUserPasswordPolicyInfo **policy) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -1138,7 +1211,7 @@ wbcErr wbcLogonUser(const struct wbcLogonUserParams *params, } } - wbc_status = wbcRequestResponse(WINBINDD_PAM_AUTH, + wbc_status = wbcRequestResponse(ctx, WINBINDD_PAM_AUTH, &request, &response); @@ -1172,6 +1245,14 @@ done: return wbc_status; } +wbcErr wbcLogonUser(const struct wbcLogonUserParams *params, + struct wbcLogonUserInfo **info, + struct wbcAuthErrorInfo **error, + struct wbcUserPasswordPolicyInfo **policy) +{ + return wbcCtxLogonUser(NULL, params, info, error, policy); +} + static void wbcCredentialCacheInfoDestructor(void *ptr) { struct wbcCredentialCacheInfo *i = @@ -1180,9 +1261,10 @@ static void wbcCredentialCacheInfoDestructor(void *ptr) } /* Authenticate a user with cached credentials */ -wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params, - struct wbcCredentialCacheInfo **info, - struct wbcAuthErrorInfo **error) +wbcErr wbcCtxCredentialCache(struct wbcContext *ctx, + struct wbcCredentialCacheParams *params, + struct wbcCredentialCacheInfo **info, + struct wbcAuthErrorInfo **error) { wbcErr status = WBC_ERR_UNKNOWN_FAILURE; struct wbcCredentialCacheInfo *result = NULL; @@ -1227,7 +1309,8 @@ wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params, } if (params->domain_name != NULL) { - status = wbcRequestResponse(WINBINDD_INFO, NULL, &response); + status = wbcRequestResponse(ctx, WINBINDD_INFO, + NULL, &response); if (!WBC_ERROR_IS_OK(status)) { goto fail; } @@ -1276,8 +1359,8 @@ wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params, challenge_blob->blob.length); } - status = wbcRequestResponse(WINBINDD_CCACHE_NTLMAUTH, &request, - &response); + status = wbcRequestResponse(ctx, WINBINDD_CCACHE_NTLMAUTH, + &request, &response); if (!WBC_ERROR_IS_OK(status)) { goto fail; } @@ -1316,8 +1399,16 @@ fail: return status; } +wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params, + struct wbcCredentialCacheInfo **info, + struct wbcAuthErrorInfo **error) +{ + return wbcCtxCredentialCache(NULL, params, info, error); +} + /* Authenticate a user with cached credentials */ -wbcErr wbcCredentialSave(const char *user, const char *password) +wbcErr wbcCtxCredentialSave(struct wbcContext *ctx, + const char *user, const char *password) { struct winbindd_request request; struct winbindd_response response; @@ -1331,5 +1422,10 @@ wbcErr wbcCredentialSave(const char *user, const char *password) sizeof(request.data.ccache_save.pass)-1); request.data.ccache_save.uid = getuid(); - return wbcRequestResponse(WINBINDD_CCACHE_SAVE, &request, &response); + return wbcRequestResponse(ctx, WINBINDD_CCACHE_SAVE, &request, &response); +} + +wbcErr wbcCredentialSave(const char *user, const char *password) +{ + return wbcCtxCredentialSave(NULL, user, password); } diff --git a/nsswitch/libwbclient/wbc_pwd.c b/nsswitch/libwbclient/wbc_pwd.c index 6df694d..0b05133 100644 --- a/nsswitch/libwbclient/wbc_pwd.c +++ b/nsswitch/libwbclient/wbc_pwd.c @@ -167,7 +167,8 @@ fail: } /* Fill in a struct passwd* for a domain user based on username */ -wbcErr wbcGetpwnam(const char *name, struct passwd **pwd) +wbcErr wbcCtxGetpwnam(struct wbcContext *ctx, + const char *name, struct passwd **pwd) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -187,7 +188,7 @@ wbcErr wbcGetpwnam(const char *name, struct passwd **pwd) strncpy(request.data.username, name, sizeof(request.data.username)-1); - wbc_status = wbcRequestResponse(WINBINDD_GETPWNAM, + wbc_status = wbcRequestResponse(ctx, WINBINDD_GETPWNAM, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -199,8 +200,13 @@ wbcErr wbcGetpwnam(const char *name, struct passwd **pwd) return wbc_status; } +wbcErr wbcGetpwnam(const char *name, struct passwd **pwd) +{ + return wbcCtxGetpwnam(NULL, name, pwd); +} + /* Fill in a struct passwd* for a domain user based on uid */ -wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd) +wbcErr wbcCtxGetpwuid(struct wbcContext *ctx, uid_t uid, struct passwd **pwd) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -218,7 +224,7 @@ wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd) request.data.uid = uid; - wbc_status = wbcRequestResponse(WINBINDD_GETPWUID, + wbc_status = wbcRequestResponse(ctx, WINBINDD_GETPWUID, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -230,8 +236,14 @@ wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd) return wbc_status; } +wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd) +{ + return wbcCtxGetpwuid(NULL, uid, pwd); +} + /* Fill in a struct passwd* for a domain user based on sid */ -wbcErr wbcGetpwsid(struct wbcDomainSid *sid, struct passwd **pwd) +wbcErr wbcCtxGetpwsid(struct wbcContext *ctx, + struct wbcDomainSid *sid, struct passwd **pwd) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -249,7 +261,7 @@ wbcErr wbcGetpwsid(struct wbcDomainSid *sid, struct passwd **pwd) wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid)); - wbc_status = wbcRequestResponse(WINBINDD_GETPWSID, + wbc_status = wbcRequestResponse(ctx, WINBINDD_GETPWSID, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -261,8 +273,14 @@ wbcErr wbcGetpwsid(struct wbcDomainSid *sid, struct passwd **pwd) return wbc_status; } +wbcErr wbcGetpwsid(struct wbcDomainSid *sid, struct passwd **pwd) +{ + return wbcCtxGetpwsid(NULL, sid, pwd); +} + /* Fill in a struct passwd* for a domain user based on username */ -wbcErr wbcGetgrnam(const char *name, struct group **grp) +wbcErr wbcCtxGetgrnam(struct wbcContext *ctx, + const char *name, struct group **grp) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -282,7 +300,7 @@ wbcErr wbcGetgrnam(const char *name, struct group **grp) strncpy(request.data.groupname, name, sizeof(request.data.groupname)-1); - wbc_status = wbcRequestResponse(WINBINDD_GETGRNAM, + wbc_status = wbcRequestResponse(ctx, WINBINDD_GETGRNAM, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -297,8 +315,13 @@ wbcErr wbcGetgrnam(const char *name, struct group **grp) return wbc_status; } +wbcErr wbcGetgrnam(const char *name, struct group **grp) +{ + return wbcCtxGetgrnam(NULL, name, grp); +} + /* Fill in a struct passwd* for a domain user based on uid */ -wbcErr wbcGetgrgid(gid_t gid, struct group **grp) +wbcErr wbcCtxGetgrgid(struct wbcContext *ctx, gid_t gid, struct group **grp) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -316,7 +339,7 @@ wbcErr wbcGetgrgid(gid_t gid, struct group **grp) request.data.gid = gid; - wbc_status = wbcRequestResponse(WINBINDD_GETGRGID, + wbc_status = wbcRequestResponse(ctx, WINBINDD_GETGRGID, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -331,6 +354,11 @@ wbcErr wbcGetgrgid(gid_t gid, struct group **grp) return wbc_status; } +wbcErr wbcGetgrgid(gid_t gid, struct group **grp) +{ + return wbcCtxGetgrgid(NULL, gid, grp); +} + /** @brief Number of cached passwd structs * */ @@ -347,7 +375,7 @@ static uint32_t pw_cache_idx; static struct winbindd_response pw_response; /* Reset the passwd iterator */ -wbcErr wbcSetpwent(void) +wbcErr wbcCtxSetpwent(struct wbcContext *ctx) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; @@ -358,7 +386,7 @@ wbcErr wbcSetpwent(void) ZERO_STRUCT(pw_response); - wbc_status = wbcRequestResponse(WINBINDD_SETPWENT, + wbc_status = wbcRequestResponse(ctx, WINBINDD_SETPWENT, NULL, NULL); BAIL_ON_WBC_ERROR(wbc_status); @@ -366,8 +394,13 @@ wbcErr wbcSetpwent(void) return wbc_status; } +wbcErr wbcSetpwent(void) +{ + return wbcCtxSetpwent(NULL); +} + /* Close the passwd iterator */ -wbcErr wbcEndpwent(void) +wbcErr wbcCtxEndpwent(struct wbcContext *ctx) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; @@ -376,7 +409,7 @@ wbcErr wbcEndpwent(void) winbindd_free_response(&pw_response); } - wbc_status = wbcRequestResponse(WINBINDD_ENDPWENT, + wbc_status = wbcRequestResponse(ctx, WINBINDD_ENDPWENT, NULL, NULL); BAIL_ON_WBC_ERROR(wbc_status); @@ -384,8 +417,13 @@ wbcErr wbcEndpwent(void) return wbc_status; } +wbcErr wbcEndpwent(void) +{ + return wbcCtxEndpwent(NULL); +} + /* Return the next struct passwd* entry from the pwent iterator */ -wbcErr wbcGetpwent(struct passwd **pwd) +wbcErr wbcCtxGetpwent(struct wbcContext *ctx, struct passwd **pwd) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -405,7 +443,7 @@ wbcErr wbcGetpwent(struct passwd **pwd) ZERO_STRUCT(request); request.data.num_entries = MAX_GETPWENT_USERS; - wbc_status = wbcRequestResponse(WINBINDD_GETPWENT, &request, + wbc_status = wbcRequestResponse(ctx, WINBINDD_GETPWENT, &request, &pw_response); BAIL_ON_WBC_ERROR(wbc_status); @@ -426,6 +464,11 @@ done: return wbc_status; } +wbcErr wbcGetpwent(struct passwd **pwd) +{ + return wbcCtxGetpwent(NULL, pwd); +} + /** @brief Number of cached group structs * */ @@ -442,7 +485,7 @@ static uint32_t gr_cache_idx; static struct winbindd_response gr_response; /* Reset the group iterator */ -wbcErr wbcSetgrent(void) +wbcErr wbcCtxSetgrent(struct wbcContext *ctx) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; @@ -453,7 +496,7 @@ wbcErr wbcSetgrent(void) ZERO_STRUCT(gr_response); - wbc_status = wbcRequestResponse(WINBINDD_SETGRENT, + wbc_status = wbcRequestResponse(ctx, WINBINDD_SETGRENT, NULL, NULL); BAIL_ON_WBC_ERROR(wbc_status); @@ -461,8 +504,13 @@ wbcErr wbcSetgrent(void) return wbc_status; } +wbcErr wbcSetgrent(void) +{ + return wbcCtxSetgrent(NULL); +} + /* Close the group iterator */ -wbcErr wbcEndgrent(void) +wbcErr wbcCtxEndgrent(struct wbcContext *ctx) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; @@ -471,7 +519,7 @@ wbcErr wbcEndgrent(void) winbindd_free_response(&gr_response); } - wbc_status = wbcRequestResponse(WINBINDD_ENDGRENT, + wbc_status = wbcRequestResponse(ctx, WINBINDD_ENDGRENT, NULL, NULL); BAIL_ON_WBC_ERROR(wbc_status); @@ -479,8 +527,13 @@ wbcErr wbcEndgrent(void) return wbc_status; } +wbcErr wbcEndgrent(void) +{ + return wbcCtxEndgrent(NULL); +} + /* Return the next struct group* entry from the pwent iterator */ -wbcErr wbcGetgrent(struct group **grp) +wbcErr wbcCtxGetgrent(struct wbcContext *ctx, struct group **grp) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -501,8 +554,8 @@ wbcErr wbcGetgrent(struct group **grp) ZERO_STRUCT(request); request.data.num_entries = MAX_GETGRENT_GROUPS; - wbc_status = wbcRequestResponse(WINBINDD_GETGRENT, &request, - &gr_response); + wbc_status = wbcRequestResponse(ctx, WINBINDD_GETGRENT, + &request, &gr_response); BAIL_ON_WBC_ERROR(wbc_status); @@ -526,8 +579,13 @@ done: return wbc_status; } +wbcErr wbcGetgrent(struct group **grp) +{ + return wbcCtxGetgrent(NULL, grp); +} + /* Return the next struct group* entry from the pwent iterator */ -wbcErr wbcGetgrlist(struct group **grp) +wbcErr wbcCtxGetgrlist(struct wbcContext *ctx, struct group **grp) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -548,8 +606,8 @@ wbcErr wbcGetgrlist(struct group **grp) ZERO_STRUCT(request); request.data.num_entries = MAX_GETGRENT_GROUPS; - wbc_status = wbcRequestResponse(WINBINDD_GETGRLST, &request, - &gr_response); + wbc_status = wbcRequestResponse(ctx, WINBINDD_GETGRLST, + &request, &gr_response); BAIL_ON_WBC_ERROR(wbc_status); @@ -569,10 +627,14 @@ done: return wbc_status; } +wbcErr wbcGetgrlist(struct group **grp) +{ + return wbcCtxGetgrlist(NULL, grp); +} + /* Return the unix group array belonging to the given user */ -wbcErr wbcGetGroups(const char *account, - uint32_t *num_groups, - gid_t **_groups) +wbcErr wbcCtxGetGroups(struct wbcContext *ctx, const char *account, + uint32_t *num_groups, gid_t **_groups) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -594,7 +656,7 @@ wbcErr wbcGetGroups(const char *account, strncpy(request.data.username, account, sizeof(request.data.username)-1); - wbc_status = wbcRequestResponse(WINBINDD_GETGROUPS, + wbc_status = wbcRequestResponse(ctx, WINBINDD_GETGROUPS, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -618,3 +680,8 @@ wbcErr wbcGetGroups(const char *account, wbcFreeMemory(groups); return wbc_status; } + +wbcErr wbcGetGroups(const char *account, uint32_t *num_groups, gid_t **_groups) +{ + return wbcCtxGetGroups(NULL, account, num_groups, _groups); +} diff --git a/nsswitch/libwbclient/wbc_sid.c b/nsswitch/libwbclient/wbc_sid.c index 0877ed0..cc71b9e 100644 --- a/nsswitch/libwbclient/wbc_sid.c +++ b/nsswitch/libwbclient/wbc_sid.c @@ -180,10 +180,11 @@ done: /* Convert a domain and name to SID */ -wbcErr wbcLookupName(const char *domain, - const char *name, - struct wbcDomainSid *sid, - enum wbcSidType *name_type) +wbcErr wbcCtxLookupName(struct wbcContext *ctx, + const char *domain, + const char *name, + struct wbcDomainSid *sid, + enum wbcSidType *name_type) { struct winbindd_request request; struct winbindd_response response; @@ -206,7 +207,7 @@ wbcErr wbcLookupName(const char *domain, strncpy(request.data.name.name, name, sizeof(request.data.name.name)-1); - wbc_status = wbcRequestResponse(WINBINDD_LOOKUPNAME, + wbc_status = wbcRequestResponse(ctx, WINBINDD_LOOKUPNAME, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -222,12 +223,21 @@ wbcErr wbcLookupName(const char *domain, return wbc_status; } +wbcErr wbcLookupName(const char *domain, + const char *name, + struct wbcDomainSid *sid, + enum wbcSidType *name_type) +{ + return wbcCtxLookupName(NULL, domain, name, sid, name_type); +} + /* Convert a SID to a domain and name */ -wbcErr wbcLookupSid(const struct wbcDomainSid *sid, - char **pdomain, - char **pname, - enum wbcSidType *pname_type) +wbcErr wbcCtxLookupSid(struct wbcContext *ctx, + const struct wbcDomainSid *sid, + char **pdomain, + char **pname, + enum wbcSidType *pname_type) { struct winbindd_request request; struct winbindd_response response; @@ -247,7 +257,8 @@ wbcErr wbcLookupSid(const struct wbcDomainSid *sid, /* Make request */ - wbc_status = wbcRequestResponse(WINBINDD_LOOKUPSID, &request, + wbc_status = wbcRequestResponse(ctx, WINBINDD_LOOKUPSID, + &request, &response); if (!WBC_ERROR_IS_OK(wbc_status)) { return wbc_status; @@ -285,6 +296,14 @@ done: return wbc_status; } +wbcErr wbcLookupSid(const struct wbcDomainSid *sid, + char **pdomain, + char **pname, + enum wbcSidType *pname_type) +{ + return wbcCtxLookupSid(NULL, sid, pdomain, pname, pname_type); +} + static void wbcDomainInfosDestructor(void *ptr) { struct wbcDomainInfo *i = (struct wbcDomainInfo *)ptr; @@ -306,9 +325,10 @@ static void wbcTranslatedNamesDestructor(void *ptr) } } -wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids, - struct wbcDomainInfo **pdomains, int *pnum_domains, - struct wbcTranslatedName **pnames) +wbcErr wbcCtxLookupSids(struct wbcContext *ctx, + const struct wbcDomainSid *sids, int num_sids, + struct wbcDomainInfo **pdomains, int *pnum_domains, + struct wbcTranslatedName **pnames) { struct winbindd_request request; struct winbindd_response response; @@ -350,7 +370,7 @@ wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids, request.extra_data.data = sidlist; request.extra_len = p - sidlist; - wbc_status = wbcRequestResponse(WINBINDD_LOOKUPSIDS, + wbc_status = wbcRequestResponse(ctx, WINBINDD_LOOKUPSIDS, &request, &response); free(sidlist); if (!WBC_ERROR_IS_OK(wbc_status)) { @@ -475,9 +495,17 @@ fail: return wbc_status; } +wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids, + struct wbcDomainInfo **pdomains, int *pnum_domains, + struct wbcTranslatedName **pnames) +{ + return wbcCtxLookupSids(NULL, sids, num_sids, pdomains, + pnum_domains, pnames); +} + /* Translate a collection of RIDs within a domain to names */ -wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid, +wbcErr wbcCtxLookupRids(struct wbcContext *ctx, struct wbcDomainSid *dom_sid, int num_rids, uint32_t *rids, const char **pp_domain_name, @@ -527,7 +555,7 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid, request.extra_data.data = ridlist; request.extra_len = len; - wbc_status = wbcRequestResponse(WINBINDD_LOOKUPRIDS, + wbc_status = wbcRequestResponse(ctx, WINBINDD_LOOKUPRIDS, &request, &response); free(ridlist); @@ -599,11 +627,23 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid, return wbc_status; } +wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid, + int num_rids, + uint32_t *rids, + const char **pp_domain_name, + const char ***pnames, + enum wbcSidType **ptypes) +{ + return wbcCtxLookupRids(NULL, dom_sid, num_rids, rids, + pp_domain_name, pnames, ptypes); +} + /* Get the groups a user belongs to */ -wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid, - bool domain_groups_only, - uint32_t *num_sids, - struct wbcDomainSid **_sids) +wbcErr wbcCtxLookupUserSids(struct wbcContext *ctx, + const struct wbcDomainSid *user_sid, + bool domain_groups_only, + uint32_t *num_sids, + struct wbcDomainSid **_sids) { uint32_t i; const char *s; @@ -631,7 +671,7 @@ wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid, cmd = WINBINDD_GETUSERSIDS; } - wbc_status = wbcRequestResponse(cmd, + wbc_status = wbcRequestResponse(ctx, cmd, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -672,6 +712,15 @@ wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid, return wbc_status; } +wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid, + bool domain_groups_only, + uint32_t *num_sids, + struct wbcDomainSid **_sids) +{ + return wbcCtxLookupUserSids(NULL, user_sid, domain_groups_only, + num_sids, _sids); +} + static inline wbcErr _sid_to_rid(struct wbcDomainSid *sid, uint32_t *rid) { @@ -684,11 +733,12 @@ wbcErr _sid_to_rid(struct wbcDomainSid *sid, uint32_t *rid) } /* Get alias membership for sids */ -wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid, - struct wbcDomainSid *sids, - uint32_t num_sids, - uint32_t **alias_rids, - uint32_t *num_alias_rids) +wbcErr wbcCtxGetSidAliases(struct wbcContext *ctx, + const struct wbcDomainSid *dom_sid, + struct wbcDomainSid *sids, + uint32_t num_sids, + uint32_t **alias_rids, + uint32_t *num_alias_rids) { uint32_t i; const char *s; @@ -749,7 +799,7 @@ wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid, request.extra_data.data = extra_data; request.extra_len = extra_data_len; - wbc_status = wbcRequestResponse(WINBINDD_GETSIDALIASES, + wbc_status = wbcRequestResponse(ctx, WINBINDD_GETSIDALIASES, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -789,11 +839,22 @@ wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid, return wbc_status; } +wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid, + struct wbcDomainSid *sids, + uint32_t num_sids, + uint32_t **alias_rids, + uint32_t *num_alias_rids) +{ + return wbcCtxGetSidAliases(NULL, dom_sid, sids, num_sids, + alias_rids, num_alias_rids); +} + /* Lists Users */ -wbcErr wbcListUsers(const char *domain_name, - uint32_t *_num_users, - const char ***_users) +wbcErr wbcCtxListUsers(struct wbcContext *ctx, + const char *domain_name, + uint32_t *_num_users, + const char ***_users) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -812,7 +873,7 @@ wbcErr wbcListUsers(const char *domain_name, sizeof(request.domain_name)-1); } - wbc_status = wbcRequestResponse(WINBINDD_LIST_USERS, + wbc_status = wbcRequestResponse(ctx, WINBINDD_LIST_USERS, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -864,10 +925,18 @@ wbcErr wbcListUsers(const char *domain_name, return wbc_status; } +wbcErr wbcListUsers(const char *domain_name, + uint32_t *_num_users, + const char ***_users) +{ + return wbcCtxListUsers(NULL, domain_name, _num_users, _users); +} + /* Lists Groups */ -wbcErr wbcListGroups(const char *domain_name, - uint32_t *_num_groups, - const char ***_groups) +wbcErr wbcCtxListGroups(struct wbcContext *ctx, + const char *domain_name, + uint32_t *_num_groups, + const char ***_groups) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -886,7 +955,7 @@ wbcErr wbcListGroups(const char *domain_name, sizeof(request.domain_name)-1); } - wbc_status = wbcRequestResponse(WINBINDD_LIST_GROUPS, + wbc_status = wbcRequestResponse(ctx, WINBINDD_LIST_GROUPS, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -938,27 +1007,35 @@ wbcErr wbcListGroups(const char *domain_name, return wbc_status; } -wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid, - char **pdomain, - char **pfullname, - enum wbcSidType *pname_type) +wbcErr wbcListGroups(const char *domain_name, + uint32_t *_num_groups, + const char ***_groups) +{ + return wbcCtxListGroups(NULL, domain_name, _num_groups, _groups); +} + +wbcErr wbcCtxGetDisplayName(struct wbcContext *ctx, + const struct wbcDomainSid *sid, + char **pdomain, + char **pfullname, + enum wbcSidType *pname_type) { wbcErr wbc_status; char *domain = NULL; char *name = NULL; enum wbcSidType name_type; - wbc_status = wbcLookupSid(sid, &domain, &name, &name_type); + wbc_status = wbcCtxLookupSid(ctx, sid, &domain, &name, &name_type); BAIL_ON_WBC_ERROR(wbc_status); if (name_type == WBC_SID_NAME_USER) { uid_t uid; struct passwd *pwd; - wbc_status = wbcSidToUid(sid, &uid); + wbc_status = wbcCtxSidToUid(ctx, sid, &uid); BAIL_ON_WBC_ERROR(wbc_status); - wbc_status = wbcGetpwuid(uid, &pwd); + wbc_status = wbcCtxGetpwuid(ctx, uid, &pwd); BAIL_ON_WBC_ERROR(wbc_status); wbcFreeMemory(name); @@ -983,6 +1060,14 @@ wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid, return wbc_status; } +wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid, + char **pdomain, + char **pfullname, + enum wbcSidType *pname_type) +{ + return wbcCtxGetDisplayName(NULL, sid, pdomain, pfullname, pname_type); +} + const char* wbcSidTypeString(enum wbcSidType type) { switch (type) { diff --git a/nsswitch/libwbclient/wbc_util.c b/nsswitch/libwbclient/wbc_util.c index 4060e25..3dab0a2 100644 --- a/nsswitch/libwbclient/wbc_util.c +++ b/nsswitch/libwbclient/wbc_util.c @@ -28,9 +28,11 @@ /** @brief Ping winbindd to see if the daemon is running * + * @param *ctx wbclient Context + * * @return #wbcErr **/ -wbcErr wbcPing(void) +wbcErr wbcCtxPing(struct wbcContext *ctx) { struct winbindd_request request; struct winbindd_response response; @@ -40,7 +42,12 @@ wbcErr wbcPing(void) ZERO_STRUCT(request); ZERO_STRUCT(response); - return wbcRequestResponse(WINBINDD_PING, &request, &response); + return wbcRequestResponse(ctx, WINBINDD_PING, &request, &response); +} + +wbcErr wbcPing(void) +{ + return wbcCtxPing(NULL); } static void wbcInterfaceDetailsDestructor(void *ptr) @@ -60,7 +67,8 @@ static void wbcInterfaceDetailsDestructor(void *ptr) * @return #wbcErr */ -wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details) +wbcErr wbcCtxInterfaceDetails(struct wbcContext *ctx, + struct wbcInterfaceDetails **_details) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct wbcInterfaceDetails *info; @@ -79,12 +87,13 @@ wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details) BAIL_ON_PTR_ERROR(info, wbc_status); /* first the interface version */ - wbc_status = wbcRequestResponse(WINBINDD_INTERFACE_VERSION, NULL, &response); + wbc_status = wbcRequestResponse(ctx, WINBINDD_INTERFACE_VERSION, + NULL, &response); BAIL_ON_WBC_ERROR(wbc_status); info->interface_version = response.data.interface_version; /* then the samba version and the winbind separator */ - wbc_status = wbcRequestResponse(WINBINDD_INFO, NULL, &response); + wbc_status = wbcRequestResponse(ctx, WINBINDD_INFO, NULL, &response); BAIL_ON_WBC_ERROR(wbc_status); info->winbind_version = strdup(response.data.info.samba_version); @@ -92,20 +101,22 @@ wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details) info->winbind_separator = response.data.info.winbind_separator; /* then the local netbios name */ - wbc_status = wbcRequestResponse(WINBINDD_NETBIOS_NAME, NULL, &response); + wbc_status = wbcRequestResponse(ctx, WINBINDD_NETBIOS_NAME, + NULL, &response); BAIL_ON_WBC_ERROR(wbc_status); info->netbios_name = strdup(response.data.netbios_name); BAIL_ON_PTR_ERROR(info->netbios_name, wbc_status); /* then the local workgroup name */ - wbc_status = wbcRequestResponse(WINBINDD_DOMAIN_NAME, NULL, &response); + wbc_status = wbcRequestResponse(ctx, WINBINDD_DOMAIN_NAME, + NULL, &response); BAIL_ON_WBC_ERROR(wbc_status); info->netbios_domain = strdup(response.data.domain_name); BAIL_ON_PTR_ERROR(info->netbios_domain, wbc_status); - wbc_status = wbcDomainInfo(info->netbios_domain, &domain); + wbc_status = wbcCtxDomainInfo(ctx, info->netbios_domain, &domain); if (wbc_status == WBC_ERR_DOMAIN_NOT_FOUND) { /* maybe it's a standalone server */ domain = NULL; @@ -132,6 +143,11 @@ done: return wbc_status; } +wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details) +{ + return wbcCtxInterfaceDetails(NULL, _details); +} + static void wbcDomainInfoDestructor(void *ptr) { struct wbcDomainInfo *i = (struct wbcDomainInfo *)ptr; @@ -147,7 +163,9 @@ static void wbcDomainInfoDestructor(void *ptr) * @return #wbcErr */ -wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo) +wbcErr wbcCtxDomainInfo(struct wbcContext *ctx, + const char *domain, + struct wbcDomainInfo **dinfo) { struct winbindd_request request; struct winbindd_response response; @@ -167,7 +185,7 @@ wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo) strncpy(request.domain_name, domain, sizeof(request.domain_name)-1); - wbc_status = wbcRequestResponse(WINBINDD_DOMAIN_INFO, + wbc_status = wbcRequestResponse(ctx, WINBINDD_DOMAIN_INFO, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -203,9 +221,15 @@ wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo) return wbc_status; } +wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo) +{ + return wbcCtxDomainInfo(NULL, domain, dinfo); +} + /* Get the list of current DCs */ -wbcErr wbcDcInfo(const char *domain, size_t *num_dcs, - const char ***dc_names, const char ***dc_ips) +wbcErr wbcCtxDcInfo(struct wbcContext *ctx, + const char *domain, size_t *num_dcs, + const char ***dc_names, const char ***dc_ips) { struct winbindd_request request; struct winbindd_response response; @@ -226,7 +250,7 @@ wbcErr wbcDcInfo(const char *domain, size_t *num_dcs, sizeof(request.domain_name) - 1); } - wbc_status = wbcRequestResponse(WINBINDD_DC_INFO, + wbc_status = wbcRequestResponse(ctx, WINBINDD_DC_INFO, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -290,8 +314,15 @@ done: return wbc_status; } +wbcErr wbcDcInfo(const char *domain, size_t *num_dcs, + const char ***dc_names, const char ***dc_ips) +{ + return wbcCtxDcInfo(NULL, domain, num_dcs, dc_names, dc_ips); +} + /* Resolve a NetbiosName via WINS */ -wbcErr wbcResolveWinsByName(const char *name, char **ip) +wbcErr wbcCtxResolveWinsByName(struct wbcContext *ctx, + const char *name, char **ip) { struct winbindd_request request; struct winbindd_response response; @@ -306,7 +337,7 @@ wbcErr wbcResolveWinsByName(const char *name, char **ip) strncpy(request.data.winsreq, name, sizeof(request.data.winsreq)-1); - wbc_status = wbcRequestResponse(WINBINDD_WINS_BYNAME, + wbc_status = wbcRequestResponse(ctx, WINBINDD_WINS_BYNAME, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -323,8 +354,14 @@ wbcErr wbcResolveWinsByName(const char *name, char **ip) return wbc_status; } +wbcErr wbcResolveWinsByName(const char *name, char **ip) +{ + return wbcCtxResolveWinsByName(NULL, name, ip); +} + /* Resolve an IP address via WINS into a NetbiosName */ -wbcErr wbcResolveWinsByIP(const char *ip, char **name) +wbcErr wbcCtxResolveWinsByIP(struct wbcContext *ctx, + const char *ip, char **name) { struct winbindd_request request; struct winbindd_response response; @@ -339,7 +376,7 @@ wbcErr wbcResolveWinsByIP(const char *ip, char **name) strncpy(request.data.winsreq, ip, sizeof(request.data.winsreq)-1); - wbc_status = wbcRequestResponse(WINBINDD_WINS_BYIP, + wbc_status = wbcRequestResponse(ctx, WINBINDD_WINS_BYIP, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -356,6 +393,11 @@ wbcErr wbcResolveWinsByIP(const char *ip, char **name) return wbc_status; } +wbcErr wbcResolveWinsByIP(const char *ip, char **name) +{ + return wbcCtxResolveWinsByIP(NULL, ip, name); +} + /** */ @@ -489,7 +531,8 @@ static void wbcDomainInfoListDestructor(void *ptr) } /* Enumerate the domain trusts known by Winbind */ -wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains) +wbcErr wbcCtxListTrusts(struct wbcContext *ctx, + struct wbcDomainInfo **domains, size_t *num_domains) { struct winbindd_response response; wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; @@ -505,7 +548,7 @@ wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains) /* Send request */ - wbc_status = wbcRequestResponse(WINBINDD_LIST_TRUSTDOM, + wbc_status = wbcRequestResponse(ctx, WINBINDD_LIST_TRUSTDOM, NULL, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -559,6 +602,11 @@ wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains) return wbc_status; } +wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains) +{ + return wbcCtxListTrusts(NULL, domains, num_domains); +} + static void wbcDomainControllerInfoDestructor(void *ptr) { struct wbcDomainControllerInfo *i = @@ -567,9 +615,9 @@ static void wbcDomainControllerInfoDestructor(void *ptr) } /* Enumerate the domain trusts known by Winbind */ -wbcErr wbcLookupDomainController(const char *domain, - uint32_t flags, - struct wbcDomainControllerInfo **dc_info) +wbcErr wbcCtxLookupDomainController(struct wbcContext *ctx, + const char *domain, uint32_t flags, + struct wbcDomainControllerInfo **dc_info) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -598,7 +646,7 @@ wbcErr wbcLookupDomainController(const char *domain, /* Send request */ - wbc_status = wbcRequestResponse(WINBINDD_DSGETDCNAME, + wbc_status = wbcRequestResponse(ctx, WINBINDD_DSGETDCNAME, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -614,6 +662,12 @@ done: return wbc_status; } +wbcErr wbcLookupDomainController(const char *domain, uint32_t flags, + struct wbcDomainControllerInfo **dc_info) +{ + return wbcCtxLookupDomainController(NULL, domain, flags, dc_info); +} + static void wbcDomainControllerInfoExDestructor(void *ptr) { struct wbcDomainControllerInfoEx *i = @@ -688,11 +742,12 @@ done: } /* Get extended domain controller information */ -wbcErr wbcLookupDomainControllerEx(const char *domain, - struct wbcGuid *guid, - const char *site, - uint32_t flags, - struct wbcDomainControllerInfoEx **dc_info) +wbcErr wbcCtxLookupDomainControllerEx(struct wbcContext *ctx, + const char *domain, + struct wbcGuid *guid, + const char *site, + uint32_t flags, + struct wbcDomainControllerInfoEx **dc_info) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct winbindd_request request; @@ -732,7 +787,7 @@ wbcErr wbcLookupDomainControllerEx(const char *domain, /* Send request */ - wbc_status = wbcRequestResponse(WINBINDD_DSGETDCNAME, + wbc_status = wbcRequestResponse(ctx, WINBINDD_DSGETDCNAME, &request, &response); BAIL_ON_WBC_ERROR(wbc_status); @@ -748,6 +803,16 @@ done: return wbc_status; } +wbcErr wbcLookupDomainControllerEx(const char *domain, + struct wbcGuid *guid, + const char *site, + uint32_t flags, + struct wbcDomainControllerInfoEx **dc_info) +{ + return wbcCtxLookupDomainControllerEx(NULL, domain, guid, site, + flags, dc_info); +} + static void wbcNamedBlobDestructor(void *ptr) { struct wbcNamedBlob *b = (struct wbcNamedBlob *)ptr; diff --git a/nsswitch/libwbclient/wbclient.h b/nsswitch/libwbclient/wbclient.h index ad2bfd0..4f28074 100644 --- a/nsswitch/libwbclient/wbclient.h +++ b/nsswitch/libwbclient/wbclient.h @@ -631,12 +631,17 @@ wbcErr wbcStringToGuid(const char *guid_string, /** * @brief Ping winbindd to see if the daemon is running * + * @param *ctx wbclient Context + * * @return #wbcErr **/ +wbcErr wbcCtxPing(struct wbcContext *ctx); wbcErr wbcPing(void); wbcErr wbcLibraryDetails(struct wbcLibraryDetails **details); +wbcErr wbcCtxInterfaceDetails(struct wbcContext *ctx, + struct wbcInterfaceDetails **details); wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details); /********************************************************** @@ -646,6 +651,7 @@ wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details); /** * @brief Convert a domain and name to SID * + * @param *ctx wbclient Context * @param dom_name Domain name (possibly "") * @param name User or group name * @param *sid Pointer to the resolved domain SID @@ -653,6 +659,11 @@ wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details); * * @return #wbcErr **/ +wbcErr wbcCtxLookupName(struct wbcContext *ctx, + const char *dom_name, + const char *name, + struct wbcDomainSid *sid, + enum wbcSidType *name_type); wbcErr wbcLookupName(const char *dom_name, const char *name, struct wbcDomainSid *sid, @@ -661,13 +672,19 @@ wbcErr wbcLookupName(const char *dom_name, /** * @brief Convert a SID to a domain and name * - * @param *sid Pointer to the domain SID to be resolved + * @param *ctx wbclient Context + * @param *sid Pointer to the domain SID to be resolved * @param domain Resolved Domain name (possibly "") * @param name Resolved User or group name * @param *name_type Pointer to the resolved SID type * * @return #wbcErr **/ +wbcErr wbcCtxLookupSid(struct wbcContext *ctx, + const struct wbcDomainSid *sid, + char **domain, + char **name, + enum wbcSidType *name_type); wbcErr wbcLookupSid(const struct wbcDomainSid *sid, char **domain, char **name, @@ -679,6 +696,10 @@ struct wbcTranslatedName { int domain_index; }; +wbcErr wbcCtxLookupSids(struct wbcContext *ctx, + const struct wbcDomainSid *sids, int num_sids, + struct wbcDomainInfo **domains, int *num_domains, + struct wbcTranslatedName **names); wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids, struct wbcDomainInfo **domains, int *num_domains, struct wbcTranslatedName **names); @@ -686,6 +707,13 @@ wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids, /** * @brief Translate a collection of RIDs within a domain to names */ +wbcErr wbcCtxLookupRids(struct wbcContext *ctx, + struct wbcDomainSid *dom_sid, + int num_rids, + uint32_t *rids, + const char **domain_name, + const char ***names, + enum wbcSidType **types); wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid, int num_rids, uint32_t *rids, @@ -696,6 +724,11 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid, /* * @brief Get the groups a user belongs to **/ +wbcErr wbcCtxLookupUserSids(struct wbcContext *ctx, + const struct wbcDomainSid *user_sid, + bool domain_groups_only, + uint32_t *num_sids, + struct wbcDomainSid **sids); wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid, bool domain_groups_only, uint32_t *num_sids, @@ -704,6 +737,12 @@ wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid, /* * @brief Get alias membership for sids **/ +wbcErr wbcCtxGetSidAliases(struct wbcContext *ctx, + const struct wbcDomainSid *dom_sid, + struct wbcDomainSid *sids, + uint32_t num_sids, + uint32_t **alias_rids, + uint32_t *num_alias_rids); wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid, struct wbcDomainSid *sids, uint32_t num_sids, @@ -713,6 +752,10 @@ wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid, /** * @brief Lists Users **/ +wbcErr wbcCtxListUsers(struct wbcContext *ctx, + const char *domain_name, + uint32_t *num_users, + const char ***users); wbcErr wbcListUsers(const char *domain_name, uint32_t *num_users, const char ***users); @@ -720,10 +763,19 @@ wbcErr wbcListUsers(const char *domain_name, /** * @brief Lists Groups **/ +wbcErr wbcCtxListGroups(struct wbcContext *ctx, + const char *domain_name, + uint32_t *num_groups, + const char ***groups); wbcErr wbcListGroups(const char *domain_name, uint32_t *num_groups, const char ***groups); +wbcErr wbcCtxGetDisplayName(struct wbcContext *ctx, + const struct wbcDomainSid *sid, + char **pdomain, + char **pfullname, + enum wbcSidType *pname_type); wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid, char **pdomain, char **pfullname, @@ -736,12 +788,16 @@ wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid, /** * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed * + * @param *ctx wbclient Context * @param *sid Pointer to the domain SID to be resolved * @param *puid Pointer to the resolved uid_t value * * @return #wbcErr * **/ +wbcErr wbcCtxSidToUid(struct wbcContext *ctx, + const struct wbcDomainSid *sid, + uid_t *puid); wbcErr wbcSidToUid(const struct wbcDomainSid *sid, uid_t *puid); @@ -760,12 +816,15 @@ wbcErr wbcQuerySidToUid(const struct wbcDomainSid *sid, /** * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed * + * @param *ctx wbclient Context * @param uid Unix uid to be resolved * @param *sid Pointer to the resolved domain SID * * @return #wbcErr * **/ +wbcErr wbcCtxUidToSid(struct wbcContext *ctx, uid_t uid, + struct wbcDomainSid *sid); wbcErr wbcUidToSid(uid_t uid, struct wbcDomainSid *sid); @@ -784,12 +843,16 @@ wbcErr wbcQueryUidToSid(uid_t uid, /** * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed * + * @param *ctx wbclient Context * @param *sid Pointer to the domain SID to be resolved * @param *pgid Pointer to the resolved gid_t value * * @return #wbcErr * **/ +wbcErr wbcCtxSidToGid(struct wbcContext *ctx, + const struct wbcDomainSid *sid, + gid_t *pgid); wbcErr wbcSidToGid(const struct wbcDomainSid *sid, gid_t *pgid); @@ -808,12 +871,15 @@ wbcErr wbcQuerySidToGid(const struct wbcDomainSid *sid, /** * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed * + * @param *ctx wbclient Context * @param gid Unix gid to be resolved * @param *sid Pointer to the resolved domain SID * * @return #wbcErr * **/ +wbcErr wbcCtxGidToSid(struct wbcContext *ctx, gid_t gid, + struct wbcDomainSid *sid); wbcErr wbcGidToSid(gid_t gid, struct wbcDomainSid *sid); @@ -849,6 +915,7 @@ struct wbcUnixId { /** * @brief Convert a list of sids to unix ids * + * @param *ctx wbclient Context * @param sids Pointer to an array of SIDs to convert * @param num_sids Number of SIDs * @param ids Preallocated output array for translated IDs @@ -856,25 +923,32 @@ struct wbcUnixId { * @return #wbcErr * **/ +wbcErr wbcCtxSidsToUnixIds(struct wbcContext *ctx, + const struct wbcDomainSid *sids, uint32_t num_sids, + struct wbcUnixId *ids); wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids, struct wbcUnixId *ids); /** * @brief Obtain a new uid from Winbind * - * @param *puid *pointer to the allocated uid + * @param *ctx wbclient Context + * @param *puid Pointer to the allocated uid * * @return #wbcErr **/ +wbcErr wbcCtxAllocateUid(struct wbcContext *ctx, uid_t *puid); wbcErr wbcAllocateUid(uid_t *puid); /** * @brief Obtain a new gid from Winbind * - * @param *pgid Pointer to the allocated gid + * @param *ctx wbclient Context + * @param *pgid Pointer to the allocated gid * * @return #wbcErr **/ +wbcErr wbcCtxAllocateGid(struct wbcContext *ctx, gid_t *pgid); wbcErr wbcAllocateGid(gid_t *pgid); /** @@ -961,101 +1035,132 @@ wbcErr wbcSetGidHwm(gid_t gid_hwm); * @brief Fill in a struct passwd* for a domain user based * on username * + * @param *ctx wbclient Context * @param *name Username to lookup * @param **pwd Pointer to resulting struct passwd* from the query. * * @return #wbcErr **/ +wbcErr wbcCtxGetpwnam(struct wbcContext *ctx, + const char *name, struct passwd **pwd); wbcErr wbcGetpwnam(const char *name, struct passwd **pwd); /** * @brief Fill in a struct passwd* for a domain user based * on uid * + * @param *ctx wbclient Context * @param uid Uid to lookup * @param **pwd Pointer to resulting struct passwd* from the query. * * @return #wbcErr **/ +wbcErr wbcCtxGetpwuid(struct wbcContext *ctx, + uid_t uid, struct passwd **pwd); wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd); /** * @brief Fill in a struct passwd* for a domain user based * on sid * + * @param *ctx wbclient Context * @param sid Sid to lookup * @param **pwd Pointer to resulting struct passwd* from the query. * * @return #wbcErr **/ +wbcErr wbcCtxGetpwsid(struct wbcContext *ctx, + struct wbcDomainSid * sid, struct passwd **pwd); wbcErr wbcGetpwsid(struct wbcDomainSid * sid, struct passwd **pwd); /** * @brief Fill in a struct passwd* for a domain user based * on username * + * @param *ctx wbclient Context * @param *name Username to lookup * @param **grp Pointer to resulting struct group* from the query. * * @return #wbcErr **/ +wbcErr wbcCtxGetgrnam(struct wbcContext *ctx, + const char *name, struct group **grp); wbcErr wbcGetgrnam(const char *name, struct group **grp); /** * @brief Fill in a struct passwd* for a domain user based * on uid * + * @param *ctx wbclient Context * @param gid Uid to lookup * @param **grp Pointer to resulting struct group* from the query. * * @return #wbcErr **/ +wbcErr wbcCtxGetgrgid(struct wbcContext *ctx, + gid_t gid, struct group **grp); wbcErr wbcGetgrgid(gid_t gid, struct group **grp); /** * @brief Reset the passwd iterator * + * @param *ctx wbclient Context + * * @return #wbcErr **/ +wbcErr wbcCtxSetpwent(struct wbcContext *ctx); wbcErr wbcSetpwent(void); /** * @brief Close the passwd iterator * + * @param *ctx wbclient Context + * * @return #wbcErr **/ +wbcErr wbcCtxEndpwent(struct wbcContext *ctx); wbcErr wbcEndpwent(void); /** * @brief Return the next struct passwd* entry from the pwent iterator * - * @param **pwd Pointer to resulting struct passwd* from the query. + * @param *ctx wbclient Context + * @param **pwd Pointer to resulting struct passwd* from the query. * * @return #wbcErr **/ +wbcErr wbcCtxGetpwent(struct wbcContext *ctx, struct passwd **pwd); wbcErr wbcGetpwent(struct passwd **pwd); /** * @brief Reset the group iterator * + * @param *ctx wbclient Context + * * @return #wbcErr **/ +wbcErr wbcCtxSetgrent(struct wbcContext *ctx); wbcErr wbcSetgrent(void); /** * @brief Close the group iterator * + * @param *ctx wbclient Context + * * @return #wbcErr **/ +wbcErr wbcCtxEndgrent(struct wbcContext *ctx); wbcErr wbcEndgrent(void); /** * @brief Return the next struct group* entry from the pwent iterator * - * @param **grp Pointer to resulting struct group* from the query. + * @param *ctx wbclient Context + * @param **grp Pointer to resulting struct group* from the query. * * @return #wbcErr **/ +wbcErr wbcCtxGetgrent(struct wbcContext *ctx, struct group **grp); wbcErr wbcGetgrent(struct group **grp); /** @@ -1063,21 +1168,28 @@ wbcErr wbcGetgrent(struct group **grp); * * This is similar to #wbcGetgrent, just that the member list is empty * - * @param **grp Pointer to resulting struct group* from the query. + * @param *ctx wbclient Context + * @param **grp Pointer to resulting struct group* from the query. * * @return #wbcErr **/ +wbcErr wbcCtxGetgrlist(struct wbcContext *ctx, struct group **grp); wbcErr wbcGetgrlist(struct group **grp); /** * @brief Return the unix group array belonging to the given user * + * @param *ctx wbclient Context * @param *account The given user name * @param *num_groups Number of elements returned in the groups array * @param **_groups Pointer to resulting gid_t array. * * @return #wbcErr **/ +wbcErr wbcCtxGetGroups(struct wbcContext *ctx, + const char *account, + uint32_t *num_groups, + gid_t **_groups); wbcErr wbcGetGroups(const char *account, uint32_t *num_groups, gid_t **_groups); @@ -1090,18 +1202,23 @@ wbcErr wbcGetGroups(const char *account, /** * @brief Lookup the current status of a trusted domain * - * @param domain The domain to query + * @param *ctx wbclient Context + * @param domain The domain to query * * @param dinfo A pointer to store the returned domain_info struct. * * @return #wbcErr **/ +wbcErr wbcCtxDomainInfo(struct wbcContext *ctx, + const char *domain, + struct wbcDomainInfo **dinfo); wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo); /** * @brief Lookup the currently contacted DCs * + * @param *ctx wbclient Context * @param domain The domain to query * * @param num_dcs Number of DCs currently known @@ -1110,17 +1227,24 @@ wbcErr wbcDomainInfo(const char *domain, * * @return #wbcErr **/ +wbcErr wbcCtxDcInfo(struct wbcContext *ctx, + const char *domain, size_t *num_dcs, + const char ***dc_names, const char ***dc_ips); wbcErr wbcDcInfo(const char *domain, size_t *num_dcs, const char ***dc_names, const char ***dc_ips); /** * @brief Enumerate the domain trusts known by Winbind * + * @param *ctx wbclient Context * @param **domains Pointer to the allocated domain list array * @param *num_domains Pointer to number of domains returned * * @return #wbcErr **/ +wbcErr wbcCtxListTrusts(struct wbcContext *ctx, + struct wbcDomainInfo **domains, + size_t *num_domains); wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains); @@ -1149,12 +1273,17 @@ wbcErr wbcListTrusts(struct wbcDomainInfo **domains, /** * @brief Enumerate the domain trusts known by Winbind * + * @param *ctx wbclient Context * @param domain Name of the domain to query for a DC * @param flags Bit flags used to control the domain location query * @param *dc_info Pointer to the returned domain controller information * * @return #wbcErr **/ +wbcErr wbcCtxLookupDomainController(struct wbcContext *ctx, + const char *domain, + uint32_t flags, + struct wbcDomainControllerInfo **dc_info); wbcErr wbcLookupDomainController(const char *domain, uint32_t flags, struct wbcDomainControllerInfo **dc_info); @@ -1162,6 +1291,7 @@ wbcErr wbcLookupDomainController(const char *domain, /** * @brief Get extended domain controller information * + * @param *ctx wbclient Context * @param domain Name of the domain to query for a DC * @param guid Guid of the domain to query for a DC * @param site Site of the domain to query for a DC @@ -1170,6 +1300,12 @@ wbcErr wbcLookupDomainController(const char *domain, * * @return #wbcErr **/ +wbcErr wbcCtxLookupDomainControllerEx(struct wbcContext *ctx, + const char *domain, + struct wbcGuid *guid, + const char *site, + uint32_t flags, + struct wbcDomainControllerInfoEx **dc_info); wbcErr wbcLookupDomainControllerEx(const char *domain, struct wbcGuid *guid, const char *site, @@ -1183,17 +1319,22 @@ wbcErr wbcLookupDomainControllerEx(const char *domain, /** * @brief Authenticate a username/password pair * + * @param *ctx wbclient Context * @param username Name of user to authenticate * @param password Clear text password os user * * @return #wbcErr **/ +wbcErr wbcCtxAuthenticateUser(struct wbcContext *ctx, + const char *username, + const char *password); wbcErr wbcAuthenticateUser(const char *username, const char *password); /** * @brief Authenticate with more detailed information * + * @param *ctx wbclient Context * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH * is not supported yet * @param info Output details on WBC_ERR_SUCCESS @@ -1201,6 +1342,10 @@ wbcErr wbcAuthenticateUser(const char *username, * * @return #wbcErr **/ +wbcErr wbcCtxAuthenticateUserEx(struct wbcContext *ctx, + const struct wbcAuthUserParams *params, + struct wbcAuthUserInfo **info, + struct wbcAuthErrorInfo **error); wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, struct wbcAuthUserInfo **info, struct wbcAuthErrorInfo **error); @@ -1223,6 +1368,7 @@ wbcErr wbcLogonUser(const struct wbcLogonUserParams *params, /** * @brief Trigger a logoff notification to Winbind for a specific user * + * @param *ctx wbclient Context * @param username Name of user to remove from Winbind's list of * logged on users. * @param uid Uid assigned to the username @@ -1231,6 +1377,9 @@ wbcErr wbcLogonUser(const struct wbcLogonUserParams *params, * * @return #wbcErr **/ +wbcErr wbcCtxLogoffUser(struct wbcContext *ctx, + const char *username, uid_t uid, + const char *ccfilename); wbcErr wbcLogoffUser(const char *username, uid_t uid, const char *ccfilename); @@ -1238,23 +1387,32 @@ wbcErr wbcLogoffUser(const char *username, /** * @brief Trigger an extended logoff notification to Winbind for a specific user * + * @param *ctx wbclient Context * @param params A wbcLogoffUserParams structure * @param error User output details on error * * @return #wbcErr **/ +wbcErr wbcCtxLogoffUserEx(struct wbcContext *ctx, + const struct wbcLogoffUserParams *params, + struct wbcAuthErrorInfo **error); wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params, struct wbcAuthErrorInfo **error); /** * @brief Change a password for a user * + * @param *ctx wbclient Context * @param username Name of user to authenticate * @param old_password Old clear text password of user * @param new_password New clear text password of user * * @return #wbcErr **/ +wbcErr wbcCtxChangeUserPassword(struct wbcContext *ctx, + const char *username, + const char *old_password, + const char *new_password); wbcErr wbcChangeUserPassword(const char *username, const char *old_password, const char *new_password); @@ -1263,6 +1421,7 @@ wbcErr wbcChangeUserPassword(const char *username, * @brief Change a password for a user with more detailed information upon * failure * + * @param *ctx wbclient Context * @param params Input parameters * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED @@ -1270,6 +1429,11 @@ wbcErr wbcChangeUserPassword(const char *username, * * @return #wbcErr **/ +wbcErr wbcCtxChangeUserPasswordEx(struct wbcContext *ctx, + const struct wbcChangePasswordParams *params, + struct wbcAuthErrorInfo **error, + enum wbcPasswordChangeRejectReason *reject_reason, + struct wbcUserPasswordPolicyInfo **policy); wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params, struct wbcAuthErrorInfo **error, enum wbcPasswordChangeRejectReason *reject_reason, @@ -1278,12 +1442,17 @@ wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params, /** * @brief Authenticate a user with cached credentials * + * @param *ctx wbclient Context * @param *params Pointer to a wbcCredentialCacheParams structure * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure * * @return #wbcErr **/ +wbcErr wbcCtxCredentialCache(struct wbcContext *ctx, + struct wbcCredentialCacheParams *params, + struct wbcCredentialCacheInfo **info, + struct wbcAuthErrorInfo **error); wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params, struct wbcCredentialCacheInfo **info, struct wbcAuthErrorInfo **error); @@ -1291,11 +1460,14 @@ wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params, /** * @brief Save a password with winbind for doing wbcCredentialCache() later * + * @param *ctx wbclient Context * @param *user Username * @param *password Password * * @return #wbcErr **/ +wbcErr wbcCtxCredentialSave(struct wbcContext *ctx, + const char *user, const char *password); wbcErr wbcCredentialSave(const char *user, const char *password); /********************************************************** @@ -1305,22 +1477,28 @@ wbcErr wbcCredentialSave(const char *user, const char *password); /** * @brief Resolve a NetbiosName via WINS * + * @param *ctx wbclient Context * @param name Name to resolve * @param *ip Pointer to the ip address string * * @return #wbcErr **/ +wbcErr wbcCtxResolveWinsByName(struct wbcContext *ctx, + const char *name, char **ip); wbcErr wbcResolveWinsByName(const char *name, char **ip); /** * @brief Resolve an IP address via WINS into a NetbiosName * - * @param ip The ip address string - * @param *name Pointer to the name + * @param *ctx wbclient Context + * @param ip The ip address string + * @param *name Pointer to the name * * @return #wbcErr * **/ +wbcErr wbcCtxResolveWinsByIP(struct wbcContext *ctx, + const char *ip, char **name); wbcErr wbcResolveWinsByIP(const char *ip, char **name); /********************************************************** @@ -1330,22 +1508,28 @@ wbcErr wbcResolveWinsByIP(const char *ip, char **name); /** * @brief Trigger a verification of the trust credentials of a specific domain * + * @param *ctx wbclient Context * @param *domain The name of the domain. * @param error Output details on WBC_ERR_AUTH_ERROR * * @return #wbcErr **/ +wbcErr wbcCtxCheckTrustCredentials(struct wbcContext *ctx, const char *domain, + struct wbcAuthErrorInfo **error); wbcErr wbcCheckTrustCredentials(const char *domain, struct wbcAuthErrorInfo **error); /** * @brief Trigger a change of the trust credentials for a specific domain * + * @param *ctx wbclient Context * @param *domain The name of the domain. * @param error Output details on WBC_ERR_AUTH_ERROR * * @return #wbcErr **/ +wbcErr wbcCtxChangeTrustCredentials(struct wbcContext *ctx, const char *domain, + struct wbcAuthErrorInfo **error); wbcErr wbcChangeTrustCredentials(const char *domain, struct wbcAuthErrorInfo **error); @@ -1353,6 +1537,7 @@ wbcErr wbcChangeTrustCredentials(const char *domain, * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost * version of wbcCheckTrustCredentials * + * @param *ctx wbclient Context * @param *domain The name of the domain, only NULL for the default domain is * supported yet. Other values than NULL will result in * WBC_ERR_NOT_IMPLEMENTED. @@ -1360,12 +1545,15 @@ wbcErr wbcChangeTrustCredentials(const char *domain, * * @return #wbcErr **/ +wbcErr wbcCtxPingDc(struct wbcContext *ctx, const char *domain, + struct wbcAuthErrorInfo **error); wbcErr wbcPingDc(const char *domain, struct wbcAuthErrorInfo **error); /** * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost * version of wbcCheckTrustCredentials * + * @param *ctx wbclient Context * @param *domain The name of the domain, only NULL for the default domain is * supported yet. Other values than NULL will result in * WBC_ERR_NOT_IMPLEMENTED. @@ -1374,6 +1562,9 @@ wbcErr wbcPingDc(const char *domain, struct wbcAuthErrorInfo **error); * * @return #wbcErr **/ +wbcErr wbcCtxPingDc2(struct wbcContext *ctx, const char *domain, + struct wbcAuthErrorInfo **error, + char **dcname); wbcErr wbcPingDc2(const char *domain, struct wbcAuthErrorInfo **error, char **dcname); -- 1.7.10.4