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_cracklib/pam_cracklib.c
static int simple(struct cracklib_options* opt, const char* new)
{
    int digits = 0;
    int uppers = 0;
    int lowers = 0;
    int others = 0;
    int size;
    int i;
    enum
    {
        NONE,
        DIGIT,
        UCASE,
        LCASE,
        OTHER
    } prevclass = NONE;
    int sameclass = 0;

    for (i = 0; new[i]; i++)
    {
        if (isdigit(new[i]))
        {
            digits++;
            if (prevclass != DIGIT)
            {
                prevclass = DIGIT;
                sameclass = 1;
            }
            else
                sameclass++;
        }
        else if (isupper(new[i]))
        {
            uppers++;
            if (prevclass != UCASE)
            {
                prevclass = UCASE;
                sameclass = 1;
            }
            else
                sameclass++;
        }
        else if (islower(new[i]))
        {
            lowers++;
            if (prevclass != LCASE)
            {
                prevclass = LCASE;
                sameclass = 1;
            }
            else
                sameclass++;
        }
        else
        {
            others++;
            if (prevclass != OTHER)
            {
                prevclass = OTHER;
                sameclass = 1;
            }
            else
                sameclass++;
        }
        if (opt->max_class_repeat > 0 && sameclass > opt->max_class_repeat)
        {
            return 1;
        }
    }

    /*
     * The scam was this - a password of only one character type
     * must be 8 letters long.  Two types, 7, and so on.
     * This is now changed, the base size and the credits or defaults
     * see the docs on the module for info on these parameters, the
     * defaults cause the effect to be the same as before the change
     */

    if ((opt->dig_credit >= 0) && (digits > opt->dig_credit))
        digits = opt->dig_credit;

    if ((opt->up_credit >= 0) && (uppers > opt->up_credit))
        uppers = opt->up_credit;

    if ((opt->low_credit >= 0) && (lowers > opt->low_credit))
        lowers = opt->low_credit;

    if ((opt->oth_credit >= 0) && (others > opt->oth_credit))
        others = opt->oth_credit;

    size = opt->min_length;

    if (opt->dig_credit >= 0)
        size -= digits;
    else if (digits < opt->dig_credit * -1)
        return 1;

    if (opt->up_credit >= 0)
        size -= uppers;
    else if (uppers < opt->up_credit * -1)
        return 1;

    if (opt->low_credit >= 0)
        size -= lowers;
    else if (lowers < opt->low_credit * -1)
        return 1;

    if (opt->oth_credit >= 0)
        size -= others;
    else if (others < opt->oth_credit * -1)
        return 1;

    if (size <= i)
        return 0;

    return 1;
}
/*
 * a nice mix of characters.
 */
