Added two realm module configure options. Ignore_default and
authorcparker <cparker>
Mon, 15 Mar 2004 01:27:11 +0000 (01:27 +0000)
committercparker <cparker>
Mon, 15 Mar 2004 01:27:11 +0000 (01:27 +0000)
ignore_null.  Boolean values that can be set to yes to cause the
specific module instance to not return a match on DEFAULT or NULL
realms respectively.  This allows mutliple realm modules to coexist
with DEFAULT and NULL entries in 'raddb/proxy.conf' much nicer.

Updated man page, and radiusd.conf with examples.

man/man5/rlm_realm.5
raddb/radiusd.conf.in
src/modules/rlm_realm/rlm_realm.c

index 77d1c27..2c4e76e 100644 (file)
@@ -1,4 +1,4 @@
-.TH rlm_realm 5 "5 February 2004" "" "FreeRADIUS Module"
+.TH rlm_realm 5 "14 March 2004" "" "FreeRADIUS Module"
 .SH NAME
 rlm_realm \- FreeRADIUS Module
 .SH DESCRIPTION
@@ -14,6 +14,16 @@ Realm is before or after the User portion in the User-Name string.
 .IP delimiter
 A single character in quotes, which is used as the delimiting
 character that separates the Realm and User sections of the string.
+.IP ignore_default
+This is set to either 'yes' or 'no'.  If set to 'yes', this will 
+prevent the module instance from matching a realm against the DEFAULT
+entry.  This may be useful if you have multiple realm module instances.
+The default is 'no'.
+.IP ignore_null
+This is set to either 'yes' or 'no'.  If set to 'yes', this will 
+prevent the module instance from matching a realm against the NULL
+entry.  This may be useful if you have multiple realm module instances.
+The default is 'no'.
 .PP
 This module parses the realm from the User-Name attrbiute according
 to the instance configuration, and then performs a lookup to find a
index a84d4a5..9bb6e53 100644 (file)
@@ -1036,9 +1036,17 @@ modules {
        #  search order is defined the order in the authorize and
        #  preacct blocks after the module config block.
        #
-       #  Two config options:
-       #       format     -  must be 'prefix' or 'suffix'
-       #       delimiter  -  must be a single character
+       #  Four config options:
+       #       format         -  must be 'prefix' or 'suffix'
+       #       delimiter      -  must be a single character
+       #       ignore_default -  set to 'yes' or 'no'
+       #       ignore_null    -  set to 'yes' or 'no'
+       #
+       #  ignore_default and ignore_null can be set to 'yes' to prevent
+       #  the module from matching against DEFAULT or NULL realms.  This
+       #  may be useful if you have have multiple realm module instances.
+       #  They both default to 'no'.
+       #
 
        #  'realm/username'
        #
@@ -1046,6 +1054,8 @@ modules {
        realm IPASS {
                format = prefix
                delimiter = "/"
+               ignore_default = no
+               ignore_null = no
        }
 
        #  'username@realm'
@@ -1053,6 +1063,8 @@ modules {
        realm suffix {
                format = suffix
                delimiter = "@"
+               ignore_default = no
+               ignore_null = no
        }
 
        #  'username%realm'
@@ -1060,6 +1072,8 @@ modules {
        realm realmpercent {
                format = suffix
                delimiter = "%"
+               ignore_default = no
+               ignore_null = no
        }
        
        #  rewrite arbitrary packets.  Useful in accounting and authorization.
index 674481c..b72cff2 100644 (file)
@@ -48,6 +48,8 @@ typedef struct realm_config_t {
         int        format;
         char       *formatstring;
         char       *delim;
+       int        ignore_default;
+       int        ignore_null;
 } realm_config_t;
 
 static CONF_PARSER module_config[] = {
@@ -55,6 +57,10 @@ static CONF_PARSER module_config[] = {
     offsetof(realm_config_t,formatstring), NULL, "suffix" },
   { "delimiter", PW_TYPE_STRING_PTR,
     offsetof(realm_config_t,delim), NULL, "@" },
+  { "ignore_default", PW_TYPE_BOOLEAN,
+    offsetof(realm_config_t,ignore_default), NULL, "no" },
+  { "ignore_null", PW_TYPE_BOOLEAN,
+    offsetof(realm_config_t,ignore_null), NULL, "no" },
   { NULL, -1, 0, NULL, NULL }    /* end the list */
 };
 
@@ -147,12 +153,17 @@ static REALM *check_for_realm(void *instance, REQUEST *request)
                DEBUG2("    rlm_realm: Looking up realm \"%s\" for User-Name = \"%s\"",
                       realmname, request->username->strvalue);
        } else {
+               if( inst->ignore_null ) {
+                       DEBUG2("    rlm_realm: No '%c' in User-Name = \"%s\", skipping NULL due to config.",
+                       inst->delim[0], request->username->strvalue);
+                       return NULL;
+               }
                DEBUG2("    rlm_realm: No '%c' in User-Name = \"%s\", looking up realm NULL",
                       inst->delim[0], request->username->strvalue);
        }
 
        /*
-        *      Allow NULL realms.
+        *      Allow DEFAULT realms unless told not to.
         */
        realm = realm_find(realmname, (request->packet->code == PW_ACCOUNTING_REQUEST));
        if (!realm) {
@@ -160,6 +171,13 @@ static REALM *check_for_realm(void *instance, REQUEST *request)
                       (realmname == NULL) ? "NULL" : realmname);
                return NULL;
        }
+       if( inst->ignore_default &&
+           (strcmp(realm->realm, "DEFAULT")) == 0) {
+               DEBUG2("    rlm_realm: Found DEFAULT, but skipping due to config.");
+               return NULL;
+       }
+
+
        DEBUG2("    rlm_realm: Found realm \"%s\"", realm->realm);
 
        /*