From 61fc4e61c6644d2e0abdffe8cbdfafd4b092e84b Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 6 Jul 2000 08:57:28 +0000 Subject: support for radius check attributes (except importing). poorly documented. --- bin/fs-radius-add | 53 ------------------------------------------------- bin/fs-radius-add-check | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ bin/fs-radius-add-reply | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ bin/fs-setup | 29 ++++++++++++++++++++++----- bin/svc_acct.export | 41 ++++++++++++++++++++++++++++++-------- 5 files changed, 163 insertions(+), 66 deletions(-) delete mode 100755 bin/fs-radius-add create mode 100755 bin/fs-radius-add-check create mode 100755 bin/fs-radius-add-reply (limited to 'bin') diff --git a/bin/fs-radius-add b/bin/fs-radius-add deleted file mode 100755 index 707926677..000000000 --- a/bin/fs-radius-add +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/perl -Tw - -# quick'n'dirty hack of fs-setup to add radius attributes - -use strict; -use DBI; -use FS::UID qw(adminsuidsetup checkeuid getsecrets); -die "Not running uid freeside!" unless checkeuid(); - -my $user = shift or die &usage; -getsecrets($user); - -my $dbh = adminsuidsetup $user; - -### - -print "\n\n", <); - chop $x; - $x; -} - -### - -my($char_d) = 80; #default maxlength for text fields - -### - -foreach my $attribute ( @attributes ) { - foreach my $statement ( - "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", - "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", - "ALTER TABLE part_svc ADD svc_acct__radius_$attribute varchar($char_d) NULL;", - "ALTER TABLE part_svc ADD svc_acct__radius_${attribute}_flag char(1) NULL;", - ) { - $dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; } -} - -$dbh->disconnect or die $dbh->errstr; - -print "\n\n", "Now you must run dbdef-create.\n\n"; - -sub usage { - die "Usage:\n fs-radius-add user\n"; -} - - diff --git a/bin/fs-radius-add-check b/bin/fs-radius-add-check new file mode 100755 index 000000000..435f3e88a --- /dev/null +++ b/bin/fs-radius-add-check @@ -0,0 +1,53 @@ +#!/usr/bin/perl -Tw + +# quick'n'dirty hack of fs-setup to add radius attributes + +use strict; +use DBI; +use FS::UID qw(adminsuidsetup checkeuid getsecrets); +die "Not running uid freeside!" unless checkeuid(); + +my $user = shift or die &usage; +getsecrets($user); + +my $dbh = adminsuidsetup $user; + +### + +print "\n\n", <); + chop $x; + $x; +} + +### + +my($char_d) = 80; #default maxlength for text fields + +### + +foreach my $attribute ( @attributes ) { + foreach my $statement ( + "ALTER TABLE svc_acct ADD rc_$attribute varchar($char_d) NULL", + "ALTER TABLE svc_acct ADD rc_$attribute varchar($char_d) NULL", + "ALTER TABLE part_svc ADD svc_acct__rc_$attribute varchar($char_d) NULL;", + "ALTER TABLE part_svc ADD svc_acct__rc_${attribute}_flag char(1) NULL;", + ) { + $dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; } +} + +$dbh->disconnect or die $dbh->errstr; + +print "\n\n", "Now you must run dbdef-create.\n\n"; + +sub usage { + die "Usage:\n fs-radius-add user\n"; +} + + diff --git a/bin/fs-radius-add-reply b/bin/fs-radius-add-reply new file mode 100755 index 000000000..23a8d78a3 --- /dev/null +++ b/bin/fs-radius-add-reply @@ -0,0 +1,53 @@ +#!/usr/bin/perl -Tw + +# quick'n'dirty hack of fs-setup to add radius attributes + +use strict; +use DBI; +use FS::UID qw(adminsuidsetup checkeuid getsecrets); +die "Not running uid freeside!" unless checkeuid(); + +my $user = shift or die &usage; +getsecrets($user); + +my $dbh = adminsuidsetup $user; + +### + +print "\n\n", <); + chop $x; + $x; +} + +### + +my($char_d) = 80; #default maxlength for text fields + +### + +foreach my $attribute ( @attributes ) { + foreach my $statement ( + "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", + "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", + "ALTER TABLE part_svc ADD svc_acct__radius_$attribute varchar($char_d) NULL;", + "ALTER TABLE part_svc ADD svc_acct__radius_${attribute}_flag char(1) NULL;", + ) { + $dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; } +} + +$dbh->disconnect or die $dbh->errstr; + +print "\n\n", "Now you must run dbdef-create.\n\n"; + +sub usage { + die "Usage:\n fs-radius-add user\n"; +} + + diff --git a/bin/fs-setup b/bin/fs-setup index 002a4ed4c..ac8ff5eb7 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.25 2000-06-29 12:00:49 ivan Exp $ +# $Id: fs-setup,v 1.26 2000-07-06 08:57:27 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.25 2000-06-29 12:00:49 ivan +# Revision 1.26 2000-07-06 08:57:27 ivan +# support for radius check attributes (except importing). poorly documented. +# +# Revision 1.25 2000/06/29 12:00:49 ivan # support for pre-encrypted md5 passwords. # # Revision 1.24 2000/03/02 07:44:07 ivan @@ -127,9 +130,16 @@ print "\nEnter the maximum username length: "; my($username_len)=&getvalue; print "\n\n", <addcolumn( new FS::dbdef_column ( + 'rc_'. $attribute, + 'varchar', + 'NULL', + $char_d, + )); +} + #make part_svc table (but now as object) my($part_svc)=$dbdef->table('part_svc'); diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 53fd1f0c7..57be2ddb7 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.14 2000-06-29 15:01:25 ivan Exp $ +# $Id: svc_acct.export,v 1.15 2000-07-06 08:57:28 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,7 +38,10 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.14 2000-06-29 15:01:25 ivan +# Revision 1.15 2000-07-06 08:57:28 ivan +# support for radius check attributes (except importing). poorly documented. +# +# Revision 1.14 2000/06/29 15:01:25 ivan # another silly typo in svc_acct.export # # Revision 1.13 2000/06/28 12:37:28 ivan @@ -240,16 +243,24 @@ foreach $svc_acct (@svc_acct) { print ACP_DIALUP $svc_acct->username, "\t*\t", $svc_acct->slipip, "\n"; } - my %radius = $svc_acct->radius; + my %radreply = $svc_acct->radius_reply; + my %radcheck = $svc_acct->radius_check; + + my $radcheck = join ", ", map { qq($_ = "$radcheck{$_}") } keys %radcheck; + $radcheck .= ", " if $radcheck; ### # FORMAT OF THE USERS FILE HERE print USERS - $svc_acct->username, qq(\t${textradiusprepend}Password = "$rpassword"\n\t), - join ",\n\t", map { qq($_ = "$radius{$_}") } keys %radius; + $svc_acct->username, + qq(\t${textradiusprepend}), + $radcheck, + qq(Password = "$rpassword"\n\t), + join ",\n\t", map { qq($_ = "$radreply{$_}") } keys %radreply; if ( $ip && $ip ne '0e0' ) { - print USERS qq(,\n\tFramed-Address = "$ip"\n\n); + #print USERS qq(,\n\tFramed-Address = "$ip"\n\n); + print USERS qq(,\n\tFramed-IP-Address = "$ip"\n\n); } else { print USERS qq(\n\n); } @@ -257,6 +268,7 @@ foreach $svc_acct (@svc_acct) { ### # ICRADIUS export if ( $icradiusmachines ) { + my $sth = $icradius_dbh->prepare( "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ". join(", ", map { $icradius_dbh->quote( $_ ) } ( @@ -268,14 +280,27 @@ foreach $svc_acct (@svc_acct) { ); $sth->execute or die "Can't insert into radcheck table: ". $sth->errstr; - foreach my $attribute ( keys %radius ) { + foreach my $attribute ( keys %radcheck ) { + my $sth = $icradius_dbh->prepare( + "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ". + join(", ", map { $icradius_dbh->quote( $_ ) } ( + '', + $svc_acct->username, + $attribute + $radcheck{$attribute}, + ) ). " )" + ); + $sth->execute or die "Can't insert into radcheck table: ". $sth->errstr; + } + + foreach my $attribute ( keys %radreply ) { my $sth = $icradius_dbh->prepare( "INSERT INTO radreply (id, UserName, Attribute, Value) VALUES ( ". join(", ", map { $icradius_dbh->quote( $_ ) } ( '', $svc_acct->username, $attribute, - $radius{$attribute}, + $radreply{$attribute}, ) ). " )" ); $sth->execute or die "Can't insert into radreply table: ". $sth->errstr; -- cgit v1.2.1