openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/shadow/4.6-r0/shadow-4.6/src/newusers.c
static void open_files(void)
{
    /*
     * Lock the password files and open them for update. This will bring
     * all of the entries into memory where they may be searched for an
     * modified, or new entries added. The password file is the key - if
     * it gets locked, assume the others can be locked right away.
     */
    if (pw_lock() == 0)
    {
        fprintf(stderr, _("%s: cannot lock %s; try again later.\n"), Prog,
                pw_dbname());
        fail_exit(EXIT_FAILURE);
    }
    pw_locked = true;
    if (is_shadow)
    {
        if (spw_lock() == 0)
        {
            fprintf(stderr, _("%s: cannot lock %s; try again later.\n"), Prog,
                    spw_dbname());
            fail_exit(EXIT_FAILURE);
        }
        spw_locked = true;
    }
    if (gr_lock() == 0)
    {
        fprintf(stderr, _("%s: cannot lock %s; try again later.\n"), Prog,
                gr_dbname());
        fail_exit(EXIT_FAILURE);
    }
    gr_locked = true;
#ifdef SHADOWGRP
    if (is_shadow_grp)
    {
        if (sgr_lock() == 0)
        {
            fprintf(stderr, _("%s: cannot lock %s; try again later.\n"), Prog,
                    sgr_dbname());
            fail_exit(EXIT_FAILURE);
        }
        sgr_locked = true;
    }
#endif
#ifdef ENABLE_SUBIDS
    if (is_sub_uid)
    {
        if (sub_uid_lock() == 0)
        {
            fprintf(stderr, _("%s: cannot lock %s; try again later.\n"), Prog,
                    sub_uid_dbname());
            fail_exit(EXIT_FAILURE);
        }
        sub_uid_locked = true;
    }
    if (is_sub_gid)
    {
        if (sub_gid_lock() == 0)
        {
            fprintf(stderr, _("%s: cannot lock %s; try again later.\n"), Prog,
                    sub_gid_dbname());
            fail_exit(EXIT_FAILURE);
        }
        sub_gid_locked = true;
    }
#endif /* ENABLE_SUBIDS */

    if (pw_open(O_CREAT | O_RDWR) == 0)
    {
        fprintf(stderr, _("%s: cannot open %s\n"), Prog, pw_dbname());
        fail_exit(EXIT_FAILURE);
    }
    if (is_shadow && (spw_open(O_CREAT | O_RDWR) == 0))
    {
        fprintf(stderr, _("%s: cannot open %s\n"), Prog, spw_dbname());
        fail_exit(EXIT_FAILURE);
    }
    if (gr_open(O_CREAT | O_RDWR) == 0)
    {
        fprintf(stderr, _("%s: cannot open %s\n"), Prog, gr_dbname());
        fail_exit(EXIT_FAILURE);
    }
#ifdef SHADOWGRP
    if (is_shadow_grp && (sgr_open(O_CREAT | O_RDWR) == 0))
    {
        fprintf(stderr, _("%s: cannot open %s\n"), Prog, sgr_dbname());
        fail_exit(EXIT_FAILURE);
    }
#endif
#ifdef ENABLE_SUBIDS
    if (is_sub_uid)
    {
        if (sub_uid_open(O_CREAT | O_RDWR) == 0)
        {
            fprintf(stderr, _("%s: cannot open %s\n"), Prog, sub_uid_dbname());
            fail_exit(EXIT_FAILURE);
        }
    }
    if (is_sub_gid)
    {
        if (sub_gid_open(O_CREAT | O_RDWR) == 0)
        {
            fprintf(stderr, _("%s: cannot open %s\n"), Prog, sub_gid_dbname());
            fail_exit(EXIT_FAILURE);
        }
    }
#endif /* ENABLE_SUBIDS */
}
/*
 * open_files - lock and open the password, group and shadow databases
 */
