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

Fix params_empty_string_assignment of freeradius::radsniff::options #208

Open
wants to merge 1 commit into
base: main
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
34 changes: 8 additions & 26 deletions manifests/radsniff.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,22 @@
# @param options commandline options passed to radsniff when it runs
# @param
class freeradius::radsniff (
Optional[String] $envfile = undef,
String $options = '',
Optional[String] $pidfile = undef,
String $envfile = $freeradius::params::fr_radsniff_envfile,
Optional[String] $options = undef,
String $pidfile = $freeradius::params::fr_radsniff_pidfile,
) inherits freeradius::params {
unless $::freeradius::utils_support {
fail('freeradius::radsniff requires freeradius have utils_support enabled')
}

# Calculate the envfile to use - specified, then calculated, then error if none
if $envfile {
$final_envfile = $envfile
} else {
if $freeradius::radsniff::fr_radsniff_envfile {
$final_envfile = $freeradius::radsniff::fr_radsniff_envfile
} else {
fail('freeradius::radsniff requires envfile to be explicitly set on this OS')
}
$escaped_cmd = $options ? {
String[1] => $options.regsubst('"','\\\\"','G'),
default => '',
}

# Calculate the pidfile to use - specified, then calculated, then error if none
if $pidfile {
$final_pidfile = $pidfile
} else {
if $freeradius::radsniff::fr_radsniff_pidfile {
$final_pidfile = $freeradius::radsniff::fr_radsniff_pidfile
} else {
fail('freeradius::radsniff requires pidfile to be explicitly set on this OS')
}
}

$escaped_cmd = $options.regsubst('"','\\\\"','G')

file { 'freeradius radsniff envfile':
path => $final_envfile,
ensure => file,
path => $envfile,
content => @("SYSCONFIG"),
RADSNIFF_OPTIONS="${escaped_cmd}"
| SYSCONFIG
Expand Down
6 changes: 3 additions & 3 deletions templates/radsniff.service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ After=radiusd.target

[Service]
Type=forking
PIDFile=<%=scope['::freeradius::radsniff::final_pidfile']%>
EnvironmentFile=<%=scope['::freeradius::radsniff::final_envfile']%>
ExecStart=/usr/bin/radsniff -P <%=scope['::freeradius::radsniff::final_pidfile']%> -d <%=scope['::freeradius::radsniff::fr_basepath']%> $RADSNIFF_OPTIONS
PIDFile=<%= @pidfile %>
EnvironmentFile=<%= @envfile %>
ExecStart=/usr/bin/radsniff -P <%= @pidfile %> -d <%= @fr_basepath %> $RADSNIFF_OPTIONS

[Install]
WantedBy=multi-user.target