summaryrefslogtreecommitdiff
path: root/FS/FS/part_export/sqlradius.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-08-02 14:59:53 -0700
committerMark Wells <mark@freeside.biz>2012-08-02 14:59:53 -0700
commit7404ff9d5df7679054dd73f17b3737f5474e5512 (patch)
tree2eac04ce2fbc5d52b1739edd97644d434dda1e88 /FS/FS/part_export/sqlradius.pm
parent4d6c465f4b32a49f8bce091f6cb5abb209123ec2 (diff)
fix some illegal RADIUS attributes during import, #18751
Diffstat (limited to 'FS/FS/part_export/sqlradius.pm')
-rw-r--r--FS/FS/part_export/sqlradius.pm22
1 files changed, 22 insertions, 0 deletions
diff --git a/FS/FS/part_export/sqlradius.pm b/FS/FS/part_export/sqlradius.pm
index d7cd459..7213966 100644
--- a/FS/FS/part_export/sqlradius.pm
+++ b/FS/FS/part_export/sqlradius.pm
@@ -1160,6 +1160,7 @@ sub import_attrs {
SELECT groupname, attribute, op, value, \'C\' FROM radgroupcheck
UNION
SELECT groupname, attribute, op, value, \'R\' FROM radgroupreply';
+ my @fixes; # things that need to be changed on the radius db
foreach my $row ( @{ $dbh->selectall_arrayref($sql) } ) {
my ($groupname, $attrname, $op, $value, $attrtype) = @$row;
warn "$groupname.$attrname\n";
@@ -1181,6 +1182,20 @@ SELECT groupname, attribute, op, value, \'R\' FROM radgroupreply';
my $old = $a->{$attrname};
my $new;
+ if ( $attrtype eq 'R' ) {
+ # Freeradius tolerates illegal operators in reply attributes. We don't.
+ if ( !grep ($_ eq $op, FS::radius_attr->ops('R')) ) {
+ warn "$groupname.$attrname: changing $op to +=\n";
+ # Make a note to change it in the db
+ push @fixes, [
+ 'UPDATE radgroupreply SET op = \'+=\' WHERE groupname = ? AND attribute = ? AND op = ? AND VALUE = ?',
+ $groupname, $attrname, $op, $value
+ ];
+ # and import it correctly.
+ $op = '+=';
+ }
+ }
+
if ( defined $old ) {
# replace
$new = new FS::radius_attr {
@@ -1210,6 +1225,13 @@ SELECT groupname, attribute, op, value, \'R\' FROM radgroupreply';
}
$attrs_of{$groupname}->{$attrname} = $new;
} #foreach $row
+
+ foreach (@fixes) {
+ my ($sql, @args) = @$_;
+ my $sth = $dbh->prepare($sql);
+ $sth->execute(@args) or warn $sth->errstr;
+ }
+
return;
}