mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
libwbclient: Implement wbc[Ctx]UnixIdsToSids
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
parent
5cd5ce70a1
commit
171931cf7d
132
nsswitch/libwbclient/ABI/wbclient-0.13.sigs
Normal file
132
nsswitch/libwbclient/ABI/wbclient-0.13.sigs
Normal file
@ -0,0 +1,132 @@
|
||||
wbcAddNamedBlob: wbcErr (size_t *, struct wbcNamedBlob **, const char *, uint32_t, uint8_t *, size_t)
|
||||
wbcAllocateGid: wbcErr (gid_t *)
|
||||
wbcAllocateMemory: void *(size_t, size_t, void (*)(void *))
|
||||
wbcAllocateStringArray: const char **(int)
|
||||
wbcAllocateUid: wbcErr (uid_t *)
|
||||
wbcAuthenticateUser: wbcErr (const char *, const char *)
|
||||
wbcAuthenticateUserEx: wbcErr (const struct wbcAuthUserParams *, struct wbcAuthUserInfo **, struct wbcAuthErrorInfo **)
|
||||
wbcChangeTrustCredentials: wbcErr (const char *, struct wbcAuthErrorInfo **)
|
||||
wbcChangeUserPassword: wbcErr (const char *, const char *, const char *)
|
||||
wbcChangeUserPasswordEx: wbcErr (const struct wbcChangePasswordParams *, struct wbcAuthErrorInfo **, enum wbcPasswordChangeRejectReason *, struct wbcUserPasswordPolicyInfo **)
|
||||
wbcCheckTrustCredentials: wbcErr (const char *, struct wbcAuthErrorInfo **)
|
||||
wbcCredentialCache: wbcErr (struct wbcCredentialCacheParams *, struct wbcCredentialCacheInfo **, struct wbcAuthErrorInfo **)
|
||||
wbcCredentialSave: wbcErr (const char *, const char *)
|
||||
wbcCtxAllocateGid: wbcErr (struct wbcContext *, gid_t *)
|
||||
wbcCtxAllocateUid: wbcErr (struct wbcContext *, uid_t *)
|
||||
wbcCtxAuthenticateUser: wbcErr (struct wbcContext *, const char *, const char *)
|
||||
wbcCtxAuthenticateUserEx: wbcErr (struct wbcContext *, const struct wbcAuthUserParams *, struct wbcAuthUserInfo **, struct wbcAuthErrorInfo **)
|
||||
wbcCtxChangeTrustCredentials: wbcErr (struct wbcContext *, const char *, struct wbcAuthErrorInfo **)
|
||||
wbcCtxChangeUserPassword: wbcErr (struct wbcContext *, const char *, const char *, const char *)
|
||||
wbcCtxChangeUserPasswordEx: wbcErr (struct wbcContext *, const struct wbcChangePasswordParams *, struct wbcAuthErrorInfo **, enum wbcPasswordChangeRejectReason *, struct wbcUserPasswordPolicyInfo **)
|
||||
wbcCtxCheckTrustCredentials: wbcErr (struct wbcContext *, const char *, struct wbcAuthErrorInfo **)
|
||||
wbcCtxCreate: struct wbcContext *(void)
|
||||
wbcCtxCredentialCache: wbcErr (struct wbcContext *, struct wbcCredentialCacheParams *, struct wbcCredentialCacheInfo **, struct wbcAuthErrorInfo **)
|
||||
wbcCtxCredentialSave: wbcErr (struct wbcContext *, const char *, const char *)
|
||||
wbcCtxDcInfo: wbcErr (struct wbcContext *, const char *, size_t *, const char ***, const char ***)
|
||||
wbcCtxDomainInfo: wbcErr (struct wbcContext *, const char *, struct wbcDomainInfo **)
|
||||
wbcCtxEndgrent: wbcErr (struct wbcContext *)
|
||||
wbcCtxEndpwent: wbcErr (struct wbcContext *)
|
||||
wbcCtxFree: void (struct wbcContext *)
|
||||
wbcCtxGetDisplayName: wbcErr (struct wbcContext *, const struct wbcDomainSid *, char **, char **, enum wbcSidType *)
|
||||
wbcCtxGetGroups: wbcErr (struct wbcContext *, const char *, uint32_t *, gid_t **)
|
||||
wbcCtxGetSidAliases: wbcErr (struct wbcContext *, const struct wbcDomainSid *, struct wbcDomainSid *, uint32_t, uint32_t **, uint32_t *)
|
||||
wbcCtxGetgrent: wbcErr (struct wbcContext *, struct group **)
|
||||
wbcCtxGetgrgid: wbcErr (struct wbcContext *, gid_t, struct group **)
|
||||
wbcCtxGetgrlist: wbcErr (struct wbcContext *, struct group **)
|
||||
wbcCtxGetgrnam: wbcErr (struct wbcContext *, const char *, struct group **)
|
||||
wbcCtxGetpwent: wbcErr (struct wbcContext *, struct passwd **)
|
||||
wbcCtxGetpwnam: wbcErr (struct wbcContext *, const char *, struct passwd **)
|
||||
wbcCtxGetpwsid: wbcErr (struct wbcContext *, struct wbcDomainSid *, struct passwd **)
|
||||
wbcCtxGetpwuid: wbcErr (struct wbcContext *, uid_t, struct passwd **)
|
||||
wbcCtxGidToSid: wbcErr (struct wbcContext *, gid_t, struct wbcDomainSid *)
|
||||
wbcCtxInterfaceDetails: wbcErr (struct wbcContext *, struct wbcInterfaceDetails **)
|
||||
wbcCtxListGroups: wbcErr (struct wbcContext *, const char *, uint32_t *, const char ***)
|
||||
wbcCtxListTrusts: wbcErr (struct wbcContext *, struct wbcDomainInfo **, size_t *)
|
||||
wbcCtxListUsers: wbcErr (struct wbcContext *, const char *, uint32_t *, const char ***)
|
||||
wbcCtxLogoffUser: wbcErr (struct wbcContext *, const char *, uid_t, const char *)
|
||||
wbcCtxLogoffUserEx: wbcErr (struct wbcContext *, const struct wbcLogoffUserParams *, struct wbcAuthErrorInfo **)
|
||||
wbcCtxLogonUser: wbcErr (struct wbcContext *, const struct wbcLogonUserParams *, struct wbcLogonUserInfo **, struct wbcAuthErrorInfo **, struct wbcUserPasswordPolicyInfo **)
|
||||
wbcCtxLookupDomainController: wbcErr (struct wbcContext *, const char *, uint32_t, struct wbcDomainControllerInfo **)
|
||||
wbcCtxLookupDomainControllerEx: wbcErr (struct wbcContext *, const char *, struct wbcGuid *, const char *, uint32_t, struct wbcDomainControllerInfoEx **)
|
||||
wbcCtxLookupName: wbcErr (struct wbcContext *, const char *, const char *, struct wbcDomainSid *, enum wbcSidType *)
|
||||
wbcCtxLookupRids: wbcErr (struct wbcContext *, struct wbcDomainSid *, int, uint32_t *, const char **, const char ***, enum wbcSidType **)
|
||||
wbcCtxLookupSid: wbcErr (struct wbcContext *, const struct wbcDomainSid *, char **, char **, enum wbcSidType *)
|
||||
wbcCtxLookupSids: wbcErr (struct wbcContext *, const struct wbcDomainSid *, int, struct wbcDomainInfo **, int *, struct wbcTranslatedName **)
|
||||
wbcCtxLookupUserSids: wbcErr (struct wbcContext *, const struct wbcDomainSid *, bool, uint32_t *, struct wbcDomainSid **)
|
||||
wbcCtxPing: wbcErr (struct wbcContext *)
|
||||
wbcCtxPingDc: wbcErr (struct wbcContext *, const char *, struct wbcAuthErrorInfo **)
|
||||
wbcCtxPingDc2: wbcErr (struct wbcContext *, const char *, struct wbcAuthErrorInfo **, char **)
|
||||
wbcCtxResolveWinsByIP: wbcErr (struct wbcContext *, const char *, char **)
|
||||
wbcCtxResolveWinsByName: wbcErr (struct wbcContext *, const char *, char **)
|
||||
wbcCtxSetgrent: wbcErr (struct wbcContext *)
|
||||
wbcCtxSetpwent: wbcErr (struct wbcContext *)
|
||||
wbcCtxSidToGid: wbcErr (struct wbcContext *, const struct wbcDomainSid *, gid_t *)
|
||||
wbcCtxSidToUid: wbcErr (struct wbcContext *, const struct wbcDomainSid *, uid_t *)
|
||||
wbcCtxSidsToUnixIds: wbcErr (struct wbcContext *, const struct wbcDomainSid *, uint32_t, struct wbcUnixId *)
|
||||
wbcCtxUidToSid: wbcErr (struct wbcContext *, uid_t, struct wbcDomainSid *)
|
||||
wbcCtxUnixIdsToSids: wbcErr (struct wbcContext *, const struct wbcUnixId *, uint32_t, struct wbcDomainSid *)
|
||||
wbcDcInfo: wbcErr (const char *, size_t *, const char ***, const char ***)
|
||||
wbcDomainInfo: wbcErr (const char *, struct wbcDomainInfo **)
|
||||
wbcEndgrent: wbcErr (void)
|
||||
wbcEndpwent: wbcErr (void)
|
||||
wbcErrorString: const char *(wbcErr)
|
||||
wbcFreeMemory: void (void *)
|
||||
wbcGetDisplayName: wbcErr (const struct wbcDomainSid *, char **, char **, enum wbcSidType *)
|
||||
wbcGetGlobalCtx: struct wbcContext *(void)
|
||||
wbcGetGroups: wbcErr (const char *, uint32_t *, gid_t **)
|
||||
wbcGetSidAliases: wbcErr (const struct wbcDomainSid *, struct wbcDomainSid *, uint32_t, uint32_t **, uint32_t *)
|
||||
wbcGetgrent: wbcErr (struct group **)
|
||||
wbcGetgrgid: wbcErr (gid_t, struct group **)
|
||||
wbcGetgrlist: wbcErr (struct group **)
|
||||
wbcGetgrnam: wbcErr (const char *, struct group **)
|
||||
wbcGetpwent: wbcErr (struct passwd **)
|
||||
wbcGetpwnam: wbcErr (const char *, struct passwd **)
|
||||
wbcGetpwsid: wbcErr (struct wbcDomainSid *, struct passwd **)
|
||||
wbcGetpwuid: wbcErr (uid_t, struct passwd **)
|
||||
wbcGidToSid: wbcErr (gid_t, struct wbcDomainSid *)
|
||||
wbcGuidToString: wbcErr (const struct wbcGuid *, char **)
|
||||
wbcInterfaceDetails: wbcErr (struct wbcInterfaceDetails **)
|
||||
wbcLibraryDetails: wbcErr (struct wbcLibraryDetails **)
|
||||
wbcListGroups: wbcErr (const char *, uint32_t *, const char ***)
|
||||
wbcListTrusts: wbcErr (struct wbcDomainInfo **, size_t *)
|
||||
wbcListUsers: wbcErr (const char *, uint32_t *, const char ***)
|
||||
wbcLogoffUser: wbcErr (const char *, uid_t, const char *)
|
||||
wbcLogoffUserEx: wbcErr (const struct wbcLogoffUserParams *, struct wbcAuthErrorInfo **)
|
||||
wbcLogonUser: wbcErr (const struct wbcLogonUserParams *, struct wbcLogonUserInfo **, struct wbcAuthErrorInfo **, struct wbcUserPasswordPolicyInfo **)
|
||||
wbcLookupDomainController: wbcErr (const char *, uint32_t, struct wbcDomainControllerInfo **)
|
||||
wbcLookupDomainControllerEx: wbcErr (const char *, struct wbcGuid *, const char *, uint32_t, struct wbcDomainControllerInfoEx **)
|
||||
wbcLookupName: wbcErr (const char *, const char *, struct wbcDomainSid *, enum wbcSidType *)
|
||||
wbcLookupRids: wbcErr (struct wbcDomainSid *, int, uint32_t *, const char **, const char ***, enum wbcSidType **)
|
||||
wbcLookupSid: wbcErr (const struct wbcDomainSid *, char **, char **, enum wbcSidType *)
|
||||
wbcLookupSids: wbcErr (const struct wbcDomainSid *, int, struct wbcDomainInfo **, int *, struct wbcTranslatedName **)
|
||||
wbcLookupUserSids: wbcErr (const struct wbcDomainSid *, bool, uint32_t *, struct wbcDomainSid **)
|
||||
wbcPing: wbcErr (void)
|
||||
wbcPingDc: wbcErr (const char *, struct wbcAuthErrorInfo **)
|
||||
wbcPingDc2: wbcErr (const char *, struct wbcAuthErrorInfo **, char **)
|
||||
wbcQueryGidToSid: wbcErr (gid_t, struct wbcDomainSid *)
|
||||
wbcQuerySidToGid: wbcErr (const struct wbcDomainSid *, gid_t *)
|
||||
wbcQuerySidToUid: wbcErr (const struct wbcDomainSid *, uid_t *)
|
||||
wbcQueryUidToSid: wbcErr (uid_t, struct wbcDomainSid *)
|
||||
wbcRemoveGidMapping: wbcErr (gid_t, const struct wbcDomainSid *)
|
||||
wbcRemoveUidMapping: wbcErr (uid_t, const struct wbcDomainSid *)
|
||||
wbcRequestResponse: wbcErr (struct wbcContext *, int, struct winbindd_request *, struct winbindd_response *)
|
||||
wbcRequestResponsePriv: wbcErr (struct wbcContext *, int, struct winbindd_request *, struct winbindd_response *)
|
||||
wbcResolveWinsByIP: wbcErr (const char *, char **)
|
||||
wbcResolveWinsByName: wbcErr (const char *, char **)
|
||||
wbcSetGidHwm: wbcErr (gid_t)
|
||||
wbcSetGidMapping: wbcErr (gid_t, const struct wbcDomainSid *)
|
||||
wbcSetUidHwm: wbcErr (uid_t)
|
||||
wbcSetUidMapping: wbcErr (uid_t, const struct wbcDomainSid *)
|
||||
wbcSetgrent: wbcErr (void)
|
||||
wbcSetpwent: wbcErr (void)
|
||||
wbcSidToGid: wbcErr (const struct wbcDomainSid *, gid_t *)
|
||||
wbcSidToString: wbcErr (const struct wbcDomainSid *, char **)
|
||||
wbcSidToStringBuf: int (const struct wbcDomainSid *, char *, int)
|
||||
wbcSidToUid: wbcErr (const struct wbcDomainSid *, uid_t *)
|
||||
wbcSidTypeString: const char *(enum wbcSidType)
|
||||
wbcSidsToUnixIds: wbcErr (const struct wbcDomainSid *, uint32_t, struct wbcUnixId *)
|
||||
wbcStrDup: char *(const char *)
|
||||
wbcStringToGuid: wbcErr (const char *, struct wbcGuid *)
|
||||
wbcStringToSid: wbcErr (const char *, struct wbcDomainSid *)
|
||||
wbcUidToSid: wbcErr (uid_t, struct wbcDomainSid *)
|
||||
wbcUnixIdsToSids: wbcErr (const struct wbcUnixId *, uint32_t, struct wbcDomainSid *)
|
@ -433,3 +433,88 @@ wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids,
|
||||
{
|
||||
return wbcCtxSidsToUnixIds(NULL, sids, num_sids, ids);
|
||||
}
|
||||
|
||||
wbcErr wbcCtxUnixIdsToSids(struct wbcContext *ctx,
|
||||
const struct wbcUnixId *ids, uint32_t num_ids,
|
||||
struct wbcDomainSid *sids)
|
||||
{
|
||||
struct winbindd_request request;
|
||||
struct winbindd_response response;
|
||||
wbcErr wbc_status;
|
||||
char *buf;
|
||||
char *s;
|
||||
size_t ofs, buflen;
|
||||
uint32_t i;
|
||||
|
||||
buflen = num_ids * (1 /* U/G */ + 10 /* 2^32 */ + 1 /* \n */) + 1;
|
||||
buf = malloc(buflen);
|
||||
if (buf == NULL) {
|
||||
return WBC_ERR_NO_MEMORY;
|
||||
}
|
||||
|
||||
ofs = 0;
|
||||
|
||||
for (i=0; i<num_ids; i++) {
|
||||
const struct wbcUnixId *id = &ids[i];
|
||||
int len;
|
||||
|
||||
switch (id->type) {
|
||||
case WBC_ID_TYPE_UID:
|
||||
len = snprintf(buf+ofs, buflen-ofs, "U%"PRIu32"\n",
|
||||
(uint32_t)id->id.uid);
|
||||
break;
|
||||
case WBC_ID_TYPE_GID:
|
||||
len = snprintf(buf+ofs, buflen-ofs, "G%"PRIu32"\n",
|
||||
(uint32_t)id->id.gid);
|
||||
break;
|
||||
default:
|
||||
free(buf);
|
||||
return WBC_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (len + ofs >= buflen) { /* >= for the terminating '\0' */
|
||||
free(buf);
|
||||
return WBC_ERR_UNKNOWN_FAILURE;
|
||||
}
|
||||
ofs += len;
|
||||
}
|
||||
|
||||
request = (struct winbindd_request) {
|
||||
.extra_data.data = buf, .extra_len = ofs+1
|
||||
};
|
||||
response = (struct winbindd_response) {0};
|
||||
|
||||
wbc_status = wbcRequestResponse(ctx, WINBINDD_XIDS_TO_SIDS,
|
||||
&request, &response);
|
||||
free(buf);
|
||||
if (!WBC_ERROR_IS_OK(wbc_status)) {
|
||||
return wbc_status;
|
||||
}
|
||||
|
||||
s = response.extra_data.data;
|
||||
for (i=0; i<num_ids; i++) {
|
||||
char *n = strchr(s, '\n');
|
||||
|
||||
if (n == NULL) {
|
||||
goto fail;
|
||||
}
|
||||
*n = '\0';
|
||||
|
||||
wbc_status = wbcStringToSid(s, &sids[i]);
|
||||
if (!WBC_ERROR_IS_OK(wbc_status)) {
|
||||
sids[i] = (struct wbcDomainSid) {0};
|
||||
}
|
||||
s = n+1;
|
||||
}
|
||||
|
||||
wbc_status = WBC_ERR_SUCCESS;
|
||||
fail:
|
||||
winbindd_free_response(&response);
|
||||
return wbc_status;
|
||||
}
|
||||
|
||||
wbcErr wbcUnixIdsToSids(const struct wbcUnixId *ids, uint32_t num_ids,
|
||||
struct wbcDomainSid *sids)
|
||||
{
|
||||
return wbcCtxUnixIdsToSids(NULL, ids, num_ids, sids);
|
||||
}
|
||||
|
@ -73,9 +73,10 @@ const char *wbcErrorString(wbcErr error);
|
||||
* 0.10: Added wbcPingDc2()
|
||||
* 0.11: Extended wbcAuthenticateUserEx to provide PAC parsing
|
||||
* 0.12: Added wbcCtxCreate and friends
|
||||
* 0.13: Added wbcCtxUnixIdsToSids and wbcUnixIdsToSids
|
||||
**/
|
||||
#define WBCLIENT_MAJOR_VERSION 0
|
||||
#define WBCLIENT_MINOR_VERSION 12
|
||||
#define WBCLIENT_MINOR_VERSION 13
|
||||
#define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
|
||||
struct wbcLibraryDetails {
|
||||
uint16_t major_version;
|
||||
@ -1030,6 +1031,12 @@ wbcErr wbcCtxSidsToUnixIds(struct wbcContext *ctx,
|
||||
wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids,
|
||||
struct wbcUnixId *ids);
|
||||
|
||||
wbcErr wbcCtxUnixIdsToSids(struct wbcContext *ctx,
|
||||
const struct wbcUnixId *ids, uint32_t num_ids,
|
||||
struct wbcDomainSid *sids);
|
||||
wbcErr wbcUnixIdsToSids(const struct wbcUnixId *ids, uint32_t num_ids,
|
||||
struct wbcDomainSid *sids);
|
||||
|
||||
/**
|
||||
* @brief Obtain a new uid from Winbind
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
import Options, Logs
|
||||
|
||||
# Remember to also update wbclient.h
|
||||
VERSION="0.12"
|
||||
VERSION="0.13"
|
||||
|
||||
# It may be useful at some point to allow Samba to build against a
|
||||
# system libwbclient, such as the one provided by Likewise. To to
|
||||
|
Loading…
x
Reference in New Issue
Block a user