### ### Copyright 2000-2007 University of Illinois Board of Trustees ### All rights reserved. ### ### sudo.pm - sudo module for psgconf ### ### Campus Information Technologies and Educational Services ### University of Illinois at Urbana-Champaign ### package PSGConf::Control::sudo; use strict; use PSGConf::Action::GenerateFile::sudoers; use PSGConf::Action::Remove; use PSGConf::Data::Boolean; use PSGConf::Data::Hash; use PSGConf::Data::List; use PSGConf::Data::String; use PSGConf::Control::Packages qw(_add_pkgs); ############################################################################### ### Constructor ############################################################################### sub new { my ($class, $psgconf) = @_; my ($self); $self = {}; bless($self, $class); ### So that _add_pkgs knows which directives to look at $self->{name} = 'sudo'; $self->{enable} = $self->{name} . '_enable'; $self->{packages} = $self->{name} . '_packages'; $psgconf->register_data( 'sudo_enable' => PSGConf::Data::Boolean->new( value => 'false' ), 'sudo' => PSGConf::Data::Hash->new( 'value_type' => 'HASH' ), 'sudoers_path' => PSGConf::Data::String->new( 'value_abspath' => 1, value => '/etc/sudoers' ), 'sudo_defaults' => PSGConf::Data::String->new(), 'sudo_packages' => PSGConf::Data::List->new(), 'sudo_nopasswd' => PSGConf::Data::Boolean->new( value => 'true' ) ); $psgconf->register_policy($self, sudo_add_packages => '_add_pkgs' ); return $self; } ############################################################################### ### decide() method ############################################################################### sub decide { my ($self, $psgconf) = @_; if ($psgconf->data_obj('sudo_enable')->equals('false') || ! $psgconf->data_obj('sudo')->count()) { $psgconf->register_actions( PSGConf::Action::Remove->new( 'name' => $psgconf->data_obj('sudoers_path')->get() ) ); return; } $psgconf->register_actions( PSGConf::Action::GenerateFile::sudoers->new( 'name' => $psgconf->data_obj('sudoers_path')->get(), 'description' => 'sudo access control file', 'mode' => 0440, 'hostname' => $psgconf->data_obj('hostname')->get(), 'defaults' => $psgconf->data_obj('sudo_defaults')->get(), 'sudo' => $psgconf->data_obj('sudo')->get(), 'no_passwd' => $psgconf->data_obj('sudo_nopasswd')->get() ) ); } ############################################################################### ### documentation ############################################################################### 1; __END__ =head1 NAME PSGConf::Control::sudo - psgconf control class for sudo =head1 SYNOPSIS In F: Control PSGConf::Control::sudo =head1 DESCRIPTION The B module provides a B control object for configuring C. 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 indicating if we should use C on the system. The default is no. =item I A B object containing the permission entries for F. The hash key is the command. The value is a reference to a hash whose key is the user to run the command as, and whose value is a reference to yet another hash whose keys are the list of users who are allowed to run the command as that user. =item I A B object containing the filename for the F file. =item I A B object containing the arguments for the C directive in F. =item I A B object indicating whether the user should be required to enter a password when using C. =item I A B object containing the packages to install. =back The constructor also registers the following policy method: =over 4 =item I If I is defined, adds the C package to the I object, which is provided by the B module. =back =item decide() If I is defined, it registers a B action object to create the C config file. Otherwise, registers a B object to remove the C config file. =back =head1 SEE ALSO sudoers(4) L L L L L L L L L L =cut