struct passwd p, *res;
char buf[MAXPWBUF];
kern_return_t kstatus;
- uint32_t i, maxgroups, count, gidptrCnt, gg_count;
+ uint32_t i, maxgroups, count, gg_count;
int pwstatus;
GIDArray gids;
gid_t *gidptr, *gg_list;
+ size_t gidptrsz;
int status, do_dealloc;
audit_token_t token;
do_dealloc = 0;
*grpcnt = 0;
gidptr = NULL;
- gidptrCnt = 0;
+ gidptrsz = 0;
gg_list = NULL;
gg_count = 0;
kstatus = 0;
if (maxgroups > 16)
{
+ uint32_t gidptrCnt = 0;
kstatus = memberdDSmig_GetAllGroups(_ds_port, p.pw_uid, &count, &gidptr, &gidptrCnt, &token);
+ gidptrsz = gidptrCnt * sizeof(gid_t);
do_dealloc = 1;
}
else
for (i = 0; i < count; i++) _add_group(gidptr[i], &gg_list, &gg_count, 0);
- if ((do_dealloc == 1) && (gidptr != NULL)) vm_deallocate(mach_task_self(), (vm_address_t)gidptr, gidptrCnt);
+ if ((do_dealloc == 1) && (gidptr != NULL)) vm_deallocate(mach_task_self(), (vm_address_t)gidptr, gidptrsz);
if (gg_list == NULL)
{
uint32_t i, count, gidptrCnt, out_count;
int pwstatus;
gid_t *gidptr, *out_list;
+ size_t gidptrsz;
audit_token_t token;
if (_ds_port == MACH_PORT_NULL) return -1;
gidptr = NULL;
gidptrCnt = 0;
+ gidptrsz = 0;
out_list = NULL;
out_count = 0;
if (out_list != NULL) free(out_list);
return -1;
}
+ gidptrsz = gidptrCnt * sizeof(gid_t);
if (audit_token_uid(token) != 0)
{
if (out_list != NULL) free(out_list);
- if (gidptr != NULL) vm_deallocate(mach_task_self(), (vm_address_t)gidptr, gidptrCnt);
+ if (gidptr != NULL) vm_deallocate(mach_task_self(), (vm_address_t)gidptr, gidptrsz);
return -1;
}
for (i = 0; i < count; i++) _add_group(gidptr[i], &out_list, &out_count, 0);
- if (gidptr != NULL) vm_deallocate(mach_task_self(), (vm_address_t)gidptr, gidptrCnt);
+ if (gidptr != NULL) vm_deallocate(mach_task_self(), (vm_address_t)gidptr, gidptrsz);
*grplist = out_list;
return out_count;
int status;
request.el_seqno = 1;
- request.el_flags = KAUTH_EXTLOOKUP_VALID_GSID | KAUTH_EXTLOOKUP_WANT_GGUID;
+ request.el_flags = KAUTH_EXTLOOKUP_VALID_GSID | KAUTH_EXTLOOKUP_WANT_GGUID | KAUTH_EXTLOOKUP_VALID_USID | KAUTH_EXTLOOKUP_WANT_UGUID;
memset(&request.el_gsid, 0, sizeof(ntsid_t));
memcpy(&request.el_gsid, sid, KAUTH_NTSID_SIZE(sid));
+ memset(&request.el_usid, 0, sizeof(ntsid_t));
+ memcpy(&request.el_usid, sid, KAUTH_NTSID_SIZE(sid));
status = _mbr_MembershipCall(&request);
if (status != 0) return status;
- if ((request.el_flags & KAUTH_EXTLOOKUP_VALID_GGUID) == 0) return ENOENT;
- memcpy(uu, &request.el_gguid, sizeof(guid_t));
+ if ((request.el_flags & KAUTH_EXTLOOKUP_VALID_GGUID) != 0) memcpy(uu, &request.el_gguid, sizeof(guid_t));
+ else if ((request.el_flags & KAUTH_EXTLOOKUP_VALID_UGUID) != 0) memcpy(uu, &request.el_uguid, sizeof(guid_t));
+ else return ENOENT;
+
return 0;
}
while (*current != '\0' && count < NTSID_MAX_AUTHORITIES)
{
current++;
- sid->sid_authorities[count] = strtol(current, ¤t, 10);
+ sid->sid_authorities[count] = (u_int32_t)strtoll(current, ¤t, 10);
count++;
}