|
|
|
Documentation > Example Script
Example Perl Script
Here is a simple perl script which authenticates all users with a username of "pippo".
#! /usr/bin/perl
# Very simple XtRadius Authentication Plugin
# (c) 1998/2001 XtRadius Staff
# 02/12/1998 - Natalino Picone (npicone@xtradius.com)
$DENY_ACCESS = 255;
$GRANT_ACCESS = 0;
$ret = $DENY_ACCESS;
$UNAME = $ARGV[1];
if ($UNAME ~= "pippo") {
$ret = $GRANT_ACCESS;
} else {
$ret = $DENY_ACCESS;
}
exit $ret;
Analysis
Obviously not very useful, but an example of how easy it is to do external authentication with XtRadius. Note that the arguments are taken from the command line ($ARGV[1]), this implies that the script was called with the username as an argument from the radius users file.
Fetching the username from the environment is just as easy, here's the same example in Perl except using the enviroment set by XtRadius instead of explicit command line options.
An Example using the Environment
#! /usr/bin/perl
# Very simple XtRadius Authentication Plugin
# (c) 1998/2001 XtRadius Staff
# 02/12/1998 - Natalino Picone (npicone@xtradius.com)
$DENY_ACCESS = 255;
$GRANT_ACCESS = 0;
$ret = $DENY_ACCESS;
$UNAME = $ENV{'Username'};
if ($UNAME ~= "pippo") {
$ret = $GRANT_ACCESS;
} else {
$ret = $DENY_ACCESS;
}
exit $ret;
|
|