###
### Copyright 2000-2007 University of Illinois Board of Trustees
### All rights reserved.
###
### Shells.pm - /etc/shell module for psgconf
###
### Campus Information Technologies and Educational Services
### University of Illinois at Urbana-Champaign
###
package PSGConf::Control::Shells;
use strict;
use PSGConf::Action::RunCommand;
use PSGConf::Action::GenerateFile::Literal;
use PSGConf::Data::List;
###############################################################################
### plugin function for PSGConf::Action::RunCommand
###############################################################################
sub _check_login_cfg
{
my ($self, $psgconf) = @_;
my ($shell_list);
if (! open(LSSEC,
'lssec -f /etc/security/login.cfg -s usw -a shells |'))
{
warn "\n\t!!! cannot run lssec: $!\n";
return -1;
}
$shell_list = <LSSEC>;
chomp $shell_list;
$shell_list =~ s/usw shells=//;
close LSSEC;
return 1
if ($shell_list ne join(',', @{$psgconf->data_obj('shells')->get()}));
return 0;
}
###############################################################################
### decide() method
###############################################################################
sub decide
{
my ($self, $psgconf) = @_;
my ($cmd);
if ($psgconf->data_obj('platform')->match('aix'))
{
$cmd = 'chsec -f /etc/security/login.cfg -s usw -a shells='
. join(',', @{$psgconf->data_obj('shells')->get()});
$psgconf->register_actions(
PSGConf::Action::RunCommand->new(
name => 'Shells in login.cfg',
command => $cmd,
check_func => \&_check_login_cfg,
)
);
}
else
{
$psgconf->register_actions(
PSGConf::Action::GenerateFile::Literal->new(
name => '/etc/shells',
content => join("\n", @{$psgconf->data_obj('shells')->get()}) . "\n",
)
);
}
}
###############################################################################
### constructor
###############################################################################
sub new
{
my ($class, $psgconf) = @_;
my ($self);
$self = {};
bless($self, $class);
$self->{name} = 'Shells';
$psgconf->register_data(
shells => PSGConf::Data::List->new(),
);
return $self;
}
###############################################################################
### documentation
###############################################################################
1;
__END__
=head1 NAME
PSGConf::Control::Shells - psgconf control class for generating /etc/shells
=head1 SYNOPSIS
In F<psgconf_modules>:
Control PSGConf::Control::Shells
=head1 DESCRIPTION
The B<PSGConf::Control::Shells> module provides a B<psgconf> control object
for generating F</etc/shells> (or editing F</etc/security/login.cfg> on AIX).
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<shells>
A B<PSGConf::Data::List> object containing whose keys are the list of
shells to be added to the F</etc/shells> or F</etc/security/login.cfg> file.
=back
=item decide()
Registers a B<PSGConf::Action::GenerateFile::Literal> or
B<PSGConf::Action::RunCommand> object to create F</etc/shells> or
edit F</etc/security/login.cfg>.
=back
=head1 SEE ALSO
L<perl>
L<PSGConf>
L<PSGConf::Action::RunCommand>
L<PSGConf::Action::GenerateFile::Literal>
L<PSGConf::Data::List>
L<psgconf-intro>
=cut
syntax highlighted by Code2HTML, v. 0.9.1