Minor re-arrangements to Expiration. Attribute 21 is deprecated,
authoraland <aland>
Thu, 9 Aug 2001 15:07:32 +0000 (15:07 +0000)
committeraland <aland>
Thu, 9 Aug 2001 15:07:32 +0000 (15:07 +0000)
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.

raddb/dictionary
share/dictionary
src/include/radius.h
src/lib/valuepair.c
src/main/valuepair.c

index 2710280..bd8707c 100644 (file)
@@ -169,7 +169,6 @@ ATTRIBUTE   SQL-User-Name    1055   string
 #      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
@@ -180,6 +179,7 @@ ATTRIBUTE   Crypt-Password          1006    string
 ATTRIBUTE      Connect-Rate            1007    integer
 ATTRIBUTE      Add-Prefix              1008    string
 ATTRIBUTE      Add-Suffix              1009    string
+ATTRIBUTE      Expiration              1010    date
 
 #
 #      Integer Translations
index 2710280..bd8707c 100644 (file)
@@ -169,7 +169,6 @@ ATTRIBUTE   SQL-User-Name    1055   string
 #      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
@@ -180,6 +179,7 @@ ATTRIBUTE   Crypt-Password          1006    string
 ATTRIBUTE      Connect-Rate            1007    integer
 ATTRIBUTE      Add-Prefix              1008    string
 ATTRIBUTE      Add-Suffix              1009    string
+ATTRIBUTE      Expiration              1010    date
 
 #
 #      Integer Translations
index 06c31e8..4986628 100644 (file)
 #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
@@ -92,6 +97,7 @@
 #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
index feaa932..765dafb 100644 (file)
@@ -452,7 +452,7 @@ static int gettime(const char *valstr, time_t *lvalue)
 
        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;
                }
@@ -462,6 +462,10 @@ static int gettime(const char *valstr, time_t *lvalue)
        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;
 
index 52cdb1d..419c739 100644 (file)
@@ -529,6 +529,31 @@ static int attrcmp(void *instance, VALUE_PAIR *request, VALUE_PAIR *check,
 }
 
 /*
+ *     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)
@@ -539,4 +564,5 @@ 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);
 }