1 /* vi: set sw=4 ts=4: */
2 /* Copyright (C) 2003 Manuel Novoa III
4 * Licensed under GPL v2, or later. See file LICENSE in this tarball.
7 /* Nov 6, 2003 Initial version.
9 * NOTE: This implementation is quite strict about requiring all
10 * field seperators. It also does not allow leading whitespace
11 * except when processing the numeric fields. glibc is more
12 * lenient. See the various glibc difference comments below.
15 * Move to dynamic allocation of (currently statically allocated)
16 * buffers; especially for the group-related functions since
17 * large group member lists will cause error returns.
25 #define _PATH_SHADOW "/etc/shadow"
28 #define _PATH_PASSWD "/etc/passwd"
31 #define _PATH_GROUP "/etc/group"
34 /**********************************************************************/
35 /* Sizes for statically allocated buffers. */
37 /* If you change these values, also change _SC_GETPW_R_SIZE_MAX and
38 * _SC_GETGR_R_SIZE_MAX in libc/unistd/sysconf.c to match */
39 #define PWD_BUFFER_SIZE 256
40 #define GRP_BUFFER_SIZE 256
42 /**********************************************************************/
43 /* Prototypes for internal functions. */
45 static int bb__pgsreader(
46 int FAST_FUNC (*parserfunc)(void *d, char *line),
48 char *__restrict line_buff,
52 static int FAST_FUNC bb__parsepwent(void *pw, char *line);
53 static int FAST_FUNC bb__parsegrent(void *gr, char *line);
54 #if ENABLE_USE_BB_SHADOW
55 static int FAST_FUNC bb__parsespent(void *sp, char *line);
58 /**********************************************************************/
59 /* We avoid having big global data. */
62 /* Smaller things first */
63 struct passwd getpwuid_resultbuf;
64 struct group getgrgid_resultbuf;
65 struct passwd getpwnam_resultbuf;
66 struct group getgrnam_resultbuf;
68 char getpwuid_buffer[PWD_BUFFER_SIZE];
69 char getgrgid_buffer[GRP_BUFFER_SIZE];
70 char getpwnam_buffer[PWD_BUFFER_SIZE];
71 char getgrnam_buffer[GRP_BUFFER_SIZE];
73 struct passwd fgetpwent_resultbuf;
74 struct group fgetgrent_resultbuf;
75 struct spwd fgetspent_resultbuf;
76 char fgetpwent_buffer[PWD_BUFFER_SIZE];
77 char fgetgrent_buffer[GRP_BUFFER_SIZE];
78 char fgetspent_buffer[PWD_BUFFER_SIZE];
80 #if 0 //ENABLE_USE_BB_SHADOW
81 struct spwd getspuid_resultbuf;
82 struct spwd getspnam_resultbuf;
83 char getspuid_buffer[PWD_BUFFER_SIZE];
84 char getspnam_buffer[PWD_BUFFER_SIZE];
86 // Not converted - too small to bother
87 //pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
88 //FILE *pwf /*= NULL*/;
89 //FILE *grf /*= NULL*/;
90 //FILE *spf /*= NULL*/;
92 struct passwd getpwent_pwd;
93 struct group getgrent_gr;
94 char getpwent_line_buff[PWD_BUFFER_SIZE];
95 char getgrent_line_buff[GRP_BUFFER_SIZE];
97 #if 0 //ENABLE_USE_BB_SHADOW
98 struct spwd getspent_spwd;
99 struct spwd sgetspent_spwd;
100 char getspent_line_buff[PWD_BUFFER_SIZE];
101 char sgetspent_line_buff[PWD_BUFFER_SIZE];
105 static struct statics *ptr_to_statics;
107 static struct statics *get_S(void)
110 ptr_to_statics = xzalloc(sizeof(*ptr_to_statics));
111 return ptr_to_statics;
114 /* Always use in this order, get_S() must be called first */
115 #define RESULTBUF(name) &((S = get_S())->name##_resultbuf)
116 #define BUFFER(name) (S->name##_buffer)
118 /**********************************************************************/
119 /* For the various fget??ent_r funcs, return
122 * ENOENT: end-of-file encountered
123 * ERANGE: buflen too small
124 * other error values possible. See bb__pgsreader.
126 * Also, *result == resultbuf on success and NULL on failure.
128 * NOTE: glibc difference - For the ENOENT case, glibc also sets errno.
129 * We do not, as it really isn't an error if we reach the end-of-file.
130 * Doing so is analogous to having fgetc() set errno on EOF.
132 /**********************************************************************/
134 int fgetpwent_r(FILE *__restrict stream, struct passwd *__restrict resultbuf,
135 char *__restrict buffer, size_t buflen,
136 struct passwd **__restrict result)
142 rv = bb__pgsreader(bb__parsepwent, resultbuf, buffer, buflen, stream);
150 int fgetgrent_r(FILE *__restrict stream, struct group *__restrict resultbuf,
151 char *__restrict buffer, size_t buflen,
152 struct group **__restrict result)
158 rv = bb__pgsreader(bb__parsegrent, resultbuf, buffer, buflen, stream);
166 #if ENABLE_USE_BB_SHADOW
167 #ifdef UNUSED_FOR_NOW
168 int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
169 char *__restrict buffer, size_t buflen,
170 struct spwd **__restrict result)
176 rv = bb__pgsreader(bb__parsespent, resultbuf, buffer, buflen, stream);
186 /**********************************************************************/
187 /* For the various fget??ent funcs, return NULL on failure and a
188 * pointer to the appropriate struct (statically allocated) on success.
189 * TODO: audit & stop using these in bbox, they pull in static buffers */
190 /**********************************************************************/
192 #ifdef UNUSED_SINCE_WE_AVOID_STATIC_BUFS
193 struct passwd *fgetpwent(FILE *stream)
196 struct passwd *resultbuf = RESULTBUF(fgetpwent);
197 char *buffer = BUFFER(fgetpwent);
198 struct passwd *result;
200 fgetpwent_r(stream, resultbuf, buffer, sizeof(BUFFER(fgetpwent)), &result);
204 struct group *fgetgrent(FILE *stream)
207 struct group *resultbuf = RESULTBUF(fgetgrent);
208 char *buffer = BUFFER(fgetgrent);
209 struct group *result;
211 fgetgrent_r(stream, resultbuf, buffer, sizeof(BUFFER(fgetgrent)), &result);
216 #if ENABLE_USE_BB_SHADOW
217 #ifdef UNUSED_SINCE_WE_AVOID_STATIC_BUFS
218 struct spwd *fgetspent(FILE *stream)
221 struct spwd *resultbuf = RESULTBUF(fgetspent);
222 char *buffer = BUFFER(fgetspent);
225 fgetspent_r(stream, resultbuf, buffer, sizeof(BUFFER(fgetspent)), &result);
230 #ifdef UNUSED_FOR_NOW
231 int sgetspent_r(const char *string, struct spwd *result_buf,
232 char *buffer, size_t buflen, struct spwd **result)
238 if (buflen < PWD_BUFFER_SIZE) {
244 if (string != buffer) {
245 if (strlen(string) >= buflen) {
248 strcpy(buffer, string);
251 rv = bb__parsespent(result_buf, buffer);
253 *result = result_buf;
260 #endif /* ENABLE_USE_BB_SHADOW */
262 /**********************************************************************/
264 #define GETXXKEY_R_FUNC getpwnam_r
265 #define GETXXKEY_R_PARSER bb__parsepwent
266 #define GETXXKEY_R_ENTTYPE struct passwd
267 #define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->pw_name, key))
268 #define GETXXKEY_R_KEYTYPE const char *__restrict
269 #define GETXXKEY_R_PATHNAME _PATH_PASSWD
270 #include "pwd_grp_internal.c"
272 #define GETXXKEY_R_FUNC getgrnam_r
273 #define GETXXKEY_R_PARSER bb__parsegrent
274 #define GETXXKEY_R_ENTTYPE struct group
275 #define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->gr_name, key))
276 #define GETXXKEY_R_KEYTYPE const char *__restrict
277 #define GETXXKEY_R_PATHNAME _PATH_GROUP
278 #include "pwd_grp_internal.c"
280 #if ENABLE_USE_BB_SHADOW
281 #define GETXXKEY_R_FUNC getspnam_r
282 #define GETXXKEY_R_PARSER bb__parsespent
283 #define GETXXKEY_R_ENTTYPE struct spwd
284 #define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->sp_namp, key))
285 #define GETXXKEY_R_KEYTYPE const char *__restrict
286 #define GETXXKEY_R_PATHNAME _PATH_SHADOW
287 #include "pwd_grp_internal.c"
290 #define GETXXKEY_R_FUNC getpwuid_r
291 #define GETXXKEY_R_PARSER bb__parsepwent
292 #define GETXXKEY_R_ENTTYPE struct passwd
293 #define GETXXKEY_R_TEST(ENT) ((ENT)->pw_uid == key)
294 #define GETXXKEY_R_KEYTYPE uid_t
295 #define GETXXKEY_R_PATHNAME _PATH_PASSWD
296 #include "pwd_grp_internal.c"
298 #define GETXXKEY_R_FUNC getgrgid_r
299 #define GETXXKEY_R_PARSER bb__parsegrent
300 #define GETXXKEY_R_ENTTYPE struct group
301 #define GETXXKEY_R_TEST(ENT) ((ENT)->gr_gid == key)
302 #define GETXXKEY_R_KEYTYPE gid_t
303 #define GETXXKEY_R_PATHNAME _PATH_GROUP
304 #include "pwd_grp_internal.c"
306 /**********************************************************************/
307 /* TODO: audit & stop using these in bbox, they pull in static buffers */
309 /* This one has many users */
310 struct passwd *getpwuid(uid_t uid)
313 struct passwd *resultbuf = RESULTBUF(getpwuid);
314 char *buffer = BUFFER(getpwuid);
315 struct passwd *result;
317 getpwuid_r(uid, resultbuf, buffer, sizeof(BUFFER(getpwuid)), &result);
321 /* This one has many users */
322 struct group *getgrgid(gid_t gid)
325 struct group *resultbuf = RESULTBUF(getgrgid);
326 char *buffer = BUFFER(getgrgid);
327 struct group *result;
329 getgrgid_r(gid, resultbuf, buffer, sizeof(BUFFER(getgrgid)), &result);
333 #if 0 //ENABLE_USE_BB_SHADOW
334 /* This function is non-standard and is currently not built. It seems
335 * to have been created as a reentrant version of the non-standard
336 * functions getspuid. Why getspuid was added, I do not know. */
337 int getspuid_r(uid_t uid, struct spwd *__restrict resultbuf,
338 char *__restrict buffer, size_t buflen,
339 struct spwd **__restrict result)
343 struct passwd password;
344 char pwd_buff[PWD_BUFFER_SIZE];
347 rv = getpwuid_r(uid, &password, pwd_buff, sizeof(pwd_buff), &pp);
349 rv = getspnam_r(password.pw_name, resultbuf, buffer, buflen, result);
355 /* This function is non-standard and is currently not built.
356 * Why it was added, I do not know. */
357 struct spwd *getspuid(uid_t uid)
360 struct spwd *resultbuf = RESULTBUF(getspuid);
361 char *buffer = BUFFER(getspuid);
364 getspuid_r(uid, resultbuf, buffer, sizeof(BUFFER(getspuid)), &result);
369 /* This one has many users */
370 struct passwd *getpwnam(const char *name)
373 struct passwd *resultbuf = RESULTBUF(getpwnam);
374 char *buffer = BUFFER(getpwnam);
375 struct passwd *result;
377 getpwnam_r(name, resultbuf, buffer, sizeof(BUFFER(getpwnam)), &result);
381 /* This one has many users */
382 struct group *getgrnam(const char *name)
385 struct group *resultbuf = RESULTBUF(getgrnam);
386 char *buffer = BUFFER(getgrnam);
387 struct group *result;
389 getgrnam_r(name, resultbuf, buffer, sizeof(BUFFER(getgrnam)), &result);
393 #if 0 //ENABLE_USE_BB_SHADOW
394 struct spwd *getspnam(const char *name)
397 struct spwd *resultbuf = RESULTBUF(getspnam);
398 char *buffer = BUFFER(getspnam);
401 getspnam_r(name, resultbuf, buffer, sizeof(BUFFER(getspnam)), &result);
406 /**********************************************************************/
408 /* FIXME: we don't have such CONFIG_xx - ?! */
410 #if defined CONFIG_USE_BB_THREADSAFE_SHADOW && defined PTHREAD_MUTEX_INITIALIZER
411 static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
412 # define LOCK pthread_mutex_lock(&mylock)
413 # define UNLOCK pthread_mutex_unlock(&mylock);
415 # define LOCK ((void) 0)
416 # define UNLOCK ((void) 0)
419 static FILE *pwf /*= NULL*/;
440 int getpwent_r(struct passwd *__restrict resultbuf,
441 char *__restrict buffer, size_t buflen,
442 struct passwd **__restrict result)
447 *result = NULL; /* In case of error... */
450 pwf = fopen_for_read(_PATH_PASSWD);
457 rv = bb__pgsreader(bb__parsepwent, resultbuf, buffer, buflen, pwf);
467 static FILE *grf /*= NULL*/;
487 int getgrent_r(struct group *__restrict resultbuf,
488 char *__restrict buffer, size_t buflen,
489 struct group **__restrict result)
494 *result = NULL; /* In case of error... */
497 grf = fopen_for_read(_PATH_GROUP);
504 rv = bb__pgsreader(bb__parsegrent, resultbuf, buffer, buflen, grf);
514 #ifdef UNUSED_FOR_NOW
515 #if ENABLE_USE_BB_SHADOW
516 static FILE *spf /*= NULL*/;
536 int getspent_r(struct spwd *resultbuf, char *buffer,
537 size_t buflen, struct spwd **result)
542 *result = NULL; /* In case of error... */
545 spf = fopen_for_read(_PATH_SHADOW);
552 rv = bb__pgsreader(bb__parsespent, resultbuf, buffer, buflen, spf);
562 #endif /* UNUSED_FOR_NOW */
564 #ifdef UNUSED_SINCE_WE_AVOID_STATIC_BUFS
565 struct passwd *getpwent(void)
567 static char line_buff[PWD_BUFFER_SIZE];
568 static struct passwd pwd;
569 struct passwd *result;
571 getpwent_r(&pwd, line_buff, sizeof(line_buff), &result);
575 struct group *getgrent(void)
577 static char line_buff[GRP_BUFFER_SIZE];
578 static struct group gr;
579 struct group *result;
581 getgrent_r(&gr, line_buff, sizeof(line_buff), &result);
585 #if ENABLE_USE_BB_SHADOW
586 struct spwd *getspent(void)
588 static char line_buff[PWD_BUFFER_SIZE];
589 static struct spwd spwd;
592 getspent_r(&spwd, line_buff, sizeof(line_buff), &result);
596 struct spwd *sgetspent(const char *string)
598 static char line_buff[PWD_BUFFER_SIZE];
599 static struct spwd spwd;
602 sgetspent_r(string, &spwd, line_buff, sizeof(line_buff), &result);
606 #endif /* UNUSED_SINCE_WE_AVOID_STATIC_BUFS */
608 static gid_t *getgrouplist_internal(int *ngroups_ptr, const char *user, gid_t gid)
614 char buff[PWD_BUFFER_SIZE];
616 /* We alloc space for 8 gids at a time. */
617 group_list = xmalloc(8 * sizeof(group_list[0]));
621 grfile = fopen_for_read(_PATH_GROUP);
623 while (!bb__pgsreader(bb__parsegrent, &group, buff, sizeof(buff), grfile)) {
625 assert(group.gr_mem); /* Must have at least a NULL terminator. */
626 if (group.gr_gid == gid)
628 for (m = group.gr_mem; *m; m++) {
629 if (strcmp(*m, user) != 0)
631 group_list = xrealloc_vector(group_list, /*8=2^3:*/ 3, ngroups);
632 group_list[ngroups++] = group.gr_gid;
638 *ngroups_ptr = ngroups;
642 int initgroups(const char *user, gid_t gid)
645 gid_t *group_list = getgrouplist_internal(&ngroups, user, gid);
647 ngroups = setgroups(ngroups, group_list);
652 int getgrouplist(const char *user, gid_t gid, gid_t *groups, int *ngroups)
654 int ngroups_old = *ngroups;
655 gid_t *group_list = getgrouplist_internal(ngroups, user, gid);
657 if (*ngroups <= ngroups_old) {
658 ngroups_old = *ngroups;
659 memcpy(groups, group_list, ngroups_old * sizeof(groups[0]));
667 #ifdef UNUSED_SINCE_WE_AVOID_STATIC_BUFS
668 int putpwent(const struct passwd *__restrict p, FILE *__restrict f)
673 /* glibc does this check */
680 /* No extra thread locking is needed above what fprintf does. */
681 if (fprintf(f, "%s:%s:%lu:%lu:%s:%s:%s\n",
682 p->pw_name, p->pw_passwd,
683 (unsigned long)(p->pw_uid),
684 (unsigned long)(p->pw_gid),
685 p->pw_gecos, p->pw_dir, p->pw_shell) >= 0
693 int putgrent(const struct group *__restrict p, FILE *__restrict f)
698 /* glibc does this check */
705 if (fprintf(f, "%s:%s:%lu:",
706 p->gr_name, p->gr_passwd,
707 (unsigned long)(p->gr_gid)) >= 0
709 static const char format[] ALIGN1 = ",%s";
721 if (fputc('\n', f) >= 0) {
726 if (fprintf(f, fmt, *m) < 0) {
738 #if ENABLE_USE_BB_SHADOW
739 #ifdef UNUSED_FOR_NOW
740 static const unsigned char put_sp_off[] ALIGN1 = {
741 offsetof(struct spwd, sp_lstchg), /* 2 - not a char ptr */
742 offsetof(struct spwd, sp_min), /* 3 - not a char ptr */
743 offsetof(struct spwd, sp_max), /* 4 - not a char ptr */
744 offsetof(struct spwd, sp_warn), /* 5 - not a char ptr */
745 offsetof(struct spwd, sp_inact), /* 6 - not a char ptr */
746 offsetof(struct spwd, sp_expire) /* 7 - not a char ptr */
749 int putspent(const struct spwd *p, FILE *stream)
756 /* Unlike putpwent and putgrent, glibc does not check the args. */
757 if (fprintf(stream, "%s:%s:", p->sp_namp,
758 (p->sp_pwdp ? p->sp_pwdp : "")) < 0
763 for (i = 0; i < sizeof(put_sp_off); i++) {
765 x = *(long *)((char *)p + put_sp_off[i]);
769 if (fprintf(stream, fmt, x) < 0) {
774 if ((p->sp_flag != ~0UL) && (fprintf(stream, "%lu", p->sp_flag) < 0)) {
778 if (fputc('\n', stream) > 0) {
786 #endif /* USE_BB_SHADOW */
788 /**********************************************************************/
789 /* Internal functions */
790 /**********************************************************************/
792 static const unsigned char pw_off[] ALIGN1 = {
793 offsetof(struct passwd, pw_name), /* 0 */
794 offsetof(struct passwd, pw_passwd), /* 1 */
795 offsetof(struct passwd, pw_uid), /* 2 - not a char ptr */
796 offsetof(struct passwd, pw_gid), /* 3 - not a char ptr */
797 offsetof(struct passwd, pw_gecos), /* 4 */
798 offsetof(struct passwd, pw_dir), /* 5 */
799 offsetof(struct passwd, pw_shell) /* 6 */
802 static int FAST_FUNC bb__parsepwent(void *data, char *line)
810 p = (char *) data + pw_off[i];
812 if (i < 2 || i > 3) {
813 *((char **) p) = line;
817 /* NOTE: glibc difference - glibc allows omission of
818 * ':' seperators after the gid field if all remaining
819 * entries are empty. We require all separators. */
820 line = strchr(line, ':');
825 unsigned long t = strtoul(line, &endptr, 10);
826 /* Make sure we had at least one digit, and that the
827 * failing char is the next field seperator ':'. See
828 * glibc difference note above. */
829 /* TODO: Also check for leading whitespace? */
830 if ((endptr == line) || (*endptr != ':')) {
834 if (i & 1) { /* i == 3 -- gid */
836 } else { /* i == 2 -- uid */
848 /**********************************************************************/
850 static const unsigned char gr_off[] ALIGN1 = {
851 offsetof(struct group, gr_name), /* 0 */
852 offsetof(struct group, gr_passwd), /* 1 */
853 offsetof(struct group, gr_gid) /* 2 - not a char ptr */
856 static int FAST_FUNC bb__parsegrent(void *data, char *line)
864 end_of_buf = ((struct group *) data)->gr_name; /* Evil hack! */
867 p = (char *) data + gr_off[i];
870 *((char **) p) = line;
871 line = strchr(line, ':');
878 *((gid_t *) p) = strtoul(line, &endptr, 10);
880 /* NOTE: glibc difference - glibc allows omission of the
881 * trailing colon when there is no member list. We treat
882 * this as an error. */
884 /* Make sure we had at least one digit, and that the
885 * failing char is the next field seperator ':'. See
886 * glibc difference note above. */
887 if ((endptr == line) || (*endptr != ':')) {
891 i = 1; /* Count terminating NULL ptr. */
894 if (p[1]) { /* We have a member list to process. */
895 /* Overwrite the last ':' with a ',' before counting.
896 * This allows us to (1) test for initial ','
897 * and (2) adds one ',' so that the number of commas
898 * equals the member count. */
901 /* NOTE: glibc difference - glibc allows and trims leading
902 * (but not trailing) space. We treat this as an error. */
903 /* NOTE: glibc difference - glibc allows consecutive and
904 * trailing commas, and ignores "empty string" users. We
905 * treat this as an error. */
908 *p = 0; /* nul-terminate each member string. */
909 if (!*++p || (*p == ',') || isspace(*p)) {
916 /* Now align (p+1), rounding up. */
917 /* Assumes sizeof(char **) is a power of 2. */
918 members = (char **)( (((intptr_t) p) + sizeof(char **))
919 & ~((intptr_t)(sizeof(char **) - 1)) );
921 if (((char *)(members + i)) > end_of_buf) { /* No space. */
925 ((struct group *) data)->gr_mem = members;
928 p = endptr; /* Pointing to char prior to first member. */
947 /**********************************************************************/
949 #if ENABLE_USE_BB_SHADOW
950 static const unsigned char sp_off[] ALIGN1 = {
951 offsetof(struct spwd, sp_namp), /* 0: char* */
952 offsetof(struct spwd, sp_pwdp), /* 1: char* */
953 offsetof(struct spwd, sp_lstchg), /* 2: long */
954 offsetof(struct spwd, sp_min), /* 3: long */
955 offsetof(struct spwd, sp_max), /* 4: long */
956 offsetof(struct spwd, sp_warn), /* 5: long */
957 offsetof(struct spwd, sp_inact), /* 6: long */
958 offsetof(struct spwd, sp_expire), /* 7: long */
959 offsetof(struct spwd, sp_flag) /* 8: unsigned long */
962 static int FAST_FUNC bb__parsespent(void *data, char *line)
970 p = (char *) data + sp_off[i];
972 *((char **) p) = line;
973 line = strchr(line, ':');
978 *((long *) p) = strtoul(line, &endptr, 10);
979 if (endptr == line) {
987 return 0; /* all ok */
1001 /**********************************************************************/
1003 /* Reads until EOF, or until it finds a line which fits in the buffer
1004 * and for which the parser function succeeds.
1006 * Returns 0 on success and ENOENT for end-of-file (glibc convention).
1008 static int bb__pgsreader(
1009 int FAST_FUNC (*parserfunc)(void *d, char *line),
1011 char *__restrict line_buff,
1018 if (buflen < PWD_BUFFER_SIZE) {
1025 if (!fgets(line_buff, buflen, f)) {
1033 int line_len = strlen(line_buff) - 1;
1034 if (line_len >= 0 && line_buff[line_len] == '\n') {
1035 line_buff[line_len] = '\0';
1037 if (line_len + 2 == buflen) {
1038 /* A start (or continuation) of overlong line */
1041 } /* else: a last line in the file, and it has no '\n' */
1045 /* This "line" is a remainder of overlong line, ignore */
1050 /* NOTE: glibc difference - glibc strips leading whitespace from
1051 * records. We do not allow leading whitespace. */
1053 /* Skip empty lines, comment lines, and lines with leading
1055 if (line_buff[0] != '\0' && line_buff[0] != '#' && !isspace(line_buff[0])) {
1056 if (parserfunc == bb__parsegrent) {
1057 /* Do evil group hack:
1058 * The group entry parsing function needs to know where
1059 * the end of the buffer is so that it can construct the
1060 * group member ptr table. */
1061 ((struct group *) data)->gr_name = line_buff + buflen;
1063 if (parserfunc(data, line_buff) == 0) {