Results 1 to 5 of 5

Thread: WHM plugin: Save account custom parameters

  1. #1
    Member
    Join Date
    Jan 2004
    Posts
    36

    Default WHM plugin: Save account custom parameters

    Hello,

    In the plugin (whm/cpanel) that we are currently developping we need to save custom parameters related to some cPanel accounts.

    We want those informations to be backuped and transfered with the normal backup and transfer function of cPanel and we don't want that users can modify them. Thus we thought about using a file saved in this directory :

    Code:
    /var/cpanel/userdata/<username>/my_plugin.conf
    But it seems that this file is not transfered when the account is transfered on another server.

    Another idea was using the cpanel information file :

    Code:
    /var/cpanel/users/oneuser
    But we didn't find anything in the API showing the possibility to use custom configurations for cPanel accounts and we don't know if it's a good idea as this file is maybe overwrite (instead of modified) by some WHM/cPanel specific function.

    Another possibility was to save those informations in a file directly in the user account but with rights that prevent the user to modify it. But this possibility is not really valid in a unix point of view.

    Is there another place where we can save custom account parameters in a easy way ?

    Thanks for any tips.

    Cheers,
    Philippe

  2. #2
    Member This forum account has been confirmed by cPanel staff to represent a vendor. KostonConsulting's Avatar
    Join Date
    Jun 2010
    Location
    Austin, TX
    Posts
    148
    cPanel/WHM Access Level

    Root Administrator

    Default Re: WHM plugin: Save account custom parameters

    Only the users home directory is transferred with an account copy. Everything else is recreated through the Whostmgr::Accounts::Create and PkgAcct::Restore processes. As far as I understand it, /var/cpanel/users/$user will be re-created during a transfer so you won't be able to send it over.

    You could however use a custom hook for PkgAcct::Create and PkgAcct::Restore hooks to read your information from your custom config file, save it to the user's home directory (both in PkgAcct::Create (pre)) , and restore it to the proper location after the account is transferred (PkgAcct::Restore (pre or post)):

    Account Packaging, Backups, and Transfers Functions


    In order to modify the information via the XML/JSON API, you can make your own custom API2 function ( Writing cPanel Modules ) and call it via the XML/JSON API ( cPanel XML and JSON APIs ).
    Dave Koston
    Koston Consulting
    http://www.kostonconsulting.com

  3. #3
    Member
    Join Date
    Jan 2004
    Posts
    36

    Default Re: WHM plugin: Save account custom parameters

    Hi Dave,

    Thank you for your answer. I also came to the conclusion that this directory is created when copying a package.

    Using cpanel hooks may be a solution but not really KISS, which means more problems, bugs, and so on.

    A solution could be using the file

    Code:
    /var/cpanel/users/<username>
    As it is backuped, transfered when copying an account on another server and deleted when deleting an account. Although the file could be easily manipulated with PHP we don't think it's a good solution as it would be more secure to manipulate it through a cPanel API but this doesn't exist for custom parameters and maybe this file would be modified in the future by the cPanel guys.

    Another idea is using an encrypted file in the user home directory...

    Maybe cPanel guys could told us whether there is another solution than using the complexe manipulation you described or not ?

    Thanks in advance for any tips

    Philippe

  4. #4
    Member This forum account has been confirmed by cPanel staff to represent a vendor. KostonConsulting's Avatar
    Join Date
    Jun 2010
    Location
    Austin, TX
    Posts
    148
    cPanel/WHM Access Level

    Root Administrator

    Default Re: WHM plugin: Save account custom parameters

    Quote Originally Posted by tizoo View Post
    A solution could be using the file

    Code:
    /var/cpanel/users/<username>
    As it is backuped, transfered when copying an account on another server and deleted when deleting an account. Although the file could be easily manipulated with PHP we don't think it's a good solution as it would be more secure to manipulate it through a cPanel API but this doesn't exist for custom parameters and maybe this file would be modified in the future by the cPanel guys.
    If you're willing to write perl to accomplish this task, you can use the cPanel modules /usr/local/cpanel/Cpanel/Config/LoadCpUserFile.pm and /usr/local/cpanel/Cpanel/Config/SaveCpUserFile.pm to manipulate the user file within your custom API2 tag.

    You could also use the NVDATA part of the API to store and retrieve data in/from /home/$user/.cpanel/ and use whatever encryption methods you prefer.
    Dave Koston
    Koston Consulting
    http://www.kostonconsulting.com

  5. #5
    Member
    Join Date
    Jan 2004
    Posts
    36

    Default Re: WHM plugin: Save account custom parameters

    Hi Dave,

    Finally we decided to use a file owned by root in the home directory of the user, which was the simplest solution.

    Thanks for your differents suggestions.

    Cheers,
    Philippe

Similar Threads

  1. Replies: 24
    Last Post: 11-23-2010, 07:44 PM
  2. Edit Package should not edit accounts with custom parameters
    By JawadArshad in forum Feature Requests for cPanel & WHM
    Replies: 3
    Last Post: 12-28-2009, 09:51 AM
  3. WHM Plugin (Custom)
    By LifeSteala in forum cPanel Developers
    Replies: 1
    Last Post: 01-11-2009, 11:55 PM
  4. [Ask] Custom Plugin
    By finly in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 02-07-2008, 02:38 AM