Case-insensitive regexps in rlm_files

Brian Candler B.Candler at
Fri Nov 19 12:43:45 CET 2010

Alan DeKok wrote:
> > The benefit to us in doing this in rlm_files/rlm_fastusers is that when
> > these files are rsynced out, freeradius re-reads them without needing a
> > restart.
>   While the modules are reloaded on HUP, so are the virtual servers.  So
> you can put "unlang" into a file, and it will be reloaded on HUP.

However, rlm_fastusers doesn't even require a HUP: it notices any changed
file and reloads it on demand.  (rlm_files doesn't though).

>   It's probably simpler just to add case-insensitive regex matching to
> the core.  That way *all* of the modules get the functionality, and not
> just "users".

Absolutely. So the options I see are:

(1) lib/valuepair.c, paircmp()

* before calling regcomp, look for (?i: ... )
* if found, strip it off and add REG_ICASE to regcomp.

- tiny change
- fully backwards compat, regexps like (?i:...) fail to compile today

- it's a frig, as we're not really implementing non-capturing groups

(2) Set case-insensitive flag on the value

* Parse /xxx/ and /xxx/i as a PW_STRING containing xxx
* Add new flag 'case_insensitive' to attr_flags
* Use this flag when calling regcomp

- changes parser, but otherwise touches relatively little code
- gives the expected user syntax for regexps

- technically this is an incompatible change for existing configs with
  User-Name == /foo/, which would have to change to User-Name == "/foo/"
  (I think this is very unlikely in practice though)

I'd say (2) looks like the most attractive, what do you think?

As a separate point, I think it's possible to cache the regcomp when do_xlat
is not set.  This would require another field in struct value_pair (to avoid
changing strvalue into a struct).  Worthwhile?



More information about the Freeradius-Users mailing list