Hi Philip,
I have attached a new version of the goodies/convert
program that can read a unix password file and create user entries in the
Radmin database.
Run it like this:
convert -password filename filename ....
Let me know how it works for you.
Cheers.
On Jan 5, 5:30pm, Philip Buckley wrote:
> Subject: (RADIATOR) Need help setting RAdmin
>
> Hi Everyone,
>
>
> I am now setting up RAdmin but cannot allow authentication via
RAdmin database this is because all my users are now a unix shadow file. How do
I convert my users from unix shadow file to the RAdmin database. Has anybody
done any such conversion.
>
> [ Attachment (text/x-html): 786 bytes
> Character set: iso-8859-1
> Encoded with "quoted-printable" ]
>-- End of excerpt from Philip Buckley
--
Mike McCauley [EMAIL PROTECTED]
Open System Consultants Pty. Ltd Unix, Perl, Motif, C++, WWW
24 Bateman St Hampton, VIC 3188 Australia http://www.open.com.au
Phone +61 3 9598-0985 Fax +61 3 9598-0955
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
Platypus, Freeside, TACACS+, PAM, external, etc etc on Unix, Win95/8,
NT, Rhapsody
#!/usr/local/bin/perl
# -*- mode: Perl -*-
# convert
# Convert SQL user database from the vanilla Radiator schema
# as suppplied with Radiator to the format that Radmin uses.
# Only the username and plaintext password are moved across
#
# If the -password arg is supplied, the input is assumed
# to be a number of unix password format files
#
# Author: Mike McCauley ([EMAIL PROTECTED])
# Copyright (C) 1999 Open System Consultants
# $Id: convert,v 1.1 1999/08/04 03:19:54 mikem Exp mikem $
# Make sure we get the libs in the current directory for preference
BEGIN
{
unshift(@INC, '.');
}
require "newgetopt.pl";
use Radmin::DBSQL;
use Radmin::Util;
use Radmin::Site;
#################################################################
# Configurable variables
# Connection details of the source database, which is assumed to
# be in the format of the eaxmple SUBSCRIBERS table supplied
# in the Radiator goodies directory
$DBSource = 'dbi:mysql:radius';
$DBUsername = 'mikem';
$DBAuth = 'fred';
# End of configurable variables
#################################################################
my @options = (
'password', # source is a password styler flat file
'dbsource=s',
'dbusername=s',
'dbauth=s',
'update', # Update if already exists
'v', # Verbose
);
&NGetOpt(@options) || &usage;
&usage if $opt_h;
$DBSource = $opt_dbsource if defined $opt_dbsource;
$DBUsername = $opt_dbusername if defined $opt_dbusername;
$DBAuth = $opt_dbauth if defined $opt_dbauth;
# Load the schema description into %Radmin::schema
&Radmin::Util::init();
#$main::db->{Debug}++;
if ($opt_password)
{
my ($username, $password);
while (<>)
{
if (($username, $password) = split(/:/, $_))
{
# Skip some trivial non-entities
next if $password eq 'x'
|| $password eq 'NP'
|| $password eq '*LK*';
insertuser($username, $password);
}
}
}
else
{
# Connect to the source database
$fromdbh = DBI->connect($DBSource,
$DBUsername,
$DBAuth)
|| die "Could not connect to source database $fromDBSource: $DBI::errstr";
$q = "select USERNAME, PASSWORD from SUBSCRIBERS";
$sth = $fromdbh->prepare($q)
|| die "Could not prepare SQL query for source database: $DBI::errstr";
$rc = $sth->execute();
while (($username, $password) = $sth->fetchrow())
{
insertuser($username, $password);
}
}
sub insertuser
{
my ($username, $password) = @_;
my %obj;
$obj{Type} = 'RADUSERS';
$obj{USERNAME} = $username;
$obj{PASS_WORD} = $password;
if ($main::db->exists(\%obj))
{
if ($opt_update)
{
print "updating $username\n" if $opt_v;
$main::db->update(\%obj)
|| print STDERR "Failed to update $username\n";
}
else
{
print STDERR "User $username already exists in Radmin. Ignoring\n";
}
}
else
{
print "inserting $username\n" if $opt_v;
$main::db->insert(\%obj)
|| print STDERR "Failed to insert $username\n";
}
}
sub usage
{
print "usage: $0 [-h] [-v] [-update] [-password]
[-dbsource dbi:drivername:option]
[-dbusername dbusername] [-dbauth auth]\n";
exit;
}