25 RCSID(
"$Id: c04554e6d9ceec6fbdfe62471815a6cdff4a5fe1 $")
27 #include <freeradius-devel/radiusd.h>
28 #include <freeradius-devel/modules.h>
71 req ? req->
timestamp.tv_sec : time(NULL)) >= 0)
94 if (strspn(check->vp_strvalue,
"0123456789: ") != strlen(check->vp_strvalue)) {
95 DEBUG(
"rlm_logintime: Bad Time-Of-Day value \"%s\"",
101 hhmmss = (tm->tm_hour * 3600) + (tm->tm_min * 60) + tm->tm_sec;
106 p = check->vp_strvalue;
109 if ((scan > 23) || !p) {
110 DEBUG(
"rlm_logintime: Bad Time-Of-Day value \"%s\"",
119 DEBUG(
"rlm_logintime: Bad Time-Of-Day value \"%s\"",
129 DEBUG(
"rlm_logintime: Bad Time-Of-Day value \"%s\"",
136 fprintf(stderr,
"returning %d - %d\n",
139 return hhmmss - when;
159 RDEBUG(
"Checking Login-Time");
164 left =
timestr_match(ends->vp_strvalue, request->timestamp.tv_sec);
181 REDEBUG(
"Login outside of allowed time-slot (session end %s, with lockout %i seconds before)",
193 RDEBUG(
"Login within allowed time-slot, %d seconds left in this session", left);
197 if (timeout->vp_integer > (
unsigned int) left) {
198 timeout->vp_integer = left;
201 timeout =
radius_pair_create(request->reply, &request->reply->vps, PW_SESSION_TIMEOUT, 0);
202 timeout->vp_integer = left;
205 RDEBUG(
"reply:Session-Timeout set to %d", left);
226 cf_log_err_cs(conf,
"Invalid value '0' for minimum_timeout");
253 .config = module_config,
int timestr_match(char const *, time_t)
int paircompare_register(fr_dict_attr_t const *attribute, fr_dict_attr_t const *from, bool first_only, RAD_COMPARE_FUNC func, void *instance)
Register a function as compare function.
The module is OK, continue.
Metadata exported by the module.
7 methods index for postauth section.
VALUE_PAIR * radius_pair_create(TALLOC_CTX *ctx, VALUE_PAIR **vps, unsigned int attribute, unsigned int vendor)
Create a VALUE_PAIR and add it to a list of VALUE_PAIR s.
static const CONF_PARSER module_config[]
static rlm_rcode_t mod_authorize(void *instance, REQUEST *request)
Handle authorization requests using Couchbase document data.
#define CONF_PARSER_TERMINATOR
static int time_of_day(UNUSED void *instance, REQUEST *req, UNUSED VALUE_PAIR *request, VALUE_PAIR *check, UNUSED VALUE_PAIR *check_pairs, UNUSED VALUE_PAIR **reply_pairs)
static int timecmp(UNUSED void *instance, REQUEST *req, UNUSED VALUE_PAIR *request, VALUE_PAIR *check, UNUSED VALUE_PAIR *check_pairs, UNUSED VALUE_PAIR **reply_pairs)
Defines a CONF_PAIR to C data type mapping.
struct rlm_logintime_t rlm_logintime_t
Reject the request (user is locked out).
Stores an attribute, a value and various bits of other data.
static rlm_rcode_t CC_HINT(nonnull)
void void cf_log_err_cs(CONF_SECTION const *cs, char const *fmt,...) CC_HINT(format(printf
enum rlm_rcodes rlm_rcode_t
Return codes indicating the result of the module call.
Module succeeded without doing anything.
uint64_t magic
Used to validate module struct.
struct timeval timestamp
When we started processing the request.
#define FR_CONF_OFFSET(_n, _t, _s, _f)
VALUE_PAIR * fr_pair_find_by_num(VALUE_PAIR *head, unsigned int vendor, unsigned int attr, int8_t tag)
Find the pair with the matching attribute.
static int mod_instantiate(CONF_SECTION *conf, void *instance)
fr_dict_attr_t const * fr_dict_attr_by_num(fr_dict_t *dict, unsigned int vendor, unsigned int attr)
Lookup a fr_dict_attr_t by its vendor and attribute numbers.
1 methods index for authorize section.
struct tm * localtime_r(time_t const *l_clock, struct tm *result)