Prevent default domain deletion or change

minadreapta

New member
Joined
Sep 14, 2019
Messages
1
Hello,

we are migrating from cPanel and stumbled upon this "inconvenient": by default a user can delete or change his main/default domain name in DA Domain management
interface.
We are also using WHMCS and the main domains in whmcs should match the main domain in DA panel.

How can we achieve this, or is this achievable:
1. the users can't delete or change the main/defaul domain name, but the reseller or admin should be able to do this
and
2. where allowed by the hosting plan, the users should be able to add/delete/modify only additional domains (but not the main one).

I tried different settings in directadmin.conf for "users_can_add_remove_domains" parameter but none was what i wanted.


Thanks.
 
Stumbled across this today too.

This is a slightly old thread... but no replies... so I'm guessing this was never resolved?

There may be an option that disabled this. But trying to find the correct option to flag is really a tough exercise with DirectAdmin scattered documentation.
 
Correct me if I'm wrong here.


Only refers to changing the name of a domain name. It doesn't prevent deletion of the domain name.


Doesn't do anything specifically to prevent the deletion of JUST the "main" or "default" domain name. You can set it to block deletion of domain names, but then users can't delete any extra domain names they may have previously created.

Basically I'm looking for an option that forces a user to always have at least 1 domain name. IDEALLY, that 1 domain name would be the one that the reseller or admin assigned to them - end-users shouldn't be able to delete that domain name. This is because we (and I suspect most everyone else) ties hosting accounts to the domain name that the reseller or admin assigned to the account. If that domain name is allowed to be deleted without the intervention of the reseller or admin then this can throw the reseller or admin's billing system out of whack. Addon or extra domain names are of little consequence in terms of billing system recognition, so those can be added and deleted at will by the end-user. But when the admin or reseller assigned domain name is deleted without explicit intervention by the admin or reseller, then that can create a lot of havoc.

What good is a web hosting account with no domain names assigned to it?
 
For billing purposes use LOGIN instead of domain name. Users/resellers can't modify their logins.
 
We were able to sneak in the ability to not rename any domain for the upcoming 1.61.0 release:

Allows direcadmin.conf setting, or per-User user.conf override if needed.
GUI/package option probable to be included in the future.

However, your request for only blocking the removal of the default domain would need to be custom scripted.. and it's actually 2 steps, since Users can also change their default domain too.

So you'd want to create 2 custom hooks to check if it's the default domain and block:
Code:
/usr/local/directadmin/scripts/custom/domain_destroy_pre/default_domain.sh
/usr/local/directadmin/scripts/custom/domain_destroy_pre/default_domain.sh
/usr/local/directadmin/scripts/custom/public_html_link_set_pre/default_domain.sh

The domain_destroy_pre/default_domain.sh could be:
Code:
#!/bin/sh
if [ "$defaultdomain" = "yes" ]; then
    echo "Cannot delete the default domain";
    exit 1;
fi
exit 0;
and the public_html_link_set_pre/default_domain.sh would be:
Code:
#!/bin/sh
if [ "$main_domain" = "$domain" ]; then
    echo "Cannot change the default domain";
    exit 1;
fi
exit 0;
Chmod both new directories and scripts to 755 (700 would be enough) and that should do it.

But if you only want to block the rename of the default domain, then the new id=2775 guide won't cut it.
For blocking the rename only on the default domain, you'd create:
Code:
/usr/local/directadmin/scripts/custom/domain_change_pre/default_domain.sh
with the same code as public_html_link_set_pre/default_domain.sh, and of course change the word "delete" with "rename".

John
 
The

/usr/local/directadmin/scripts/custom/domain_destroy_pre/default_domain.sh

Looks like it would accomplish what I need and this will work just fine.

I suppose to stray this a bit off-topic, but to my point about documentation... is there a list of all of the /usr/local/directadmin/scripts/custom available hooks? And then what environment variables are passed to each hook would also be beneficial. Is that information any where in any central location?
 
The one issue with the code in - /usr/local/directadmin/scripts/custom/domain_destroy_pre/default_domain.sh -

Code:
#!/bin/sh
if [ "$defaultdomain" = "yes" ]; then
    echo "Cannot delete the default domain";
    exit 1;
fi
exit 0;

Is that it will create issue if the account (i.e - the username) is deleted by the admin or reseller (I presume). The domain won't get fully deleted with this code present.

My solution to this was to modify the code slightly:

Code:
#!/bin/sh

if [ -z "${creator}" ]
then
        if [ "$defaultdomain" = "yes" ]
        then
                echo "Cannot delete the default domain";
                exit 1;
        fi
        exit 0;
fi

It would seem tha the ${creator} environment variable is not present when the domain_destroy_pre hook is called from within a user's control panel. But it is present when deleted from the admin panel (or at least using the API). So you check for the existence of the ${creator} variable and if it's not found, then you check to make sure the domain name is not the default domain before exiting.
 
Back
Top