syslint

Well-Known Member
Verifed Vendor
Oct 9, 2006
271
7
168
India
cPanel Access Level
Root Administrator
Twitter
Hi,

Two cpanel Api2 hooks are not working

1) Api2::Park::park => Not working
2) Api2::Park::unpark => Not working

How to generate this issue ?

1) Create a test hook script and add it as follows,
Code:
/usr/local/cpanel/bin/manage_hooks add script /path//parkdomain.pl --category=Cpanel --event=Api2::Park::park --escalateprivs=1 --stage=post --manual
2) Now enable the debug mode from whm ->tweak settings ,so that you can see the logs

3) Login to cpanel and try to add an Alias . You can see the hooks not executing or sending any data to the hook scripts STDIN


I am on cpanel 11.59.9999.78

IMP : Any one one use hooks for the above two functions there applications won't work. Please forward this request to the concerned developers
 

syslint

Well-Known Member
Verifed Vendor
Oct 9, 2006
271
7
168
India
cPanel Access Level
Root Administrator
Twitter
Result from command line which also not calling the hooks .
Code:
[[email protected] hooks]# cpapi2 --user=fun Park park domain=funx.com subdomain=x
---
cpanelresult:
  apiversion: 2
  data:
  -
  reason: The system successfully parked (aliased) the domain “funx.com” on top of the domain “”.
  result: 1
  event:
  result: 1
  func: park
  module: Park
  postevent:
  result: 1
  preevent:
  result: 1
[[email protected] hooks]#
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
Hello,

Now enable the debug mode from whm ->tweak settings ,so that you can see the logs
Please post the output from the following commands so we can determine if debug mode is properly enabled:

Code:
grep "debughooks" /var/cpanel/cpanel.config
cat /var/cpanel/debughooks
Result from command line which also not calling the hooks .
CPANEL-8197 is open to address an issue where the output from the cpapi2 Park::park function is missing values. There's currently no specific time frame available on the publication of a resolution, however you should be able to utilize the "topdomain" parameter documented at cPanel API 2 Functions - Park::park as a temporary workaround. I'll update this thread once the resolution is published.

Thank you.
 

syslint

Well-Known Member
Verifed Vendor
Oct 9, 2006
271
7
168
India
cPanel Access Level
Root Administrator
Twitter
It is a bug. There is nothing in cpanel logs. As I said Park::park doesn't respond to api requests.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
It is a bug. There is nothing in cpanel logs. As I said Park::park doesn't respond to api requests.
I've been unable to reproduce this issue on a test system running cPanel 11.59.9999.89 (you mentioned using 11.59). Could you review the steps I've taken and let us know how this differs from the method you are using to reproduce the issue?

Code:
# touch /root/cptest123
# chmod 0755 /root/cptest123
# vi /root/cptest123
# cat /root/cptest123
   #!/bin/bash
   touch /root/123456
# /usr/local/cpanel/bin/manage_hooks add script /root/cptest123 --category=Cpanel --event=Api2::Park::park --escalateprivs=1 --stage=post --manual
# cpapi2 --user=cptest01 Park park domain=cptest096.com subdomain=cptest096
This finishes successfully, and I've confirmed "/root/123456" exists:

Code:
# cpapi2 --user=cptest01 Park park domain=cptest096.com subdomain=cptest096
[2016-08-25 22:44:23 +0000] info [cpanel] ---debug_hooks---
[2016-08-25 22:44:23 +0000] info [cpanel]             msg: Beginning execution of script hook.
[2016-08-25 22:44:23 +0000] info [cpanel]         context: Cpanel::Api2::Park::park
[2016-08-25 22:44:23 +0000] info [cpanel]           stage: post
[2016-08-25 22:44:23 +0000] info [cpanel]           point: main
[2016-08-25 22:44:23 +0000] info [cpanel]              id: 5Pjrf7ulmKGSKMGWGID
[2016-08-25 22:44:23 +0000] info [cpanel]            hook: /root/cptest123
[2016-08-25 22:44:23 +0000] info [cpanel]   escalateprivs: 1
[2016-08-25 22:44:23 +0000] info [cpanel]          weight: 100
[2016-08-25 22:44:23 +0000] info [cpanel]            data: {"output":[{"result":1,"reason":"The system successfully parked (aliased) the domain “cptest096.com” on top of the domain “”."}],"args":{"subdomain":"cptest096","api.module":"Park","domain":"cptest096.com","api.version":"2","api.function":"park"},"user":"cptest01"}
[2016-08-25 22:44:23 +0000] info [cpanel] HOOK INFO: hook /root/cptest123 did not output any data
[2016-08-25 22:44:23 +0000] info [cpanel] ---debug_hooks---
[2016-08-25 22:44:23 +0000] info [cpanel]             msg: Finished execution of script hook.
[2016-08-25 22:44:23 +0000] info [cpanel]         context: Cpanel::Api2::Park::park
[2016-08-25 22:44:23 +0000] info [cpanel]           stage: post
[2016-08-25 22:44:23 +0000] info [cpanel]          result: 1
[2016-08-25 22:44:23 +0000] info [cpanel]           point: main
[2016-08-25 22:44:23 +0000] info [cpanel]              id: 5Pjrf7ulmKGSKMGWGID
[2016-08-25 22:44:23 +0000] info [cpanel]            hook: /root/cptest123
[2016-08-25 22:44:23 +0000] info [cpanel]   escalateprivs: 1
[2016-08-25 22:44:23 +0000] info [cpanel]          weight: 100
[2016-08-25 22:44:23 +0000] info [cpanel]            data: {"output":[{"result":1,"reason":"The system successfully parked (aliased) the domain “cptest096.com” on top of the domain “”."}],"args":{"subdomain":"cptest096","api.module":"Park","domain":"cptest096.com","api.version":"2","api.function":"park"},"user":"cptest01"}
---
cpanelresult:
  apiversion: 2
  data:
    -
      reason: The system successfully parked (aliased) the domain “cptest096.com” on top of the domain “”.
      result: 1
  event:
    result: 1
  func: park
  module: Park
  postevent:
    result: 1
  preevent:
    result: 1
