### ### Copyright 2000-2007 University of Illinois Board of Trustees ### All rights reserved. ### ### sudoers.pm - psgconf action class to generate /etc/sudoers ### ### Campus Information Technologies and Educational Services ### University of Illinois at Urbana-Champaign ### package PSGConf::Action::GenerateFile::sudoers; use strict; use PSGConf::Action::GenerateFile; our @ISA = qw(PSGConf::Action::GenerateFile); ############################################################################### ### generate() method ############################################################################### sub generate { my ($self, $fh, $psgconf) = @_; my ($cmd, $run_as_user, @userlist); print $fh "Defaults $self->{defaults}\n" if (defined($self->{defaults})); foreach $cmd (sort keys %{$self->{sudo}}) { foreach $run_as_user (sort keys %{$self->{sudo}->{$cmd}}) { print $fh join(',', sort keys %{$self->{sudo}->{$cmd}->{$run_as_user}}); print $fh ' ' . $self->{hostname}; print $fh "=($run_as_user)"; print $fh ($self->{no_passwd} ? 'NOPASSWD:' : ' '); print $fh "$cmd\n"; } } return 1; } ############################################################################### ### documentation ############################################################################### 1; __END__ =head1 NAME PSGConf::Action::GenerateFile::sudoers - generate /etc/sudoers file =head1 SYNOPSIS use PSGConf::Action::GenerateFile::sudoers; $psgconf->register_actions( PSGConf::Action::GenerateFile::sudoers->new( 'name' => '/etc/sudoers', 'defaults' => '...', 'sudo' => { ... }, 'no_passwd' => 0, ... ), ... ); =head1 DESCRIPTION The B module provides a B action class for generating the F file. The B class is derived from the B class, but it defines/overrides the following methods: =over 4 =item generate() Generate the F file. =back In addition to the attributes supported by the B class, the B class supports the following attributes: =over 4 =item I Arguments for the C directive. This attribute is optional. =item I A hash mapping the command to a hash mapping the run-as user to a hash whose keys are the names of users that are allowed to execute the command as the run-as user. =item I A string containing the system's hostname. =item I A boolean value indicating whether to add C to each entry. =back =head1 BUGS The structure of the I attribute is cumbersome. The I attribute should be set on a per-entry basis, not globally. =head1 SEE ALSO L L L =cut