struct sys_userlist *get_users_in_group(const char *gname) { struct sys_userlist *list_head = NULL; struct group *gptr; /* * If we're doing this via winbindd, don't do the * entire group list enumeration as we know this is * pointless (and slow). */ if (strchr(gname,*lp_winbind_separator())) { if ((gptr = (struct group *)getgrnam(gname)) == NULL) return NULL; return add_members_to_userlist(list_head, gptr); } #if !defined(BROKEN_GETGRNAM) if ((gptr = (struct group *)getgrnam(gname)) == NULL) return NULL; return add_members_to_userlist(list_head, gptr); #else setgrent(); while((gptr = getgrent()) != NULL) { if (strequal(gname, gptr->gr_name)) { list_head = add_members_to_userlist(list_head, gptr); if (list_head == NULL) return NULL; } } endgrent(); return list_head; #endif }
struct sys_userlist *get_users_in_group(const char *gname) { struct sys_userlist *list_head = NULL; struct group *gptr; fstring domain; fstring groupname; DOM_SID sid; enum SID_NAME_USE name_type; /* No point using winbind if we can't split it in the first place */ if (split_domain_and_name(gname, domain, groupname)) { /* * If we're doing this via winbindd, don't do the * entire group list enumeration as we know this is * pointless (and slow). */ if (winbind_lookup_name(domain, groupname, &sid, &name_type) && name_type == SID_NAME_DOM_GRP) { if ((gptr = (struct group *)getgrnam(gname)) == NULL) return NULL; return add_members_to_userlist(list_head, gptr); } } #if !defined(BROKEN_GETGRNAM) if ((gptr = (struct group *)getgrnam(gname)) == NULL) return NULL; return add_members_to_userlist(list_head, gptr); #else /* BROKEN_GETGRNAM - True64 */ setgrent(); while((gptr = getgrent()) != NULL) { if (strequal(gname, gptr->gr_name)) { list_head = add_members_to_userlist(list_head, gptr); if (list_head == NULL) return NULL; } } endgrent(); return list_head; #endif }