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/groupmod.c
static void grp_update(void)
{
    struct group grp;
    const struct group* ogrp;

#ifdef SHADOWGRP
    struct sgrp sgrp;
    const struct sgrp* osgrp = NULL;
#endif /* SHADOWGRP */

    /*
     * Get the current settings for this group.
     */
    ogrp = gr_locate(group_name);
    if (NULL == ogrp)
    {
        fprintf(stderr, _("%s: group '%s' does not exist in %s\n"), Prog,
                group_name, gr_dbname());
        exit(E_GRP_UPDATE);
    }
    grp = *ogrp;
    new_grent(&grp);
#ifdef SHADOWGRP
    if (is_shadow_grp && (pflg || nflg))
    {
        osgrp = sgr_locate(group_name);
        if (NULL != osgrp)
        {
            sgrp = *osgrp;
            new_sgent(&sgrp);
        }
        else if (pflg && (strcmp(grp.gr_passwd, SHADOW_PASSWD_STRING) == 0))
        {
            static char* empty = NULL;
            /* If there is a gshadow file with no entries for
             * the group, but the group file indicates a
             * shadowed password, we force the creation of a
             * gshadow entry when a new password is requested.
             */
            memset(&sgrp, 0, sizeof sgrp);
            sgrp.sg_name = xstrdup(grp.gr_name);
            sgrp.sg_passwd = xstrdup(grp.gr_passwd);
            sgrp.sg_adm = &empty;
            sgrp.sg_mem = dup_list(grp.gr_mem);
            new_sgent(&sgrp);
            osgrp = &sgrp; /* entry needs to be committed */
        }
    }
#endif /* SHADOWGRP */

    if (gflg)
    {
        update_primary_groups(ogrp->gr_gid, group_newid);
    }

    /*
     * Write out the new group file entry.
     */
    if (gr_update(&grp) == 0)
    {
        fprintf(stderr, _("%s: failed to prepare the new %s entry '%s'\n"),
                Prog, gr_dbname(), grp.gr_name);
        exit(E_GRP_UPDATE);
    }
    if (nflg && (gr_remove(group_name) == 0))
    {
        fprintf(stderr, _("%s: cannot remove entry '%s' from %s\n"), Prog,
                grp.gr_name, gr_dbname());
        exit(E_GRP_UPDATE);
    }

#ifdef SHADOWGRP
    /*
     * Make sure there was a shadow entry to begin with.
     */
    if (NULL != osgrp)
    {
        /*
         * Write out the new shadow group entries as well.
         */
        if (sgr_update(&sgrp) == 0)
        {
            fprintf(stderr, _("%s: failed to prepare the new %s entry '%s'\n"),
                    Prog, sgr_dbname(), sgrp.sg_name);
            exit(E_GRP_UPDATE);
        }
        if (nflg && (sgr_remove(group_name) == 0))
        {
            fprintf(stderr, _("%s: cannot remove entry '%s' from %s\n"), Prog,
                    group_name, sgr_dbname());
            exit(E_GRP_UPDATE);
        }
    }
#endif /* SHADOWGRP */
}
/*
 * grp_update - update group file entries
 *
 *	grp_update() updates the new records in the memory databases.
 */