lock and open the password, group and shadow databases
lock and open the password group and shadow databases
static void open_files(void)
{
    if (pw_lock() == 0)
    {
        fprintf(stderr, _("%s: cannot lock %s; try again later.\n"), Prog,
                pw_dbname());
        fail_exit(EXIT_FAILURE);
    }
    pw_locked = true;
    if (is_shadow)
    {
        if (spw_lock() == 0)
        {
            fprintf(stderr, _("%s: cannot lock %s; try again later.\n"), Prog,
                    spw_dbname());
            fail_exit(EXIT_FAILURE);
        }
        spw_locked = true;
    }
    if (gr_lock() == 0)
    {
        fprintf(stderr, _("%s: cannot lock %s; try again later.\n"), Prog,
                gr_dbname());
        fail_exit(EXIT_FAILURE);
    }
    gr_locked = true;
#ifdef SHADOWGRP
    if (is_shadow_grp)
    {
        if (sgr_lock() == 0)
        {
            fprintf(stderr, _("%s: cannot lock %s; try again later.\n"), Prog,
                    sgr_dbname());
            fail_exit(EXIT_FAILURE);
        }
        sgr_locked = true;
    }
#endif
#ifdef ENABLE_SUBIDS
    if (is_sub_uid)
    {
        if (sub_uid_lock() == 0)
        {
            fprintf(stderr, _("%s: cannot lock %s; try again later.\n"), Prog,
                    sub_uid_dbname());
            fail_exit(EXIT_FAILURE);
        }
        sub_uid_locked = true;
    }
    if (is_sub_gid)
    {
        if (sub_gid_lock() == 0)
        {
            fprintf(stderr, _("%s: cannot lock %s; try again later.\n"), Prog,
                    sub_gid_dbname());
            fail_exit(EXIT_FAILURE);
        }
        sub_gid_locked = true;
    }
#endif 
    if (pw_open(O_CREAT | O_RDWR) == 0)
    {
        fprintf(stderr, _("%s: cannot open %s\n"), Prog, pw_dbname());
        fail_exit(EXIT_FAILURE);
    }
    if (is_shadow && (spw_open(O_CREAT | O_RDWR) == 0))
    {
        fprintf(stderr, _("%s: cannot open %s\n"), Prog, spw_dbname());
        fail_exit(EXIT_FAILURE);
    }
    if (gr_open(O_CREAT | O_RDWR) == 0)
    {
        fprintf(stderr, _("%s: cannot open %s\n"), Prog, gr_dbname());
        fail_exit(EXIT_FAILURE);
    }
#ifdef SHADOWGRP
    if (is_shadow_grp && (sgr_open(O_CREAT | O_RDWR) == 0))
    {
        fprintf(stderr, _("%s: cannot open %s\n"), Prog, sgr_dbname());
        fail_exit(EXIT_FAILURE);
    }
#endif
#ifdef ENABLE_SUBIDS
    if (is_sub_uid)
    {
        if (sub_uid_open(O_CREAT | O_RDWR) == 0)
        {
            fprintf(stderr, _("%s: cannot open %s\n"), Prog, sub_uid_dbname());
            fail_exit(EXIT_FAILURE);
        }
    }
    if (is_sub_gid)
    {
        if (sub_gid_open(O_CREAT | O_RDWR) == 0)
        {
            fprintf(stderr, _("%s: cannot open %s\n"), Prog, sub_gid_dbname());
            fail_exit(EXIT_FAILURE);
        }
    }
#endif 
}
static void open_files ( void ) { if ( pw_lock ( ) == 0 ) { fprintf ( stderr , _ ( " \n " ) , Prog , pw_dbname ( ) ) ; fail_exit ( EXIT_FAILURE ) ; } pw_locked = true ; if ( is_shadow ) { if ( spw_lock ( ) == 0 ) { fprintf ( stderr , _ ( " \n " ) , Prog , spw_dbname ( ) ) ; fail_exit ( EXIT_FAILURE ) ; } spw_locked = true ; } if ( gr_lock ( ) == 0 ) { fprintf ( stderr , _ ( " \n " ) , Prog , gr_dbname ( ) ) ; fail_exit ( EXIT_FAILURE ) ; } gr_locked = true ; #ifdef SHADOWGRP if ( is_shadow_grp ) { if ( sgr_lock ( ) == 0 ) { fprintf ( stderr , _ ( " \n " ) , Prog , sgr_dbname ( ) ) ; fail_exit ( EXIT_FAILURE ) ; } sgr_locked = true ; } #endif #ifdef ENABLE_SUBIDS if ( is_sub_uid ) { if ( sub_uid_lock ( ) == 0 ) { fprintf ( stderr , _ ( " \n " ) , Prog , sub_uid_dbname ( ) ) ; fail_exit ( EXIT_FAILURE ) ; } sub_uid_locked = true ; } if ( is_sub_gid ) { if ( sub_gid_lock ( ) == 0 ) { fprintf ( stderr , _ ( " \n " ) , Prog , sub_gid_dbname ( ) ) ; fail_exit ( EXIT_FAILURE ) ; } sub_gid_locked = true ; } #endif if ( pw_open ( O_CREAT | O_RDWR ) == 0 ) { fprintf ( stderr , _ ( " \n " ) , Prog , pw_dbname ( ) ) ; fail_exit ( EXIT_FAILURE ) ; } if ( is_shadow && ( spw_open ( O_CREAT | O_RDWR ) == 0 ) ) { fprintf ( stderr , _ ( " \n " ) , Prog , spw_dbname ( ) ) ; fail_exit ( EXIT_FAILURE ) ; } if ( gr_open ( O_CREAT | O_RDWR ) == 0 ) { fprintf ( stderr , _ ( " \n " ) , Prog , gr_dbname ( ) ) ; fail_exit ( EXIT_FAILURE ) ; } #ifdef SHADOWGRP if ( is_shadow_grp && ( sgr_open ( O_CREAT | O_RDWR ) == 0 ) ) { fprintf ( stderr , _ ( " \n " ) , Prog , sgr_dbname ( ) ) ; fail_exit ( EXIT_FAILURE ) ; } #endif #ifdef ENABLE_SUBIDS if ( is_sub_uid ) { if ( sub_uid_open ( O_CREAT | O_RDWR ) == 0 ) { fprintf ( stderr , _ ( " \n " ) , Prog , sub_uid_dbname ( ) ) ; fail_exit ( EXIT_FAILURE ) ; } } if ( is_sub_gid ) { if ( sub_gid_open ( O_CREAT | O_RDWR ) == 0 ) { fprintf ( stderr , _ ( " \n " ) , Prog , sub_gid_dbname ( ) ) ; fail_exit ( EXIT_FAILURE ) ; } } #endif }
open_files - lock and open the password, group and shadow databases
open_files - lock and open the password group and shadow databases
/*
     * Lock the password files and open them for update. This will bring
     * all of the entries into memory where they may be searched for an
     * modified, or new entries added. The password file is the key - if
     * it gets locked, assume the others can be locked right away.
     */ /* ENABLE_SUBIDS */ /* ENABLE_SUBIDS */