2 a replacement for getgrent() on AIX that enumerates
3 all user databases, not just /etc/group
5 Andrew Tridgell tridge@au.ibm.com
13 #include <sys/types.h>
23 free up any resources associated with getgrent()
27 if (getgrent_state.all_groups) {
28 free(getgrent_state.all_groups);
30 getgrent_state.all_groups = NULL;
31 getgrent_state.next = NULL;
36 reset the state to the start of the group database
42 /* getgroupattr returns a null separated list of groups,
43 with each group being of the form REGISTRY:GROUPNAME */
44 if (getgroupattr("ALL", "groups", &s, SEC_CHAR) == 0) {
45 getgrent_state.all_groups = s;
46 getgrent_state.next = getgrent_state.all_groups;
54 struct group *getgrent(void)
58 if (!getgrent_state.all_groups) {
60 if (!getgrent_state.all_groups) {
65 group = getgrent_state.next;
70 group = strchr(group, ':');
75 grp = getgrnam(group+1);
76 getgrent_state.next += strlen(getgrent_state.next)+1;
90 while ((grp = getgrent())) {
91 printf("%s\n", grp->gr_name);