###
### Copyright 2000-2007 University of Illinois Board of Trustees
### All rights reserved.
###
### NameServiceSwitch.pm - Name Service Switch control module for psgconf
###
### Campus Information Technologies and Educational Services
### University of Illinois at Urbana-Champaign
###
package PSGConf::Control::NameServiceSwitch;
use strict;
use PSGConf::Action::GenerateFile::nsswitch_conf;
use PSGConf::Data::String;
use PSGConf::Data::Hash;
###############################################################################
### constructor
###############################################################################
sub new
{
my ($class, $psgconf) = @_;
my ($self);
$self = {};
bless($self, $class);
$self->{name} = 'name_service';
$psgconf->register_data(
name_service_conf_path => PSGConf::Data::String->new(
'value_abspath' => 1,
value => '/etc/nsswitch.conf'
),
name_service_switch => PSGConf::Data::Hash->new(
value_type => 'ARRAY'
),
name_service_delimiter => PSGConf::Data::String->new(
value => ":\t"
),
name_service_seperator => PSGConf::Data::String->new(
value => ' '
),
);
return $self;
}
###############################################################################
### decide() method
###############################################################################
sub decide
{
my ($self, $psgconf) = @_;
return
if (! $psgconf->data_obj('name_service_switch')->count());
$psgconf->register_actions(
PSGConf::Action::GenerateFile::nsswitch_conf->new(
name => $psgconf->data_obj('name_service_conf_path')->get(),
description => 'name service switch config file',
name_service_switch
=> $psgconf->data_obj('name_service_switch')->get(),
name_service_delimiter
=> $psgconf->data_obj('name_service_delimiter')->get(),
name_service_seperator
=> $psgconf->data_obj('name_service_seperator')->get()
)
);
}
###############################################################################
### documentation
###############################################################################
1;
__END__
=head1 NAME
PSGConf::Control::NameServiceSwitch - psgconf control class for nsswitch config
=head1 SYNOPSIS
In F<psgconf_modules>:
Control PSGConf::Control::NameServiceSwitch
=head1 DESCRIPTION
The B<PSGConf::Control::NameServiceSwitch> module provides a B<psgconf>
control object for configuring name service lookups. 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<name_service_switch>
A B<PSGConf::Data::Hash> object containing information on which name
services to use for each type. The hash key is the type of name
service. The value is an array containing the ordered list of services
to use for that type of name service.
=item I<name_service_conf_path>
A B<PSGConf::Data::String> object that contains the name of the file of
the name service switch config file. It defaults to F</etc/nsswitch.conf>.
=item I<name_service_delimiter>
The character used to seperate the name service from the services to use.
Defaults to ":\t".
=item I<name_service_seperator>
The character used to seperate the names of the services to use. Defaults
to ' '.
=back
=item decide()
If I<name_service_switch> is set, instantiates and registers a
B<PSGConf::Action::GenerateFile::nsswitch_conf> object to create
F</etc/nsswitch.conf>.
=back
=head1 SEE ALSO
L<perl>
nsswitch.conf(5)
L<PSGConf>
L<PSGConf::Action::GenerateFile::nsswitch_conf>
L<PSGConf::Data::Hash>
L<PSGConf::Data::String>
L<psgconf-intro>
=cut
syntax highlighted by Code2HTML, v. 0.9.1