Re: problems getting rewrite hook right

"Sergey Poznyakoff" <[email protected]> Tue, 31 Oct 2006 23:42:45 +0200
Newsgroups gmane.comp.gnu.radius.general
Organization Err, what do you mean?
Message-ID <[email protected]>
Charles Sprickman <[email protected]> wrote:

> We also have domain accounts where the user's actual username is
> "[email protected]".  We instruct those users to use
> "username%[email protected]" when dialing in.

As a side note: they could have safely used another '@', as the proxying
protocol allows for stacking the user domains
(e.g. [email protected]@bway.net). 

> The "@bway.net" is stripped by our dial provider and we see the user as
> "username%domain.com".

>From what I see in your previous posting, they seem to fail to do so:

>>Oct 25 15:53:10 elephant radiusd: Auth.debug:
>>mysql.c:216:rad_mysql_exec: query:
>>SELECT attr,value FROM radius_attrib WHERE username='[email protected]' AND
>>op IS NULL AND domain='[email protected]'
>>
>>The test user logs in using "test%[email protected]"...  I'm so lost
>>with this since I haven't touched it for years (literally).

So, your server received the name as "test%[email protected]" anyway.

> Does that pretty much make sense?  It's kind of a strange setup...

If I get it right, the domain_split function should return the part
between '%' and '@', if there is a percent sign, the part after '@',
if there's none, and "bway.net" otherwise. Does that make sense? If
so, the following function will do it:

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 =~ "\(.*\)%\(.*\)") 
	        domainpart = \2;

         return domainpart;
}

Here's its output in the test run:

** TEST SHELL **
(radiusd) source /home/gray/1.rw
0
(radiusd) r domain_split("username%domain.com")
domain.com
(radiusd) r domain_split("[email protected]")
domain.com
(radiusd) r domain_split("username%[email protected]")
domain.com
(radiusd) r domain_split("username")
bway.net
(radiusd)

> I'd like to get it setup with FreeBSD 4.11 and 6.2, would that be helpful?

Sure, that would be great.


Regards,
Sergey