diff options
author | ivan <ivan> | 2001-09-07 20:17:50 +0000 |
---|---|---|
committer | ivan <ivan> | 2001-09-07 20:17:50 +0000 |
commit | 3beb58199322355f8caa166000bb94e9419b4232 (patch) | |
tree | fd2ab49c213276b181e2d4bf49df4961b48f3e23 /bin | |
parent | 34e22e18b050b9a507433d24eb7a896ce2182afd (diff) |
fix RADIUS attribute capitalization
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/fs-radius-add-check | 8 | ||||
-rwxr-xr-x | bin/fs-radius-add-reply | 8 | ||||
-rwxr-xr-x | bin/fs-setup | 12 | ||||
-rwxr-xr-x | bin/generate-raddb | 35 |
4 files changed, 58 insertions, 5 deletions
diff --git a/bin/fs-radius-add-check b/bin/fs-radius-add-check index fadba0165..eedd9b699 100755 --- a/bin/fs-radius-add-check +++ b/bin/fs-radius-add-check @@ -5,8 +5,13 @@ use strict; use DBI; use FS::UID qw(adminsuidsetup checkeuid getsecrets); +use FS::raddb; + die "Not running uid freeside!" unless checkeuid(); +my %attrib2db = + map { $FS::raddb::attrib{lc($_)} => $_ } keys %FS::raddb::attrib; + my $user = shift or die &usage; getsecrets($user); @@ -18,7 +23,8 @@ print "\n\n", <<END, ":"; Enter the additional RADIUS check attributes you need to track for each user, separated by whitespace. END -my @attributes = map { s/\-/_/g; $_; } split(" ",&getvalue); +my @attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; } + split(" ",&getvalue); sub getvalue { my($x)=scalar(<STDIN>); diff --git a/bin/fs-radius-add-reply b/bin/fs-radius-add-reply index 997a8eac7..d2f2e11f0 100755 --- a/bin/fs-radius-add-reply +++ b/bin/fs-radius-add-reply @@ -5,8 +5,13 @@ use strict; use DBI; use FS::UID qw(adminsuidsetup checkeuid getsecrets); +use FS::raddb; + die "Not running uid freeside!" unless checkeuid(); +my %attrib2db = + map { $FS::raddb::attrib{lc($_)} => $_ } keys %FS::raddb::attrib; + my $user = shift or die &usage; getsecrets($user); @@ -18,7 +23,8 @@ print "\n\n", <<END, ":"; Enter the additional RADIUS reply attributes you need to track for each user, separated by whitespace. END -my @attributes = map { s/\-/_/g; $_; } split(" ",&getvalue); +my @attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; } + split(" ",&getvalue); sub getvalue { my($x)=scalar(<STDIN>); diff --git a/bin/fs-setup b/bin/fs-setup index 53d96f692..dc597ccb4 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.54 2001-09-06 20:41:59 ivan Exp $ +# $Id: fs-setup,v 1.55 2001-09-07 20:17:50 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -15,9 +15,13 @@ use DBIx::DBSchema::ColGroup::Index; use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets); use FS::Record; use FS::cust_main_county; +use FS::raddb; die "Not running uid freeside!" unless checkeuid(); +my %attrib2db = + map { $FS::raddb::attrib{lc($_)} => $_ } keys %FS::raddb::attrib; + my $user = shift or die &usage; getsecrets($user); @@ -35,13 +39,15 @@ reply attribute Framed-IP-Address for each user. You can specify additional check and reply attributes. First enter any additional RADIUS check attributes you need to track for each user, separated by whitespace. END -my @check_attributes = map { s/\-/_/g; $_; } split(" ",&getvalue); +my @check_attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; } + split(" ",&getvalue); print "\n\n", <<END, ":"; Now enter any additional reply attributes you need to track for each user, separated by whitespace. END -my @attributes = map { s/\-/_/g; $_; } split(" ",&getvalue); +my @attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; } + split(" ",&getvalue); print "\n\n", <<END, ":"; Do you wish to enable the tracking of a second, separate shipping/service diff --git a/bin/generate-raddb b/bin/generate-raddb new file mode 100755 index 000000000..e9580d645 --- /dev/null +++ b/bin/generate-raddb @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +# usage: generate-raddb radius-server/raddb/dictionary* >raddb.pm +# i.e.: generate-raddb ~/src/freeradius-0.2/raddb/dictionary* >FS/raddb.pm + +print <<END; +package FS::raddb; +use vars qw(%attrib); + +%attrib = ( +END + +while (<>) { + next if /^(#|\s*$|\$INCLUDE\s+)/; + next if /^(VALUE|VENDOR|BEGIN\-VENDOR|END\-VENDOR)\s+/; + /^(ATTRIBUTE|ATTRIB_NMC)\s+([\w\-]+)\s+/ or die $_; + $attrib = $2; + $dbname = lc($2); + $dbname =~ s/\-/_/g; + $hash{$dbname} = $attrib; + #print "$2\n"; +} + +foreach ( keys %hash ) { +# print "$_\n" if length($_)>24; +# print substr($_,0,24),"\n" if length($_)>24; +# $max = length($_) if length($_)>$max; +#everything >24 is still unique, at least with freeradius comprehensive dataset + print " '". substr($_,0,24). "' => '$hash{$_}'\n"; +} + +print <<END; +1; +END + |