openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/shadow/4.6-r0/shadow-4.6/lib/port.c
bool isttytime(const char* id, const char* port, time_t when)
{
    int i;
    int dtime;
    struct port* pp;
    struct tm* tm;

    /*
     * Try to find a matching entry for this user.  Default to
     * letting the user in - there are plenty of ways to have an
     * entry to match all users.
     */

    pp = getttyuser(port, id);
    if (NULL == pp)
    {
        return true;
    }

    /*
     * The entry is there, but has no time entries - don't
     * ever let them login.
     */

    if (0 == pp->pt_times)
    {
        return false;
    }

    /*
     * The current time is converted to HHMM format for
     * comparison against the time values in the TTY entry.
     */

    tm = localtime(&when);
    dtime = tm->tm_hour * 100 + tm->tm_min;

    /*
     * Each time entry is compared against the current
     * time.  For entries with the start after the end time,
     * the comparison is made so that the time is between
     * midnight and either the start or end time.
     */

    for (i = 0; pp->pt_times[i].t_start != -1; i++)
    {
        if (!(pp->pt_times[i].t_days & PORT_DAY(tm->tm_wday)))
        {
            continue;
        }

        if (pp->pt_times[i].t_start <= pp->pt_times[i].t_end)
        {
            if ((dtime >= pp->pt_times[i].t_start) &&
                (dtime <= pp->pt_times[i].t_end))
            {
                return true;
            }
        }
        else
        {
            if ((dtime >= pp->pt_times[i].t_start) ||
                (dtime <= pp->pt_times[i].t_end))
            {
                return true;
            }
        }
    }

    /*
     * No matching time entry was found, user shouldn't
     * be let in right now.
     */

    return false;
}
/*
 * isttytime - tell if a given user may login at a particular time
 *
 *	isttytime searches the ports file for an entry which matches
 *	the user name and TTY given.
 */
tell if a given user may login at a particular time
isttytime searches the ports file for an entry which matches
the user name and TTY given.
tell if a given user may login at a particular time isttytime searches the ports file for an entry which matches the user name and TTY given .
bool isttytime(const char* id, const char* port, time_t when)
{
    int i;
    int dtime;
    struct port* pp;
    struct tm* tm;
    pp = getttyuser(port, id);
    if (NULL == pp)
    {
        return true;
    }
    if (0 == pp->pt_times)
    {
        return false;
    }
    tm = localtime(&when);
    dtime = tm->tm_hour * 100 + tm->tm_min;
    for (i = 0; pp->pt_times[i].t_start != -1; i++)
    {
        if (!(pp->pt_times[i].t_days & PORT_DAY(tm->tm_wday)))
        {
            continue;
        }
        if (pp->pt_times[i].t_start <= pp->pt_times[i].t_end)
        {
            if ((dtime >= pp->pt_times[i].t_start) &&
                (dtime <= pp->pt_times[i].t_end))
            {
                return true;
            }
        }
        else
        {
            if ((dtime >= pp->pt_times[i].t_start) ||
                (dtime <= pp->pt_times[i].t_end))
            {
                return true;
            }
        }
    }
    return false;
}
bool isttytime ( const char * id , const char * port , time_t when ) { int i ; int dtime ; struct port * pp ; struct tm * tm ; pp = getttyuser ( port , id ) ; if ( NULL == pp ) { return true ; } if ( 0 == pp -> pt_times ) { return false ; } tm = localtime ( & when ) ; dtime = tm -> tm_hour * 100 + tm -> tm_min ; for ( i = 0 ; pp -> pt_times [ i ] . t_start != -1 ; i ++ ) { if ( ! ( pp -> pt_times [ i ] . t_days & PORT_DAY ( tm -> tm_wday ) ) ) { continue ; } if ( pp -> pt_times [ i ] . t_start <= pp -> pt_times [ i ] . t_end ) { if ( ( dtime >= pp -> pt_times [ i ] . t_start ) && ( dtime <= pp -> pt_times [ i ] . t_end ) ) { return true ; } } else { if ( ( dtime >= pp -> pt_times [ i ] . t_start ) || ( dtime <= pp -> pt_times [ i ] . t_end ) ) { return true ; } } } return false ; }
isttytime - tell if a given user may login at a particular time
      isttytime searches the ports file for an entry which matches
      the user name and TTY given.
isttytime - tell if a given user may login at a particular time isttytime searches the ports file for an entry which matches the user name and TTY given .
/*
     * Try to find a matching entry for this user.  Default to
     * letting the user in - there are plenty of ways to have an
     * entry to match all users.
     */ /*
     * The entry is there, but has no time entries - don't
     * ever let them login.
     */ /*
     * The current time is converted to HHMM format for
     * comparison against the time values in the TTY entry.
     */ /*
     * Each time entry is compared against the current
     * time.  For entries with the start after the end time,
     * the comparison is made so that the time is between
     * midnight and either the start or end time.
     */ /*
     * No matching time entry was found, user shouldn't
     * be let in right now.
     */