Adding custom user config key for all users

sangeeths

Member
May 25, 2021
5
0
76
India
cPanel Access Level
Root Administrator
I'm working on a cPanel integration and we use custom config keys stored in /var/cpanel/users/<username> config files to toggle certain functionalities.

The way we currently do this when we want to add a new key, is to loop over every file in the /var/cpanel/users directory and modify them which seems a bit overkill, and quite possibly unsafe if there're large number of users. It's possible to add this parameter using the modify/create account hooks but I'd like this to happen as soon as our custom integration is installed or updated.

I was wondering if there's a common config file with keys that are inherited by every existing user, where we can add such custom flags. Or is looping and modifying individual user configs the only way to do this?

Would love any advise on this and what'd be the general recommendation.
 

sangeeths

Member
May 25, 2021
5
0
76
India
cPanel Access Level
Root Administrator
Hey there! Can you let me know what the keys provide access to? In general, we don't support adding custom code to the users file, but I'm not 100% certain I understand the situation.
Hey, sure. The key help us determine the custom sections we define in the UI config file to show using if condition and $CPDATA. This is one of the main use cases. Besides this, we also include UI JS/CSS to add extra functionality, like showing modals/popovers etc and we have customizations based on our hosting partner.

For example, a condition we use in the dynamicui file would look like:

JSON:
"group_customsetup": {
    "attrs": {
      "width": "48",
      "height": "48",
      "grouporder": "-1",
      "file": "group_customsetup",
      "description": "$LANG{'Setup'}",
      "groupdesc": "$LANG{'Setup'}",
      "group": "customsetup",
      "subtype": "img",
      "imgtype": "icon",
      "type": "image",
      "if": "$CPDATA{'custom_setup_shown'}"
    }
}
 

cPanelTJ

Product Owner
Staff member
Jan 29, 2019
89
43
93
Houston, TX
cPanel Access Level
Root Administrator
Twitter
@sangeeths ,

We are actually working on a feature right now that will allow you to do a lot of what you're wanting in a supported fashion. This will be available starting in version 98.

The concept of an "enhancement" will be created which can be assigned to an account. "Enhancements" will be registered and created through a plugin's install.json process, and then can be assigned to accounts in WHM Create Account, Modify Account, and through the WHM API (this data will be stored in the user file). cPanel's UAPI will have a function to check if the account has a specific enhancement assigned.

Here is the question I have for you: Do you want these "certain functionalities" managed by the server admin or by your integration?
 
Last edited:
  • Like
Reactions: sangeeths and cPRex

sangeeths

Member
May 25, 2021
5
0
76
India
cPanel Access Level
Root Administrator
@sangeeths ,

We are actually working on a feature right now that will allow you to do a lot of what you're wanting in a supported fashion. This will be available starting in version 98.

The concept of an "enhancement" will be created which can be assigned to an account. "Enhancements" will be registered and created through a plugin's install.json process, and then can be assigned to accounts in WHM Create Account, Modify Account, and through the WHM API (this data will be stored in the user file). cPanel's UAPI will have a function to check if the account has a specific enhancement assigned.

Here is the question I have for you: Do you want these "certain functionalities" managed by the server admin or by your integration?
Hey TJ,

That's awesome that you're considering to add such features.

The integration I work on applies to all cPanel user accounts—existing and new. The hosting provider basically installs our plugin and that's that. AFAIK, our plugin just affects cPanel, not WHM. Adding custom prefixed keys to user config files is done by us and not usually by server admins (unless something went wrong which is rare so far). We also have some remote functionality to modify just these keys if a user needs the UI to change or our integration totally disabled for some reason. We rely on the cPanel hooks to modify these custom keys as well at times.

We provide certain "modes" through our integration which results in certain custom UI groups to appear or be hidden. The "mode" information is what we persist in the user file. This also helps the scripts we inject into cPanel front-end determine the right course of action via UAPI queries.

To answer your question: it's definitely our integration that wants to manage these "enhancements", should we come to use them in the future.