Semantics of !~ operator

Gerald Vogt vogt at spamcop.net
Fri Apr 24 07:14:54 CEST 2015


Hi!

I don't quite understand the semantics of !~. So far I though it would 
be the negated result of =~, i.e. if (a =~ b) is true (a !~ b) is false 
and v.v.

But that doesn't seem to be the case. If I add this in the beginning of 
the users file (extract starting at line no. 6)

DEFAULT
                 Reply-Message += "Realm is %{Realm}",
                 Fall-Through = Yes

DEFAULT         Realm =~ example.com|NULL
                 Reply-Message += "Internal User",
                 Fall-Through = Yes

DEFAULT         Realm !~ example.com|NULL
                 Reply-Message += "External User",
                 Fall-Through = Yes

it works correctly for a user name test or test at example.com:

(106)   files : users: Matched entry DEFAULT at line 6
(106)   files : EXPAND Realm is %{Realm}
(106)   files :    --> Realm is example.com
(106)   files : users: Matched entry DEFAULT at line 10
...
(106)    Reply:
	Reply-Message = 'Realm is example.com'
	Reply-Message = 'Internal User'


(140)  files : users: Matched entry DEFAULT at line 6
(140)  files : EXPAND Realm is %{Realm}
(140)  files :    --> Realm is NULL
(140)  files : users: Matched entry DEFAULT at line 10
...
	Reply-Message = 'Realm is NULL'
	Reply-Message = 'Internal User'

But it never gets the !~ (line 47 is a later rule in the users file):

(191)  files : users: Matched entry DEFAULT at line 6
(191)  files : EXPAND Realm is %{Realm}
(191)  files :    --> Realm is DEFAULT
(191)  files : users: Matched entry DEFAULT at line 47
...

So it seems the !~ never matches. That is kind of unexpected and doesn't 
make sense to me. Is that a bug or am I missing something?

Thanks,

Gerald


More information about the Freeradius-Users mailing list