openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libpam/1.3.1-r0/Linux-PAM-1.3.1/modules/pam_access/pam_access.c
static int list_match(pam_handle_t* pamh, char* list, char* sptr,
                      struct login_info* item, match_func* match_fn)
{
    char* tok;
    int match = NO;

    if (item->debug && list != NULL)
        pam_syslog(pamh, LOG_DEBUG, "list_match: list=%s, item=%s", list,
                   item->user->pw_name);

    /*
     * Process tokens one at a time. We have exhausted all possible matches
     * when we reach an "EXCEPT" token or the end of the list. If we do find
     * a match, look for an "EXCEPT" list and recurse to determine whether
     * the match is affected by any exceptions.
     */

    for (tok = strtok_r(list, item->sep, &sptr); tok != 0;
         tok = strtok_r(NULL, item->sep, &sptr))
    {
        if (strcasecmp(tok, "EXCEPT") == 0) /* EXCEPT: give up */
            break;
        if ((match = (*match_fn)(pamh, tok, item))) /* YES */
            break;
    }
    /* Process exceptions to matches. */

    if (match != NO)
    {
        while ((tok = strtok_r(NULL, item->sep, &sptr)) &&
               strcasecmp(tok, "EXCEPT"))
            /* VOID */;
        if (tok == 0)
            return match;
        if (list_match(pamh, NULL, sptr, item, match_fn) == NO)
            return YES; /* drop special meaning of ALL */
    }
    return (NO);
}
/* list_match - match an item against a list of tokens with exceptions */
match an item against a list of tokens with exceptions
match an item against a list of tokens with exceptions
static int list_match(pam_handle_t* pamh, char* list, char* sptr,
                      struct login_info* item, match_func* match_fn)
{
    char* tok;
    int match = NO;
    if (item->debug && list != NULL)
        pam_syslog(pamh, LOG_DEBUG, "list_match: list=%s, item=%s", list,
                   item->user->pw_name);
    for (tok = strtok_r(list, item->sep, &sptr); tok != 0;
         tok = strtok_r(NULL, item->sep, &sptr))
    {
        if (strcasecmp(tok, "EXCEPT") == 0) 
            break;
        if ((match = (*match_fn)(pamh, tok, item))) 
            break;
    }
    if (match != NO)
    {
        while ((tok = strtok_r(NULL, item->sep, &sptr)) &&
               strcasecmp(tok, "EXCEPT"))
            ;
        if (tok == 0)
            return match;
        if (list_match(pamh, NULL, sptr, item, match_fn) == NO)
            return YES; 
    }
    return (NO);
}
static int list_match ( pam_handle_t * pamh , char * list , char * sptr , struct login_info * item , match_func * match_fn ) { char * tok ; int match = NO ; if ( item -> debug && list != NULL ) pam_syslog ( pamh , LOG_DEBUG , " " , list , item -> user -> pw_name ) ; for ( tok = strtok_r ( list , item -> sep , & sptr ) ; tok != 0 ; tok = strtok_r ( NULL , item -> sep , & sptr ) ) { if ( strcasecmp ( tok , " " ) == 0 ) break ; if ( ( match = ( * match_fn ) ( pamh , tok , item ) ) ) break ; } if ( match != NO ) { while ( ( tok = strtok_r ( NULL , item -> sep , & sptr ) ) && strcasecmp ( tok , " " ) ) ; if ( tok == 0 ) return match ; if ( list_match ( pamh , NULL , sptr , item , match_fn ) == NO ) return YES ; } return ( NO ) ; }
list_match - match an item against a list of tokens with exceptions
list_match - match an item against a list of tokens with exceptions
/*
     * Process tokens one at a time. We have exhausted all possible matches
     * when we reach an "EXCEPT" token or the end of the list. If we do find
     * a match, look for an "EXCEPT" list and recurse to determine whether
     * the match is affected by any exceptions.
     */ /* EXCEPT: give up */ /* YES */ /* Process exceptions to matches. */ /* VOID */ /* drop special meaning of ALL */