Skip to main content

Permission denied when creating database via publicapi

Comments

12 comments

  • cPanelMichael
    Hello @bimbo1989, Can you let us know the contents of your test script? Is this for a script you are running as a plugin within the cPanel or WHM interface, or are you running it via a standalone PHP script uploaded to your server? Thank you.
    0
  • cPanelMichael
    I could successfully create a database using the default user that our hosting provider (FastComet) gave us, but I need to use a dedicated user for this task. So we created a new user on our server, with appearently the same permissions, but we can't get it to work.

    Hello @bimbo1989, Could you provide some more background information on this issue? I'd like to reproduce it on a test environment but I need more information about what the overall goal or task you need to complete. Also, can you clarify what you mean by "dedicated user"? Thank you.
    0
  • bimbo1989
    Hello, the goal is to create a database everytime someone registers to my portal. With "dedicated user" I mean using credentials for this task only, without using the "root" user (in my case named "software").
    0
  • cPanelMichael
    With "dedicated user" I mean using credentials for this task only, without using the "root" user (in my case named "software").

    The authentication process accesses the server in order to run code as a specific cPanel or WHM user with a specific set of permissions. There's no support for authenticating as a non-root user that's not associated with an existing cPanel account.
    the goal is to create a database everytime someone registers to my portal.

    Do you have root access to this server, or just access to the cPanel account? If you have root access, you may want to consider setting up a hook that makes use of the Mysql::create_database UAPI function: Guide to Standardized Hooks - Developer Documentation - cPanel Documentation UAPI Functions - Mysql::create_database - Developer Documentation - cPanel Documentation Thank you.
    0
  • bimbo1989
    The authentication process accesses the server in order to run code as a specific cPanel or WHM user with a specific set of permissions. There's no support for authenticating as a non-root user that's not associated with an existing cPanel account.

    Ok, this closes this problem but opens another. If I use my root user, named "software", I can successfully create the database via the whm BUT... somehow, I don't know what I'm doing wrong, after I create the database I can't access the control panel anymore and I need to reset the password of the "software" user to be able to log in again in the control panel of the server. Am I missing something?
    0
  • cPanelMichael
    If I use my root user, named "software", I can successfully create the database via the whm BUT... somehow, I don't know what I'm doing wrong, after I create the database I can't access the control panel anymore and I need to reset the password of the "software" user to be able to log in again in the control panel of the server. Am I missing something?

    Hello, Generally, "root" is the only username that has full root access to the system. Is "software" a reseller user? What method are you using to create a database from Web Host Manager? Thank you.
    0
  • bimbo1989
    Hello, Generally, "root" is the only username that has full root access to the system. Is "software" a reseller user? What method are you using to create a database from Web Host Manager? Thank you.

    It probably is the name that FastComet (the reseller) gave to the our user on our server. I am using this WHM API cPanel API 2 Functions - MysqlFE::createdb - Developer Documentation - cPanel Documentation . The fact is that it WORKS and the database gets created successfully, but after the creation of the db I can't access to cpanel anymore and I need to reset the password of my user.
    0
  • cPanelMichael
    It probably is the name that FastComet (the reseller) gave to the our user on our server. I am using this WHM API
    0
  • bimbo1989
    No, I explained myself badly. At the moment of the execution of the script, I never logged on cpanel before (not on the PC i was using). I was executing the script in localhost, calling of course the live server URL. The database got created just fine, only lost my user credentials. I'll try and contact them for the logs.
    0
  • bimbo1989
    This is the relevant log we found [2018-05-05 12:59:24 +0200] info [whostmgrd] 149.13.148.129 - software_api "GET /json-api/cpanel?cpanel_jsonapi_module=MysqlFE&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_user=software_api&cpanel_jsonapi_func=createdb&db=software_prova HTTP/1.1" FAILED LOGIN whostmgrd: login attempt to whm by a non-reseller/root That is coherent with what you told me: "software_api" was a user created by ourselves, so it's not capable of creating databases. But a trouble remains: if I use cpanel_jsonapi_user=software that IS our main account, the database gets created but the password of the user gets somehow reset.
    0
  • cPanelMichael
    But a trouble remains: if I use cpanel_jsonapi_user=software that IS our main account, the database gets created but the password of the user gets somehow reset.

    Hello @bimbo1989, I've been unable to reproduce this issue on a test environment. Could you ask your provider to open a support ticket with the link in my signature so we can take a closer look at the affected system to see what's happening? Thank you.
    0

Please sign in to leave a comment.