summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorivan <ivan>2000-07-06 08:57:28 +0000
committerivan <ivan>2000-07-06 08:57:28 +0000
commit61fc4e61c6644d2e0abdffe8cbdfafd4b092e84b (patch)
tree8945c8d68f503da4f9fe6952d31b983c11b72a1d /bin
parentab67932df5b5999bcc0a94b3020bba7f57dd4980 (diff)
support for radius check attributes (except importing). poorly documented.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/fs-radius-add-check53
-rwxr-xr-xbin/fs-radius-add-reply (renamed from bin/fs-radius-add)2
-rwxr-xr-xbin/fs-setup29
-rwxr-xr-xbin/svc_acct.export41
4 files changed, 111 insertions, 14 deletions
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", <<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);
+
+sub getvalue {
+ my($x)=scalar(<STDIN>);
+ 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 b/bin/fs-radius-add-reply
index 707926677..23a8d78a3 100755
--- a/bin/fs-radius-add
+++ b/bin/fs-radius-add-reply
@@ -15,7 +15,7 @@ my $dbh = adminsuidsetup $user;
###
print "\n\n", <<END, ":";
-Enter the additional RADIUS attributes you need to track for
+Enter the additional RADIUS reply attributes you need to track for
each user, separated by whitespace.
END
my @attributes = map { s/\-/_/g; $_; } split(" ",&getvalue);
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", <<END, ":";
-Freeside tracks the RADIUS attributes User-Name, Password and Framed-IP-Address
-for each user. Enter any additional RADIUS attributes you need to track for
-each user, separated by whitespace.
+Freeside tracks the RADIUS attributes User-Name, check attribute Password and
+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);
+
+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);
@@ -186,6 +196,15 @@ foreach $attribute (@attributes) {
));
}
+foreach $attribute (@check_attributes) {
+ $svc_acct->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;