Internal Server Error 500 - subprocess exited with status 13

Kheang

Member
Apr 25, 2014
19
0
1
cPanel Access Level
Root Administrator
Hi,

I made a quick plugin for WHM and put it in:

/usr/local/cpanel/whostmgr/docroot/cgi/addon_sc.cgi

Here is the content:
Code:
#!/usr/local/bin/perl

#WHMADDON:simplecommerce:Simple Commerce Admin

use lib '/usr/local/cpanel' , '/usr/local/cpanel/whostmgr/docroot/cgi' ;

use strict ;

print "Content-Type: text/html\n\n" ;

my %ACL = %Whostmgr::ACLS::default ;

if ( 'root' eq $ENV{'REMOTE_USER'} )
{
    $ACL{'all'} = 1 ;
}

if ( !$ACL{'all'} )
{
    exit ;
}
else
{
    print "<meta http-equiv=\"refresh\" content=\"0;url=$ENV{'cp_security_token'}/cgi/simplecommerce/index.php\"/>" ;
}
The plugin appears in the WHM and when I clicked on it I got the error access denied. So I went and created a simplecommerce.conf file and used appconfig to register it and it appears in the list of registered apps.

Here is the content of the .conf file:

Code:
name=simplecommerce

# This is the name that will be displayed for your application in WHM.
displayname=Simple Commerce Admin

# service that will serve this app
service=whostmgr

# Physical path: /usr/local/cpanel/3rdparty/Foo.php
# Literal URL path: $server:$port/$cpsession/3rdparty/Foo.php
url=/cgi/addon_sc.cgi

# Directory containing php.ini
# - must exist in /usr/local/cpanel/3rdparty/etc/
#phpHandler=Foo

# Features required
features=any

# This is a comma-separated list of ACLs. The logged-in user must have at least one of these ACLs in order to access your application at the URL(s) provided.
acls=all

# This is the filename of the icon that is used by the application (For example: myapp_icon.png).
icon=sc_icon.jpg
Now when I click on the plugin i get the error:

Internal Server Error

500

No response from subprocess (/usr/local/cpanel/whostmgr/docroot/cgi/addon_sc.cgi): subprocess exited with status 13 (EACCES)

I looked at the error log and it says:

Duplicate logaccess: at cpsrvd-ssl line 6398
main::body_internal_error(500, 'No response from subprocess (/usr/local/cpanel/whostmgr/docroot/...') called at cpsrvd-ssl line 6457
main::internal_error('No response from subprocess (/usr/local/cpanel/whostmgr/docroot/...') called at cpsrvd-ssl line 9477
main::handle_subprocess_failure(3, undef, 2, 'No response from subprocess (/usr/local/cpanel/whostmgr/docroot/...') called at cpsrvd-ssl line 7710
main::subprocess_handler('/usr/local/cpanel/whostmgr/docroot/cgi/addon_sc.cgi', 'IO::Handle=GLOB(0xa1b4b74)', 'GLOB(0xa1b4b5c)', 0) called at cpsrvd-ssl line 7570
main::cgiHandler('docroot', '/usr/local/cpanel/whostmgr/docroot') called at cpsrvd-ssl line 6963
main::dodoc_whostmgrd() called at cpsrvd-ssl line 1824
main::dodoc('HASH(0x8698d04)') called at cpsrvd-ssl line 1355
main::handle_one_connection() called at cpsrvd-ssl line 996
Internal Server Error: "GET /cpsess5397775926/cgi/addon_sc.cgi HTTP/1.1" 500 No response from subprocess (/usr/local/cpanel/whostmgr/docroot/cgi/addon_sc.cgi): subprocess exited with status 13 (EACCES)

Any ideas what is causing this?

Any help is appreciated, thanks!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
The plugin appears in the WHM and when I clicked on it I got the error access denied.
As for the first error message that occurred, what was output to /usr/local/cpanel/logs/login_log?

Thank you.
 

Kheang

Member
Apr 25, 2014
19
0
1
cPanel Access Level
Root Administrator
As for the first error message that occurred, what was output to /usr/local/cpanel/logs/login_log?

Thank you.
Sorry the first error no longer appears because I went an registered it in AppConfig.

The first error had a message saying i could not access the script because it wasn't registered or the option to allow unregistered scripts wasn't set to On. That's why I tried registered it with AppConfig.

Is this how it should be done?
The .cgi first and then through AppConfig?
Or it's one or the other only?

Also if I want to remove it from AppConfig what do i do? Do I just delete the .conf file from the apps folder?

I still get that error 500 though.
 

Kheang

Member
Apr 25, 2014
19
0
1
cPanel Access Level
Root Administrator
As for the first error message that occurred, what was output to /usr/local/cpanel/logs/login_log?

Thank you.
I just looked again and I saw this:

198.48.203.84 - root [04/30/2014:18:05:57 -0000] "GET / HTTP/1.1" DEFERRED LOGIN whostmgrd: security token missing
198.48.203.84 - root [04/30/2014:18:17:38 -0000] "GET / HTTP/1.1" DEFERRED LOGIN whostmgrd: security token missing

I guess I am missing something in the .cgi script?

- - - Updated - - -

Ok nevermind its only when I try to access /cgi/simplecommerce/index.php directly when logged in.
But the login log doesn't show anything when I type the /cgi/addon_sc.cgi directly. Only that error in error_log

- - - Updated - - -

It still gives the same error when I remove all the code and put a simple print line with the configuration on top.
 

Kheang

Member
Apr 25, 2014
19
0
1
cPanel Access Level
Root Administrator
OK so I figured out what was the problem!

My cgi script was fine, I only needed to add a newline at the end of the file. (weird)
Now it does what it should do but brings me this error:


HTTP error 401
cgi/simplecommerce/index.php

WHM is configured to disallow execution of unregistered applications when logged in as root or a reseller with the "all" ACL. To enable this functionality you must do one of the following: Register this addon using /usr/local/cpanel/bin/register_appconfig (AppConfig), Enable the "Allow apps that have not registered with AppConfig to be run when logged in as root or a reseller with the "all" ACL in WHM" option in "Tweak Settings", or add permit_unregistered_apps_as_root=1 to /var/cpanel/cpanel.config, and run /usr/local/cpanel/etc/init/startcpsrvd

I have registered the plugin in AppConfig using my simplecommerce.conf:

name=simplecommerce

# This is the name that will be displayed for your application in WHM.
displayname=Simple Commerce Admin

# service that will serve this app
service=whostmgr

# Physical path: /usr/local/cpanel/3rdparty/Foo.php
# Literal URL path: $server:$port/$cpsession/3rdparty/Foo.php
url=/cgi/addon_simplecommerce.cgi

# This is a comma-separated list of ACLs. The logged-in user must have at least one of these ACLs in order to access your application at the URL(s) provided.
acls=all

After that I tried running the plugin again and it still gave me that error.
What am I missing in the conf file to make it work? Or do i absolutely have to turn the security features on?
 

Kheang

Member
Apr 25, 2014
19
0
1
cPanel Access Level
Root Administrator
Ok i figured out my problem here too. I had to put all the url's of my scripts in the .conf file or it would not allow me to execute them.