update group file entries
grp_update() updates the new records in the memory databases.
update group file entries grp_update () updates the new records in the memory databases .
static void grp_update(void)
{
    struct group grp;
    const struct group* ogrp;
#ifdef SHADOWGRP
    struct sgrp sgrp;
    const struct sgrp* osgrp = NULL;
#endif 
    ogrp = gr_locate(group_name);
    if (NULL == ogrp)
    {
        fprintf(stderr, _("%s: group '%s' does not exist in %s\n"), Prog,
                group_name, gr_dbname());
        exit(E_GRP_UPDATE);
    }
    grp = *ogrp;
    new_grent(&grp);
#ifdef SHADOWGRP
    if (is_shadow_grp && (pflg || nflg))
    {
        osgrp = sgr_locate(group_name);
        if (NULL != osgrp)
        {
            sgrp = *osgrp;
            new_sgent(&sgrp);
        }
        else if (pflg && (strcmp(grp.gr_passwd, SHADOW_PASSWD_STRING) == 0))
        {
            static char* empty = NULL;
            memset(&sgrp, 0, sizeof sgrp);
            sgrp.sg_name = xstrdup(grp.gr_name);
            sgrp.sg_passwd = xstrdup(grp.gr_passwd);
            sgrp.sg_adm = &empty;
            sgrp.sg_mem = dup_list(grp.gr_mem);
            new_sgent(&sgrp);
            osgrp = &sgrp; 
        }
    }
#endif 
    if (gflg)
    {
        update_primary_groups(ogrp->gr_gid, group_newid);
    }
    if (gr_update(&grp) == 0)
    {
        fprintf(stderr, _("%s: failed to prepare the new %s entry '%s'\n"),
                Prog, gr_dbname(), grp.gr_name);
        exit(E_GRP_UPDATE);
    }
    if (nflg && (gr_remove(group_name) == 0))
    {
        fprintf(stderr, _("%s: cannot remove entry '%s' from %s\n"), Prog,
                grp.gr_name, gr_dbname());
        exit(E_GRP_UPDATE);
    }
#ifdef SHADOWGRP
    if (NULL != osgrp)
    {
        if (sgr_update(&sgrp) == 0)
        {
            fprintf(stderr, _("%s: failed to prepare the new %s entry '%s'\n"),
                    Prog, sgr_dbname(), sgrp.sg_name);
            exit(E_GRP_UPDATE);
        }
        if (nflg && (sgr_remove(group_name) == 0))
        {
            fprintf(stderr, _("%s: cannot remove entry '%s' from %s\n"), Prog,
                    group_name, sgr_dbname());
            exit(E_GRP_UPDATE);
        }
    }
#endif 
}
static void grp_update ( void ) { struct group grp ; const struct group * ogrp ; #ifdef SHADOWGRP struct sgrp sgrp ; const struct sgrp * osgrp = NULL ; #endif ogrp = gr_locate ( group_name ) ; if ( NULL == ogrp ) { fprintf ( stderr , _ ( " \n " ) , Prog , group_name , gr_dbname ( ) ) ; exit ( E_GRP_UPDATE ) ; } grp = * ogrp ; new_grent ( & grp ) ; #ifdef SHADOWGRP if ( is_shadow_grp && ( pflg || nflg ) ) { osgrp = sgr_locate ( group_name ) ; if ( NULL != osgrp ) { sgrp = * osgrp ; new_sgent ( & sgrp ) ; } else if ( pflg && ( strcmp ( grp . gr_passwd , SHADOW_PASSWD_STRING ) == 0 ) ) { static char * empty = NULL ; memset ( & sgrp , 0 , sizeof sgrp ) ; sgrp . sg_name = xstrdup ( grp . gr_name ) ; sgrp . sg_passwd = xstrdup ( grp . gr_passwd ) ; sgrp . sg_adm = & empty ; sgrp . sg_mem = dup_list ( grp . gr_mem ) ; new_sgent ( & sgrp ) ; osgrp = & sgrp ; } } #endif if ( gflg ) { update_primary_groups ( ogrp -> gr_gid , group_newid ) ; } if ( gr_update ( & grp ) == 0 ) { fprintf ( stderr , _ ( " \n " ) , Prog , gr_dbname ( ) , grp . gr_name ) ; exit ( E_GRP_UPDATE ) ; } if ( nflg && ( gr_remove ( group_name ) == 0 ) ) { fprintf ( stderr , _ ( " \n " ) , Prog , grp . gr_name , gr_dbname ( ) ) ; exit ( E_GRP_UPDATE ) ; } #ifdef SHADOWGRP if ( NULL != osgrp ) { if ( sgr_update ( & sgrp ) == 0 ) { fprintf ( stderr , _ ( " \n " ) , Prog , sgr_dbname ( ) , sgrp . sg_name ) ; exit ( E_GRP_UPDATE ) ; } if ( nflg && ( sgr_remove ( group_name ) == 0 ) ) { fprintf ( stderr , _ ( " \n " ) , Prog , group_name , sgr_dbname ( ) ) ; exit ( E_GRP_UPDATE ) ; } } #endif }
grp_update - update group file entries
      grp_update() updates the new records in the memory databases.
grp_update - update group file entries grp_update () updates the new records in the memory databases .
/* SHADOWGRP */ /*
     * Get the current settings for this group.
     */ /* If there is a gshadow file with no entries for
             * the group, but the group file indicates a
             * shadowed password, we force the creation of a
             * gshadow entry when a new password is requested.
             */ /* entry needs to be committed */ /* SHADOWGRP */ /*
     * Write out the new group file entry.
     */ /*
     * Make sure there was a shadow entry to begin with.
     */ /*
         * Write out the new shadow group entries as well.
         */ /* SHADOWGRP */