and no longer used, so Expiration is now an internal server attribute.
Registered the handler for expiration at init time, so that we
can check for it when a packet comes in.
Bug noted by Leon Dorfman <leon_dorfman@yahoo.com>. This should
fix bug #141.
# Non-Protocol Attributes
# These attributes are used internally by the server
#
-ATTRIBUTE Expiration 21 date
ATTRIBUTE Auth-Type 1000 integer
ATTRIBUTE Menu 1001 string
ATTRIBUTE Termination-Menu 1002 string
ATTRIBUTE Connect-Rate 1007 integer
ATTRIBUTE Add-Prefix 1008 string
ATTRIBUTE Add-Suffix 1009 string
+ATTRIBUTE Expiration 1010 date
#
# Integer Translations
# Non-Protocol Attributes
# These attributes are used internally by the server
#
-ATTRIBUTE Expiration 21 date
ATTRIBUTE Auth-Type 1000 integer
ATTRIBUTE Menu 1001 string
ATTRIBUTE Termination-Menu 1002 string
ATTRIBUTE Connect-Rate 1007 integer
ATTRIBUTE Add-Prefix 1008 string
ATTRIBUTE Add-Suffix 1009 string
+ATTRIBUTE Expiration 1010 date
#
# Integer Translations
#define PW_REPLY_MESSAGE 18
#define PW_CALLBACK_NUMBER 19
#define PW_CALLBACK_ID 20
+#if 0
+/*
+ * Deprecated, and no longer used.
+ */
#define PW_EXPIRATION 21
+#endif
#define PW_FRAMED_ROUTE 22
#define PW_FRAMED_IPXNET 23
#define PW_STATE 24
#define PW_CONNECT_RATE 1007
#define PW_ADD_PREFIX 1008
#define PW_ADD_SUFFIX 1009
+#define PW_EXPIRATION 1010
#define PW_USER_CATEGORY 1029
#define PW_GROUP_NAME 1030
#define PW_HUNTGROUP_NAME 1031
tm->tm_mon = 12;
for (i = 0; i < 12; i++) {
- if (strncmp(months[i], month, 3) == 0) {
+ if (strncasecmp(months[i], month, 3) == 0) {
tm->tm_mon = i;
break;
}
if (tm->tm_mon == 12) return -1;
tm->tm_mday = atoi(day);
+ if ((tm->tm_mday < 1) || (tm->tm_mday > 31)) {
+ return -1;
+ }
+
tm->tm_year = atoi(year);
if (tm->tm_year >= 1900) tm->tm_year -= 1900;
}
/*
+ * Compare the expiration date.
+ */
+static int expirecmp(void *instance, VALUE_PAIR *request, VALUE_PAIR *check,
+ VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs)
+{
+ time_t now;
+
+ instance = instance;
+ request = request; /* shut the compiler up */
+ check_pairs = check_pairs;
+ reply_pairs = reply_pairs;
+
+ /*
+ * FIXME! This should be request->timestamp!
+ */
+ now = time(NULL);
+
+ if (now <= check->lvalue) {
+ return 0;
+ }
+
+ return +1;
+}
+
+/*
* Register server-builtin special attributes.
*/
void pair_builtincompare_init(void)
paircompare_register(PW_CONNECT_RATE, PW_CONNECT_INFO, connectcmp, NULL);
paircompare_register(PW_CURRENT_TIME, 0, timecmp, NULL);
paircompare_register(PW_NO_SUCH_ATTRIBUTE, 0, attrcmp, NULL);
+ paircompare_register(PW_EXPIRATION, 0, expirecmp, NULL);
}