1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-23 09:57:40 +03:00

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 <matthew-git@newtoncomputing.co.uk>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Matthew Newton 2015-02-21 22:30:11 +00:00 committed by Jeremy Allison
parent 348f93ff6e
commit 063c56dba5
6 changed files with 1161 additions and 176 deletions

View File

@ -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);
}

View File

@ -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(&params, NULL, NULL);
wbc_status = wbcCtxAuthenticateUserEx(ctx, &params, 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) {
@ -547,9 +555,16 @@ done:
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;
@ -649,7 +682,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);
@ -679,9 +712,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;
@ -744,7 +784,7 @@ wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params,
/* Send request */
wbc_status = wbcRequestResponse(WINBINDD_PAM_LOGOFF,
wbc_status = wbcRequestResponse(ctx, WINBINDD_PAM_LOGOFF,
&request,
&response);
@ -765,10 +805,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;
@ -795,7 +841,7 @@ wbcErr wbcLogoffUser(const char *username,
/* Send request */
wbc_status = wbcRequestResponse(WINBINDD_PAM_LOGOFF,
wbc_status = wbcRequestResponse(ctx, WINBINDD_PAM_LOGOFF,
&request,
&response);
@ -805,11 +851,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;
@ -968,7 +1022,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)) {
@ -1003,10 +1057,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;
@ -1018,21 +1082,30 @@ wbcErr wbcChangeUserPassword(const char *username,
params.old_password.plaintext = old_password;
params.new_password.plaintext = new_password;
wbc_status = wbcChangeUserPasswordEx(&params,
NULL,
NULL,
NULL);
wbc_status = wbcCtxChangeUserPasswordEx(ctx, &params,
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;
@ -1134,7 +1207,7 @@ wbcErr wbcLogonUser(const struct wbcLogonUserParams *params,
}
}
wbc_status = wbcRequestResponse(WINBINDD_PAM_AUTH,
wbc_status = wbcRequestResponse(ctx, WINBINDD_PAM_AUTH,
&request,
&response);
@ -1168,6 +1241,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 =
@ -1176,9 +1257,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;
@ -1223,7 +1305,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;
}
@ -1272,8 +1355,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;
}
@ -1312,8 +1395,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;
@ -1327,5 +1418,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);
}

View File

@ -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);
}

View File

