### ### 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: Control PSGConf::Control::inetd =head1 DESCRIPTION The B module provides a B 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 object. It registers the following data objects: =over 4 =item I A B object that indicates whether C should be configured. The default is true. =item I A B object containing entries for F. The hash key is a string of the form C, where C is the service name from F and C is something like C or C. The value is an anonymous hash containing the attributes for the service. =item I A B object containing RPC entries for F. The hash key is a string of the form C, where C is the program name from F and C is the RPC version. The value is an anonymous hash containing the attributes for the service. =item I A B object containing literal text to add to F. (This is a hack to accomodate system-specific entry types, such as TLI or RPC entries. It should be avoided if possible.) =item I A B object containing names, port number and aliases for F. The first column is the port name, the second is the port number and protocol in C/C format, and the third is the optional port alias. =item I A B object that indicates whether C should be configured instead of C. The default is false. =item I A B object that contains attributes for the C section of the F file. This object is ignored unless the I Data object is enabled. =back The constructor also registers the following policy methods: =over 4 =item I Modifies the I data object (provided by B) to enable C. =back =item decide() Registers a B object to create F/inetd.conf> or F/xinetd.conf>. Also registers a B object to create F/services>. (The I object is provided by the B module.) =back =head1 BUGS The I Data object is a nasty hack and should be removed. =head1 SEE ALSO L inetd.conf(4) services(4) L L L L L L L L L L L L L L =cut