Introduction
The universal password trap hook triggers each time a user's password changes. This hook triggers regardless of which method changed the password, and regardless of whether the account is a cPanel or WHM account.
Warning:
This hook method is deprecated. To convert function hooks to use the Standardized Hooks system, use the API::Module::function
Cpanel
event or the Passwd
event in your Hook Action Code.
Basic usage
To use the universal password trap hook, perform the following steps:
- Write a custom module that contains a
process()
subroutine.- The system runs this subroutine as the
root
user. - Your module can access, use, and store specific universal password trap module variables.
- To write your module in a language other than Perl, create a Perl wrapper script that calls and executes another script.
- The system runs this subroutine as the
- Store your custom module in the
/usr/local/cpanel/Cpanel/ChangePasswd/
directory.
The system attempts to run the process()
subroutine for each module file in the /usr/local/cpanel/Cpanel/ChangePasswd/
directory each time that a password changes.
Note:
If your script writes to a file, you must create that file before the script runs.
Module variables
Warning:
Only transmit or store these variables over an SSL/TLS-encrypted connection. Storage or transmission of password information in plain text is a huge security risk.
Your module can access the following variables:
Variable |
Type |
Description |
Possible values |
Example |
user |
string |
The account's username. |
A valid username. |
username |
newpass |
string |
The account's new password. |
A secure password. |
12345luggage |
message |
string |
A status message about the password change process. |
A valid string. |
The password changed successfully. |
rawout |
string |
Raw output from the password change process. |
A valid string. |
Changing system password for user username. |
service_ref |
string |
The cPanel product that changed the password. |
|
cPanel
|
applist |
array of hashes |
An array of hashes of the services that cPanel & WHM checks whenever a password changes. |
An array of hashes of service information.
Note:
If the user chose not to update their MySQL® password, the applist value will not list MySQL information.
|