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 check_perms(void)
{
#ifdef ACCT_TOOLS_SETUID
#ifdef USE_PAM
    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);
        fail_exit(EXIT_FAILURE);
    }

    retval = pam_start("newusers", 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);
        }
        fail_exit(EXIT_FAILURE);
    }
    (void)pam_end(pamh, retval);
#endif /* USE_PAM */
#endif /* ACCT_TOOLS_SETUID */
}
/*
 * check_perms - check if the caller is allowed to add a group
 *
 *	With PAM support, the setuid bit can be set on groupadd 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 groupadd 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 groupadd 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 ACCT_TOOLS_SETUID
#ifdef USE_PAM
    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);
        fail_exit(EXIT_FAILURE);
    }
    retval = pam_start("newusers", 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);
        }
        fail_exit(EXIT_FAILURE);
    }
    (void)pam_end(pamh, retval);
#endif 
#endif 
}
static void check_perms ( void ) { #ifdef ACCT_TOOLS_SETUID #ifdef USE_PAM pam_handle_t * pamh = NULL ; int retval ; struct passwd * pampw ; pampw = getpwuid ( getuid ( ) ) ; if ( NULL == pampw ) { fprintf ( stderr , _ ( " \n " ) , Prog ) ; fail_exit ( EXIT_FAILURE ) ; } 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 ) ; } fail_exit ( EXIT_FAILURE ) ; } ( 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 groupadd 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 groupadd to allow non - root users to groups .
/* local, no need for xgetpwuid */ /* USE_PAM */ /* ACCT_TOOLS_SETUID */