SOLVED [CPANEL-29847] Pkgacct::Restore hook not working?

sparek-3

Well-Known Member
Aug 10, 2002
1,929
178
343
cPanel Access Level
Root Administrator
I can't seem to get the Pkgacct::Restore hook to execute anything. Is this hook working?

Adding a script to execute at post stage for this event:

/usr/local/cpanel/bin/manage_hooks add script /var/cpanel/hooks/monitor_restore.php --manual --category=Pkgacct --event=Restore --stage=post

The logs don't even indicate anything:

---debug_hooks---
msg: No hooks found for traversed context
context: PkgAcct::Restore
stage: post


Perhaps I'm doing something wrong. Or perhaps Pkgacct::Restore isn't actually being hooked?

I would expect the logs to at least say something. But No hooks found for traversed context would seem to indicate that either my add hook line is wrong or it's not picking up on any Pkgacct::Restore hooks

This is in cPanel 82.0.16
 

sparek-3

Well-Known Member
Aug 10, 2002
1,929
178
343
cPanel Access Level
Root Administrator
Yes.

Pkgacct:
Restore:
hook: /var/cpanel/hooks/monitor_restore.php
stage: post
escalateprivs: 0
id: fDarP6RT5mAeXQ8uN2AvEOQq
weight: 200
exectype: script
 

cPanelTJ

Product Owner
Staff member
Jan 29, 2019
34
10
83
Houston, TX
cPanel Access Level
Root Administrator
Twitter
Sparek,

After further testing, I do have some GOOD news. The Hook needs to be registered under PkgAcct::Restore, not Pkgacct::Restore.

See the below output from debug mode:

Code:
[2019-10-09 12:32:51 -0500] info [transfer_session] ---debug_hooks---
[2019-10-09 12:32:51 -0500] info [transfer_session]             msg: Beginning execution of script hook.
[2019-10-09 12:32:51 -0500] info [transfer_session]         context: PkgAcct::Restore
[2019-10-09 12:32:51 -0500] info [transfer_session]           stage: post
[2019-10-09 12:32:51 -0500] info [transfer_session]          result: 0
[2019-10-09 12:32:51 -0500] info [transfer_session]           point: main
[2019-10-09 12:32:51 -0500] info [transfer_session]              id: c6866781-a409-48ea-8106-50393bd5fbeb
[2019-10-09 12:32:51 -0500] info [transfer_session]            hook: /usr/local/cpanel/3rdparty/bin/PkgacctRestoreTest.php
[2019-10-09 12:32:51 -0500] info [transfer_session]   escalateprivs: 0
[2019-10-09 12:32:51 -0500] info [transfer_session]          weight: 200
We've also filed an internal case to provide proper validation for hookable events when registering action code.
 

sparek-3

Well-Known Member
Aug 10, 2002
1,929
178
343
cPanel Access Level
Root Administrator
Indeed

/usr/local/cpanel/bin/manage_hooks add script /var/cpanel/hooks/monitor_restore.php --manual --category=PkgAcct --event=Restore --stage=post

does work. I'm not sure where I got Pkgacct from. Everything's pretty clear as day that this should be PkgAcct. Brain fart I guess.
 

cPanelLauren

Forums Analyst II
Staff member
Nov 14, 2017
8,040
652
263
Houston
cPanel Access Level
DataCenter Provider
Actually, @cPanelTJ and I were discussing it earlier and I think we both came to the conclusion that at the very least this should give you an error and it might be something contributing to frustrations using the hooks system. I am curious still if you had this added this way on any other servers previously (though it's sounding like you may not have)