Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (7 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

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

    r2725 r3232  
    2121#include <assert.h>
    2222
    23 #ifndef _PATH_SHADOW
    24 #define _PATH_SHADOW    "/etc/shadow"
    25 #endif
    26 #ifndef _PATH_PASSWD
    27 #define _PATH_PASSWD    "/etc/passwd"
    28 #endif
    29 #ifndef _PATH_GROUP
    30 #define _PATH_GROUP "/etc/group"
    31 #endif
    32 
    3323/**********************************************************************/
    3424/* Sizes for statically allocated buffers. */
    3525
    36 /* If you change these values, also change _SC_GETPW_R_SIZE_MAX and
    37  * _SC_GETGR_R_SIZE_MAX in libc/unistd/sysconf.c to match */
    3826#define PWD_BUFFER_SIZE 256
    3927#define GRP_BUFFER_SIZE 256
     
    6048struct statics {
    6149    /* Smaller things first */
    62     struct passwd getpwuid_resultbuf;
    63     struct group getgrgid_resultbuf;
    64     struct passwd getpwnam_resultbuf;
    65     struct group getgrnam_resultbuf;
    66 
    67     char getpwuid_buffer[PWD_BUFFER_SIZE];
    68     char getgrgid_buffer[GRP_BUFFER_SIZE];
    69     char getpwnam_buffer[PWD_BUFFER_SIZE];
    70     char getgrnam_buffer[GRP_BUFFER_SIZE];
    71 #if 0
    72     struct passwd fgetpwent_resultbuf;
    73     struct group fgetgrent_resultbuf;
    74     struct spwd fgetspent_resultbuf;
    75     char fgetpwent_buffer[PWD_BUFFER_SIZE];
    76     char fgetgrent_buffer[GRP_BUFFER_SIZE];
    77     char fgetspent_buffer[PWD_BUFFER_SIZE];
    78 #endif
     50    /* It's ok to use one buffer for getpwuid and getpwnam. Manpage says:
     51     * "The return value may point to a static area, and may be overwritten
     52     * by subsequent calls to getpwent(), getpwnam(), or getpwuid()."
     53     */
     54    struct passwd getpw_resultbuf;
     55    struct group getgr_resultbuf;
     56
     57    char getpw_buffer[PWD_BUFFER_SIZE];
     58    char getgr_buffer[GRP_BUFFER_SIZE];
    7959#if 0 //ENABLE_USE_BB_SHADOW
    80     struct spwd getspuid_resultbuf;
    81     struct spwd getspnam_resultbuf;
    82     char getspuid_buffer[PWD_BUFFER_SIZE];
    83     char getspnam_buffer[PWD_BUFFER_SIZE];
     60    struct spwd getsp_resultbuf;
     61    char getsp_buffer[PWD_BUFFER_SIZE];
    8462#endif
    8563// Not converted - too small to bother
     
    8866//FILE *grf /*= NULL*/;
    8967//FILE *spf /*= NULL*/;
    90 #if 0
    91     struct passwd getpwent_pwd;
    92     struct group getgrent_gr;
    93     char getpwent_line_buff[PWD_BUFFER_SIZE];
    94     char getgrent_line_buff[GRP_BUFFER_SIZE];
    95 #endif
    96 #if 0 //ENABLE_USE_BB_SHADOW
    97     struct spwd getspent_spwd;
    98     struct spwd sgetspent_spwd;
    99     char getspent_line_buff[PWD_BUFFER_SIZE];
    100     char sgetspent_line_buff[PWD_BUFFER_SIZE];
    101 #endif
    10268};
    10369
     
    193159{
    194160    struct statics *S;
    195     struct passwd *resultbuf = RESULTBUF(fgetpwent);
    196     char *buffer = BUFFER(fgetpwent);
     161    struct passwd *resultbuf = RESULTBUF(getpw);
     162    char *buffer = BUFFER(getpw);
    197163    struct passwd *result;
    198164
    199     fgetpwent_r(stream, resultbuf, buffer, sizeof(BUFFER(fgetpwent)), &result);
     165    fgetpwent_r(stream, resultbuf, buffer, sizeof(BUFFER(getpw)), &result);
    200166    return result;
    201167}
     
    204170{
    205171    struct statics *S;
    206     struct group *resultbuf = RESULTBUF(fgetgrent);
    207     char *buffer = BUFFER(fgetgrent);
     172    struct group *resultbuf = RESULTBUF(getgr);
     173    char *buffer = BUFFER(getgr);
    208174    struct group *result;
    209175
    210     fgetgrent_r(stream, resultbuf, buffer, sizeof(BUFFER(fgetgrent)), &result);
     176    fgetgrent_r(stream, resultbuf, buffer, sizeof(BUFFER(getgr)), &result);
    211177    return result;
    212178}
     
    218184{
    219185    struct statics *S;
    220     struct spwd *resultbuf = RESULTBUF(fgetspent);
    221     char *buffer = BUFFER(fgetspent);
     186    struct spwd *resultbuf = RESULTBUF(getsp);
     187    char *buffer = BUFFER(getsp);
    222188    struct spwd *result;
    223189
    224     fgetspent_r(stream, resultbuf, buffer, sizeof(BUFFER(fgetspent)), &result);
     190    fgetspent_r(stream, resultbuf, buffer, sizeof(BUFFER(getsp)), &result);
    225191    return result;
    226192}
     
    310276{
    311277    struct statics *S;
    312     struct passwd *resultbuf = RESULTBUF(getpwuid);
    313     char *buffer = BUFFER(getpwuid);
     278    struct passwd *resultbuf = RESULTBUF(getpw);
     279    char *buffer = BUFFER(getpw);
    314280    struct passwd *result;
    315281
    316     getpwuid_r(uid, resultbuf, buffer, sizeof(BUFFER(getpwuid)), &result);
     282    getpwuid_r(uid, resultbuf, buffer, sizeof(BUFFER(getpw)), &result);
    317283    return result;
    318284}
     
    322288{
    323289    struct statics *S;
    324     struct group *resultbuf = RESULTBUF(getgrgid);
    325     char *buffer = BUFFER(getgrgid);
     290    struct group *resultbuf = RESULTBUF(getgr);
     291    char *buffer = BUFFER(getgr);
    326292    struct group *result;
    327293
    328     getgrgid_r(gid, resultbuf, buffer, sizeof(BUFFER(getgrgid)), &result);
     294    getgrgid_r(gid, resultbuf, buffer, sizeof(BUFFER(getgr)), &result);
    329295    return result;
    330296}
     
    335301 * functions getspuid.  Why getspuid was added, I do not know. */
    336302int getspuid_r(uid_t uid, struct spwd *__restrict resultbuf,
    337                char *__restrict buffer, size_t buflen,
    338                struct spwd **__restrict result)
     303            char *__restrict buffer, size_t buflen,
     304            struct spwd **__restrict result)
    339305{
    340306    int rv;
     
    357323{
    358324    struct statics *S;
    359     struct spwd *resultbuf = RESULTBUF(getspuid);
    360     char *buffer = BUFFER(getspuid);
     325    struct spwd *resultbuf = RESULTBUF(getsp);
     326    char *buffer = BUFFER(getsp);
    361327    struct spwd *result;
    362328
    363     getspuid_r(uid, resultbuf, buffer, sizeof(BUFFER(getspuid)), &result);
     329    getspuid_r(uid, resultbuf, buffer, sizeof(BUFFER(getsp)), &result);
    364330    return result;
    365331}
     
    370336{
    371337    struct statics *S;
    372     struct passwd *resultbuf = RESULTBUF(getpwnam);
    373     char *buffer = BUFFER(getpwnam);
     338    struct passwd *resultbuf = RESULTBUF(getpw);
     339    char *buffer = BUFFER(getpw);
    374340    struct passwd *result;
    375341
    376     getpwnam_r(name, resultbuf, buffer, sizeof(BUFFER(getpwnam)), &result);
     342    getpwnam_r(name, resultbuf, buffer, sizeof(BUFFER(getpw)), &result);
    377343    return result;
    378344}
     
    382348{
    383349    struct statics *S;
    384     struct group *resultbuf = RESULTBUF(getgrnam);
    385     char *buffer = BUFFER(getgrnam);
     350    struct group *resultbuf = RESULTBUF(getgr);
     351    char *buffer = BUFFER(getgr);
    386352    struct group *result;
    387353
    388     getgrnam_r(name, resultbuf, buffer, sizeof(BUFFER(getgrnam)), &result);
     354    getgrnam_r(name, resultbuf, buffer, sizeof(BUFFER(getgr)), &result);
    389355    return result;
    390356}
     
    394360{
    395361    struct statics *S;
    396     struct spwd *resultbuf = RESULTBUF(getspnam);
    397     char *buffer = BUFFER(getspnam);
     362    struct spwd *resultbuf = RESULTBUF(getsp);
     363    char *buffer = BUFFER(getsp);
    398364    struct spwd *result;
    399365
    400     getspnam_r(name, resultbuf, buffer, sizeof(BUFFER(getspnam)), &result);
     366    getspnam_r(name, resultbuf, buffer, sizeof(BUFFER(getsp)), &result);
    401367    return result;
    402368}
     
    438404
    439405int getpwent_r(struct passwd *__restrict resultbuf,
    440                char *__restrict buffer, size_t buflen,
    441                struct passwd **__restrict result)
     406            char *__restrict buffer, size_t buflen,
     407            struct passwd **__restrict result)
    442408{
    443409    int rv;
     
    452418            goto ERR;
    453419        }
     420        close_on_exec_on(fileno(pwf));
    454421    }
    455422
     
    485452
    486453int getgrent_r(struct group *__restrict resultbuf,
    487                char *__restrict buffer, size_t buflen,
    488                struct group **__restrict result)
     454            char *__restrict buffer, size_t buflen,
     455            struct group **__restrict result)
    489456{
    490457    int rv;
     
    499466            goto ERR;
    500467        }
     468        close_on_exec_on(fileno(grf));
    501469    }
    502470
     
    534502
    535503int getspent_r(struct spwd *resultbuf, char *buffer,
    536                size_t buflen, struct spwd **result)
     504            size_t buflen, struct spwd **result)
    537505{
    538506    int rv;
     
    547515            goto ERR;
    548516        }
     517        close_on_exec_on(fileno(spf));
    549518    }
    550519
Note: See TracChangeset for help on using the changeset viewer.