summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2016-02-09 08:19:41 +0100
committerRalph Boehme <slow@samba.org>2016-02-22 20:29:16 +0100
commit148452b446e020537ac52e96f13a176f2e1c99d2 (patch)
tree97d3ab15af8147a9cc31da7bccebace705240901
parent1e4e215f2f2580b9e5946070f3b736e353cf5b78 (diff)
downloadsamba-148452b446e020537ac52e96f13a176f2e1c99d2.tar.gz
libwbclient: Use wbcCtxUnixIdsToSids in wbcCtxGidToSid
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
-rw-r--r--nsswitch/libwbclient/wbc_idmap.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/nsswitch/libwbclient/wbc_idmap.c b/nsswitch/libwbclient/wbc_idmap.c
index 26613be9134..f61efb92b8d 100644
--- a/nsswitch/libwbclient/wbc_idmap.c
+++ b/nsswitch/libwbclient/wbc_idmap.c
@@ -160,33 +160,30 @@ wbcErr wbcQuerySidToGid(const struct wbcDomainSid *sid,
/* Convert a Unix gid to a Windows SID, allocating a SID if needed */
wbcErr wbcCtxGidToSid(struct wbcContext *ctx, gid_t gid,
- struct wbcDomainSid *sid)
+ struct wbcDomainSid *psid)
{
- struct winbindd_request request;
- struct winbindd_response response;
- wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ struct wbcUnixId xid;
+ struct wbcDomainSid sid;
+ struct wbcDomainSid null_sid = { 0 };
+ wbcErr wbc_status;
- if (!sid) {
+ if (!psid) {
wbc_status = WBC_ERR_INVALID_PARAM;
BAIL_ON_WBC_ERROR(wbc_status);
}
- /* Initialize request */
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- request.data.gid = gid;
+ xid = (struct wbcUnixId) { .type = WBC_ID_TYPE_GID, .id.gid = gid };
- /* Make request */
-
- wbc_status = wbcRequestResponse(ctx, WINBINDD_GID_TO_SID,
- &request,
- &response);
- BAIL_ON_WBC_ERROR(wbc_status);
+ wbc_status = wbcCtxUnixIdsToSids(ctx, &xid, 1, &sid);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ goto done;
+ }
- wbc_status = wbcStringToSid(response.data.sid.sid, sid);
- BAIL_ON_WBC_ERROR(wbc_status);
+ if (memcmp(&sid, &null_sid, sizeof(sid)) != 0) {
+ *psid = sid;
+ } else {
+ wbc_status = WBC_ERR_DOMAIN_NOT_FOUND;
+ }
done:
return wbc_status;