Skip to content

Commit

Permalink
Merge pull request #551 from cpanel/what_executable
Browse files Browse the repository at this point in the history
Document what executable is failing
  • Loading branch information
cPholloway authored Nov 15, 2024
2 parents 7753160 + 1e6060c commit f938c04
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion elevate-cpanel
Original file line number Diff line number Diff line change
Expand Up @@ -8435,7 +8435,7 @@ EOS
sub _ssystem ( $command, %opts ) {
my @args = @{ $command // [] };

Carp::croak("Program is not an executable absolute path.") if $args[0] !~ '^/' || !-x $args[0];
Carp::croak("Program '$args[0]' is not an executable absolute path.") if $args[0] !~ '^/' || !-x $args[0];

INFO( "Running: " . join( " ", @args ) );
INFO(); # Buffer so they can more easily read the output.
Expand Down
2 changes: 1 addition & 1 deletion lib/Elevate/Roles/Run.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ sub _ssystem ( $command, %opts ) {
my @args = @{ $command // [] };

# Only allow the program to be an executable absolute path
Carp::croak("Program is not an executable absolute path.") if $args[0] !~ '^/' || !-x $args[0];
Carp::croak("Program '$args[0]' is not an executable absolute path.") if $args[0] !~ '^/' || !-x $args[0];

INFO( "Running: " . join( " ", @args ) );
INFO(); # Buffer so they can more easily read the output.
Expand Down
6 changes: 3 additions & 3 deletions t/ssystem.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ my $cpev = cpev->new->_init;

like(
dies { cpev->ssystem('nope') },
qr/Program is not an executable absolute path/,
qr/Program 'nope' is not an executable absolute path/,
'Program is not an executable path.'
);

like(
dies { cpev->ssystem('grep') },
qr/Program is not an executable absolute path/,
qr/Program 'grep' is not an executable absolute path/,
'Program is not an executable absolute path.'
);

like(
dies { cpev->ssystem('/etc/apache2/conf/httpd.conf') },
qr/Program is not an executable absolute path/,
qr{Program '/etc/apache2/conf/httpd.conf' is not an executable absolute path},
'Paths that are not executable are not allowed.'
);

Expand Down

0 comments on commit f938c04

Please sign in to comment.