File Coverage

blib/lib/Archer/Plugin/Exec/Local.pm
Criterion Covered Total %
statement 16 16 100.0
branch 3 4 75.0
condition 2 3 66.6
subroutine 4 4 100.0
pod n/a
total 25 27 92.5


line stmt bran cond sub pod time code
1             package Archer::Plugin::Exec::Local;
2 1     1   6 use strict;
  1         2  
  1         46  
3 1     1   7 use warnings;
  1         2  
  1         39  
4 1     1   6 use base qw/Archer::Plugin::Exec/;
  1         3  
  1         550  
5              
6             sub _execute {
7 2     2   6 my ($self, $cmd, $args) = @_;
8              
9 2         7 my $user = $self->{config}->{user};
10 2 50       7 my $real_command = $user ? "sudo -u $user $cmd " : $cmd;
11 2         9 $self->log(debug => "real execute: $real_command");
12              
13 2         27340 my $exit_code = system $real_command; # XXX security!!!
14              
15 2 100 66     230 if ($self->{config}{validate} && $exit_code != 0) {
16 1         128 $self->detach("Exit code: $exit_code! Command validation failed! Deployment is cancelled.");
17             }
18             }
19              
20             1;
21             __END__