SOLVED [CPANEL-30602][CPANEL-30605] Api2::AddonDomain::addaddondomain hook blocking but not displaying status message

nathan.l

Registered
Nov 27, 2019
4
0
1
Denver
cPanel Access Level
DataCenter Provider
I'm working on a hook for Api2::AddonDomain::addaddondomain to filter some domains while leaving their subdomains usable. I can block the event from happening so that it does not actually add the addon domain but cPanel is not displaying the status message to the enduser, instead it is reporting that the addon domain is adding successfully.

Here's my code:

Code:
#!/usr/bin/perl

package CheckDomain;

use strict;
use warnings;

use Cpanel::Logger;

use JSON;

my $logger = Cpanel::Logger->new();

my @blockedDomains = ( "example.com", "example.org" );
sub describe {
    my $hooks = [
        {
            'category' => 'Cpanel',
            'event'    => 'Api2::AddonDomain::addaddondomain',
            'stage'    => 'pre',
            'hook'     => 'CheckDomain::checkdomain',
            'exectype' => 'module',
            'blocking' => 1,
        }
    ];
    return $hooks;
}


sub checkdomain {
    my ( $context, @data ) = @_;
    my $newdomain = $data[0]{'args'}{'newdomain'};
    my $user = $data[0]{'user'};
    foreach my $domain (@blockedDomains) {
        if ($domain eq $newdomain) {
            my $message = "ERROR: Registering domain $domain is not allowed. Try a subdomain of $domain such as $user.$newdomain";
            my $status = 0;
            return $status, $message;
        }
    }
    return 1, "";
};

Is there an issue with what I'm doing, or is displaying this message to the user something that is not supported by cPanel? It is present in the logs.
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,300
363
Houston
Are any errors included in the output that is included in the cPanel error logs?

Does this get output anywhere?
Code:
            my $message = "ERROR: Registering domain $domain is not allowed. Try a subdomain of $domain such as $user.$newdomain";
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,300
363
Houston
Hi @nathan.l

Can you tell me which version of cPanel/WHM you're running? I asked one of our development teams to take a look at this and they believe there is an issue with the message that should pop up in the UI. They're looking at the code further right now and should be opening a case when the investigation is complete. I'll update more as to their findings and how to move forward as I get more information.


Thanks!
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,300
363
Houston
Actually, what you might find on the v84 server is that the function to block isn't working, this was a secondary issue that the developers found while looking into this today.

I just wanted to confirm whether or not you were in fact on v82.
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,300
363
Houston
Hi @nathan.l

I wanted to let you know that our developers opened two cases in respect to this.

CPANEL-30602 - cPanel standardized hooks fails to block/BAILOUT properly on 84+

CPANEL-30605 - cPanel standardized hooks block/BAILOUT message fail to reach API and UI events.

I'll update you again with the status of these as soon as there is anything further to report.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
14,385
2,253
363
cPanel Access Level
Root Administrator
I just checked on the cases now and I see that CPANEL-30602 is scheduled to be applied to version 86. CPANEL-30605 does not have any official updates as to when that will be fixed.

With all tiers of cPanel set to 84 right now, I would expect a Q1 2020 release of version 86.
 
  • Like
Reactions: cPanelLauren

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,300
363
Houston
Hello,

Both cases listed here have been marked as resolved in v86 - this can be referenced in our changelogs here: Change Logs - Change Logs - cPanel Documentation though CPANEL-30605 isn't listed there, it is marked as completed internally.