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

nathan.l

Registered
Nov 27, 2019
3
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

Forums Analyst II
Staff member
Nov 14, 2017
8,421
690
263
Houston
cPanel Access Level
DataCenter Provider
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

Forums Analyst II
Staff member
Nov 14, 2017
8,421
690
263
Houston
cPanel Access Level
DataCenter Provider
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.