From 236d0a0f93ffa2f7609f930c8af2c507741060ad Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Mar 2000 14:12:57 +0000 Subject: [PATCH] ICRADIUS export support --- TODO | 40 ++++++++++++++++++++++++++++++++++- bin/svc_acct.export | 56 +++++++++++++++++++++++++++++++++++++++++++++---- htdocs/docs/config.html | 3 +++ htdocs/docs/export.html | 7 ++++--- 4 files changed, 98 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index ae39d824e..19baa7228 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -$Id: TODO,v 1.41 2000-01-30 06:11:09 ivan Exp $ +$Id: TODO,v 1.42 2000-03-06 14:12:56 ivan Exp $ If you are interested in helping with any of these, please join the mailing list (send a blank message to ivan-freeside-subscribe@sisd.com) to avoid @@ -6,6 +6,44 @@ duplication of effort. --- +more email which should make it into a more organized TODO list: +. +I would also love to see Freeside support bandwidth billing by reading the +Cisco NetFlow Accounting data so we and other ISP's could automatically bill +co-located servers and even potentially other virtually hosted sites like +MUD, Palace Chat, IRC Chat, etc based on the bandwidth they use or average +sustained rates or whatever. I'm not much of a programmer so I don't know +what all this entails but I did download a NetFlow client agent/whatever for +Linux though. + . +It would also be nice to see Freeside be able to read Apache log files and +bill customers for web traffic that way as an option also. Plus an option to +bill for excessive disk usage without having to use quotas if you didn't +want to, would be a nice feature as well. So you could monitor with a script +or something to see how much disk space a user was using then get some +average and charge a certain amount for anything above some preset limit for +that account type. I might be able to hack something like this up, but I'm +not 100% sure where to start or if there is something out there that could +be modified or not. +. +Do you think that you will ever support the HKS CCVS (Hell's Kitchen +Software Credit Card Verification Software) since Red Hat bought them out +and is going to be including that for credit card processing when you buy +the professional version? What about possibly supporting the OpenCCVS which +is a GNU/GPL version of a credit card program? I haven't had time to comb +through the Freeside code to see how hard it would be to add support for +these as externally called programs. +. +Also any thoughts on help desk, and knowledge base stuff? Any thoughts on +this stuff, and how possible and what kinds of work or time frame would be +involved? +. +Tim Jung +System Admin +Internet Gateway Inc. +tjung@igateway.net + + CVS via SSH (Score:1) by platinum (jedgar at fxp dot org) on Thursday September 30, @07:13PM EDT (#4) diff --git a/bin/svc_acct.export b/bin/svc_acct.export index d4ebe6bdc..8cdccda1f 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.export,v 1.2 1998-12-10 07:23:15 ivan Exp $ +# $Id: svc_acct.export,v 1.3 2000-03-06 14:12:57 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,16 +38,20 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.2 1998-12-10 07:23:15 ivan +# Revision 1.3 2000-03-06 14:12:57 ivan +# ICRADIUS export support +# +# Revision 1.2 1998/12/10 07:23:15 ivan # use FS::Conf, need user (for datasrc) # use strict; use vars qw($conf); use Fcntl qw(:flock); +use IO::Handle; use FS::Conf; -use FS::SSH qw(scp ssh); -use FS::UID qw(adminsuidsetup datasrc); +use FS::SSH qw(scp ssh sshopen2); +use FS::UID qw(adminsuidsetup datasrc dbh); use FS::Record qw(qsearch fields); use FS::svc_acct; @@ -71,6 +75,17 @@ my @erpcdmachines = $conf->config('erpcdmachines') my @radiusmachines = $conf->config('radiusmachines') if $conf->exists('radiusmachines'); +my $icradiusmachines = $conf->exists('icradiusmachines'); +my @icradiusmachines = $conf->config('icradiusmachines') if $icradiusmachines; +my $icradius_mysqldest = + $conf->config('icradius_mysqldest') || "/usr/local/var/radius" + if $icradiusmachines; +my $icradius_mysqlsource = + $conf->config('icradius_mysqlsource') || "/usr/local/var/freeside" + if $icradiusmachines; +my $icradius_dbh = dbh; #could eventually get it from a config file if you're + #not running MySQL for your Freeside database + my(@saltset)= ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); require 5.004; #srand(time|$$); @@ -119,6 +134,11 @@ chmod 0600, "$spooldir/master.passwd", "$spooldir/users", ; +if ( $icradiusmachines ) { + my $sth = $icradius_dbh->prepare("DELETE FROM radcheck"); + $sth->execute or die "Can't reset radcheck table: ". $sth->errstr; +} + setpriority(0,0,10); my($svc_acct); @@ -226,6 +246,21 @@ foreach $svc_acct (@svc_acct) { print USERS qq(\n\n); } + ### + # ICRADIUS export + if ( $icradiusmachines ) { + my $sth = $icradius_dbh->prepare( + "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ". + join(", ", map { $icradius_dbh->quote( $_ ) } qw ( + $svc_acct->svcnum + $svc_acct->username + "Password" + $svc_acct->_password + ) ). " )" + ); + $sth->execute or die "Can't insert into radcheck table: ". $sth->errstr; + } + } } @@ -318,6 +353,19 @@ foreach $radiusmachine (@radiusmachines) { == 0 or die "ssh error: $!"; } +foreach my $icradiusmachine ( @icradiusmachines ) { + my( $machine, $db, $user, $pass ) = split(/\s+/, $icradiusmachine); + chdir $icradius_mysqlsource or die "Can't cd $icradius_mysqlsource: $!"; + my($reader,$writer)=(new IO::Handle, new IO::Handle); + sshopen2("root\@$machine", $reader, $writer, "mysql --user=$user -p $db"); + print $writer "$pass\nLOCK TABLES radcheck WRITE;\n"; + foreach my $file ( glob("radcheck.*") ) { + scp($file,"root\@$icradiusmachine:$icradius_mysqldest/$file"); + } + close $writer; + close $reader; +} + unlink $spoollock; flock(EXPORT,LOCK_UN); close EXPORT; diff --git a/htdocs/docs/config.html b/htdocs/docs/config.html index 6f7a2b561..3c7c0bd29 100644 --- a/htdocs/docs/config.html +++ b/htdocs/docs/config.html @@ -37,6 +37,9 @@ All further configuration files and directories are located in
  • hidecancelledpackages - The existance of this file will prevent cancelled packages from showing up in listings (though they will still be in the database)
  • hidecancelledcustomers - The existance of this file will prevent customers with only cancelled packages from showing up in listings (though they will still be in the database)
  • home - For new users, prefixed to usrename to create a directory name. Should have a leading but not a trailing slash. +
  • icradiusmachines - Your ICRADIUS machines, one per line. The existance of this file (even if empty) turns on radcheck table creation (in the freeside database - the radcheck table needs to be created manually). Machines listed in this file will have the radcheck table exported to them. Each line of this file should contain four items, separted by whitespace: machine name, MySQL database name, MySQL username, and MySQL password. For example: "radius.isp.tld radius_db radius_user passw0rd". Note that to use ICRADIUS export you need to be using MySQL. +
  • icradius_mysqldest - Destination directory for the MySQL radcheck table files, on the ICRADIUS machines. Defaults to "/usr/local/var/radius". +
  • icradius_mysqlsource - Source directory for for the MySQL radcheck table files, on the Freeside machine. Defaults to "/usr/local/var/freeside".
  • invoice_from - Return address on email invoices.
  • lpr - Print command for paper invoices, for example `lpr -h'.
  • mxmachines - MX entries for new domains, weight and machine, one per line, with trailing `.' diff --git a/htdocs/docs/export.html b/htdocs/docs/export.html index 86a2b4ccd..82da86c17 100644 --- a/htdocs/docs/export.html +++ b/htdocs/docs/export.html @@ -4,14 +4,15 @@

    File exporting