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/groups.c
static void print_groups(const char* member)
{
    int groups = 0;
    struct group* grp;
    struct passwd* pwd;
    bool flag = false;

    pwd = getpwnam(member); /* local, no need for xgetpwnam */
    if (NULL == pwd)
    {
        (void)fprintf(stderr, _("%s: unknown user %s\n"), Prog, member);
        exit(EXIT_FAILURE);
    }

    setgrent();
    while ((grp = getgrent()) != NULL)
    {
        if (is_on_list(grp->gr_mem, member))
        {
            if (0 != groups)
            {
                (void)putchar(' ');
            }
            groups++;

            (void)printf("%s", grp->gr_name);
            if (grp->gr_gid == pwd->pw_gid)
            {
                flag = true;
            }
        }
    }
    endgrent();

    /* The user may not be in the list of members of its primary group */
    if (!flag)
    {
        grp = getgrgid(pwd->pw_gid); /* local, no need for xgetgrgid */
        if (NULL != grp)
        {
            if (0 != groups)
            {
                (void)putchar(' ');
            }
            groups++;

            (void)printf("%s", grp->gr_name);
        }
    }

    if (0 != groups)
    {
        (void)putchar('\n');
    }
}
/*
 * print_groups - print the groups which the named user is a member of
 *
 *	print_groups() scans the groups file for the list of groups which
 *	the user is listed as being a member of.
 */
print the groups which the named user is a member of
print_groups() scans the groups file for the list of groups which
the user is listed as being a member of.
print the groups which the named user is a member of print_groups () scans the groups file for the list of groups which the user is listed as being a member of .
static void print_groups(const char* member)
{
    int groups = 0;
    struct group* grp;
    struct passwd* pwd;
    bool flag = false;
    pwd = getpwnam(member); 
    if (NULL == pwd)
    {
        (void)fprintf(stderr, _("%s: unknown user %s\n"), Prog, member);
        exit(EXIT_FAILURE);
    }
    setgrent();
    while ((grp = getgrent()) != NULL)
    {
        if (is_on_list(grp->gr_mem, member))
        {
            if (0 != groups)
            {
                (void)putchar(' ');
            }
            groups++;
            (void)printf("%s", grp->gr_name);
            if (grp->gr_gid == pwd->pw_gid)
            {
                flag = true;
            }
        }
    }
    endgrent();
    if (!flag)
    {
        grp = getgrgid(pwd->pw_gid); 
        if (NULL != grp)
        {
            if (0 != groups)
            {
                (void)putchar(' ');
            }
            groups++;
            (void)printf("%s", grp->gr_name);
        }
    }
    if (0 != groups)
    {
        (void)putchar('\n');
    }
}
static void print_groups ( const char * member ) { int groups = 0 ; struct group * grp ; struct passwd * pwd ; bool flag = false ; pwd = getpwnam ( member ) ; if ( NULL == pwd ) { ( void ) fprintf ( stderr , _ ( " \n " ) , Prog , member ) ; exit ( EXIT_FAILURE ) ; } setgrent ( ) ; while ( ( grp = getgrent ( ) ) != NULL ) { if ( is_on_list ( grp -> gr_mem , member ) ) { if ( 0 != groups ) { ( void ) putchar ( ' ' ) ; } groups ++ ; ( void ) printf ( " " , grp -> gr_name ) ; if ( grp -> gr_gid == pwd -> pw_gid ) { flag = true ; } } } endgrent ( ) ; if ( ! flag ) { grp = getgrgid ( pwd -> pw_gid ) ; if ( NULL != grp ) { if ( 0 != groups ) { ( void ) putchar ( ' ' ) ; } groups ++ ; ( void ) printf ( " " , grp -> gr_name ) ; } } if ( 0 != groups ) { ( void ) putchar ( ' \n ' ) ; } }
print_groups - print the groups which the named user is a member of
      print_groups() scans the groups file for the list of groups which
      the user is listed as being a member of.
print_groups - print the groups which the named user is a member of print_groups () scans the groups file for the list of groups which the user is listed as being a member of .
/* local, no need for xgetpwnam */ /* The user may not be in the list of members of its primary group */ /* local, no need for xgetgrgid */