The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Unknown App Requested: sectacls - Help Please!

Discussion in 'cPanel Developers' started by Apenex, Jul 1, 2010.

  1. Apenex

    Apenex Registered

    Joined:
    Jul 1, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    I'm working on a script to automate the creation of cpanel and reseller accounts. Thus far I've had no problems integrating the API from the documentation into my code. However I just tried the function: sectacls

    and all it will do is give me the error above.

    Any solutions, ideas, suggestions?

    SetResellersACLList < AllDocumentation/AutomationIntegration < TWiki
     
  2. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Are you authenticating as root?

    What version are you running?
     
  3. Apenex

    Apenex Registered

    Joined:
    Jul 1, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Yes I'm authenticating as root. I'm able to have the script I'm writing log in, create an account and even make it a reseller, it just fails when I get to setting an ACL for that reseller. My cpanel version is: cPanel 11.25.0-S46156
     
  4. cPanelCraig

    cPanelCraig Member
    Staff Member

    Joined:
    Apr 29, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    When you are calling setacls() what parameters are you passing in the associative array? Are you passing the name of a predefined acllist or a list of acls?

    What are you getting as the return value from the function?

    I was not able to reproduce the error on a 11.25.0-R46156 test server. Knowing how you are calling the function will give us some idea on how to reproduce the behavior.
     
  5. Apenex

    Apenex Registered

    Joined:
    Jul 1, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    I'm using the code bellow to attempt to set the acls. They are all variables from the database. After that, is the url that the script creates to execute... I replaced my password and ip address with a fake one in this case for security reasons.

    Code In PHP File:
    Code:
    $site = "http://{$whm_user}:{$whm_pass}@{$whm_host}:2086/xml-api/sectacls";
    
    $parameters = "?reseller={$user_name}&acl-add-pkg={$res['add_packages']}&acl-allow-addoncreate={$res['unlimited_addon_packages']}&acl-allow-parkedcreate={$res['parked_endable_packages']}&acl-allow-unlimited-disk-pkgs={$res['unlimited_storage_packages']}&acl-allow-unlimited-pkgs={$res['unlimited_bandwidth_packages']}&acl-clustering{$res['enable_clustering']}&acl-create-acct={$res['allow_account_creation']}&acl-create-dns={$res['add_dns_enable']}&acl-edit-account={$res['enable_account_modification']}acl-edit-dns={$res['edit_dns_enable']}&acl-frontpage={$res['enable_frontpage']}&acl-kill-acct={$res['terminate_account_enable']}&acl-kill-dns={$res['remove_dns_enable']}&acl-list-accts={$res['list_accounts']}&acl-mod-subdomains={$res['subdomains_enable']}&acl-news={$res['modify_news']}&acl-park-dns={$res['park_dns_enable']}&acl-passwd={$res['change_passwords']}&acl-show-bandwidth={$res['view_bandwidth_usage_enable']}&acl-stats={$res['view_statisitcs']}&acl-status={$res['service_status']}&acl-suspend-accts={$res['enable_upgrades']}&acl-upgrade-account={$res['enable_upgrades']}";
    $result = file_get_contents($site.$parameters);
    echo $result;
    
    URL Executed By PHP File:
    Code:
    http://root:mypassword@myipaddress:2086/xml-api/sectacls?reseller=apenexa&acl-add-pkg=1&acl-allow-addoncreate=1&acl-allow-parkedcreate=0&acl-allow-unlimited-disk-pkgs=1&acl-allow-unlimited-pkgs=1&acl-clustering1&acl-create-acct=1&acl-create-dns=1&acl-edit-account=0acl-edit-dns=0&acl-frontpage=0&acl-kill-acct=0&acl-kill-dns=0&acl-list-accts=1&acl-mod-subdomains=1&acl-news=0&acl-park-dns=1&acl-passwd=1&acl-show-bandwidth=1&acl-stats=1&acl-status=1&acl-suspend-accts=1&acl-upgrade-account=1
    
    All of my other functions on the xml-api work just fine (createacct and setresellerlimits)
     
    #5 Apenex, Jul 11, 2010
    Last edited: Jul 11, 2010
  6. cPanelCraig

    cPanelCraig Member
    Staff Member

    Joined:
    Apr 29, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    Double check this line carefully:
    Code:
    $parameters = "?reseller={$user_name}&acl-add-pkg={$res['add_packages']}&acl-allow-addoncreate={$res['unlimited_addon_packages']}&acl-allow-parkedcreate={$res['parked_endable_packages']}&acl-allow-unlimited-disk-pkgs={$res['unlimited_storage_packages']}&acl-allow-unlimited-pkgs={$res['unlimited_bandwidth_packages']}&acl-clustering{$res['enable_clustering']}&acl-create-acct={$res['allow_account_creation']}&acl-create-dns={$res['add_dns_enable']}&acl-edit-account={$res['enable_account_modification']}acl-edit-dns={$res['edit_dns_enable']}&acl-frontpage={$res['enable_frontpage']}&acl-kill-acct={$res['terminate_account_enable']}&acl-kill-dns={$res['remove_dns_enable']}&acl-list-accts={$res['list_accounts']}&acl-mod-subdomains={$res['subdomains_enable']}&acl-news={$res['modify_news']}&acl-park-dns={$res['park_dns_enable']}&acl-passwd={$res['change_passwords']}&acl-show-bandwidth={$res['view_bandwidth_usage_enable']}&acl-stats={$res['view_statisitcs']}&acl-status={$res['service_status']}&acl-suspend-accts={$res['enable_upgrades']}&acl-upgrade-account={$res['enable_upgrades']}";
    
    It is missing & characters in at least one place which is causing the ACL list to be invalid. Once the syntax errors are corrected the ACL list should apply cleanly when you call the URL.
     
  7. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Yes, you're missing a ampersand ('&') and an equal ('=') sign; look at 'acl-edit-dns' and 'acl-clustering' for the respective errors.

    Also, the call is "setacls". Only one "c". The function will 'set' the ACLs...

    Making a non-encrypted connection with you root credentials in the URL is very unwise. If you must use credentials in the URL, at least use https and port 2087.

    If your application isn't dependent on the credentials in the URL, I highly recommend placing them in the http headers.

    Note on credentials and URL: cPanel discourages it from a technical stance, since we provide the XML-API which is designed to authenticate with headers. However, it should work in most cases.

    Note on PHP and SSL: anytime you make an SSL request (https), you need either OpenSSL or cURL with SSL compiled in you PHP; you'll have to check.

    In case you didn't know, there's a PHP class for making these client-side connections.
    http://sdk.cpanel.net/lib/xmlapi/php/cp_xmlapi_php_v1.0.5.tar.gz

    Makes things like this super easy. It'll set the auth headers for you. It'll even auth you with a root access hash (found in WHM: Main >> Cluster/Remote Access >> Setup Remote Access Key)

    So, to use the xml-api client class to do what you need:
    Code:
    <?php 
    // include the client class
    include_once('xmlapi.php');
    
    // basic vars
    $ip = "10.0.0.1";
    $WHMuser = 'root';
    $WHMpass = "s3cr3tP4wD!";
    $user_name = 'joebob'; //needed as an arguement to setlist function
    
    // instantiate our xmlapi client object and setup it's properties
    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth($WHMuser, $WHMpass);
    $xmlapi->set_port('2087');
    
    // you can run in debug, which i love cause it dumps the
    //  URL constructed in the request process.
    
    //$xmlapi->set_debug(1);
    
    
    // you app defines this somewhere else, I presume
    $res = array(
    	'add_packages'			=> 1,
    	//etc, etc....
    );
    
    // reseller setlist args, ie an ACL list plus the reseller
    $args = array(
    	'reseller'				 	=> $user_name,
    	'acl-add-pkg'				=> $res['add_packages'],
    	'acl-allow-addoncreate'			=> $res['unlimited_addon_packages'],
    	'acl-allow-parkedcreate'		=> $res['parked_endable_packages'],
    	'acl-allow-unlimited-disk-pkgs'	=> $res['unlimited_storage_packages'],
    	'acl-allow-unlimited-pkgs'		=> $res['unlimited_bandwidth_packages'],
    	'acl-clustering'				=> $res['enable_clustering'],
    	'acl-create-acct'				=> $res['allow_account_creation'],
    	'acl-create-dns'				=> $res['add_dns_enable'],
    	'acl-edit-account'				=> $res['enable_account_modification'],
    	'acl-edit-dns'				=> $res['edit_dns_enable'],
    	'acl-frontpage'				=> $res['enable_frontpage'],
    	'acl-kill-acct'				=> $res['terminate_account_enable'],
    	'acl-kill-dns'				=> $res['remove_dns_enable'],
    	'acl-list-accts'				=> $res['list_accounts'],
    	'acl-mod-subdomains'			=> $res['subdomains_enable'],
    	'acl-news'					=> $res['modify_news'],
    	'acl-park-dns'				=> $res['park_dns_enable'],
    	'acl-passwd'				=> $res['change_passwords'],
    	'acl-show-bandwidth'			=> $res['view_bandwidth_usage_enable'],
    	'acl-stats'					=> $res['view_statisitcs'],
    	'acl-status'					=> $res['service_status'],
    	'acl-suspend-accts'			=> $res['enable_upgrades'],
    	'acl-upgrade-account'			=> $res['enable_upgrades'],
    );
    
    
    // execute the command; by default the return value will be a SimpleXML object
    $result = $xmlapi->setacls($args);
    
    
    ?>
    

    Regards,
    -DavidN
     
Loading...

Share This Page