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/chpasswd.c
static void check_perms(void)
{
#ifdef USE_PAM
#ifdef ACCT_TOOLS_SETUID
    /* If chpasswd uses PAM and is SUID, check the permissions,
     * otherwise, the permissions are enforced by the access to the
     * passwd and shadow files.
     */
    pam_handle_t* pamh = NULL;
    int retval;
    struct passwd* pampw;

    pampw = getpwuid(getuid()); /* local, no need for xgetpwuid */
    if (NULL == pampw)
    {
        fprintf(stderr, _("%s: Cannot determine your user name.\n"), Prog);
        exit(1);
    }

    retval = pam_start("chpasswd", pampw->pw_name, &conv, &pamh);

    if (PAM_SUCCESS == retval)
    {
        retval = pam_authenticate(pamh, 0);
    }

    if (PAM_SUCCESS == retval)
    {
        retval = pam_acct_mgmt(pamh, 0);
    }

    if (PAM_SUCCESS != retval)
    {
        fprintf(stderr, _("%s: PAM: %s\n"), Prog, pam_strerror(pamh, retval));
        SYSLOG((LOG_ERR, "%s", pam_strerror(pamh, retval)));
        if (NULL != pamh)
        {
            (void)pam_end(pamh, retval);
        }
        exit(1);
    }
    (void)pam_end(pamh, retval);
#endif /* ACCT_TOOLS_SETUID */
#endif /* USE_PAM */
}
/*
 * check_perms - check if the caller is allowed to add a group
 *
 *	With PAM support, the setuid bit can be set on chpasswd to allow
 *	non-root users to groups.
 *	Without PAM support, only users who can write in the group databases
 *	can add groups.
 *
 *	It will not return if the user is not allowed.
 */
check if the caller is allowed to add a group
With PAM support, the setuid bit can be set on chpasswd to allow
non-root users to groups.
Without PAM support, only users who can write in the group databases
can add groups.

It will not return if the user is not allowed.
check if the caller is allowed to add a group With PAM support the setuid bit can be set on chpasswd to allow non - root users to groups . Without PAM support only users who can write in the group databases can add groups . It will not return if the user is not allowed .
static void check_perms(void)
{
#ifdef USE_PAM
#ifdef ACCT_TOOLS_SETUID
    pam_handle_t* pamh = NULL;
    int retval;
    struct passwd* pampw;
    pampw = getpwuid(getuid()); 
    if (NULL == pampw)
    {
        fprintf(stderr, _("%s: Cannot determine your user name.\n"), Prog);
        exit(1);
    }
    retval = pam_start("chpasswd", pampw->pw_name, &conv, &pamh);
    if (PAM_SUCCESS == retval)
    {
        retval = pam_authenticate(pamh, 0);
    }
    if (PAM_SUCCESS == retval)
    {
        retval = pam_acct_mgmt(pamh, 0);
    }
    if (PAM_SUCCESS != retval)
    {
        fprintf(stderr, _("%s: PAM: %s\n"), Prog, pam_strerror(pamh, retval));
        SYSLOG((LOG_ERR, "%s", pam_strerror(pamh, retval)));
        if (NULL != pamh)
        {
            (void)pam_end(pamh, retval);
        }
        exit(1);
    }
    (void)pam_end(pamh, retval);
#endif 
#endif 
}
static void check_perms ( void ) { #ifdef USE_PAM #ifdef ACCT_TOOLS_SETUID pam_handle_t * pamh = NULL ; int retval ; struct passwd * pampw ; pampw = getpwuid ( getuid ( ) ) ; if ( NULL == pampw ) { fprintf ( stderr , _ ( " \n " ) , Prog ) ; exit ( 1 ) ; } retval = pam_start ( " " , pampw -> pw_name , & conv , & pamh ) ; if ( PAM_SUCCESS == retval ) { retval = pam_authenticate ( pamh , 0 ) ; } if ( PAM_SUCCESS == retval ) { retval = pam_acct_mgmt ( pamh , 0 ) ; } if ( PAM_SUCCESS != retval ) { fprintf ( stderr , _ ( " \n " ) , Prog , pam_strerror ( pamh , retval ) ) ; SYSLOG ( ( LOG_ERR , " " , pam_strerror ( pamh , retval ) ) ) ; if ( NULL != pamh ) { ( void ) pam_end ( pamh , retval ) ; } exit ( 1 ) ; } ( void ) pam_end ( pamh , retval ) ; #endif #endif }
check_perms - check if the caller is allowed to add a group
      With PAM support, the setuid bit can be set on chpasswd to allow
      non-root users to groups.
check_perms - check if the caller is allowed to add a group With PAM support the setuid bit can be set on chpasswd to allow non - root users to groups .
/* If chpasswd uses PAM and is SUID, check the permissions,
     * otherwise, the permissions are enforced by the access to the
     * passwd and shadow files.
     */ /* local, no need for xgetpwuid */ /* ACCT_TOOLS_SETUID */ /* USE_PAM */