]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
convert to using fr_time_t
authorAlan T. DeKok <aland@freeradius.org>
Wed, 22 Sep 2021 16:46:57 +0000 (12:46 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 22 Sep 2021 16:46:57 +0000 (12:46 -0400)
src/modules/rlm_logintime/rlm_logintime.c
src/modules/rlm_logintime/timestr.c

index 08eaf7e943e68e4f274a7ed7e0eadef966bd6e6a..ed9eb03748b1f81ed620412d7d28b68d9d7b2d81 100644 (file)
@@ -30,7 +30,7 @@ RCSID("$Id$")
 #include <ctype.h>
 
 /* 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 */
 
        /*
index 9465f62d0a667f0c1786187ba53e96d07b3a7223..de278f745b725a2efc9a86cc7be58f54ebd0e183 100644 (file)
@@ -27,7 +27,7 @@ RCSID("$Id$")
 
 #include <ctype.h>
 
-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;