*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
- * Copyright 2001 The FreeRADIUS server project
+ * Copyright 2001,2006 The FreeRADIUS server project
* Copyright 2004 Kostas Kalevras <kkalev@noc.ntua.gr>
*/
-#include "autoconf.h"
-#include "libradius.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "radiusd.h"
-#include "modules.h"
-#include "conffile.h"
+#include <freeradius-devel/ident.h>
+RCSID("$Id$")
+#include <freeradius-devel/radiusd.h>
+#include <freeradius-devel/modules.h>
-static const char rcsid[] = "$Id$";
+#include <ctype.h>
/*
* Define a structure for our module configuration.
/*
* If there's a request, use that timestamp.
*/
- if (timestr_match((char *)check->strvalue,
+ if (timestr_match((char *)check->vp_strvalue,
req ? req->timestamp : time(NULL)) >= 0)
return 0;
*/
if (!req) return -1;
- if (strspn(check->strvalue, "0123456789: ") != strlen(check->strvalue)) {
+ if (strspn(check->vp_strvalue, "0123456789: ") != strlen(check->vp_strvalue)) {
DEBUG("rlm_logintime: Bad Time-Of-Day value \"%s\"",
- check->strvalue);
+ check->vp_strvalue);
return -1;
}
/*
* Time of day is a 24-hour clock
*/
- p = check->strvalue;
+ p = check->vp_strvalue;
scan = atoi(p);
p = strchr(p, ':');
if ((scan > 23) || !p) {
DEBUG("rlm_logintime: Bad Time-Of-Day value \"%s\"",
- check->strvalue);
+ check->vp_strvalue);
return -1;
}
when = scan * 3600;
scan = atoi(p);
if (scan > 59) {
DEBUG("rlm_logintime: Bad Time-Of-Day value \"%s\"",
- check->strvalue);
+ check->vp_strvalue);
return -1;
}
when += scan * 60;
scan = atoi(p + 1);
if (scan > 59) {
DEBUG("rlm_logintime: Bad Time-Of-Day value \"%s\"",
- check->strvalue);
+ check->vp_strvalue);
return -1;
}
when += scan;
* Authentication is OK. Now see if this
* user may login at this time of the day.
*/
- DEBUG("rlm_logintime: Checking Login-Time: '%s'",check_item->strvalue);
- r = timestr_match((char *)check_item->strvalue,
+ DEBUG("rlm_logintime: Checking Login-Time: '%s'",check_item->vp_strvalue);
+ r = timestr_match((char *)check_item->vp_strvalue,
request->timestamp);
if (r == 0) { /* unlimited */
/*
*/
DEBUG("rlm_logintime: timestr returned reject");
- if (data->msg){
+ if (data->msg && data->msg[0]){
char msg[MAX_STRING_LEN];
VALUE_PAIR *tmp;
}
snprintf(logstr, sizeof(logstr), "Outside allowed timespan (time allowed %s)",
- check_item->strvalue);
+ check_item->vp_strvalue);
module_fmsg_vp = pairmake("Module-Failure-Message", logstr, T_OP_EQ);
pairadd(&request->packet->vps, module_fmsg_vp);
return -1;
}
- /*
- * If we are passed an empty reply-message don't use it
- */
- if (!strlen(data->msg)){
- free(data->msg);
- data->msg = NULL;
- }
-
if (data->min_time == 0){
radlog(L_ERR, "rlm_logintime: Minimum timeout should be non zero.");
- free(data->msg);
free(data);
return -1;
}
rlm_logintime_t *data = (rlm_logintime_t *) instance;
paircompare_unregister(PW_CURRENT_TIME, timecmp);
- if (data->msg)
- free(data->msg);
+ paircompare_unregister(PW_TIME_OF_DAY, time_of_day);
free(instance);
return 0;
}
* is single-threaded.
*/
module_t rlm_logintime = {
+ RLM_MODULE_INIT,
"logintime",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
logintime_instantiate, /* instantiation */
+ logintime_detach, /* detach */
{
NULL, /* authentication */
logintime_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- logintime_detach, /* detach */
- NULL, /* destroy */
};