@ -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) {

View File

@ -27,10 +27,12 @@
#include "../winbind_client.h"
/** @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;

View File

@ -627,6 +627,15 @@ wbcErr wbcGuidToString(const struct wbcGuid *guid,
wbcErr wbcStringToGuid(const char *guid_string,
struct wbcGuid *guid);
/**
* @brief Ping winbindd to see if the daemon is running
*
* @param *ctx wbclient Context
*
* @return #wbcErr
**/
wbcErr wbcCtxPing(struct wbcContext *ctx);
/**
* @brief Ping winbindd to see if the daemon is running
*
@ -636,12 +645,31 @@ wbcErr wbcPing(void);
wbcErr wbcLibraryDetails(struct wbcLibraryDetails **details);
wbcErr wbcCtxInterfaceDetails(struct wbcContext *ctx,
struct wbcInterfaceDetails **details);
wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details);
/**********************************************************
* Name/SID conversion
**********************************************************/
/**
* @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
* @param *name_type Pointer to the SID type
*
* @return #wbcErr
**/
wbcErr wbcCtxLookupName(struct wbcContext *ctx,
const char *dom_name,
const char *name,
struct wbcDomainSid *sid,
enum wbcSidType *name_type);
/**
* @brief Convert a domain and name to SID
*
@ -660,7 +688,24 @@ 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);
/**
* @brief Convert a SID to a domain and name
*
* @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
@ -678,10 +723,26 @@ 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);
/**
* @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);
/**
* @brief Translate a collection of RIDs within a domain to names
*/
@ -692,6 +753,15 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
const char ***names,
enum wbcSidType **types);
/*
* @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);
/*
* @brief Get the groups a user belongs to
**/
@ -700,6 +770,16 @@ wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid,
uint32_t *num_sids,
struct wbcDomainSid **sids);
/*
* @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);
/*
* @brief Get alias membership for sids
**/
@ -709,6 +789,14 @@ wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid,
uint32_t **alias_rids,
uint32_t *num_alias_rids);
/**
* @brief Lists Users
**/
wbcErr wbcCtxListUsers(struct wbcContext *ctx,
const char *domain_name,
uint32_t *num_users,
const char ***users);
/**
* @brief Lists Users
**/
@ -716,6 +804,14 @@ wbcErr wbcListUsers(const char *domain_name,
uint32_t *num_users,
const char ***users);
/**
* @brief Lists Groups
**/
wbcErr wbcCtxListGroups(struct wbcContext *ctx,
const char *domain_name,
uint32_t *num_groups,
const char ***groups);
/**
* @brief Lists Groups
**/
@ -723,6 +819,12 @@ 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,
@ -732,6 +834,20 @@ wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid,
* SID/uid/gid Mappings
**********************************************************/
/**
* @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);
/**
* @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
*
@ -756,6 +872,19 @@ wbcErr wbcSidToUid(const struct wbcDomainSid *sid,
wbcErr wbcQuerySidToUid(const struct wbcDomainSid *sid,
uid_t *puid);
/**
* @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);
/**
* @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
*
@ -780,6 +909,20 @@ wbcErr wbcUidToSid(uid_t uid,
wbcErr wbcQueryUidToSid(uid_t uid,
struct wbcDomainSid *sid);
/**
* @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);
/**
* @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
*
@ -804,6 +947,19 @@ wbcErr wbcSidToGid(const struct wbcDomainSid *sid,
wbcErr wbcQuerySidToGid(const struct wbcDomainSid *sid,
gid_t *pgid);
/**
* @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);
/**
* @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
*
@ -845,6 +1001,21 @@ struct wbcUnixId {
union wbcUnixIdContainer id;
};
/**
* @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
*
* @return #wbcErr
*
**/
wbcErr wbcCtxSidsToUnixIds(struct wbcContext *ctx,
const struct wbcDomainSid *sids, uint32_t num_sids,
struct wbcUnixId *ids);
/**
* @brief Convert a list of sids to unix ids
*
@ -861,7 +1032,17 @@ wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids,
/**
* @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);
/**
* @brief Obtain a new uid from Winbind
*
* @param *puid Pointer to the allocated uid
*
* @return #wbcErr
**/
@ -870,7 +1051,17 @@ 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);
/**
* @brief Obtain a new gid from Winbind
*
* @param *pgid Pointer to the allocated gid
*
* @return #wbcErr
**/
@ -956,6 +1147,19 @@ wbcErr wbcSetGidHwm(gid_t gid_hwm);
* NSS Lookup User/Group details
**********************************************************/
/**
* @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);
/**
* @brief Fill in a struct passwd* for a domain user based
* on username
@ -967,6 +1171,19 @@ wbcErr wbcSetGidHwm(gid_t gid_hwm);
**/
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);
/**
* @brief Fill in a struct passwd* for a domain user based
* on uid
@ -978,6 +1195,19 @@ wbcErr wbcGetpwnam(const char *name, 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);
/**
* @brief Fill in a struct passwd* for a domain user based
* on sid
@ -989,6 +1219,19 @@ wbcErr wbcGetpwuid(uid_t uid, 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);
/**
* @brief Fill in a struct passwd* for a domain user based
* on username
@ -1000,6 +1243,19 @@ wbcErr wbcGetpwsid(struct wbcDomainSid * sid, struct passwd **pwd);
**/
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);
/**
* @brief Fill in a struct passwd* for a domain user based
* on uid
@ -1011,6 +1267,15 @@ wbcErr wbcGetgrnam(const char *name, 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);
/**
* @brief Reset the passwd iterator
*
@ -1018,6 +1283,15 @@ wbcErr wbcGetgrgid(gid_t gid, struct group **grp);
**/
wbcErr wbcSetpwent(void);
/**
* @brief Close the passwd iterator
*
* @param *ctx wbclient Context
*
* @return #wbcErr
**/
wbcErr wbcCtxEndpwent(struct wbcContext *ctx);
/**
* @brief Close the passwd iterator
*
@ -1028,12 +1302,31 @@ 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);
/**
* @brief Return the next struct passwd* entry from the pwent iterator
*
* @param **pwd Pointer to resulting struct passwd* from the query.
*
* @return #wbcErr
**/
wbcErr wbcGetpwent(struct passwd **pwd);
/**
* @brief Reset the group iterator
*
* @param *ctx wbclient Context
*
* @return #wbcErr
**/
wbcErr wbcCtxSetgrent(struct wbcContext *ctx);
/**
* @brief Reset the group iterator
*
@ -1041,6 +1334,15 @@ wbcErr wbcGetpwent(struct passwd **pwd);
**/
wbcErr wbcSetgrent(void);
/**
* @brief Close the group iterator
*
* @param *ctx wbclient Context
*
* @return #wbcErr
**/
wbcErr wbcCtxEndgrent(struct wbcContext *ctx);
/**
* @brief Close the group iterator
*
@ -1051,7 +1353,17 @@ 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);
/**
* @brief Return the next struct group* entry from the pwent iterator
*
* @param **grp Pointer to resulting struct group* from the query.
*
* @return #wbcErr
**/
@ -1062,12 +1374,39 @@ 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);
/**
* @brief Return the next struct group* entry from the pwent iterator
*
* This is similar to #wbcGetgrent, just that the member list is empty
*
* @param **grp Pointer to resulting struct group* from the query.
*
* @return #wbcErr
**/
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);
/**
* @brief Return the unix group array belonging to the given user
*
@ -1089,7 +1428,21 @@ 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);
/**
* @brief Lookup the current status of a trusted domain
*
* @param domain The domain to query
*
* @param dinfo A pointer to store the returned domain_info struct.
*
@ -1098,6 +1451,22 @@ wbcErr wbcGetGroups(const char *account,
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
* @param dc_names Names of the currently known DCs
* @param dc_ips IP addresses of the currently known DCs
*
* @return #wbcErr
**/
wbcErr wbcCtxDcInfo(struct wbcContext *ctx,
const char *domain, size_t *num_dcs,
const char ***dc_names, const char ***dc_ips);
/**
* @brief Lookup the currently contacted DCs
*
@ -1112,6 +1481,19 @@ wbcErr wbcDomainInfo(const char *domain,
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);
/**
* @brief Enumerate the domain trusts known by Winbind
*
@ -1145,6 +1527,21 @@ wbcErr wbcListTrusts(struct wbcDomainInfo **domains,
#define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
#define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
/**
* @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);
/**
* @brief Enumerate the domain trusts known by Winbind
*
@ -1158,6 +1555,25 @@ wbcErr wbcLookupDomainController(const char *domain,
uint32_t flags,
struct wbcDomainControllerInfo **dc_info);
/**
* @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
* @param flags Bit flags used to control the domain location query
* @param *dc_info Pointer to the returned extended domain controller information
*
* @return #wbcErr
**/
wbcErr wbcCtxLookupDomainControllerEx(struct wbcContext *ctx,
const char *domain,
struct wbcGuid *guid,
const char *site,
uint32_t flags,
struct wbcDomainControllerInfoEx **dc_info);
/**
* @brief Get extended domain controller information
*
@ -1179,6 +1595,19 @@ wbcErr wbcLookupDomainControllerEx(const char *domain,
* Athenticate functions
**********************************************************/
/**
* @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);
/**
* @brief Authenticate a username/password pair
*
@ -1190,6 +1619,22 @@ wbcErr wbcLookupDomainControllerEx(const char *domain,
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
* @param error Output details on WBC_ERR_AUTH_ERROR
*
* @return #wbcErr
**/
wbcErr wbcCtxAuthenticateUserEx(struct wbcContext *ctx,
const struct wbcAuthUserParams *params,
struct wbcAuthUserInfo **info,
struct wbcAuthErrorInfo **error);
/**
* @brief Authenticate with more detailed information
*
@ -1204,6 +1649,23 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
struct wbcAuthUserInfo **info,
struct wbcAuthErrorInfo **error);
/**
* @brief Logon a User
*
* @param[in] *ctx wbclient Context
* @param[in] params Pointer to a wbcLogonUserParams structure
* @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
* @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
* @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
*
* @return #wbcErr
**/
wbcErr wbcCtxLogonUser(struct wbcContext *ctx,
const struct wbcLogonUserParams *params,
struct wbcLogonUserInfo **info,
struct wbcAuthErrorInfo **error,
struct wbcUserPasswordPolicyInfo **policy);
/**
* @brief Logon a User
*
@ -1219,6 +1681,22 @@ wbcErr wbcLogonUser(const struct wbcLogonUserParams *params,
struct wbcAuthErrorInfo **error,
struct wbcUserPasswordPolicyInfo **policy);
/**
* @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
* @param ccfilename Absolute path to the Krb5 credentials cache to
* be removed
*
* @return #wbcErr
**/
wbcErr wbcCtxLogoffUser(struct wbcContext *ctx,
const char *username, uid_t uid,
const char *ccfilename);
/**
* @brief Trigger a logoff notification to Winbind for a specific user
*
@ -1234,6 +1712,19 @@ wbcErr wbcLogoffUser(const char *username,
uid_t uid,
const char *ccfilename);
/**
* @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);
/**
* @brief Trigger an extended logoff notification to Winbind for a specific user
*
@ -1245,6 +1736,21 @@ wbcErr wbcLogoffUser(const char *username,
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);
/**
* @brief Change a password for a user
*
@ -1258,6 +1764,24 @@ wbcErr wbcChangeUserPassword(const char *username,
const char *old_password,
const char *new_password);
/**
* @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
* @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
*
* @return #wbcErr
**/
wbcErr wbcCtxChangeUserPasswordEx(struct wbcContext *ctx,
const struct wbcChangePasswordParams *params,
struct wbcAuthErrorInfo **error,
enum wbcPasswordChangeRejectReason *reject_reason,
struct wbcUserPasswordPolicyInfo **policy);
/**
* @brief Change a password for a user with more detailed information upon
* failure
@ -1274,6 +1798,21 @@ wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params,
enum wbcPasswordChangeRejectReason *reject_reason,
struct wbcUserPasswordPolicyInfo **policy);
/**
* @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);
/**
* @brief Authenticate a user with cached credentials
*
@ -1287,6 +1826,18 @@ wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params,
struct wbcCredentialCacheInfo **info,
struct wbcAuthErrorInfo **error);
/**
* @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);
/**
* @brief Save a password with winbind for doing wbcCredentialCache() later
*
@ -1301,6 +1852,18 @@ wbcErr wbcCredentialSave(const char *user, const char *password);
* Resolve functions
**********************************************************/
/**
* @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);
/**
* @brief Resolve a NetbiosName via WINS
*
@ -1314,8 +1877,21 @@ 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);
/**
* @brief Resolve an IP address via WINS into a NetbiosName
*
* @param ip The ip address string
* @param *name Pointer to the name
*
* @return #wbcErr
*
@ -1326,6 +1902,18 @@ wbcErr wbcResolveWinsByIP(const char *ip, char **name);
* Trusted domain functions
**********************************************************/
/**
* @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);
/**
* @brief Trigger a verification of the trust credentials of a specific domain
*
@ -1337,6 +1925,18 @@ wbcErr wbcResolveWinsByIP(const char *ip, char **name);
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);
/**
* @brief Trigger a change of the trust credentials for a specific domain
*
@ -1348,6 +1948,21 @@ wbcErr wbcCheckTrustCredentials(const char *domain,
wbcErr wbcChangeTrustCredentials(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.
* @param error Output details on WBC_ERR_AUTH_ERROR
*
* @return #wbcErr
**/
wbcErr wbcCtxPingDc(struct wbcContext *ctx, const char *domain,
struct wbcAuthErrorInfo **error);
/**
* @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
* version of wbcCheckTrustCredentials
@ -1361,6 +1976,23 @@ wbcErr wbcChangeTrustCredentials(const char *domain,
**/
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.
* @param error Output details on WBC_ERR_AUTH_ERROR
* @param dcname DC that was attempted to ping
*
* @return #wbcErr
**/
wbcErr wbcCtxPingDc2(struct wbcContext *ctx, const char *domain,
struct wbcAuthErrorInfo **error,
char **dcname);
/**
* @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
* version of wbcCheckTrustCredentials