Hi.
I am attempting to create a new cPanel (Paper Lantern) interface which runs a shell script as root.
The process that I am attempting to use for this is as follows:
Below are each of the relevant code segments (note: these have been somewhat simplified).
cPanel interface (755 /usr/local/cpanel/base/frontend/paper_lantern/test-module/test-module.live.php):
cPanel module (644 /usr/local/cpanel/Cpanel/API/WbTestModule.pm)
Privileged callable module (700 /usr/local/cpanel/bin/admin/WbAdminModule/WbAdminModule)
Note that I do have a WbAdminModule.conf file, created by running:
What am I missing here?
I am attempting to create a new cPanel (Paper Lantern) interface which runs a shell script as root.
The process that I am attempting to use for this is as follows:
- Define interface and call custom UAPI function.
- Build custom UAPI function which calls the Cpanel::AdminBin::Call::call method to escalate privileges.
- Build a custom admin callable module which runs the shell script.
Code:
The administrative request failed because of an error (EKEYEXPIRED/127) with output: The adminbin “WbAdmin” in the “WbAdminModule” namespace call to function “ECHO” ended prematurely: The subprocess reported error number 127 when it ended.
cPanel interface (755 /usr/local/cpanel/base/frontend/paper_lantern/test-module/test-module.live.php):
PHP:
<?php
include("/usr/local/cpanel/php/cpanel.php"); // Instantiate the CPANEL object.
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
print $cpanel->header( "test" ); // Add the header.
$test_output = $cpanel->uapi(
'WbTestModule',
'testfunction',
array(
'foo' => 'bar',
)
);
echo '<pre>';
var_dump( $test_output );
echo '</pre>';
print $cpanel->footer(); // Add the footer.
$cpanel->end(); // Disconnect from cPanel - only do this once.
?>
Code:
package Cpanel::API::WbTestModule;
use strict;
use Data::Dumper ();
use Cpanel::AdminBin::Call ();
our $VERSION = '1.0';
sub testfunction{
# siphon off the input args into a hash
my ( $args, $result ) = @_;
my ( $arg1 ) = $args->get( 'foo' );
my $val;
$val = Cpanel::AdminBin::Call::call(
'WbAdminModule',
'WbAdmin',
'ECHO',
$arg1,
);
my $err = [email protected];
my $data = {
'err' => $err,
'val' => ref($val) ? Data::Dumper::Dumper($val) : $val,
};
$result->data( $data );
return 1;
}
1;
Code:
#!/usr/local/cpanel/3rdparty/bin/perl
package WbAdminModule::WbAdmin;
use strict;
use parent qw( Cpanel::AdminBin::Script::Call );
__PACKAGE__->run() if !caller;
sub _actions {
return qw(
ECHO
);
}
sub ECHO {
my ($self, $string) = @_;
return $string;
}
1;
Code:
echo mode=full > /usr/local/cpanel/bin/admin/WbAdminModule/WbAdminModule.conf