From: Alan T. DeKok Date: Wed, 22 Sep 2021 16:46:57 +0000 (-0400) Subject: convert to using fr_time_t X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66ee4812fc34fcfefb97e09750efc4608131d395;p=thirdparty%2Ffreeradius-server.git convert to using fr_time_t --- diff --git a/src/modules/rlm_logintime/rlm_logintime.c b/src/modules/rlm_logintime/rlm_logintime.c index 08eaf7e943e..ed9eb03748b 100644 --- a/src/modules/rlm_logintime/rlm_logintime.c +++ b/src/modules/rlm_logintime/rlm_logintime.c @@ -30,7 +30,7 @@ RCSID("$Id$") #include /* timestr.c */ -int timestr_match(char const *, time_t); +int timestr_match(char const *, fr_time_t); /* * Define a structure for our module configuration. @@ -78,12 +78,12 @@ fr_dict_attr_autoload_t rlm_logintime_dict_attr[] = { /* * Compare the current time to a range. */ -static int timecmp(UNUSED void *instance, request_t *req, UNUSED fr_pair_list_t *request_list, fr_pair_t const *check) +static int timecmp(UNUSED void *instance, request_t *request, UNUSED fr_pair_list_t *request_list, fr_pair_t const *check) { /* * If there's a request, use that timestamp. */ - if (timestr_match(check->vp_strvalue, req ? fr_time_to_sec(req->packet->timestamp) : time(NULL)) >= 0) return 0; + if (timestr_match(check->vp_strvalue, request->packet->timestamp) >= 0) return 0; return -1; } @@ -166,7 +166,7 @@ static unlang_action_t CC_HINT(nonnull) mod_authorize(rlm_rcode_t *p_result, mod /* * Compare the time the request was received with the current Login-Time value */ - left = timestr_match(ends->vp_strvalue, fr_time_to_sec(request->packet->timestamp)); + left = timestr_match(ends->vp_strvalue, request->packet->timestamp); if (left < 0) RETURN_MODULE_DISALLOW; /* outside of the allowed time */ /* diff --git a/src/modules/rlm_logintime/timestr.c b/src/modules/rlm_logintime/timestr.c index 9465f62d0a6..de278f745b7 100644 --- a/src/modules/rlm_logintime/timestr.c +++ b/src/modules/rlm_logintime/timestr.c @@ -27,7 +27,7 @@ RCSID("$Id$") #include -int timestr_match(char const *, time_t); +int timestr_match(char const *, fr_time_t); static char const *days[] = { "su", "mo", "tu", "we", "th", "fr", "sa", "wk", "any", "al" }; @@ -196,7 +196,7 @@ static int week_fill(char *bitmap, char const *tm) * Match a timestring and return seconds left. * -1 for no match, 0 for unlimited. */ -int timestr_match(char const *tmstr, time_t t) +int timestr_match(char const *tmstr, fr_time_t when) { struct tm *tm, s_tm; char bitmap[WEEKMIN / 8]; @@ -207,6 +207,7 @@ int timestr_match(char const *tmstr, time_t t) char *s; char null[8]; #endif + time_t t = fr_time_to_sec(when); tm = localtime_r(&t, &s_tm); now = tm->tm_wday * DAYMIN + tm->tm_hour * 60 + tm->tm_min;