http://qs321.pair.com?node_id=177983

amphiplex has asked for the wisdom of the Perl Monks concerning the following question:

I need to write a simple script checking username and password against a Radius Server.
The only module I have found so far is RadiusPerl-0.05, which is rather old (1997).
Are there any newer modules providing radius client functions ?

Thanks,
      Kurt

Replies are listed 'Best First'.
Re: Radius Client Module
by rob_au (Abbot) on Jun 28, 2002 at 10:59 UTC
    Yep, there are the Net::Radius modules which incorporate methods for building packets for authentication and accounting against a Radius server - I have used these modules fairly extensively under their older namesake, RADIUS::Dictionary and RADIUS::Packet.

    An example of usage of these Perl modules can be found in the System RADIUS Client Daemon project on Freshmeat here - From the code base for the next (and long overdue) release for this project ...

    #!/usr/bin/perl use Net::Radius::Dictionary; use Net::Radius::Packet (); use Socket; . . . sub build_radius_packet { my (%attribute) = @_; my $packet = Net::Radius::Packet->new($CONFIG->{'dictionary'}); if (defined $packet) { $packet->set_code('Accounting-Request'); $packet->set_identifier(inet_ntoa(inet_aton($CONFIG->{'hostnam +e'}))); $packet->set_authenticator(undef); $packet->set_attr($_, $attribute{$_}) foreach sort keys %attri +bute; $packet->dump if $CONFIG->{'debug'}; } return $packet; } sub send_radius_packet { my ($packet) = @_; my $response; return undef unless socket(SOCK_UDP, PF_INET, SOCK_DGRAM, getproto +byname('udp')); my $data = Net::Radius::Packet::auth_resp($packet->pack, $CONFIG-> +{'secret'}); for (1..$CONFIG->{'retry'}) { send(SOCK_UDP, $data, 0, $remote_addr); sleep 1; vec(my $rbit, fileno(SOCK_UDP), 1) = 1; vec(my $wbit, fileno(SOCK_UDP), 1) = 1; $response = select($rbit, $wbit, ($rbit | $wbit), $CONFIG->{'t +imeout'}); last if $response > 1; } close(SOCK_UDP); return $response; }