implemented No-Such-Attribute: magic server configuration
authoraland <aland>
Tue, 14 Dec 1999 16:49:16 +0000 (16:49 +0000)
committeraland <aland>
Tue, 14 Dec 1999 16:49:16 +0000 (16:49 +0000)
attribute which matches if there is NO such attribute in
the request.  The attribute which is looked up is in
the string value of the No-Such-Attribute attribute.

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

index 32683fe..ac7df11 100644 (file)
@@ -113,6 +113,7 @@ ATTRIBUTE   Login-Time              1042    string
 ATTRIBUTE      Stripped-User-Name      1043    string
 ATTRIBUTE      Current-Time            1044    string
 ATTRIBUTE      Realm                   1045    string
+ATTRIBUTE      No-Such-Attribute       1046    string
 
 #
 #      Non-Protocol Attributes
index 32683fe..ac7df11 100644 (file)
@@ -113,6 +113,7 @@ ATTRIBUTE   Login-Time              1042    string
 ATTRIBUTE      Stripped-User-Name      1043    string
 ATTRIBUTE      Current-Time            1044    string
 ATTRIBUTE      Realm                   1045    string
+ATTRIBUTE      No-Such-Attribute       1046    string
 
 #
 #      Non-Protocol Attributes
index de976be..f685861 100644 (file)
@@ -94,6 +94,7 @@
 #define PW_STRIPPED_USER_NAME          1043
 #define PW_CURRENT_TIME                        1044
 #define PW_REALM                       1045
+#define PW_NO_SUCH_ATTRIBUTE           1046
 
 /*
  *     Integer Translations
index bf2d711..84d5abf 100644 (file)
@@ -406,6 +406,47 @@ static int timecmp(VALUE_PAIR *request, VALUE_PAIR *check,
        return -1;
 }
 
+/*
+ *     Matches if there is NO SUCH ATTRIBUTE as the one named
+ *     in check->strvalue.  If there IS such an attribute, it
+ *     doesn't match.
+ *
+ *     This is ugly, and definitely non-optimal.  We should be
+ *     doing the lookup only ONCE, and storing the result
+ *     in check->lvalue...
+ */
+static int attrcmp(VALUE_PAIR *request, VALUE_PAIR *check,
+       VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs)
+{
+       VALUE_PAIR *pair;
+       DICT_ATTR  *dict;
+       int attr;
+
+       check_pairs = check_pairs; /* shut the compiler up */
+       reply_pairs = reply_pairs;
+
+       if (check->lvalue == 0) {
+               dict = dict_attrbyname(check->strvalue);
+               if (!dict) {
+                       return -1;
+               }
+               attr = dict->attr;
+       } else {
+               attr = check->lvalue;
+       }
+
+       /*
+        *      If there's no such attribute, then return MATCH,
+        *      else FAILURE.
+        */
+       pair = pairfind(request, attr);
+       if (!pair) {
+               return 0;
+       }
+
+       return -1;
+}
+
 
 /*
  *     Register server-builtin special attributes.
@@ -417,4 +458,5 @@ void pair_builtincompare_init(void)
        paircompare_register(PW_SUFFIX, PW_USER_NAME, presufcmp);
        paircompare_register(PW_CONNECT_RATE, PW_CONNECT_INFO, connectcmp);
        paircompare_register(PW_CURRENT_TIME, 0, timecmp);
+       paircompare_register(PW_NO_SUCH_ATTRIBUTE, 0, attrcmp);
 }