Unverified Commit d6d4533f authored by Jonathan's avatar Jonathan Committed by GitHub
Browse files

Merge pull request #116 from sohonet/addPerlModule

Add perl module
parents c4c94a4f fd57dc84
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
       * [`freeradius::module::eap`](#freeradiusmoduleeap)
       * [`freeradius::module::preprocess`](#freeradiusmodulepreprocess)
       * [`freeradius::module::huntgroup`](#freeradiusmodulehuntgroup)
       * [`freeradius::module::perl`](#freeradiusmoduleperl)
       * [`freeradius::policy`](#freeradiuspolicy)
       * [`freeradius::realm`](#freeradiusrealm)
       * [`freeradius::site`](#freeradiussite)
@@ -1214,6 +1215,33 @@ Order of this huntgroup in the huntgroup files. This is the `order` parameter fo
##### `huntgroup`
The path of the huntgroup file. Default: `huntgroup`.

#### `freeradius::module::perl`

Installs the Perl module [rlm_perl](https://wiki.freeradius.org/modules/rlm_perl) with more advanced configuration

```puppet
freeradius::module::perl { 'somename':
  perl_filename  => 'scriptname.pl',
  path           => "puppet:///modules/profiles/radius_proxy/",
  function_names => $function_names,
}
```
##### `perl_filename`
Filename of the Perl script.

##### `path`
The path of the source file on the Puppet server.

##### `function_names`
If different function names to default are used, or if seperate functions for accounting start and stop are used, just pass a hash of default and actual function names.
```puppet
$function_names = {
  "func_authenticate"     => "alternative_name",
  "func_start_accounting" => "start_function",
  "func_stop_accounting"  => "stop_function",
}
```

#### `freeradius::policy`

Install a policy from a flat file.
+32 −0
Original line number Diff line number Diff line
# == Define freeradius::module::perl
#
# Create the perl module configuration for FreeRADIUS
#
define freeradius::module::perl (
  $ensure                                        = file,
  String $moddir                                 = "${fr_moduleconfigpath}/perl",
  Optional[String] $perl_filename                = undef,
  Optional[String] $path                         = undef,
  Optional[String] $content                      = undef,
  Optional[Hash[String, String]] $function_names = undef,
) {
  $fr_moduleconfigpath = $::freeradius::params::fr_moduleconfigpath
  $fr_group            = $::freeradius::params::fr_group
  $fr_service          = $::freeradius::params::fr_service
  $source              = "${path}/${perl_filename}"
  freeradius::module {'perl':
    ensure  => $ensure,
    content => template('freeradius/perl.erb'),
  }

  file { "${fr_moduleconfigpath}/perl/${perl_filename}":
    ensure  => file,
    owner   => 'root',
    group   => $fr_group,
    mode    => '0640',
    source  => $source,
    content => $content,
    require => Freeradius::Module['perl'],
    notify  => Service[$fr_service],
  }
}

templates/perl.erb

0 → 100644
+88 −0
Original line number Diff line number Diff line
# File managed by puppet
##############################################################

#  Persistent, embedded Perl interpreter.
#
perl {
	#
	#  The Perl script to execute on authorize, authenticate,
	#  accounting, xlat, etc.  This is very similar to using
	#  'rlm_exec' module, but it is persistent, and therefore
	#  faster.
	#
	filename = ${modconfdir}/${.:instance}/<%= @perl_filename %>

	#
	#  The following hashes are given to the module and
	#  filled with value-pairs (Attribute names and values)
	#
	#  %RAD_CHECK               Check items
	#  %RAD_REQUEST             Attributes from the request
	#  %RAD_REPLY               Attributes for the reply
	#  %RAD_REQUEST_PROXY       Attributes from the proxied request
	#  %RAD_REQUEST_PROXY_REPLY Attributes from the proxy reply
	#
	#  The interface between FreeRADIUS and Perl is strings.
	#  That is, attributes of type "octets" are converted to
	#  printable strings, such as "0xabcdef".  If you want to
	#  access the binary values of the attributes, you should
	#  call the Perl "pack" function.  Then to send any binary
	#  data back to FreeRADIUS, call the Perl "unpack" function,
	#  so that the contents of the hashes are printable strings.
	#
	#  IP addresses are sent as strings, e.g. "192.0.2.25", and
	#  not as a 4-byte binary value.  The same applies to other
	#  attribute data types.
	#
	#  Attributes of type "string" are copied to Perl as-is.
	#  They are not escaped or interpreted.
	#
	#  The return codes from functions in the perl_script
	#  are passed directly back to the server.  These
	#  codes are defined in mods-config/example.pl
	#

	# You can define configuration items (and nested sub-sections) in perl "config" section.
	# These items will be accessible in the perl script through %RAD_PERLCONF hash.
	# For instance: $RAD_PERLCONF{'name'} $RAD_PERLCONF{'sub-config'}->{'name'}
	#
	#config {
	#	name = "value"
	#	sub-config {
	#		name = "value of name from config.sub-config"
	#	}
	#}

	#
	#  List of functions in the module to call.
	#  Uncomment and change if you want to use function
	#  names other than the defaults.
	#
	<% if defined?(@function_names) %>
	<% @function_names.each_pair do |default, function| %>
	<%=default%> = <%= function %>
    <% end -%>
    <% end %>
	#func_authenticate = authenticate
	#func_authorize = authorize
	#func_preacct = preacct
	#func_accounting = accounting
	#func_checksimul = checksimul
	#func_pre_proxy = pre_proxy
	#func_post_proxy = post_proxy
	#func_post_auth = post_auth
	#func_recv_coa = recv_coa
	#func_send_coa = send_coa
	#func_xlat = xlat
	#func_detach = detach

	#
	#  Uncomment the following lines if you wish
	#  to use separate functions for Start and Stop
	#  accounting packets. In that case, the
	#  func_accounting function is not called.
	#
	#func_start_accounting = accounting_start
	#func_stop_accounting = accounting_stop
}