I'm thinking it's possibly related to the custom script hook you are using. If it relies on output regarding the parent domain, then case CPANEL-8197 will address that issue.

Thank you.
 

syslint

Well-Known Member
Verifed Vendor
Oct 9, 2006
271
7
168
India
cPanel Access Level
Root Administrator
Twitter
Hello MIke,

This works from the command line now. But it is not working while adding the domain from cpanel.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
Hello,

I've confirmed the hook isn't checked when adding an alias via the cPanel UI and opened case CPANEL-8337 to address the issue. I'll update this thread with more information as it becomes available. In the meantime, the temporary workaround is to hook into the cPanel API 1 Park::park function.

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
Hello,

To update, the behavior reported in case CPANEL-8337 was determined to be by design. The recommended method for hooking into an action performed in the cPanel UI is to first determine which API version is used, and to then hook into that specific API function. For instance, parking a domain name in cPanel results in the following output to /usr/local/cpanel/logs/error_log when full debug mode is enabled under the "Development" tab in "WHM >> Tweak Settings":

Code:
[2016-08-30 21:46:02 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:02 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:02 +0000] info [cpanel]         context: Cpanel::Api1::Park::park

[2016-08-30 21:46:02 +0000] info [cpanel]           stage: pre

[2016-08-30 21:46:03 +0000] info [park] ---debug_hooks---

[2016-08-30 21:46:03 +0000] info [park]             msg: No hooks found for traversed context

[2016-08-30 21:46:03 +0000] info [park]         context: Whostmgr::Domain::park

[2016-08-30 21:46:03 +0000] info [park]           stage: pre

[2016-08-30 21:46:03 +0000] info [park] ---debug_hooks---

[2016-08-30 21:46:03 +0000] info [park]             msg: No hooks found for traversed context

[2016-08-30 21:46:03 +0000] info [park]         context: Whostmgr::Domain::park

[2016-08-30 21:46:03 +0000] info [park]           stage: post

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::Api1::Park::park

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: post

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::Api2::Locale::get_html_dir_attr

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: pre

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::Api2::Locale::get_html_dir_attr

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: post

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::Locale::get_attributes

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: pre

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::Locale::get_attributes

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: post

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::NVData::get

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: pre

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::NVData::get

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: post

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::Branding::get_available_applications

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: pre

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::Branding::get_available_applications

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: post

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::NVData::get

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: pre

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::NVData::get

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: post

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::Brand::read

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: pre

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::Brand::read

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: post

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::cPAddons::get_available_addons

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: pre

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::cPAddons::get_available_addons

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: post

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::Styles::current

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: pre

[2016-08-30 21:46:04 +0000] info [cpanel] ---debug_hooks---

[2016-08-30 21:46:04 +0000] info [cpanel]             msg: No hooks found for traversed context

[2016-08-30 21:46:04 +0000] info [cpanel]         context: Cpanel::UAPI::Styles::current

[2016-08-30 21:46:04 +0000] info [cpanel]           stage: post

[2016-08-30 21:46:06 +0000] info [uapi] ---debug_hooks---

[2016-08-30 21:46:06 +0000] info [uapi]             msg: No hooks found for traversed context

[2016-08-30 21:46:06 +0000] info [uapi]         context: Cpanel::UAPI::Notifications::get_notifications_count

[2016-08-30 21:46:06 +0000] info [uapi]           stage: pre

[2016-08-30 21:46:06 +0000] info [uapi] Quotas are not enabled

[2016-08-30 21:46:06 +0000] info [uapi] ---debug_hooks---

[2016-08-30 21:46:06 +0000] info [uapi]             msg: No hooks found for traversed context

[2016-08-30 21:46:06 +0000] info [uapi]         context: Cpanel::UAPI::Email::list_pops_with_disk

[2016-08-30 21:46:06 +0000] info [uapi]           stage: pre

[2016-08-30 21:46:06 +0000] info [uapi] ---debug_hooks---

[2016-08-30 21:46:06 +0000] info [uapi]             msg: No hooks found for traversed context

[2016-08-30 21:46:06 +0000] info [uapi]         context: Cpanel::UAPI::Email::list_pops_with_disk

[2016-08-30 21:46:06 +0000] info [uapi]           stage: post

[2016-08-30 21:46:06 +0000] info [uapi] ---debug_hooks---

[2016-08-30 21:46:06 +0000] info [uapi]             msg: No hooks found for traversed context

[2016-08-30 21:46:06 +0000] info [uapi]         context: Cpanel::UAPI::Notifications::get_notifications_count

[2016-08-30 21:46:06 +0000] info [uapi]           stage: post

Thus, based on this output, you would configure the hook for the Cpanel::Api1::Park::park event.

Let us know if you have any additional questions.

Thank you.