a nice mix of characters.
a nice mix of characters .
static int simple(struct cracklib_options* opt, const char* new)
{
    int digits = 0;
    int uppers = 0;
    int lowers = 0;
    int others = 0;
    int size;
    int i;
    enum
    {
        NONE,
        DIGIT,
        UCASE,
        LCASE,
        OTHER
    } prevclass = NONE;
    int sameclass = 0;
    for (i = 0; new[i]; i++)
    {
        if (isdigit(new[i]))
        {
            digits++;
            if (prevclass != DIGIT)
            {
                prevclass = DIGIT;
                sameclass = 1;
            }
            else
                sameclass++;
        }
        else if (isupper(new[i]))
        {
            uppers++;
            if (prevclass != UCASE)
            {
                prevclass = UCASE;
                sameclass = 1;
            }
            else
                sameclass++;
        }
        else if (islower(new[i]))
        {
            lowers++;
            if (prevclass != LCASE)
            {
                prevclass = LCASE;
                sameclass = 1;
            }
            else
                sameclass++;
        }
        else
        {
            others++;
            if (prevclass != OTHER)
            {
                prevclass = OTHER;
                sameclass = 1;
            }
            else
                sameclass++;
        }
        if (opt->max_class_repeat > 0 && sameclass > opt->max_class_repeat)
        {
            return 1;
        }
    }
    if ((opt->dig_credit >= 0) && (digits > opt->dig_credit))
        digits = opt->dig_credit;
    if ((opt->up_credit >= 0) && (uppers > opt->up_credit))
        uppers = opt->up_credit;
    if ((opt->low_credit >= 0) && (lowers > opt->low_credit))
        lowers = opt->low_credit;
    if ((opt->oth_credit >= 0) && (others > opt->oth_credit))
        others = opt->oth_credit;
    size = opt->min_length;
    if (opt->dig_credit >= 0)
        size -= digits;
    else if (digits < opt->dig_credit * -1)
        return 1;
    if (opt->up_credit >= 0)
        size -= uppers;
    else if (uppers < opt->up_credit * -1)
        return 1;
    if (opt->low_credit >= 0)
        size -= lowers;
    else if (lowers < opt->low_credit * -1)
        return 1;
    if (opt->oth_credit >= 0)
        size -= others;
    else if (others < opt->oth_credit * -1)
        return 1;
    if (size <= i)
        return 0;
    return 1;
}
static int simple ( struct cracklib_options * opt , const char * new ) { int digits = 0 ; int uppers = 0 ; int lowers = 0 ; int others = 0 ; int size ; int i ; enum { NONE , DIGIT , UCASE , LCASE , OTHER } prevclass = NONE ; int sameclass = 0 ; for ( i = 0 ; new [ i ] ; i ++ ) { if ( isdigit ( new [ i ] ) ) { digits ++ ; if ( prevclass != DIGIT ) { prevclass = DIGIT ; sameclass = 1 ; } else sameclass ++ ; } else if ( isupper ( new [ i ] ) ) { uppers ++ ; if ( prevclass != UCASE ) { prevclass = UCASE ; sameclass = 1 ; } else sameclass ++ ; } else if ( islower ( new [ i ] ) ) { lowers ++ ; if ( prevclass != LCASE ) { prevclass = LCASE ; sameclass = 1 ; } else sameclass ++ ; } else { others ++ ; if ( prevclass != OTHER ) { prevclass = OTHER ; sameclass = 1 ; } else sameclass ++ ; } if ( opt -> max_class_repeat > 0 && sameclass > opt -> max_class_repeat ) { return 1 ; } } if ( ( opt -> dig_credit >= 0 ) && ( digits > opt -> dig_credit ) ) digits = opt -> dig_credit ; if ( ( opt -> up_credit >= 0 ) && ( uppers > opt -> up_credit ) ) uppers = opt -> up_credit ; if ( ( opt -> low_credit >= 0 ) && ( lowers > opt -> low_credit ) ) lowers = opt -> low_credit ; if ( ( opt -> oth_credit >= 0 ) && ( others > opt -> oth_credit ) ) others = opt -> oth_credit ; size = opt -> min_length ; if ( opt -> dig_credit >= 0 ) size -= digits ; else if ( digits < opt -> dig_credit * -1 ) return 1 ; if ( opt -> up_credit >= 0 ) size -= uppers ; else if ( uppers < opt -> up_credit * -1 ) return 1 ; if ( opt -> low_credit >= 0 ) size -= lowers ; else if ( lowers < opt -> low_credit * -1 ) return 1 ; if ( opt -> oth_credit >= 0 ) size -= others ; else if ( others < opt -> oth_credit * -1 ) return 1 ; if ( size <= i ) return 0 ; return 1 ; }
a nice mix of characters.
a nice mix of characters .
/*
     * The scam was this - a password of only one character type
     * must be 8 letters long.  Two types, 7, and so on.
     * This is now changed, the base size and the credits or defaults
     * see the docs on the module for info on these parameters, the
     * defaults cause the effect to be the same as before the change
     */