###
### Copyright 2000-2007 University of Illinois Board of Trustees
### All rights reserved.
###
### inetd.pm - inetd configuration module for psgconf
###
### Campus Information Technologies and Educational Services
### University of Illinois at Urbana-Champaign
###
package PSGConf::Control::inetd;
use strict;
use PSGConf::Action::GenerateFile::inetd_conf;
use PSGConf::Action::GenerateFile::xinetd_conf;
use PSGConf::Action::GenerateFile::etc_services;
use PSGConf::Action::RestartDaemon;
use PSGConf::Action::RunCommand;
use PSGConf::Data::Boolean;
use PSGConf::Data::Hash;
use PSGConf::Data::List;
use PSGConf::Data::String;
use PSGConf::Data::Table;
use PSGConf::Control::Packages qw(_add_pkgs);
###############################################################################
### decide() method
###############################################################################
sub decide
{
my ($self, $psgconf) = @_;
my ($etc_inet_dir, $daemon);
$etc_inet_dir = $psgconf->data_obj('etc_inet_dir')->get();
$psgconf->register_actions(
PSGConf::Action::GenerateFile::etc_services->new(
'name' => $etc_inet_dir . '/services',
'description' => 'service/port mappings',
'ports' => $psgconf->data_obj('ports')->get(),
)
) if ( $psgconf->data_obj('ports')->count_col());
return
if ($psgconf->data_obj('inetd_enable')->equals('false'));
$daemon = ($psgconf->data_obj('use_xinetd')->equals('true')
? 'xinetd'
: 'inetd');
$psgconf->register_actions(
$psgconf->data_obj('use_xinetd')->equals('true')
? PSGConf::Action::GenerateFile::xinetd_conf->new(
name => $etc_inet_dir . '/'. $daemon . '.conf',
description => $daemon . ' configuration file',
defaults => $psgconf->data_obj('xinetd_defaults')->get(),
services => $psgconf->data_obj('inetd')->get(),
rpc_services => $psgconf->data_obj('inetd_rpc')->get(),
literal_text => $psgconf->data_obj('inetd_literal')->get()
)
: PSGConf::Action::GenerateFile::inetd_conf->new(
name => $etc_inet_dir . '/'. $daemon . '.conf',
'description' => $daemon . ' configuration file',
'services' => $psgconf->data_obj('inetd')->get(),
'rpc_services' => $psgconf->data_obj('inetd_rpc')->get(),
'literal_text' => $psgconf->data_obj('inetd_literal')->get()
)
);
if ( $psgconf->data_obj('platform')->match('solaris10')) {
$psgconf->register_actions(
PSGConf::Action::svcs::setprop->new(
name => 'enable TCP Wrappers for inetd',
FMRI => 'svc:/network/inetd',
property => 'defaults/tcp_wrappers',
value => 'true'
),
PSGConf::Action::svcs::setprop->new(
name => 'enable TCP tracing for inetd',
FMRI => 'svc:/network/inetd',
property => 'defaults/tcp_trace',
value => 'true'
),
PSGConf::Action::RunCommand->new(
name => 'inetd.conf conversion to SMF',
command => '/usr/sbin/inetconv -f -i ' .
$etc_inet_dir . '/inetd.conf',
filename => [ $etc_inet_dir . '/inetd.conf' ]
)
);
} elsif ( $psgconf->data_obj('platform')->match('solaris9')) {
$psgconf->register_actions(
PSGConf::Action::GenerateFile::EnvFile->new(
'name' => '/etc/default/inetd',
'comment_str' => '###',
'description' => 'inetd default settings file',
'vars' => {
'ENABLE_TCPWRAPPERS' => 'YES',
'ENABLE_CONNECTION_LOGGING' => 'YES'
}
)
);
}
$psgconf->register_actions(
PSGConf::Action::RestartDaemon->new(
name => $daemon,
filename =>
[ $etc_inet_dir . '/' . $daemon . '.conf',
$etc_inet_dir . '/services',
$etc_inet_dir . '/rpc',
'/etc/default/inetd' ]
)
);
}
###############################################################################
### policy methods
###############################################################################
sub _policy_enable_rc_scripts
{
my ($self, $psgconf) = @_;
$psgconf->data_obj('rc_scripts')->insert(
{ 'inetd' => { 'state' => 'enable' }}
) if ( $psgconf->data_obj('inetd_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} = 'inetd';
$self->{enable} = $self->{name} . '_enable';
$self->{packages} = $self->{name} . '_packages';
$psgconf->register_data(
'inetd_enable' => PSGConf::Data::Boolean->new(
value => 'true'
),
'inetd' => PSGConf::Data::Hash->new(
value_type => 'HASH'
),
'inetd_rpc' => PSGConf::Data::Hash->new(
value_type => 'HASH'
),
'inetd_literal' => PSGConf::Data::String->new(),
'inetd_packages' => PSGConf::Data::List->new(),
'ports' => PSGConf::Data::Table->new(),
'xinetd_defaults' => PSGConf::Data::Hash->new(),
'use_xinetd' => PSGConf::Data::Boolean->new(
'value' => 'false'
)
);
$psgconf->register_policy($self,
inetd_enable_rc_scripts => '_policy_enable_rc_scripts',
inetd_add_packages => '_add_pkgs'
);
return $self;
}
###############################################################################
### documentation
###############################################################################
1;
__END__
=head1 NAME
PSGConf::Control::inetd - psgconf control class for inet services
=head1 SYNOPSIS
In F<psgconf_modules>:
Control PSGConf::Control::inetd
=head1 DESCRIPTION
The B<PSGConf::Control::inetd> module provides a B<psgconf> control object
for configuring internet services. 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<inetd_enable>
A B<PSGConf::Data::Boolean> object that indicates whether C<inetd>
should be configured. The default is true.
=item I<inetd>
A B<PSGConf::Data::Hash> object containing entries for F<inetd.conf>.
The hash key is a string of the form C<service/proto>, where C<service>
is the service name from F</etc/services> and C<proto> is something like
C<udp> or C<tcp>. The value is an anonymous hash containing the
attributes for the service.
=item I<inetd_rpc>
A B<PSGConf::Data::Hash> object containing RPC entries for F<inetd.conf>.
The hash key is a string of the form C<program/version>, where C<program>
is the program name from F</etc/rpc> and C<version> is the RPC version.
The value is an anonymous hash containing the attributes for the service.
=item I<inetd_literal>
A B<PSGConf::Data::String> object containing literal text to add to
F<inetd.conf>. (This is a hack to accomodate system-specific entry
types, such as TLI or RPC entries. It should be avoided if possible.)
=item I<ports>
A B<PSGConf::Data::Table> object containing names, port number and
aliases for F</etc/services>. The first column is the port name, the
second is the port number and protocol in C<port>/C<proto> format,
and the third is the optional port alias.
=item I<use_xinetd>
A B<PSGConf::Data::Boolean> object that indicates whether C<xinetd>
should be configured instead of C<inetd>. The default is false.
=item I<xinetd_defaults>
A B<PSGConf::Data::Hash> object that contains attributes for the
C<defaults> section of the F<xinetd.conf> file. This object is ignored
unless the I<use_xinetd> Data object is enabled.
=back
The constructor also registers the following policy methods:
=over 4
=item I<inetd_enable_rc_scripts>
Modifies the I<rc_scripts> data object (provided by
B<PSGConf::Control::InitScripts>) to enable C<inetd>.
=back
=item decide()
Registers a B<PSGConf::Action::GenerateFile::inetd_conf> object to
create F<I<etc_inet_dir>/inetd.conf> or F<I<etc_inet_dir>/xinetd.conf>.
Also registers a B<PSGConf::Action::GenerateFile::etc_services> object
to create F<I<etc_inet_dir>/services>. (The I<etc_inet_dir> object is
provided by the B<PSGConf::Control::Core> module.)
=back
=head1 BUGS
The I<inetd_literal> Data object is a nasty hack and should be removed.
=head1 SEE ALSO
L<perl>
inetd.conf(4)
services(4)
L<PSGConf>
L<PSGConf::Action::GenerateFile::inetd_conf>
L<PSGConf::Action::GenerateFile::xinetd_conf>
L<PSGConf::Action::GenerateFile::etc_services>
L<PSGConf::Action::RestartDaemon>
L<PSGConf::Action::RunCommand>
L<PSGConf::Control::Core>
L<PSGConf::Control::InitScripts>
L<PSGConf::Control::Packages>
L<PSGConf::Data::Boolean>
L<PSGConf::Data::Hash>
L<PSGConf::Data::List>
L<PSGConf::Data::String>
L<psgconf-intro>
=cut
syntax highlighted by Code2HTML, v. 0.9.1