Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/libpwdgrp/pwd_grp.c

    r1765 r2725  
    11/* vi: set sw=4 ts=4: */
    2 /*  Copyright (C) 2003     Manuel Novoa III
     2/* Copyright (C) 2003     Manuel Novoa III
    33 *
    4  *  Licensed under GPL v2, or later.  See file LICENSE in this tarball.
     4 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    55 */
    66
    7 /*  Nov 6, 2003  Initial version.
     7/* Nov 6, 2003  Initial version.
    88 *
    9  *  NOTE: This implementation is quite strict about requiring all
     9 * NOTE: This implementation is quite strict about requiring all
    1010 *    field seperators.  It also does not allow leading whitespace
    1111 *    except when processing the numeric fields.  glibc is more
    1212 *    lenient.  See the various glibc difference comments below.
    1313 *
    14  *  TODO:
     14 * TODO:
    1515 *    Move to dynamic allocation of (currently statically allocated)
    1616 *      buffers; especially for the group-related functions since
    1717 *      large group member lists will cause error returns.
    18  *
    1918 */
    2019
    2120#include "libbb.h"
    22 #include <features.h>
    2321#include <assert.h>
    2422
    2523#ifndef _PATH_SHADOW
    26 #define _PATH_SHADOW    "/etc/shadow"
     24#define _PATH_SHADOW    "/etc/shadow"
    2725#endif
    2826#ifndef _PATH_PASSWD
    29 #define _PATH_PASSWD    "/etc/passwd"
     27#define _PATH_PASSWD    "/etc/passwd"
    3028#endif
    3129#ifndef _PATH_GROUP
    32 #define _PATH_GROUP "/etc/group"
     30#define _PATH_GROUP "/etc/group"
    3331#endif
    3432
     
    4442/* Prototypes for internal functions. */
    4543
    46 static int bb__pgsreader(int (*parserfunc)(void *d, char *line), void *data,
    47         char *__restrict line_buff, size_t buflen, FILE *f);
    48 
    49 static int bb__parsepwent(void *pw, char *line);
    50 static int bb__parsegrent(void *gr, char *line);
     44static int bb__pgsreader(
     45        int FAST_FUNC (*parserfunc)(void *d, char *line),
     46        void *data,
     47        char *__restrict line_buff,
     48        size_t buflen,
     49        FILE *f);
     50
     51static int FAST_FUNC bb__parsepwent(void *pw, char *line);
     52static int FAST_FUNC bb__parsegrent(void *gr, char *line);
    5153#if ENABLE_USE_BB_SHADOW
    52 static int bb__parsespent(void *sp, char *line);
     54static int FAST_FUNC bb__parsespent(void *sp, char *line);
    5355#endif
    5456
     
    162164
    163165#if ENABLE_USE_BB_SHADOW
     166#ifdef UNUSED_FOR_NOW
    164167int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
    165168                char *__restrict buffer, size_t buflen,
     
    178181}
    179182#endif
     183#endif
    180184
    181185/**********************************************************************/
     
    185189/**********************************************************************/
    186190
    187 #if 0
     191#ifdef UNUSED_SINCE_WE_AVOID_STATIC_BUFS
    188192struct passwd *fgetpwent(FILE *stream)
    189193{
     
    210214
    211215#if ENABLE_USE_BB_SHADOW
    212 #if 0
     216#ifdef UNUSED_SINCE_WE_AVOID_STATIC_BUFS
    213217struct spwd *fgetspent(FILE *stream)
    214218{
     
    223227#endif
    224228
     229#ifdef UNUSED_FOR_NOW
    225230int sgetspent_r(const char *string, struct spwd *result_buf,
    226231                char *buffer, size_t buflen, struct spwd **result)
     
    231236
    232237    if (buflen < PWD_BUFFER_SIZE) {
    233     DO_ERANGE:
    234         errno=rv;
     238 DO_ERANGE:
     239        errno = rv;
    235240        goto DONE;
    236241    }
     
    252257}
    253258#endif
     259#endif /* ENABLE_USE_BB_SHADOW */
    254260
    255261/**********************************************************************/
     
    397403#endif
    398404
    399 /* This one doesn't use static buffers */
    400 int getpw(uid_t uid, char *buf)
    401 {
    402     struct passwd resultbuf;
    403     struct passwd *result;
    404     char buffer[PWD_BUFFER_SIZE];
    405 
    406     if (!buf) {
    407         errno = EINVAL;
    408     } else if (!getpwuid_r(uid, &resultbuf, buffer, sizeof(buffer), &result)) {
    409         if (sprintf(buf, "%s:%s:%lu:%lu:%s:%s:%s\n",
    410                     resultbuf.pw_name, resultbuf.pw_passwd,
    411                     (unsigned long)(resultbuf.pw_uid),
    412                     (unsigned long)(resultbuf.pw_gid),
    413                     resultbuf.pw_gecos, resultbuf.pw_dir,
    414                     resultbuf.pw_shell) >= 0
    415             ) {
    416             return 0;
    417         }
    418     }
    419 
    420     return -1;
    421 }
    422 
    423405/**********************************************************************/
    424406
     
    465447
    466448    if (!pwf) {
    467         pwf = fopen(_PATH_PASSWD, "r");
     449        pwf = fopen_for_read(_PATH_PASSWD);
    468450        if (!pwf) {
    469451            rv = errno;
     
    512494
    513495    if (!grf) {
    514         grf = fopen(_PATH_GROUP, "r");
     496        grf = fopen_for_read(_PATH_GROUP);
    515497        if (!grf) {
    516498            rv = errno;
     
    529511}
    530512
     513#ifdef UNUSED_FOR_NOW
    531514#if ENABLE_USE_BB_SHADOW
    532515static FILE *spf /*= NULL*/;
     
    559542
    560543    if (!spf) {
    561         spf = fopen(_PATH_SHADOW, "r");
     544        spf = fopen_for_read(_PATH_SHADOW);
    562545        if (!spf) {
    563546            rv = errno;
     
    576559}
    577560#endif
    578 
    579 #if 0
     561#endif /* UNUSED_FOR_NOW */
     562
     563#ifdef UNUSED_SINCE_WE_AVOID_STATIC_BUFS
    580564struct passwd *getpwent(void)
    581565{
     
    597581    return result;
    598582}
    599 #endif
    600 
    601 #if 0 //ENABLE_USE_BB_SHADOW
     583
     584#if ENABLE_USE_BB_SHADOW
    602585struct spwd *getspent(void)
    603586{
     
    620603}
    621604#endif
    622 
    623 int initgroups(const char *user, gid_t gid)
     605#endif /* UNUSED_SINCE_WE_AVOID_STATIC_BUFS */
     606
     607static gid_t *getgrouplist_internal(int *ngroups_ptr, const char *user, gid_t gid)
    624608{
    625609    FILE *grfile;
    626610    gid_t *group_list;
    627     int num_groups, rv;
    628     char **m;
     611    int ngroups;
    629612    struct group group;
    630613    char buff[PWD_BUFFER_SIZE];
    631614
    632     rv = -1;
    633 
    634615    /* We alloc space for 8 gids at a time. */
    635     group_list = (gid_t *) malloc(8*sizeof(gid_t *));
    636     if (group_list
    637      && ((grfile = fopen(_PATH_GROUP, "r")) != NULL)
     616    group_list = xmalloc(8 * sizeof(group_list[0]));
     617    group_list[0] = gid;
     618    ngroups = 1;
     619
     620    grfile = fopen_for_read(_PATH_GROUP);
     621    if (grfile) {
     622        while (!bb__pgsreader(bb__parsegrent, &group, buff, sizeof(buff), grfile)) {
     623            char **m;
     624            assert(group.gr_mem); /* Must have at least a NULL terminator. */
     625            if (group.gr_gid == gid)
     626                continue;
     627            for (m = group.gr_mem; *m; m++) {
     628                if (strcmp(*m, user) != 0)
     629                    continue;
     630                group_list = xrealloc_vector(group_list, /*8=2^3:*/ 3, ngroups);
     631                group_list[ngroups++] = group.gr_gid;
     632                break;
     633            }
     634        }
     635        fclose(grfile);
     636    }
     637    *ngroups_ptr = ngroups;
     638    return group_list;
     639}
     640
     641int initgroups(const char *user, gid_t gid)
     642{
     643    int ngroups;
     644    gid_t *group_list = getgrouplist_internal(&ngroups, user, gid);
     645
     646    ngroups = setgroups(ngroups, group_list);
     647    free(group_list);
     648    return ngroups;
     649}
     650
     651int getgrouplist(const char *user, gid_t gid, gid_t *groups, int *ngroups)
     652{
     653    int ngroups_old = *ngroups;
     654    gid_t *group_list = getgrouplist_internal(ngroups, user, gid);
     655
     656    if (*ngroups <= ngroups_old) {
     657        ngroups_old = *ngroups;
     658        memcpy(groups, group_list, ngroups_old * sizeof(groups[0]));
     659    } else {
     660        ngroups_old = -1;
     661    }
     662    free(group_list);
     663    return ngroups_old;
     664}
     665
     666#ifdef UNUSED_SINCE_WE_AVOID_STATIC_BUFS
     667int putpwent(const struct passwd *__restrict p, FILE *__restrict f)
     668{
     669    int rv = -1;
     670
     671#if 0
     672    /* glibc does this check */
     673    if (!p || !f) {
     674        errno = EINVAL;
     675        return rv;
     676    }
     677#endif
     678
     679    /* No extra thread locking is needed above what fprintf does. */
     680    if (fprintf(f, "%s:%s:%lu:%lu:%s:%s:%s\n",
     681                p->pw_name, p->pw_passwd,
     682                (unsigned long)(p->pw_uid),
     683                (unsigned long)(p->pw_gid),
     684                p->pw_gecos, p->pw_dir, p->pw_shell) >= 0
     685        ) {
     686        rv = 0;
     687    }
     688
     689    return rv;
     690}
     691
     692int putgrent(const struct group *__restrict p, FILE *__restrict f)
     693{
     694    int rv = -1;
     695
     696#if 0
     697    /* glibc does this check */
     698    if (!p || !f) {
     699        errno = EINVAL;
     700        return rv;
     701    }
     702#endif
     703
     704    if (fprintf(f, "%s:%s:%lu:",
     705                p->gr_name, p->gr_passwd,
     706                (unsigned long)(p->gr_gid)) >= 0
    638707    ) {
    639         *group_list = gid;
    640         num_groups = 1;
    641 
    642         while (!bb__pgsreader(bb__parsegrent, &group, buff, sizeof(buff), grfile)) {
    643             assert(group.gr_mem); /* Must have at least a NULL terminator. */
    644             if (group.gr_gid != gid) {
    645                 for (m = group.gr_mem; *m; m++) {
    646                     if (!strcmp(*m, user)) {
    647                         if (!(num_groups & 7)) {
    648                             gid_t *tmp = (gid_t *)
    649                                 realloc(group_list,
    650                                         (num_groups+8) * sizeof(gid_t *));
    651                             if (!tmp) {
    652                                 rv = -1;
    653                                 goto DO_CLOSE;
    654                             }
    655                             group_list = tmp;
    656                         }
    657                         group_list[num_groups++] = group.gr_gid;
    658                         break;
    659                     }
     708        static const char format[] ALIGN1 = ",%s";
     709
     710        char **m;
     711        const char *fmt;
     712
     713        fmt = format + 1;
     714
     715        assert(p->gr_mem);
     716        m = p->gr_mem;
     717
     718        while (1) {
     719            if (!*m) {
     720                if (fputc('\n', f) >= 0) {
     721                    rv = 0;
    660722                }
    661             }
    662         }
    663 
    664         rv = setgroups(num_groups, group_list);
    665     DO_CLOSE:
    666         fclose(grfile);
    667     }
    668 
    669     /* group_list will be NULL if initial malloc failed, which may trigger
    670      * warnings from various malloc debuggers. */
    671     free(group_list);
    672     return rv;
    673 }
    674 
    675 int putpwent(const struct passwd *__restrict p, FILE *__restrict f)
    676 {
    677     int rv = -1;
    678 
    679     if (!p || !f) {
    680         errno=EINVAL;
    681     } else {
    682         /* No extra thread locking is needed above what fprintf does. */
    683         if (fprintf(f, "%s:%s:%lu:%lu:%s:%s:%s\n",
    684                     p->pw_name, p->pw_passwd,
    685                     (unsigned long)(p->pw_uid),
    686                     (unsigned long)(p->pw_gid),
    687                     p->pw_gecos, p->pw_dir, p->pw_shell) >= 0
    688             ) {
    689             rv = 0;
    690         }
    691     }
    692 
    693     return rv;
    694 }
    695 
    696 int putgrent(const struct group *__restrict p, FILE *__restrict f)
    697 {
    698     static const char format[] ALIGN1 = ",%s";
    699 
    700     char **m;
    701     const char *fmt;
    702     int rv = -1;
    703 
    704     if (!p || !f) {             /* Sigh... glibc checks. */
    705         errno=EINVAL;
    706     } else {
    707         if (fprintf(f, "%s:%s:%lu:",
    708                     p->gr_name, p->gr_passwd,
    709                     (unsigned long)(p->gr_gid)) >= 0
    710             ) {
    711 
    712             fmt = format + 1;
    713 
    714             assert(p->gr_mem);
    715             m = p->gr_mem;
    716 
    717             do {
    718                 if (!*m) {
    719                     if (fputc('\n', f) >= 0) {
    720                         rv = 0;
    721                     }
    722                     break;
    723                 }
    724                 if (fprintf(f, fmt, *m) < 0) {
    725                     break;
    726                 }
    727                 ++m;
    728                 fmt = format;
    729             } while (1);
    730 
    731         }
    732 
    733     }
    734 
    735     return rv;
    736 }
     723                break;
     724            }
     725            if (fprintf(f, fmt, *m) < 0) {
     726                break;
     727            }
     728            m++;
     729            fmt = format;
     730        }
     731    }
     732
     733    return rv;
     734}
     735#endif
    737736
    738737#if ENABLE_USE_BB_SHADOW
    739 static const unsigned char _sp_off[] ALIGN1 = {
     738#ifdef UNUSED_FOR_NOW
     739static const unsigned char put_sp_off[] ALIGN1 = {
    740740    offsetof(struct spwd, sp_lstchg),       /* 2 - not a char ptr */
    741741    offsetof(struct spwd, sp_min),          /* 3 - not a char ptr */
     
    748748int putspent(const struct spwd *p, FILE *stream)
    749749{
    750     static const char ld_format[] ALIGN1 = "%ld:";
    751 
    752     const char *f;
     750    const char *fmt;
    753751    long x;
    754752    int i;
     
    762760    }
    763761
    764     for (i = 0; i < sizeof(_sp_off); i++) {
    765         f = ld_format;
    766         x = *(const long *)(((const char *) p) + _sp_off[i]);
     762    for (i = 0; i < sizeof(put_sp_off); i++) {
     763        fmt = "%ld:";
     764        x = *(long *)((char *)p + put_sp_off[i]);
    767765        if (x == -1) {
    768             f += 3;
    769         }
    770         if (fprintf(stream, f, x) < 0) {
     766            fmt += 3;
     767        }
     768        if (fprintf(stream, fmt, x) < 0) {
    771769            goto DO_UNLOCK;
    772770        }
     
    781779    }
    782780
    783 DO_UNLOCK:
    784     return rv;
    785 }
    786 #endif
    787 
    788 /**********************************************************************/
    789 /* Internal uClibc functions.                                         */
     781 DO_UNLOCK:
     782    return rv;
     783}
     784#endif
     785#endif /* USE_BB_SHADOW */
     786
     787/**********************************************************************/
     788/* Internal functions                                                 */
    790789/**********************************************************************/
    791790
     
    800799};
    801800
    802 static int bb__parsepwent(void *data, char *line)
     801static int FAST_FUNC bb__parsepwent(void *data, char *line)
    803802{
    804803    char *endptr;
     
    807806
    808807    i = 0;
    809     do {
    810         p = ((char *) ((struct passwd *) data)) + pw_off[i];
    811 
    812         if ((i & 6) ^ 2) {  /* i!=2 and i!=3 */
     808    while (1) {
     809        p = (char *) data + pw_off[i];
     810
     811        if (i < 2 || i > 3) {
    813812            *((char **) p) = line;
    814             if (i==6) {
     813            if (i == 6) {
    815814                return 0;
    816815            }
     
    839838        }
    840839
    841         *line++ = 0;
    842         ++i;
    843     } while (1);
     840        *line++ = '\0';
     841        i++;
     842    } /* while (1) */
    844843
    845844    return -1;
     
    854853};
    855854
    856 static int bb__parsegrent(void *data, char *line)
     855static int FAST_FUNC bb__parsegrent(void *data, char *line)
    857856{
    858857    char *endptr;
     
    864863    end_of_buf = ((struct group *) data)->gr_name; /* Evil hack! */
    865864    i = 0;
    866     do {
    867         p = ((char *) ((struct group *) data)) + gr_off[i];
     865    while (1) {
     866        p = (char *) data + gr_off[i];
    868867
    869868        if (i < 2) {
     
    873872                break;
    874873            }
    875             *line++ = 0;
    876             ++i;
     874            *line++ = '\0';
     875            i++;
    877876        } else {
    878877            *((gid_t *) p) = strtoul(line, &endptr, 10);
     
    894893            if (p[1]) { /* We have a member list to process. */
    895894                /* Overwrite the last ':' with a ',' before counting.
    896                  * This allows us to test for initial ',' and adds
    897                  * one ',' so that the ',' count equals the member
    898                  * count. */
     895                 * This allows us to (1) test for initial ','
     896                 * and (2) adds one ',' so that the number of commas
     897                 * equals the member count. */
    899898                *p = ',';
    900899                do {
     
    927926            if (--i) {
    928927                p = endptr; /* Pointing to char prior to first member. */
    929                 do {
     928                while (1) {
    930929                    *members++ = ++p;
    931                     if (!--i) break;
    932                     while (*++p) {}
    933                 } while (1);
     930                    if (!--i)
     931                        break;
     932                    while (*++p)
     933                        continue;
     934                }
    934935            }
    935936            *members = NULL;
     
    937938            return 0;
    938939        }
    939     } while (1);
     940    } /* while (1) */
    940941
    941942 ERR:
     
    947948#if ENABLE_USE_BB_SHADOW
    948949static const unsigned char sp_off[] ALIGN1 = {
    949     offsetof(struct spwd, sp_namp),         /* 0 */
    950     offsetof(struct spwd, sp_pwdp),         /* 1 */
    951     offsetof(struct spwd, sp_lstchg),       /* 2 - not a char ptr */
    952     offsetof(struct spwd, sp_min),          /* 3 - not a char ptr */
    953     offsetof(struct spwd, sp_max),          /* 4 - not a char ptr */
    954     offsetof(struct spwd, sp_warn),         /* 5 - not a char ptr */
    955     offsetof(struct spwd, sp_inact),        /* 6 - not a char ptr */
    956     offsetof(struct spwd, sp_expire),       /* 7 - not a char ptr */
    957     offsetof(struct spwd, sp_flag)          /* 8 - not a char ptr */
     950    offsetof(struct spwd, sp_namp),         /* 0: char* */
     951    offsetof(struct spwd, sp_pwdp),         /* 1: char* */
     952    offsetof(struct spwd, sp_lstchg),       /* 2: long */
     953    offsetof(struct spwd, sp_min),          /* 3: long */
     954    offsetof(struct spwd, sp_max),          /* 4: long */
     955    offsetof(struct spwd, sp_warn),         /* 5: long */
     956    offsetof(struct spwd, sp_inact),        /* 6: long */
     957    offsetof(struct spwd, sp_expire),       /* 7: long */
     958    offsetof(struct spwd, sp_flag)          /* 8: unsigned long */
    958959};
    959960
    960 static int bb__parsespent(void *data, char * line)
     961static int FAST_FUNC bb__parsespent(void *data, char *line)
    961962{
    962963    char *endptr;
     
    965966
    966967    i = 0;
    967     do {
    968         p = ((char *) ((struct spwd *) data)) + sp_off[i];
     968    while (1) {
     969        p = (char *) data + sp_off[i];
    969970        if (i < 2) {
    970971            *((char **) p) = line;
    971972            line = strchr(line, ':');
    972973            if (!line) {
    973                 break;
     974                break; /* error */
    974975            }
    975976        } else {
    976             *((long *) p) = (long) strtoul(line, &endptr, 10);
    977 
     977            *((long *) p) = strtoul(line, &endptr, 10);
    978978            if (endptr == line) {
    979                 *((long *) p) = ((i != 8) ? -1L : ((long)(~0UL)));
    980             }
    981 
     979                *((long *) p) = -1L;
     980            }
    982981            line = endptr;
    983 
    984982            if (i == 8) {
    985                 if (!*endptr) {
    986                     return 0;
     983                if (*line != '\0') {
     984                    break; /* error */
    987985                }
    988                 break;
    989             }
    990 
    991             if (*endptr != ':') {
    992                 break;
    993             }
    994 
    995         }
    996 
    997         *line++ = 0;
    998         ++i;
    999     } while (1);
     986                return 0; /* all ok */
     987            }
     988            if (*line != ':') {
     989                break; /* error */
     990            }
     991        }
     992        *line++ = '\0';
     993        i++;
     994    }
    1000995
    1001996    return EINVAL;
     
    10051000/**********************************************************************/
    10061001
    1007 /* Reads until if EOF, or until if finds a line which fits in the buffer
     1002/* Reads until EOF, or until it finds a line which fits in the buffer
    10081003 * and for which the parser function succeeds.
    10091004 *
    1010  * Returns 0 on success and ENOENT for end-of-file (glibc concession).
     1005 * Returns 0 on success and ENOENT for end-of-file (glibc convention).
    10111006 */
    1012 
    1013 static int bb__pgsreader(int (*parserfunc)(void *d, char *line), void *data,
    1014                 char *__restrict line_buff, size_t buflen, FILE *f)
    1015 {
    1016     int line_len;
     1007static int bb__pgsreader(
     1008        int FAST_FUNC (*parserfunc)(void *d, char *line),
     1009        void *data,
     1010        char *__restrict line_buff,
     1011        size_t buflen,
     1012        FILE *f)
     1013{
    10171014    int skip;
    10181015    int rv = ERANGE;
     
    10201017    if (buflen < PWD_BUFFER_SIZE) {
    10211018        errno = rv;
    1022     } else {
    1023         skip = 0;
    1024         do {
    1025             if (!fgets(line_buff, buflen, f)) {
    1026                 if (feof(f)) {
    1027                     rv = ENOENT;
    1028                 }
     1019        return rv;
     1020    }
     1021
     1022    skip = 0;
     1023    while (1) {
     1024        if (!fgets(line_buff, buflen, f)) {
     1025            if (feof(f)) {
     1026                rv = ENOENT;
     1027            }
     1028            break;
     1029        }
     1030
     1031        {
     1032            int line_len = strlen(line_buff) - 1;
     1033            if (line_len >= 0 && line_buff[line_len] == '\n') {
     1034                line_buff[line_len] = '\0';
     1035            } else
     1036            if (line_len + 2 == buflen) {
     1037                /* A start (or continuation) of overlong line */
     1038                skip = 1;
     1039                continue;
     1040            } /* else: a last line in the file, and it has no '\n' */
     1041        }
     1042
     1043        if (skip) {
     1044            /* This "line" is a remainder of overlong line, ignore */
     1045            skip = 0;
     1046            continue;
     1047        }
     1048
     1049        /* NOTE: glibc difference - glibc strips leading whitespace from
     1050         * records.  We do not allow leading whitespace. */
     1051
     1052        /* Skip empty lines, comment lines, and lines with leading
     1053         * whitespace. */
     1054        if (line_buff[0] != '\0' && line_buff[0] != '#' && !isspace(line_buff[0])) {
     1055            if (parserfunc == bb__parsegrent) {
     1056                /* Do evil group hack:
     1057                 * The group entry parsing function needs to know where
     1058                 * the end of the buffer is so that it can construct the
     1059                 * group member ptr table. */
     1060                ((struct group *) data)->gr_name = line_buff + buflen;
     1061            }
     1062            if (parserfunc(data, line_buff) == 0) {
     1063                rv = 0;
    10291064                break;
    10301065            }
    1031 
    1032             line_len = strlen(line_buff) - 1; /* strlen() must be > 0. */
    1033             if (line_buff[line_len] == '\n') {
    1034                 line_buff[line_len] = 0;
    1035             } else if (line_len + 2 == buflen) { /* line too long */
    1036                 ++skip;
    1037                 continue;
    1038             }
    1039 
    1040             if (skip) {
    1041                 --skip;
    1042                 continue;
    1043             }
    1044 
    1045             /* NOTE: glibc difference - glibc strips leading whitespace from
    1046              * records.  We do not allow leading whitespace. */
    1047 
    1048             /* Skip empty lines, comment lines, and lines with leading
    1049              * whitespace. */
    1050             if (*line_buff && (*line_buff != '#') && !isspace(*line_buff)) {
    1051                 if (parserfunc == bb__parsegrent) { /* Do evil group hack. */
    1052                     /* The group entry parsing function needs to know where
    1053                      * the end of the buffer is so that it can construct the
    1054                      * group member ptr table. */
    1055                     ((struct group *) data)->gr_name = line_buff + buflen;
    1056                 }
    1057 
    1058                 if (!parserfunc(data, line_buff)) {
    1059                     rv = 0;
    1060                     break;
    1061                 }
    1062             }
    1063         } while (1);
    1064 
    1065     }
    1066 
    1067     return rv;
    1068 }
     1066        }
     1067    } /* while (1) */
     1068
     1069    return rv;
     1070}
Note: See TracChangeset for help on using the changeset viewer.