Hi, How can I configure Freeradius to call example.pl perl script in the rlm_perl module? i.e., I want the perl script to be called when Freeradius receives a request. Thanks, ASM
On 29 Sep 2011, at 19:25, Alex rsm wrote:
Hi,
How can I configure Freeradius to call example.pl perl script in the rlm_perl module? i.e., I want the perl script to be called when Freeradius receives a request.
read/modify raddb/modules/perl and list perl in sites-available/default authorize {} Arran Cudbard-Bell a.cudbardb@freeradius.org Betelwiki, Betelwiki, Betelwiki.... http://wiki.freeradius.org/ !
Hi Arran, Thank you for the response. I add perl in the sites-available/default file as follow: authorize { # # The preprocess module takes care of sanitizing some bizarre # attributes in the request, and turning them into attributes # which are more standard. # # It takes care of processing the 'raddb/hints' and the # 'raddb/huntgroups' files. preprocess .... ldap perl ..... } And added the following into raddb/modules/perl file perl { module = <path>/example.pl } And added the following in src/modules/rlm_perl/example.pl sub authorize { print "This is a TEST\n"; ..... } However, When I send a simple test request I don't see my debug line. I also don't see the message "perl loaded" when start Freeradius in debug mode (radiusd -X). Am I missing anything? I appreciate it. ASM From: a.cudbardb@freeradius.org Subject: Re: rlm_perl Date: Thu, 29 Sep 2011 19:39:55 +0200 To: freeradius-users@lists.freeradius.org On 29 Sep 2011, at 19:25, Alex rsm wrote:Hi, How can I configure Freeradius to call example.pl perl script in the rlm_perl module? i.e., I want the perl script to be called when Freeradius receives a request. read/modify raddb/modules/perl and list perl in sites-available/default authorize {} Arran Cudbard-Bell a.cudbardb@freeradius.org Betelwiki, Betelwiki, Betelwiki.... http://wiki.freeradius.org/ ! - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
However, When I send a simple test request I don't see my debug line. I also don't see the message "perl loaded" when start Freeradius in debug mode (radiusd -X).
Am I missing anything?
Could you post the debug. Might be you don't have rlm_perl built, though the server usually complains about those types of things... -Arran Arran Cudbard-Bell a.cudbardb@freeradius.org Betelwiki, Betelwiki, Betelwiki.... http://wiki.freeradius.org/ !
Alex rsm <alex-rsm@hotmail.com> wrote:
And added the following in src/modules/rlm_perl/example.pl
sub authorize { print "This is a TEST\n"; ..... }
However, When I send a simple test request I don't see my debug line. I also don't see the message "perl loaded" when start Freeradius in debug mode (radiusd -X).
I am pretty sure stdout is not plumbed up for rlm_perl, and neither is stderr so you will not see anything. Of course reading the documentation brings enlightenment in the form of '&radiusd::radlog(1, "...");'... :-/ Searching for 'debug' on the wiki page says many useful things: http://wiki.freeradius.org/Rlm_perl ...and even less surprisingly it's the same as whats in src/modules/rlm_perl/example.pl. *sigh* Cheers -- Alexander Clouter .sigmonster says: <Mongoose> knghtbrd: and the meek shall inherit k-mart
Alexander Clouter <alex@digriz.org.uk> writes:
Alex rsm <alex-rsm@hotmail.com> wrote:
And added the following in src/modules/rlm_perl/example.pl
sub authorize { print "This is a TEST\n"; ..... }
However, When I send a simple test request I don't see my debug line. I also don't see the message "perl loaded" when start Freeradius in debug mode (radiusd -X).
I am pretty sure stdout is not plumbed up for rlm_perl, and neither is stderr so you will not see anything.
Oh, but they are. At least in debug mode I don't think Alex (the other one :-) really enabled the perl module. It will NOT be silent in debug mode. You should see something like this when the module is instantiated: Module: Linked to module rlm_perl Module: Instantiating module "perl" from file /etc/freeradius/modules/perl perl { module = "/etc/freeradius/example.pl" func_authorize = "authorize" func_authenticate = "authenticate" func_accounting = "accounting" func_preacct = "preacct" func_checksimul = "checksimul" func_detach = "detach" func_xlat = "xlat" func_pre_proxy = "pre_proxy" func_post_proxy = "post_proxy" func_post_auth = "post_auth" func_recv_coa = "recv_coa" func_send_coa = "send_coa" } And with the following "/etc/freeradius/example.pl": use constant RLM_MODULE_REJECT=> 0;# /* immediately reject the request */ use constant RLM_MODULE_FAIL=> 1;# /* module failed, don't reply */ use constant RLM_MODULE_OK=> 2;# /* the module is OK, continue */ use constant RLM_MODULE_HANDLED=> 3;# /* the module handled the request, so stop. */ use constant RLM_MODULE_INVALID=> 4;# /* the module considers the request invalid. */ use constant RLM_MODULE_USERLOCK=> 5;# /* reject the request (user is locked out) */ use constant RLM_MODULE_NOTFOUND=> 6;# /* user not found */ use constant RLM_MODULE_NOOP=> 7;# /* module succeeded without doing anything */ use constant RLM_MODULE_UPDATED=> 8;# /* OK (pairs modified) */ use constant RLM_MODULE_NUMCODES=> 9;# /* How many return codes there are */ sub authorize { print "Here\n"; return RLM_MODULE_NOOP; } I get: rad_recv: Access-Request packet from host 127.0.0.1 port 41702, id=236, length=43 User-Name = "foo" User-Password = "bar" # Executing section authorize from file /etc/freeradius/sites-enabled/default +- entering group authorize {...} ++[preprocess] returns ok ++[chap] returns noop ++[mschap] returns noop [suffix] No '@' in User-Name = "foo", looking up realm NULL [suffix] No such realm "NULL" ++[suffix] returns noop [eap] No EAP-Message, not doing EAP ++[eap] returns noop ++[unix] returns notfound ++[files] returns noop ++[expiration] returns noop ++[logintime] returns noop Here rlm_perl: Added pair User-Name = foo rlm_perl: Added pair User-Password = bar rlm_perl: Added pair NAS-IP-Address = 127.0.0.1 ++[perl] returns noop [pap] WARNING! No "known good" password found for the user. Authentication may fail because of this. ++[pap] returns noop ERROR: No authenticate method (Auth-Type) found for the request: Rejecting the user Failed to authenticate the user. Using Post-Auth-Type Reject # Executing group from file /etc/freeradius/sites-enabled/default +- entering group REJECT {...} [attr_filter.access_reject] expand: %{User-Name} -> foo attr_filter: Matched entry DEFAULT at line 11 ++[attr_filter.access_reject] returns updated Delaying reject of request 0 for 1 seconds Going to the next request Waking up in 0.9 seconds. Sending delayed reject for request 0 Sending Access-Reject of id 236 to 127.0.0.1 port 41702 Waking up in 4.9 seconds. Cleaning up request 0 ID 236 with timestamp +132 Ready to process requests. Note the "Here" right before the "rlm_perl: " debug lines. That's the perl scripts stdout. But there's no use looking for output from the perl script if the rlm_perl module isn't loaded.
Of course reading the documentation brings enlightenment in the form of '&radiusd::radlog(1, "...");'... :-/
Sure. That's essential if you want to log something useful in production mode. Bjørn
hi, which version of FR? if its the latest version, then just edit the modules/perl file , ensure that the TYPE of perl you want to use is uncommented...eg for authentication, ensure that func_authenticate line is uncommented, then add 'perl' into the authenticate section of your virtual server for older versions...creaky old...you need to ensure that the server was compiled with experimental-features , you need to ensure that the INCLUDE experimental.conf is uncommented in radiusd.conf (and then edit the perl section and the server config as before...) alan
I got it working. Thanks for the help. I had to add my debugging statement in the authorize sub rather than authenticate sub.
Date: Fri, 30 Sep 2011 09:52:23 +0100 From: A.L.M.Buxey@lboro.ac.uk To: freeradius-users@lists.freeradius.org Subject: Re: rlm_perl
hi,
which version of FR?
if its the latest version, then just edit the modules/perl file , ensure that the TYPE of perl you want to use is uncommented...eg for authentication, ensure that func_authenticate line is uncommented, then add 'perl' into the authenticate section of your virtual server
for older versions...creaky old...you need to ensure that the server was compiled with experimental-features , you need to ensure that the INCLUDE experimental.conf is uncommented in radiusd.conf (and then edit the perl section and the server config as before...)
alan - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
participants (5)
-
Alan Buxey -
Alex rsm -
Alexander Clouter -
Arran Cudbard-Bell -
Bjørn Mork