###
### Copyright 2000-2007 University of Illinois Board of Trustees
### All rights reserved.
###
### SASL.pm - SASL configuration module for psgconf
###
### Campus Information Technologies and Educational Services
### University of Illinois at Urbana-Champaign
###
package PSGConf::Control::SASL;
use strict;
use PSGConf::Action::GenerateFile::SASL_conf;
use PSGConf::Data::Boolean;
use PSGConf::Data::List;
use PSGConf::Data::Hash;
use PSGConf::Data::String;
use PSGConf::Control::Packages qw(_add_pkgs);
###############################################################################
### decide() method
###############################################################################
sub decide
{
my ($self, $psgconf) = @_;
my ($lib_dir, $app_conf);
return
if ($psgconf->data_obj('SASL_enable')->equals('false'));
$lib_dir = $psgconf->data_obj('SASL_lib_dir')->get();
$app_conf = $psgconf->data_obj('SASL_app_config')->get();
$psgconf->register_actions(
map {
PSGConf::Action::GenerateFile::SASL_conf->new(
name => "$lib_dir/$_.conf",
description => 'SASL config for ' . $_,
options => $app_conf->{$_}
)
} (keys %$app_conf)
);
if ($psgconf->data_obj('saslauthd_enable')->equals('true')
&& $psgconf->data_obj('saslauthd_mechanism')->equals('ldap'))
{
$psgconf->register_actions(
PSGConf::Action::GenerateFile::SASL_conf->new(
name => '/usr/local/etc/saslauthd.conf',
description => 'saslauthd LDAP configuration',
options => $psgconf->data_obj('saslauthd_ldap_options')->get()
)
);
}
}
###############################################################################
### policy methods
###############################################################################
sub _add_rc_scripts
{
my ($self, $psgconf) = @_;
my ($start_cmd);
### set start command
$start_cmd = $psgconf->data_obj('saslauthd_path')->get()
. ' -a ' . $psgconf->data_obj('saslauthd_mechanism')->get()
if ( defined $psgconf->data_obj('saslauthd_path')->get() &&
defined $psgconf->data_obj('saslauthd_mechanism')->get() );
$start_cmd .= ' ' . $psgconf->data_obj('saslauthd_args')->get()
if ( defined $psgconf->data_obj('saslauthd_args')->get() );
$start_cmd .= ' -O /usr/local/etc/saslauthd.conf'
if ( defined $psgconf->data_obj('saslauthd_mechanism')->get() &&
$psgconf->data_obj('saslauthd_mechanism')->equals('ldap'));
$psgconf->data_obj('rc_scripts')->insert(
{ 'saslauthd' => { 'start_cmd' => $start_cmd }}
);
$psgconf->data_obj('rc_scripts')->insert(
{ 'saslauthd' => { 'state' => 'enable' }}
) if ( $psgconf->data_obj('SASL_enable')->equals('true')
&& $psgconf->data_obj('saslauthd_enable')->equals('true') );
}
###############################################################################
### constructor
###############################################################################
sub new
{
my ($class, $psgconf) = @_;
my ($self);
$self = {};
bless($self, $class);
### So that _add_pkgs knows which directives to look at
$self->{name} = 'SASL';
$self->{enable} = $self->{name} . '_enable';
$self->{packages} = $self->{name} . '_packages';
$psgconf->register_data(
SASL_enable => PSGConf::Data::Boolean->new(
value => 'false'
),
SASL_packages => PSGConf::Data::List->new(),
SASL_lib_dir => PSGConf::Data::String->new(
'value_abspath' => 1,
value => '/usr/lib/sasl2'
),
SASL_app_config => PSGConf::Data::Hash->new(
value_type => 'HASH'
),
saslauthd_path => PSGConf::Data::String->new(
'value_abspath' => 1,
value => '/usr/local/sbin/saslauthd'
),
saslauthd_mechanism => PSGConf::Data::String->new(),
saslauthd_args => PSGConf::Data::String->new(),
saslauthd_ldap_options => PSGConf::Data::Hash->new(),
saslauthd_enable => PSGConf::Data::Boolean->new(
value => 'false'
)
);
$psgconf->register_policy($self,
SASL_add_packages => '_add_pkgs',
saslauthd_add_rc_scripts => '_add_rc_scripts',
);
return $self;
}
###############################################################################
### documentation
###############################################################################
1;
__END__
=head1 NAME
PSGConf::Control::SASL - psgconf control class for SASL configuration
=head1 SYNOPSIS
In F<psgconf_modules>:
Control PSGConf::Control::SASL
=head1 DESCRIPTION
The B<PSGConf::Control::SASL> module provides a B<psgconf> control
object for configuring B<SASL>. It supports the following methods:
=over 4
=item new()
The constructor. Its parameter is a reference to the B<PSGConf>
object. It registers the following data objects:
=over 4
=item I<SASL_enable>
A B<PSGConf::Data::Boolean> object indicating whether B<SASL> should
be configured.
=item I<SASL_packages>
A B<PSGConf::Data::List> object listing what packages to install.
=item I<SASL_lib_dir>
A B<PSGConf::Data::String> object containing the absolute path of the
B<SASL> library directory. The default is F</usr/lib/sasl2>.
=item I<SASL_app_config>
A B<PSGConf::Data::Hash> object containing options for each SASL-aware
application. The hash key is the name of the application, and the value
is an anonymous hash containing the options and values for that
application.
=item I<saslauthd_enable>
A B<PSGConf::Data::Boolean> object indicating whether B<saslauthd>
should be configured.
=item I<saslauthd_path>
A B<PSGConf::Data::String> object containing the absolute path to the
B<saslauthd> daemon. The default is F</usr/local/sbin/saslauthd>.
=item I<saslauthd_mechanism>
A B<PSGConf::Data::String> object containing the authentication
mechanism to be used by B<saslauthd>. This object must be set if
I<saslauthd_enable> is set.
=item I<saslauthd_args>
A B<PSGConf::Data::String> object containing additional arguments to be
passed to B<saslauthd> when it is started.
=item I<saslauthd_ldap_options>
A B<PSGConf::Data::Hash> object containing options for the B<saslauthd>
C<ldap> authentication mechanism.
=back
The constructor also registers the following policy methods:
=over 4
=item I<SASL_add_packages>
Adds an entry for I<cyrus_sasl> to the I<pkg_install_list> object (provided
by B<PSGConf::Control::Packages>), if not already present.
=item I<saslauthd_add_rc_scripts>
Adds an entry for I<saslauthd> to the I<rc_scripts> object (provided
by B<PSGConf::Control::InitScripts>).
=back
=item decide()
If I<SASL_enable> is set, registers a
B<PSGConf::Action::GenerateFile::SASL_conf> object to create
a configuration file for each application listed in I<SASL_app_config>.
If I<saslauthd_enable> is also set and I<saslauthd_mechanism> is set to
C<ldap>, registers a B<PSGConf::Action::GenerateFile::SASL_conf> object
to generate the F</usr/local/etc/saslauthd.conf> file.
=back
=head1 SEE ALSO
L<perl>
L<PSGConf>
L<PSGConf::Action::GenerateFile::SASL_conf>
L<PSGConf::Control::Packages>
L<PSGConf::Control::InitScripts>
L<PSGConf::Control::Packages>
L<PSGConf::Data::Boolean>
L<PSGConf::Data::Hash>
L<PSGConf::Data::String>
L<psgconf-intro>
=cut
syntax highlighted by Code2HTML, v. 0.9.1