Apache-Logmonster
view release on metacpan or search on metacpan
lib/Apache/Logmonster/Utility.pm view on Meta::CPAN
return $self;
}
sub ask {
my $self = shift;
my $question = shift;
my %p = validate(
@_,
{ default => { type => SCALAR|UNDEF, optional => 1 },
timeout => { type => SCALAR, optional => 1 },
password => { type => BOOLEAN, optional => 1, default => 0 },
test_ok => { type => BOOLEAN, optional => 1 },
}
);
my $pass = $p{password};
my $default = $p{default};
if ( ! $self->is_interactive() ) {
$log->audit( "not running interactively, can not prompt!");
return $default;
}
return $log->error( "ask called with \'$question\' which looks unsafe." )
if $question !~ m{\A \p{Any}* \z}xms;
lib/Apache/Logmonster/Utility.pm view on Meta::CPAN
############ cwd_source_dir ###################
# Usage : $util->cwd_source_dir( "/usr/local/src" );
# Purpose : prepare a location to build source files in
# Returns : 0 - failure, 1 - success
# Parameters : S - dir - a directory to build programs in
=item check_homedir_ownership
Checks the ownership on all home directories to see if they are owned by their respective users in /etc/password. Offers to repair the permissions on incorrectly owned directories. This is useful when someone that knows better does something like "ch...
######### check_homedir_ownership ############
# Usage : $util->check_homedir_ownership();
# Purpose : repair user homedir ownership
# Returns : 0 - failure, 1 - success
# Parameters :
# Optional : I - auto - no prompts, just fix everything
# See Also : sysadmin
Comments: Auto mode should be run with great caution. Run it first to see the results and then, if everything looks good, run in auto mode to do the actual repairs.
t/Utility.t view on Meta::CPAN
is( lc($r), "yes", 'ask' );
ok( $r = $util->ask( 'any (non empty) answer' ), 'ask, tricky' );
# multiline prompt
ok( $r = $util->ask( 'test any (non empty) answer',
default => 'just hit enter',
),
'ask, multiline'
);
# default password prompt
ok( $r = $util->ask( 'type a secret word',
password => 1,
default => 'secret',
),
'ask, password'
);
}
# extract_archive
my $gzip = $util->find_bin( "gzip", fatal => 0 );
my $tar = $util->find_bin( "tar", fatal => 0 );
my $star = $util->find_bin( "star", fatal => 0 );
SKIP: {
skip "gzip or tar is missing!\n", 6 unless ( -x $gzip and -x $tar and -d $tmp );
( run in 0.905 second using v1.01-cache-2.11-cpan-49f99fa48dc )