Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes logic when pfacct and radius-acct are enabled #8175

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,3 @@ Licensed under the GNU General Public License v2.

[mailing_lists]: https://packetfence.org/support/index.html#/community "Community Mailing Lists"


38 changes: 32 additions & 6 deletions lib/pf/services/manager/pfacct.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ use warnings;
use pf::util;
use Moo;
use Template;
use pf::log;
use pf::cluster;
use pf::config qw(
$management_network
%Config
@radius_ints
);
use List::MoreUtils qw(any uniq);

extends 'pf::services::manager';
with 'pf::services::manager::roles::env_golang_service';
Expand Down Expand Up @@ -58,15 +62,37 @@ Generate the environment variables for running the container

sub generate_container_environments {
my ($self, $tt) = @_;
my $management_ip = $management_network->tag('ip');

my $port = '1813';
if ($cluster_enabled) {
$port = '1823';
my $logger = get_logger();
my @listen_ips;

my $port = '-p 1813:1813/udp';
my $port_save;
my $listeningIp = "";
if ($cluster_enabled || isenabled($Config{services}{radiusd_acct})) {
my $management_ip = $management_network->tag('ip');
$port = "-p $management_ip:1823:1813/udp";
$port_save = "1823"
}
if ($cluster_enabled && isenabled($Config{services}{radiusd_acct})) {
$port = "-p 1833:1813/udp";
$port_save = "1833";
}
my $listen = $port;
if (isenabled($Config{services}{radiusd_acct})) {
$listeningIp = '127.0.0.1';
$listen = "-p $listeningIp:$port_save:1813/udp";
} else {
if (!$cluster_enabled) {
foreach my $interface ( uniq(@radius_ints) ) {
push @listen_ips, $interface->tag('ip');
}
my @interfaces = map { $_.":1813:1813/udp" } @listen_ips;
$listen = "-p " . join " -p ",@interfaces;
}
}
my $vars = {
env_dict => {
PFACCT_ADDRESS=> "$port",
PFACCT_ADDRESS=> "$listen",
},
};
$tt->process("/usr/local/pf/containers/environment.template", $vars, "/usr/local/pf/var/conf/acct.env") or die $tt->error();
Expand Down
12 changes: 10 additions & 2 deletions lib/pf/services/manager/radiusd_child.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,15 @@ EOT

if(isenabled($Config{services}{pfacct})) {
my $management_ip = defined($management_network->tag('vip')) ? $management_network->tag('vip') : $management_network->tag('ip');
$tags{'pfacct'} = <<"EOT";
my $port = '1813';
if ($cluster_enabled || isenabled($Config{services}{radiusd_acct})) {
$port = '1823';
}
if ($cluster_enabled && isenabled($Config{services}{radiusd_acct})) {
$port = '1833';
}

$tags{'pfacct'} = <<"EOT";
# pfacct configuration
realm pfacct {
Expand All @@ -1094,7 +1102,7 @@ home_server_pool pfacct_pool {
home_server pfacct_local {
type = acct
ipaddr = 127.0.0.1
port = 1813
port = $port
secret = '$local_secret'
src_ipaddr = $management_ip
}
Expand Down
2 changes: 1 addition & 1 deletion sbin/pfacct-docker-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ args=`base_args $name`
args="$args -v /usr/local/pf/raddb:/usr/local/pf/raddb"
args="$args -v /usr/share/freeradius:/usr/share/freeradius"
args="$args -p 2056:2056/udp"
args="$args -p $PFACCT_ADDRESS:1813/udp"
args="$args $PFACCT_ADDRESS"

run $name "$args"
Loading