Re: problems getting rewrite hook right
"Sergey Poznyakoff" <[email protected]> Thu, 02 Nov 2006 10:36:10 +0200
| Newsgroups | gmane.comp.gnu.radius.general |
|---|---|
| Organization | Err, what do you mean? |
| Message-ID | <[email protected]> |
Charles Sprickman <[email protected]> wrote: > This gets me what I want in the domain part of the query, but the > username still comes up as "foo%foo.com". I didn't know it should:) Than, the domain_split can be rewritten to modify User-Name, as a side effect, like this: string domain_split(string name) { integer a; string localpart; string domainpart; domainpart = "bway.net"; /* provide the default value */ if (name =~ "\(.*\)@\(.*\)") { localpart = \1; domainpart = \2; } else { localpart = name; } if (localpart =~ "\(.*\)%\(.*\)") { localpart = \1; domainpart = \2; } %[User-Name] = localpart; return domainpart; } The test run gives: ** TEST SHELL ** (radiusd) source /home/gray/1.rw 0 (radiusd) r domain_split("username%domain.com") domain.com (radiusd) rp User-Name = (STRING) username (radiusd) r domain_split("[email protected]") domain.com (radiusd) rp User-Name = (STRING) user (radiusd) r domain_split("username%[email protected]") domain.com (radiusd) rp User-Name = (STRING) username (radiusd) r domain_split("username") bway.net (radiusd) rp User-Name = (STRING) username Regards, Sergey