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.

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:
    1
    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
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    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
     
  3. dgarciag

    dgarciag Registered
    PartnerNOC

    Joined:
    Feb 16, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    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
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    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
     
  5. dgarciag

    dgarciag Registered
    PartnerNOC

    Joined:
    Feb 16, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    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