Looks like this error is compiled into cpsrvd (cPanel's web server). I'd normally find it in one of their uncompiled modules by searching these locations:
Code:
[/usr/local/cpanel/Cpanel]# grep -R 'Remote execution of internal functions' *
[/usr/local/cpanel/Cpanel]# cd ../bin
[/usr/local/cpanel/bin]# grep -R 'Remote execution of internal functions' *
Now, we know the main page of cPanel prints out the main domain, so I looked at the source code for what prints that. Looks like they are using CPDATA{'DNS'}:
Code:
[/usr/local/cpanel/base/frontend/x3/branding]# grep 'CPDATA' index.html
var thisTheme = '<cpanel print="$CPDATA{'RS'}">';
here ------> <td class="stats_right"><b><cpanel print="$CPDATA{'DNS'}"></b></td>
<cpanelif !$CPDATA{'DEMO'}>
I'm aware of 2 ways to get this info locally:
%ENV (perl) $_ENV (php) contains this info:
PHP example:
Code:
$main_domain = getenv('DNS');
In Perl, you can also use this:
Code:
BEGIN{ unshift(@INC, '/usr/local/cpanel'); }
use Cpanel::AcctUtils::Domain ();
my $main_domain = Cpanel::AcctUtils::Domain::getdomain( $user );
However, those are only valid if your script is running on the server itself. If you need to get this information remotely, I suggest adding your own API2 call.
Drop this module into /usr/local/cpanel/Cpanel/MainDomain.pm (or whatever.pm but change package Cpanel::MainDomain to Cpanel::whatever if you change the name):
Code:
#!/usr/bin/perl
#
# MainDomain -- gets the main domain from a cPanel user's account
#
# Created by David Koston (dave at kostonconsulting dot com) on 2013-06-14.
# No warranty of any kind provided.
#
package Cpanel::MainDomain;
BEGIN { push( @INC, '/usr/local/cpanel' ); }
use strict;
use Cpanel::AcctUtils::Domain ();
sub api2 {
my $func = shift;
my %API;
$API{'get'}{'func'} = "api2_get";
$API{'get'}{'engine'} = 'hasharray';
return \%{ $API{$func} };
}
sub api2_get {
my %OPTS = @_;
my $return_hash = {
status => 0,
message => '',
domain => '',
};
my $user;
if( $OPTS{'user'} ){
$user = isCpanelUsername( $OPTS{'user'} ) ? $OPTS{'user'} : '';
}else{
$user = $ENV{'REMOTE_USER'};
}
if( $user eq '' ){
$return_hash->{message} = 'Invalid or empty {&user=} parameter';
}
my $domain = Cpanel::AcctUtils::Domain::getdomain( $user );
if( $domain ){
$return_hash->{status} = 1;
$return_hash->{domain} = $domain;
$return_hash->{message} = 'Success';
}
return $return_hash;
}
sub isCpanelUsername {
unless ( $_[0] ) { return 0; }
return $_[0] =~ /^[a-zA-Z][a-zA-Z0-9\-]{0,7}$/
? 1
: 0; #alpha-numeric + dashes. starts with letter, max 8 chars
}
1;
Call the API function:
Code:
https://webserver.com:2083/cpsess2517447623/json-api/cpanel?cpanel_jsonapi_module=MainDomain&cpanel_jsonapi_func=get
and you'll get a result like:
Code:
{"cpanelresult":{"data":[{"domain":"domainname.com","status":1,"message":"Success"}],"func":"get","apiversion":2,"event":{"result":1},"module":"MainDomain"}}
You can also call it via the WHM api with a specific user=$user URL variable if you find that useful.
Sorry for any extra info. Added here as it may be useful for others looking to find out how to track this stuff down.