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!

Api 1 Documentation Error in Mysql module, adduserdb function

Discussion in 'cPanel Developers' started by elia, Aug 13, 2010.

  1. elia

    elia Registered

    Joined:
    Aug 13, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    51
    Hi,
    there's an error in the documentation of the API 1: in module Mysql, in the function adduserdb the parameter perm_list is describe as follow:

    from ApiMysql < ApiDocs/Api1 < TWiki

    this isn't true, the list is SPACE-separated.

    The correct form must be:
    Code:
     	 perms_list (string)
      	A space-separated list of permissions to grant to the user (e.g., "all" or "alter drop create delete insert update lock" ). 
    
    
    I spent a lot of time to find it, please correct it.

    Thank's for your work.
     
  2. cPanelDavidN

    cPanelDavidN Integration Developer

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    3
    Trophy Points:
    68
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi Elia,

    You're correct. I've informed Documentation and it should be corrected shortly.

    Thanks and sorry for the inconvenience,
    -DavidN
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. dgarciag

    dgarciag Registered
    PartnerNOC

    Joined:
    Feb 16, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    51
    I have just the opposite problem: while documentation now says its a space-separated list, for me only works a comma-separated list.

    I've tested it with versions 11.28.83 and 11.26

    EDITED:
    I was wrong, none of them work with cPanel 11.26. But after some trial and error, I've found it works using + as separator with both versions.
     
    #3 dgarciag, Mar 3, 2011
    Last edited: Mar 4, 2011
  4. cPanelDavidN

    cPanelDavidN Integration Developer

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    3
    Trophy Points:
    68
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi dgraciag,

    How are you making your request? Via the XML-API? are you using a browser and manually placing the url in the address bar, or are you using a script based client. Please provide reproduction steps, as I was able to perform the call as documented:


    Tested on 11.28.83-STABLE_51164

    Output from debug mode on XML-API PHP client class. NOTE the "pluses" you see in the URL arg-2 are encoded SPACES!
    Code:
    URL: https://10.1.1.1:2083/xml-api/cpanel
    DATA: cpanel_xmlapi_user=dave&cpanel_xmlapi_module=Mysql&cpanel_xmlapi_func=adduserdb&cpanel_xmlapi_apiversion=1&arg-0=clidbb&arg-1=uclidbb&arg-2=create+index+drop&api.version=1
    
    
    RESPONSE:
     <?xml version="1.0" ?>
    <cpanelresult><module>Mysql</module><func>adduserdb</func><type>event</type><source>internal</source><apiversion>1</apiversion><data><result></result></data>  <event>
        <result>1</result>
      </event>
    </cpanelresult>
    URL: https://10.1.4.102:2083/xml-api/cpanel
    DATA: cpanel_xmlapi_user=dave&cpanel_xmlapi_module=MysqlFE&cpanel_xmlapi_func=listdbs&cpanel_xmlapi_apiversion=2&api.version=1
    Authentication Header: Authorization: Basic ZGF2ZTpjcDE=
    
    
    RESPONSE:
     <?xml version="1.0" ?>
      <cpanelresult>
        <apiversion>2</apiversion>
        <data>
          <db>clidbb</db>
          <size>0</size>
          <sizemeg>0.00</sizemeg>
          <usercount>1</usercount>
          <userlist>
            <db>clidbb</db>
            <user>uclidbb</user>
          </userlist>
        </data>
        <event>
          <result>1</result>
        </event>
        <func>listdbs</func>
        <module>MysqlFE</module>
      </cpanelresult>
    
    Code:
    mysql -e 'select * from mysql.db where user = "uclidbb";'
    +-----------+--------+---------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+
    | Host      | Db     | User    | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Create_tmp_table_priv | Lock_tables_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Execute_priv |
    +-----------+--------+---------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+
    | localhost | clidbb | uclidbb | N           | N           | N           | N           | Y           | Y         | N          | N               | Y          | N          | N                     | N                | N                | N              | N                   | N                  | N            | 
    +-----------+--------+---------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+
    
    Regards,
    -DavidN
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. dgarciag

    dgarciag Registered
    PartnerNOC

    Joined:
    Feb 16, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    51
    I'm constructing the url myself and fetching it with CURL, using json calls in fast mode.
    You are right about url encoding, I wrongly assumed CURL do it for me.

    Anyway it's also working fine with '&arg-2=select,insert,drop'.

    Thanks for your time
     
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