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 int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
168 char *__restrict buffer, size_t buflen,
169 struct spwd **__restrict result)
175 rv = bb__pgsreader(bb__parsespent, resultbuf, buffer, buflen, stream);
184 /**********************************************************************/
185 /* For the various fget??ent funcs, return NULL on failure and a
186 * pointer to the appropriate struct (statically allocated) on success.
187 * TODO: audit & stop using these in bbox, they pull in static buffers */
188 /**********************************************************************/
191 struct passwd *fgetpwent(FILE *stream)
194 struct passwd *resultbuf = RESULTBUF(fgetpwent);
195 char *buffer = BUFFER(fgetpwent);
196 struct passwd *result;
198 fgetpwent_r(stream, resultbuf, buffer, sizeof(BUFFER(fgetpwent)), &result);
202 struct group *fgetgrent(FILE *stream)
205 struct group *resultbuf = RESULTBUF(fgetgrent);
206 char *buffer = BUFFER(fgetgrent);
207 struct group *result;
209 fgetgrent_r(stream, resultbuf, buffer, sizeof(BUFFER(fgetgrent)), &result);
214 #if ENABLE_USE_BB_SHADOW
216 struct spwd *fgetspent(FILE *stream)
219 struct spwd *resultbuf = RESULTBUF(fgetspent);
220 char *buffer = BUFFER(fgetspent);
223 fgetspent_r(stream, resultbuf, buffer, sizeof(BUFFER(fgetspent)), &result);
228 int sgetspent_r(const char *string, struct spwd *result_buf,
229 char *buffer, size_t buflen, struct spwd **result)
235 if (buflen < PWD_BUFFER_SIZE) {
241 if (string != buffer) {
242 if (strlen(string) >= buflen) {
245 strcpy(buffer, string);
248 rv = bb__parsespent(result_buf, buffer);
250 *result = result_buf;
258 /**********************************************************************/
260 #define GETXXKEY_R_FUNC getpwnam_r
261 #define GETXXKEY_R_PARSER bb__parsepwent
262 #define GETXXKEY_R_ENTTYPE struct passwd
263 #define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->pw_name, key))
264 #define GETXXKEY_R_KEYTYPE const char *__restrict
265 #define GETXXKEY_R_PATHNAME _PATH_PASSWD
266 #include "pwd_grp_internal.c"
268 #define GETXXKEY_R_FUNC getgrnam_r
269 #define GETXXKEY_R_PARSER bb__parsegrent
270 #define GETXXKEY_R_ENTTYPE struct group
271 #define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->gr_name, key))
272 #define GETXXKEY_R_KEYTYPE const char *__restrict
273 #define GETXXKEY_R_PATHNAME _PATH_GROUP
274 #include "pwd_grp_internal.c"
276 #if ENABLE_USE_BB_SHADOW
277 #define GETXXKEY_R_FUNC getspnam_r
278 #define GETXXKEY_R_PARSER bb__parsespent
279 #define GETXXKEY_R_ENTTYPE struct spwd
280 #define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->sp_namp, key))
281 #define GETXXKEY_R_KEYTYPE const char *__restrict
282 #define GETXXKEY_R_PATHNAME _PATH_SHADOW
283 #include "pwd_grp_internal.c"
286 #define GETXXKEY_R_FUNC getpwuid_r
287 #define GETXXKEY_R_PARSER bb__parsepwent
288 #define GETXXKEY_R_ENTTYPE struct passwd
289 #define GETXXKEY_R_TEST(ENT) ((ENT)->pw_uid == key)
290 #define GETXXKEY_R_KEYTYPE uid_t
291 #define GETXXKEY_R_PATHNAME _PATH_PASSWD
292 #include "pwd_grp_internal.c"
294 #define GETXXKEY_R_FUNC getgrgid_r
295 #define GETXXKEY_R_PARSER bb__parsegrent
296 #define GETXXKEY_R_ENTTYPE struct group
297 #define GETXXKEY_R_TEST(ENT) ((ENT)->gr_gid == key)
298 #define GETXXKEY_R_KEYTYPE gid_t
299 #define GETXXKEY_R_PATHNAME _PATH_GROUP
300 #include "pwd_grp_internal.c"
302 /**********************************************************************/
303 /* TODO: audit & stop using these in bbox, they pull in static buffers */
305 /* This one has many users */
306 struct passwd *getpwuid(uid_t uid)
309 struct passwd *resultbuf = RESULTBUF(getpwuid);
310 char *buffer = BUFFER(getpwuid);
311 struct passwd *result;
313 getpwuid_r(uid, resultbuf, buffer, sizeof(BUFFER(getpwuid)), &result);
317 /* This one has many users */
318 struct group *getgrgid(gid_t gid)
321 struct group *resultbuf = RESULTBUF(getgrgid);
322 char *buffer = BUFFER(getgrgid);
323 struct group *result;
325 getgrgid_r(gid, resultbuf, buffer, sizeof(BUFFER(getgrgid)), &result);
329 #if 0 //ENABLE_USE_BB_SHADOW
330 /* This function is non-standard and is currently not built. It seems
331 * to have been created as a reentrant version of the non-standard
332 * functions getspuid. Why getspuid was added, I do not know. */
333 int getspuid_r(uid_t uid, struct spwd *__restrict resultbuf,
334 char *__restrict buffer, size_t buflen,
335 struct spwd **__restrict result)
339 struct passwd password;
340 char pwd_buff[PWD_BUFFER_SIZE];
343 rv = getpwuid_r(uid, &password, pwd_buff, sizeof(pwd_buff), &pp);
345 rv = getspnam_r(password.pw_name, resultbuf, buffer, buflen, result);
351 /* This function is non-standard and is currently not built.
352 * Why it was added, I do not know. */
353 struct spwd *getspuid(uid_t uid)
356 struct spwd *resultbuf = RESULTBUF(getspuid);
357 char *buffer = BUFFER(getspuid);
360 getspuid_r(uid, resultbuf, buffer, sizeof(BUFFER(getspuid)), &result);
365 /* This one has many users */
366 struct passwd *getpwnam(const char *name)
369 struct passwd *resultbuf = RESULTBUF(getpwnam);
370 char *buffer = BUFFER(getpwnam);
371 struct passwd *result;
373 getpwnam_r(name, resultbuf, buffer, sizeof(BUFFER(getpwnam)), &result);
377 /* This one has many users */
378 struct group *getgrnam(const char *name)
381 struct group *resultbuf = RESULTBUF(getgrnam);
382 char *buffer = BUFFER(getgrnam);
383 struct group *result;
385 getgrnam_r(name, resultbuf, buffer, sizeof(BUFFER(getgrnam)), &result);
389 #if 0 //ENABLE_USE_BB_SHADOW
390 struct spwd *getspnam(const char *name)
393 struct spwd *resultbuf = RESULTBUF(getspnam);
394 char *buffer = BUFFER(getspnam);
397 getspnam_r(name, resultbuf, buffer, sizeof(BUFFER(getspnam)), &result);
402 #ifdef THIS_ONE_IS_UNUSED
403 /* This one doesn't use static buffers */
404 int getpw(uid_t uid, char *buf)
406 struct passwd resultbuf;
407 struct passwd *result;
408 char buffer[PWD_BUFFER_SIZE];
415 if (!getpwuid_r(uid, &resultbuf, buffer, sizeof(buffer), &result)) {
416 if (sprintf(buf, "%s:%s:%lu:%lu:%s:%s:%s\n",
417 resultbuf.pw_name, resultbuf.pw_passwd,
418 (unsigned long)(resultbuf.pw_uid),
419 (unsigned long)(resultbuf.pw_gid),
420 resultbuf.pw_gecos, resultbuf.pw_dir,
421 resultbuf.pw_shell) >= 0
431 /**********************************************************************/
433 /* FIXME: we don't have such CONFIG_xx - ?! */
435 #if defined CONFIG_USE_BB_THREADSAFE_SHADOW && defined PTHREAD_MUTEX_INITIALIZER
436 static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
437 # define LOCK pthread_mutex_lock(&mylock)
438 # define UNLOCK pthread_mutex_unlock(&mylock);
440 # define LOCK ((void) 0)
441 # define UNLOCK ((void) 0)
444 static FILE *pwf /*= NULL*/;
465 int getpwent_r(struct passwd *__restrict resultbuf,
466 char *__restrict buffer, size_t buflen,
467 struct passwd **__restrict result)
472 *result = NULL; /* In case of error... */
475 pwf = fopen_for_read(_PATH_PASSWD);
482 rv = bb__pgsreader(bb__parsepwent, resultbuf, buffer, buflen, pwf);
492 static FILE *grf /*= NULL*/;
512 int getgrent_r(struct group *__restrict resultbuf,
513 char *__restrict buffer, size_t buflen,
514 struct group **__restrict result)
519 *result = NULL; /* In case of error... */
522 grf = fopen_for_read(_PATH_GROUP);
529 rv = bb__pgsreader(bb__parsegrent, resultbuf, buffer, buflen, grf);
539 #if ENABLE_USE_BB_SHADOW
540 static FILE *spf /*= NULL*/;
560 int getspent_r(struct spwd *resultbuf, char *buffer,
561 size_t buflen, struct spwd **result)
566 *result = NULL; /* In case of error... */
569 spf = fopen_for_read(_PATH_SHADOW);
576 rv = bb__pgsreader(bb__parsespent, resultbuf, buffer, buflen, spf);
588 struct passwd *getpwent(void)
590 static char line_buff[PWD_BUFFER_SIZE];
591 static struct passwd pwd;
592 struct passwd *result;
594 getpwent_r(&pwd, line_buff, sizeof(line_buff), &result);
598 struct group *getgrent(void)
600 static char line_buff[GRP_BUFFER_SIZE];
601 static struct group gr;
602 struct group *result;
604 getgrent_r(&gr, line_buff, sizeof(line_buff), &result);
609 #if 0 //ENABLE_USE_BB_SHADOW
610 struct spwd *getspent(void)
612 static char line_buff[PWD_BUFFER_SIZE];
613 static struct spwd spwd;
616 getspent_r(&spwd, line_buff, sizeof(line_buff), &result);
620 struct spwd *sgetspent(const char *string)
622 static char line_buff[PWD_BUFFER_SIZE];
623 static struct spwd spwd;
626 sgetspent_r(string, &spwd, line_buff, sizeof(line_buff), &result);
631 static gid_t *getgrouplist_internal(int *ngroups_ptr, const char *user, gid_t gid)
637 char buff[PWD_BUFFER_SIZE];
639 /* We alloc space for 8 gids at a time. */
640 group_list = xmalloc(8 * sizeof(group_list[0]));
644 grfile = fopen_for_read(_PATH_GROUP);
646 while (!bb__pgsreader(bb__parsegrent, &group, buff, sizeof(buff), grfile)) {
648 assert(group.gr_mem); /* Must have at least a NULL terminator. */
649 if (group.gr_gid == gid)
651 for (m = group.gr_mem; *m; m++) {
652 if (strcmp(*m, user) != 0)
654 group_list = xrealloc_vector(group_list, /*8=2^3:*/ 3, ngroups);
655 group_list[ngroups++] = group.gr_gid;
661 *ngroups_ptr = ngroups;
665 int initgroups(const char *user, gid_t gid)
668 gid_t *group_list = getgrouplist_internal(&ngroups, user, gid);
670 ngroups = setgroups(ngroups, group_list);
675 int getgrouplist(const char *user, gid_t gid, gid_t *groups, int *ngroups)
677 int ngroups_old = *ngroups;
678 gid_t *group_list = getgrouplist_internal(ngroups, user, gid);
680 if (*ngroups <= ngroups_old) {
681 ngroups_old = *ngroups;
682 memcpy(groups, group_list, ngroups_old * sizeof(groups[0]));
690 int putpwent(const struct passwd *__restrict p, FILE *__restrict f)
699 /* No extra thread locking is needed above what fprintf does. */
700 if (fprintf(f, "%s:%s:%lu:%lu:%s:%s:%s\n",
701 p->pw_name, p->pw_passwd,
702 (unsigned long)(p->pw_uid),
703 (unsigned long)(p->pw_gid),
704 p->pw_gecos, p->pw_dir, p->pw_shell) >= 0
712 int putgrent(const struct group *__restrict p, FILE *__restrict f)
716 if (!p || !f) { /* Sigh... glibc checks. */
721 if (fprintf(f, "%s:%s:%lu:",
722 p->gr_name, p->gr_passwd,
723 (unsigned long)(p->gr_gid)) >= 0
725 static const char format[] ALIGN1 = ",%s";
737 if (fputc('\n', f) >= 0) {
742 if (fprintf(f, fmt, *m) < 0) {
753 #if ENABLE_USE_BB_SHADOW
754 static const unsigned char put_sp_off[] ALIGN1 = {
755 offsetof(struct spwd, sp_lstchg), /* 2 - not a char ptr */
756 offsetof(struct spwd, sp_min), /* 3 - not a char ptr */
757 offsetof(struct spwd, sp_max), /* 4 - not a char ptr */
758 offsetof(struct spwd, sp_warn), /* 5 - not a char ptr */
759 offsetof(struct spwd, sp_inact), /* 6 - not a char ptr */
760 offsetof(struct spwd, sp_expire) /* 7 - not a char ptr */
763 int putspent(const struct spwd *p, FILE *stream)
770 /* Unlike putpwent and putgrent, glibc does not check the args. */
771 if (fprintf(stream, "%s:%s:", p->sp_namp,
772 (p->sp_pwdp ? p->sp_pwdp : "")) < 0
777 for (i = 0; i < sizeof(put_sp_off); i++) {
779 x = *(long *)((char *)p + put_sp_off[i]);
783 if (fprintf(stream, fmt, x) < 0) {
788 if ((p->sp_flag != ~0UL) && (fprintf(stream, "%lu", p->sp_flag) < 0)) {
792 if (fputc('\n', stream) > 0) {
801 /**********************************************************************/
802 /* Internal uClibc functions. */
803 /**********************************************************************/
805 static const unsigned char pw_off[] ALIGN1 = {
806 offsetof(struct passwd, pw_name), /* 0 */
807 offsetof(struct passwd, pw_passwd), /* 1 */
808 offsetof(struct passwd, pw_uid), /* 2 - not a char ptr */
809 offsetof(struct passwd, pw_gid), /* 3 - not a char ptr */
810 offsetof(struct passwd, pw_gecos), /* 4 */
811 offsetof(struct passwd, pw_dir), /* 5 */
812 offsetof(struct passwd, pw_shell) /* 6 */
815 static int FAST_FUNC bb__parsepwent(void *data, char *line)
823 p = (char *) data + pw_off[i];
825 if (i < 2 || i > 3) {
826 *((char **) p) = line;
830 /* NOTE: glibc difference - glibc allows omission of
831 * ':' seperators after the gid field if all remaining
832 * entries are empty. We require all separators. */
833 line = strchr(line, ':');
838 unsigned long t = strtoul(line, &endptr, 10);
839 /* Make sure we had at least one digit, and that the
840 * failing char is the next field seperator ':'. See
841 * glibc difference note above. */
842 /* TODO: Also check for leading whitespace? */
843 if ((endptr == line) || (*endptr != ':')) {
847 if (i & 1) { /* i == 3 -- gid */
849 } else { /* i == 2 -- uid */
861 /**********************************************************************/
863 static const unsigned char gr_off[] ALIGN1 = {
864 offsetof(struct group, gr_name), /* 0 */
865 offsetof(struct group, gr_passwd), /* 1 */
866 offsetof(struct group, gr_gid) /* 2 - not a char ptr */
869 static int FAST_FUNC bb__parsegrent(void *data, char *line)
877 end_of_buf = ((struct group *) data)->gr_name; /* Evil hack! */
880 p = (char *) data + gr_off[i];
883 *((char **) p) = line;
884 line = strchr(line, ':');
891 *((gid_t *) p) = strtoul(line, &endptr, 10);
893 /* NOTE: glibc difference - glibc allows omission of the
894 * trailing colon when there is no member list. We treat
895 * this as an error. */
897 /* Make sure we had at least one digit, and that the
898 * failing char is the next field seperator ':'. See
899 * glibc difference note above. */
900 if ((endptr == line) || (*endptr != ':')) {
904 i = 1; /* Count terminating NULL ptr. */
907 if (p[1]) { /* We have a member list to process. */
908 /* Overwrite the last ':' with a ',' before counting.
909 * This allows us to test for initial ',' and adds
910 * one ',' so that the ',' count equals the member
914 /* NOTE: glibc difference - glibc allows and trims leading
915 * (but not trailing) space. We treat this as an error. */
916 /* NOTE: glibc difference - glibc allows consecutive and
917 * trailing commas, and ignores "empty string" users. We
918 * treat this as an error. */
921 *p = 0; /* nul-terminate each member string. */
922 if (!*++p || (*p == ',') || isspace(*p)) {
929 /* Now align (p+1), rounding up. */
930 /* Assumes sizeof(char **) is a power of 2. */
931 members = (char **)( (((intptr_t) p) + sizeof(char **))
932 & ~((intptr_t)(sizeof(char **) - 1)) );
934 if (((char *)(members + i)) > end_of_buf) { /* No space. */
938 ((struct group *) data)->gr_mem = members;
941 p = endptr; /* Pointing to char prior to first member. */
960 /**********************************************************************/
962 #if ENABLE_USE_BB_SHADOW
963 static const unsigned char sp_off[] ALIGN1 = {
964 offsetof(struct spwd, sp_namp), /* 0: char* */
965 offsetof(struct spwd, sp_pwdp), /* 1: char* */
966 offsetof(struct spwd, sp_lstchg), /* 2: long */
967 offsetof(struct spwd, sp_min), /* 3: long */
968 offsetof(struct spwd, sp_max), /* 4: long */
969 offsetof(struct spwd, sp_warn), /* 5: long */
970 offsetof(struct spwd, sp_inact), /* 6: long */
971 offsetof(struct spwd, sp_expire), /* 7: long */
972 offsetof(struct spwd, sp_flag) /* 8: unsigned long */
975 static int FAST_FUNC bb__parsespent(void *data, char *line)
983 p = (char *) data + sp_off[i];
985 *((char **) p) = line;
986 line = strchr(line, ':');
991 *((long *) p) = strtoul(line, &endptr, 10);
992 if (endptr == line) {
1000 return 0; /* all ok */
1014 /**********************************************************************/
1016 /* Reads until if EOF, or until if finds a line which fits in the buffer
1017 * and for which the parser function succeeds.
1019 * Returns 0 on success and ENOENT for end-of-file (glibc concession).
1021 static int bb__pgsreader(
1022 int FAST_FUNC (*parserfunc)(void *d, char *line),
1024 char *__restrict line_buff,
1031 if (buflen < PWD_BUFFER_SIZE) {
1038 if (!fgets(line_buff, buflen, f)) {
1046 int line_len = strlen(line_buff) - 1;
1047 if (line_len >= 0 && line_buff[line_len] == '\n') {
1048 line_buff[line_len] = '\0';
1050 if (line_len + 2 == buflen) {
1051 /* A start (or continuation) of overlong line */
1054 } /* else: a last line in the file, and it has no '\n' */
1058 /* This "line" is a remainder of overlong line, ignore */
1063 /* NOTE: glibc difference - glibc strips leading whitespace from
1064 * records. We do not allow leading whitespace. */
1066 /* Skip empty lines, comment lines, and lines with leading
1068 if (line_buff[0] != '\0' && line_buff[0] != '#' && !isspace(line_buff[0])) {
1069 if (parserfunc == bb__parsegrent) {
1070 /* Do evil group hack:
1071 * The group entry parsing function needs to know where
1072 * the end of the buffer is so that it can construct the
1073 * group member ptr table. */
1074 ((struct group *) data)->gr_name = line_buff + buflen;
1076 if (parserfunc(data, line_buff) == 0) {