libwbclient: Use wbcCtxSidsToUnixIds in wbcCtxSidToGid
authorVolker Lendecke <vl@samba.org>
Tue, 9 Feb 2016 06:36:13 +0000 (07:36 +0100)
committerRalph Boehme <slow@samba.org>
Mon, 22 Feb 2016 19:29:15 +0000 (20:29 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
nsswitch/libwbclient/wbc_idmap.c

index 6735d3d3e9ee652570394a6ab36a82562ea58a0a..5cd082bd24a47f5c401738139deb93d945b0a0d4 100644 (file)
@@ -123,32 +123,25 @@ wbcErr wbcQueryUidToSid(uid_t uid,
 wbcErr wbcCtxSidToGid(struct wbcContext *ctx, const struct wbcDomainSid *sid,
                      gid_t *pgid)
 {
-       struct winbindd_request request;
-       struct winbindd_response response;
-       wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+       struct wbcUnixId xid;
+       wbcErr wbc_status;
 
        if (!sid || !pgid) {
                wbc_status = WBC_ERR_INVALID_PARAM;
                BAIL_ON_WBC_ERROR(wbc_status);
        }
 
-       /* Initialize request */
-
-       ZERO_STRUCT(request);
-       ZERO_STRUCT(response);
-
-        wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid));
-
-       /* Make request */
-
-       wbc_status = wbcRequestResponse(ctx, WINBINDD_SID_TO_GID,
-                                       &request,
-                                       &response);
-       BAIL_ON_WBC_ERROR(wbc_status);
-
-       *pgid = response.data.gid;
+       wbc_status = wbcCtxSidsToUnixIds(ctx, sid, 1, &xid);
+       if (!WBC_ERROR_IS_OK(wbc_status)) {
+               goto done;
+       }
 
-       wbc_status = WBC_ERR_SUCCESS;
+       if ((xid.type == WBC_ID_TYPE_GID) || (xid.type == WBC_ID_TYPE_BOTH)) {
+               *pgid = xid.id.gid;
+               wbc_status = WBC_ERR_SUCCESS;
+       } else {
+               wbc_status = WBC_ERR_DOMAIN_NOT_FOUND;
+       }
 
  done:
        return wbc_status;