How to restrict user to add subdomain of the domain he doesn't own?



Posted on: 2021-01-25 08:32:58

1. Login into the server.

 

2. Go to your Vesta control panel bin directory.

# cd /usr/local/vesta/bin

 

3. Download the TLD list and save it in above location.

# wget https://raw.githubusercontent.com/gavingmiller/second-level-domains/master/SLDs.csv

 

4. Open the file using vi editor.

# vi v-add-web-domain

 

5. Add below code at the beginning of script after the variables.

KEEPPARTS=2;
TWOLEVELS=$( /bin/echo "${domain}" | /usr/bin/rev | /usr/bin/cut -d "." --output-delimiter="." -f 1-2 | /usr/bin/rev );
if  /bin/grep -P ",.${TWOLEVELS}" $BIN/SLDs.csv >/dev/null;  then
    KEEPPARTS=3;
fi
check_domain=$( /bin/echo "${domain}" | /usr/bin/rev | /usr/bin/cut -d "." -f "1-${KEEPPARTS}" | /usr/bin/rev );
check_exist=`grep "DOMAIN='$check_domain'" $VESTA/data/users/*/web.conf | grep -v "$user/web.conf"`
if [ -z $check_exist ]; then

 

6. End this if loop at the end of the script before exist.

 

7. To restrict same thing in mail and DNS add the same code in v-add-mail-domain and v-add-dns-domain respectively.


Web Hosting

VPS Hosting