Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Calling cpanel_exec_fast from CGI script under cpsessXXXX system results in errors.

Discussion in 'cPanel Developers' started by KostonConsulting, Nov 22, 2010.

  1. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    68
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    Hello,
    It seems that recently, cPanel URLs are now under a session system that adds /cpsessXXXX/ before the theme URL. Under this system, scripts no longer work that call the XML API using cpanel_exec_fast as outline in the cPanel docs: CallingAPIFunctions < AllDocumentation/AutomationIntegration < TWiki

    Has anyone else experienced this issue? Any docs or knowledge on how to connect to the cpsessXXXXX system within scripts?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    68
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    Re: Calling cpanel_exec_fast from CGI script under cpsessXXXX system results in error

    As an update, I'm calling a script: xxx.cgi from an AJAX request through a relative URL as discussed on in this integration blog post about secuirty tokens using this code:

    Code:
    function call_out(){
    			var postData = 'code=12345';
    			var ajaxURL = '/3rdparty/issue.cgi';
    			var callback = {
    				success: function(o){
    					alert('success');
    				},
    				failure: function(o){
    					alert('failure');
    				}
    			}
    			var transaction = YAHOO.util.Connect.asyncRequest('POST', ajaxURL, callback, postData);
    
    			return false;
    		}

    When making the call, I get the following error:

    [​IMG]


    Has anyone else seen this issue? If so, how can it be averted without forcing users to disable security tokens?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    68
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    Re: Calling cpanel_exec_fast from CGI script under cpsessXXXX system results in error

    Got a response back from Matt @ cPanel on this and things seem to be working fine with his changes:

    1. Need to add CPANEL.security_token before the URL to print out the /cpsessXXXX:

    What used to be:
    Code:
    var ajaxURL = '/3rdparty/script.cgi';
    Should now be:
    Code:
    var ajaxURL = CPANEL.security_token + '/3rdparty/script.cgi';
    The CPANEL.security_token variable is implemented in stdheader.html so anything in /frontend/${theme}/* will have access to the variable.


    2. Need to output the security token session data in the CGI file's HTML output:

    Code:
    <script type="text/javascript">
    	if ( !("CPANEL" in window) ) CPANEL = {};
    	CPANEL.security_token = "$ENV{'cp_security_token'}";
    	</script>
    


    Hopefully this will help someone else. Thanks to Matt from cPanel for the solution.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice