freeside/bin sqlradius-norealm.reimport,NONE,1.1 sqlradius.import,1.4,1.5 sqlradius.reimport,1.1,1.2
ivan
ivan at pouncequick.420.am
Sat Jun 5 02:34:52 PDT 2004
Update of /home/cvs/cvsroot/freeside/bin
In directory pouncequick:/tmp/cvs-serv22410
Modified Files:
sqlradius.import sqlradius.reimport
Added Files:
sqlradius-norealm.reimport
Log Message:
sqlradius import updates
Index: sqlradius.reimport
===================================================================
RCS file: /home/cvs/cvsroot/freeside/bin/sqlradius.reimport,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- sqlradius.reimport 28 May 2004 23:26:06 -0000 1.1
+++ sqlradius.reimport 5 Jun 2004 09:34:49 -0000 1.2
@@ -107,7 +107,8 @@
}
}
- my( $password, $finger, $group ) = ( '', '', '' );
+ #my( $password, $finger, $group ) = ( '', '', '' );
+ my( $password, $group ) = ( '', '', '' );
my $rc_sth = $dbh->prepare(
'SELECT Attribute, Value, Name, GroupName'.
@@ -118,9 +119,9 @@
foreach my $rc_row ( @{$rc_sth->fetchall_arrayref} ) {
my($attribute, $value, $name, $groupname) = @$rc_row;
- if ( $attribute =~ /^(Crypt-)?Password$/ ) {
+ if ( $attribute =~ /^((Crypt|User)-)?Password$/ ) {
$password = $value;
- $finger = $name;
+ #$finger = $name;
$group = $groupname;
} else {
#handle other params!
@@ -131,7 +132,8 @@
qsearch('svc_acct', { 'username' => $username,
'domsvc' => $svc_domain->svcnum, } );
- print "$r_username / $realm: $password / $finger: ";
+ #print "$r_username / $realm: $password / $finger: ";
+ print "$r_username / $realm: $password: ";
if ( scalar(@svc_acct) == 0 ) {
print "not found\n";
next;
@@ -139,11 +141,13 @@
print "multiple matches found?!?!\n";
next;
} else {
- print "correcting password and name\n";
+ #print "correcting password and name\n";
+ print "correcting password\n";
}
my $svc_acct = $svc_acct[0];
- my $new = new FS::svc_acct { $svc_acct->hash, '_password' => $password, 'finger' => $finger };
+ #my $new = new FS::svc_acct { $svc_acct->hash, '_password' => $password, 'finger' => $finger };
+ my $new = new FS::svc_acct { $svc_acct->hash, '_password' => $password };
my $error = $new->replace($svc_acct);
#my $error = $new->check;
die "$r_username / $realm: $error" if $error;
@@ -151,6 +155,6 @@
}
sub usage {
- die "Usage:\n\n sqlradius.import user\n";
+ die "Usage:\n\n sqlradius.reimport user\n";
}
Index: sqlradius.import
===================================================================
RCS file: /home/cvs/cvsroot/freeside/bin/sqlradius.import,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sqlradius.import 28 May 2004 08:40:46 -0000 1.4
+++ sqlradius.import 5 Jun 2004 09:34:49 -0000 1.5
@@ -117,7 +117,7 @@
foreach my $rc_row ( @{$rc_sth->fetchall_arrayref} ) {
my($attribute, $value, $name, $groupname) = @$row;
- if ( $attribute =~ /^(Crypt-)?Password$/ ) {
+ if ( $attribute =~ /^((User|Crypt)-)?Password$/ ) {
$password = $value;
$finger = $name;
$group = $groupname;
--- NEW FILE: sqlradius-norealm.reimport ---
#!/usr/bin/perl -Tw
use strict;
use vars qw(%part_svc);
#use Date::Parse;
use DBI;
use Term::Query qw(query);
use FS::UID qw(adminsuidsetup); #datasrc
use FS::Record qw(qsearch qsearchs);
use FS::svc_acct;
use FS::part_svc;
my $user = shift or die &usage;
adminsuidsetup $user;
#push @FS::svc_acct::shells, qw(/bin/sync /sbin/shutdown /bin/halt /sbin/halt); #others?
$FS::svc_Common::noexport_hack = 1;
###
%part_svc=map { $_->svcpart, $_ } qsearch('part_svc',{'svcdb'=>'svc_acct'});
die "No services with svcdb svc_acct!\n" unless %part_svc;
print "\n\n", &menu_svc, "\n", <<END;
Enter part number to import.
END
my $sqlradius_svcpart = &getpart;
my $datasrc = &getvalue("\n\nEnter the DBI datasource:");
my $db_user = &getvalue("\n\nEnter the database user:");
my $db_pass = &getvalue("\n\nEnter the database password:");
sub menu_svc {
( join "\n", map "$_: ".$part_svc{$_}->svc, sort keys %part_svc ). "\n";
}
sub getpart {
$^W=0; # Term::Query isn't -w-safe
my $return = query "Enter part number:", 'irk', [ keys %part_svc ];
$^W=1;
$return;
}
sub getvalue {
my $prompt = shift;
$^W=0; # Term::Query isn't -w-safe
my $return = query $prompt, '';
$^W=1;
$return;
}
print "\n\n";
###
my $dbh = DBI->connect( $datasrc, $db_user, $db_pass )
or die $DBI::errstr;
my $sth = $dbh->prepare('SELECT DISTINCT UserName FROM radcheck')
or die $dbh->errstr;
$sth->execute or die $sth->errstr;
my $row;
while ( defined ( $row = $sth->fetchrow_arrayref ) ) {
my( $username ) = @$row;
my( $password, $group ) = ( '', '', '' );
my $rc_sth = $dbh->prepare(
'SELECT Attribute, Value'.
' FROM radcheck'.
' WHERE UserName = ?'
) or die $dbh->errstr;
$rc_sth->execute($username) or die $rc_sth->errstr;
foreach my $rc_row ( @{$rc_sth->fetchall_arrayref} ) {
my($attribute, $value) = @$rc_row;
if ( $attribute =~ /^((Crypt|User)-)?Password$/ ) {
$password = $value unless $password && !$1;
} else {
#handle other params!
}
}
my @svc_acct = grep { $_->cust_svc->svcpart == $sqlradius_svcpart }
qsearch('svc_acct', { 'username' => $username, } );
#print "$r_username / $realm: $password / $finger: ";
print "$username: $password: ";
if ( scalar(@svc_acct) == 0 ) {
print "not found\n";
next;
} elsif ( scalar(@svc_acct) > 1 ) {
print "multiple matches found?!?!\n";
next;
} else {
#print "correcting password and name\n";
print "correcting password\n";
}
my $svc_acct = $svc_acct[0];
#my $new = new FS::svc_acct { $svc_acct->hash, '_password' => $password, 'finger' => $finger };
my $new = new FS::svc_acct { $svc_acct->hash, '_password' => $password };
my $error = $new->replace($svc_acct);
#my $error = $new->check;
die "$username: $error" if $error;
}
sub usage {
die "Usage:\n\n sqlradius-norealm.reimport user\n";
}
More information about the freeside-commits
mailing list