Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/sharedra.../account_...
File: cpanel.py
#!/opt/imh-python/bin/python3
[0] Fix | Delete
"""Account-review: Shows relevant information about cPanel users"""
[1] Fix | Delete
[2] Fix | Delete
[3] Fix | Delete
import sys
[4] Fix | Delete
import os
[5] Fix | Delete
import glob
[6] Fix | Delete
import platform
[7] Fix | Delete
from prettytable import PrettyTable
[8] Fix | Delete
import rads
[9] Fix | Delete
from cpapis import whmapi1
[10] Fix | Delete
from rads import color, UserData, CpuserError
[11] Fix | Delete
[12] Fix | Delete
STANDARD_NS = [
[13] Fix | Delete
'ns1.webhostinghub.com',
[14] Fix | Delete
'ns2.webhostinghub.com',
[15] Fix | Delete
'ns1.servconfig.com',
[16] Fix | Delete
'ns2.servconfig.com',
[17] Fix | Delete
'ns.inmotionhosting.com',
[18] Fix | Delete
'ns1.inmotionhosting.com', # there's a cname to ns
[19] Fix | Delete
'ns2.inmotionhosting.com',
[20] Fix | Delete
]
[21] Fix | Delete
[22] Fix | Delete
# IOError: file unreadable
[23] Fix | Delete
# ValueError: bad json
[24] Fix | Delete
# KeyError: expected key is missing from dict
[25] Fix | Delete
# AttributeError: tried to run .values(), etc on non-dict
[26] Fix | Delete
# TypeError: tried to iterate on a None
[27] Fix | Delete
BAD_YAML = (IOError, ValueError, KeyError, AttributeError, TypeError)
[28] Fix | Delete
BAD_API = (ValueError, KeyError, AttributeError, TypeError)
[29] Fix | Delete
[30] Fix | Delete
[31] Fix | Delete
def errprint(*errmsgs, **kwargs):
[32] Fix | Delete
"""deprecated, copied from rads.common"""
[33] Fix | Delete
errmsgs = [color.red(x) for x in errmsgs]
[34] Fix | Delete
try:
[35] Fix | Delete
fatal = kwargs.pop('fatal')
[36] Fix | Delete
except KeyError:
[37] Fix | Delete
fatal = False
[38] Fix | Delete
print(*errmsgs, file=sys.stderr, **kwargs)
[39] Fix | Delete
if fatal is True:
[40] Fix | Delete
sys.exit(1)
[41] Fix | Delete
elif fatal is False:
[42] Fix | Delete
return
[43] Fix | Delete
else:
[44] Fix | Delete
sys.exit(fatal)
[45] Fix | Delete
[46] Fix | Delete
[47] Fix | Delete
def conv_size(size):
[48] Fix | Delete
"""Convert size, in MB, to human GB/MB notation"""
[49] Fix | Delete
try:
[50] Fix | Delete
size_int = int(float(str(size).rstrip('M')))
[51] Fix | Delete
except ValueError:
[52] Fix | Delete
return size
[53] Fix | Delete
if size_int > 1024:
[54] Fix | Delete
return f'{size_int / 1024.0:.1f} GB'
[55] Fix | Delete
return f'{size_int} MB'
[56] Fix | Delete
[57] Fix | Delete
[58] Fix | Delete
def fake_header(table, header):
[59] Fix | Delete
"""Supplied a prettytable object, form a fake header"""
[60] Fix | Delete
width = len(str(table).splitlines()[0]) - 2
[61] Fix | Delete
print('+', '-' * width, '+', sep='')
[62] Fix | Delete
print(f'|{color.bold(header.center(width))}|')
[63] Fix | Delete
[64] Fix | Delete
[65] Fix | Delete
def get_users_from_args():
[66] Fix | Delete
"""Parse a list of users to display from CLI args or working dir"""
[67] Fix | Delete
argv = sys.argv[1:]
[68] Fix | Delete
restricted = rads.OUR_RESELLERS
[69] Fix | Delete
restricted.extend(rads.SYS_USERS)
[70] Fix | Delete
secure_user = rads.SECURE_USER
[71] Fix | Delete
if secure_user is not None:
[72] Fix | Delete
restricted.append(secure_user)
[73] Fix | Delete
if len(sys.argv) < 2:
[74] Fix | Delete
try:
[75] Fix | Delete
argv.append(os.getcwd().split('/')[2])
[76] Fix | Delete
except IndexError:
[77] Fix | Delete
pass
[78] Fix | Delete
good_users = []
[79] Fix | Delete
for user in argv:
[80] Fix | Delete
if not rads.is_cpuser(user):
[81] Fix | Delete
errprint(user, 'is not a valid cPanel user')
[82] Fix | Delete
elif user in restricted:
[83] Fix | Delete
errprint(user, 'is a restricted user')
[84] Fix | Delete
else:
[85] Fix | Delete
good_users.append(user)
[86] Fix | Delete
if len(good_users) == 0:
[87] Fix | Delete
errprint('no users to display', fatal=True)
[88] Fix | Delete
return good_users
[89] Fix | Delete
[90] Fix | Delete
[91] Fix | Delete
def check_modsec_custom(user):
[92] Fix | Delete
"""Check for Apache customizations"""
[93] Fix | Delete
if os.path.isfile('/etc/cpanel/ea4/is_ea4'):
[94] Fix | Delete
basepath = '/etc/apache2/conf.d/userdata/std/2*'
[95] Fix | Delete
else:
[96] Fix | Delete
basepath = '/usr/local/apache/conf/userdata/std/2'
[97] Fix | Delete
conf_paths = os.path.join(basepath, user, '*/modsec.conf')
[98] Fix | Delete
return len(glob.glob(conf_paths)) > 0
[99] Fix | Delete
[100] Fix | Delete
[101] Fix | Delete
def check_homedir(user):
[102] Fix | Delete
"""Check to see if user's homedir exists"""
[103] Fix | Delete
return os.path.isdir(os.path.expanduser("~%s" % user))
[104] Fix | Delete
[105] Fix | Delete
[106] Fix | Delete
def check_email_suspension(user):
[107] Fix | Delete
"""
[108] Fix | Delete
Checks /etc/outgoing_mail_suspended_users for passed user
[109] Fix | Delete
Returns True if found, otherwise returns False.
[110] Fix | Delete
"""
[111] Fix | Delete
[112] Fix | Delete
with open('/etc/outgoing_mail_suspended_users') as file:
[113] Fix | Delete
for lines in file:
[114] Fix | Delete
if user in lines:
[115] Fix | Delete
return True
[116] Fix | Delete
return False
[117] Fix | Delete
[118] Fix | Delete
[119] Fix | Delete
def count_databases(user):
[120] Fix | Delete
"""Get number of databases"""
[121] Fix | Delete
paths = []
[122] Fix | Delete
paths.append(os.path.join('/var/cpanel/datastore', user, 'mysql-db-count'))
[123] Fix | Delete
paths.append(
[124] Fix | Delete
os.path.join('/home', user, '.cpanel/datastore/mysql-db-count')
[125] Fix | Delete
)
[126] Fix | Delete
for path in paths:
[127] Fix | Delete
try:
[128] Fix | Delete
with open(path) as file:
[129] Fix | Delete
return file.read().strip()
[130] Fix | Delete
except OSError:
[131] Fix | Delete
continue
[132] Fix | Delete
return '0'
[133] Fix | Delete
[134] Fix | Delete
[135] Fix | Delete
def display_user(user, shared_ips):
[136] Fix | Delete
"""Display one user. Called per argument by main()"""
[137] Fix | Delete
# domin info / ssl and doc roots
[138] Fix | Delete
try:
[139] Fix | Delete
udata = UserData(user)
[140] Fix | Delete
except CpuserError as exc:
[141] Fix | Delete
errprint(exc)
[142] Fix | Delete
print(
[143] Fix | Delete
'See http://wiki.inmotionhosting.com/index.php?title=Account-review#Troubleshooting'
[144] Fix | Delete
)
[145] Fix | Delete
return
[146] Fix | Delete
# get SSL status of primary domain
[147] Fix | Delete
if udata.primary.has_ssl:
[148] Fix | Delete
ssl_text = 'Has SSL'
[149] Fix | Delete
else:
[150] Fix | Delete
ssl_text = 'No SSL'
[151] Fix | Delete
# account info from WHM
[152] Fix | Delete
try:
[153] Fix | Delete
acct_summ = whmapi1('accountsummary', {"user": user})['data']['acct'][0]
[154] Fix | Delete
except BAD_API:
[155] Fix | Delete
errprint('Error running "accountsummary" in WHM API')
[156] Fix | Delete
return
[157] Fix | Delete
# Create the headers
[158] Fix | Delete
usrtable = PrettyTable(['1', '2', '3'])
[159] Fix | Delete
usrtable.align['1'] = 'r'
[160] Fix | Delete
usrtable.align['2'] = 'l'
[161] Fix | Delete
usrtable.align['3'] = 'l'
[162] Fix | Delete
usrtable.header = False
[163] Fix | Delete
[164] Fix | Delete
# 'Created On' crow
[165] Fix | Delete
usrtable.add_row(['Created on', acct_summ['startdate'], ''])
[166] Fix | Delete
[167] Fix | Delete
# 'Owner' row
[168] Fix | Delete
if acct_summ['owner'] == user:
[169] Fix | Delete
owner_text = color.yellow('Self')
[170] Fix | Delete
elif acct_summ['owner'] == 'root':
[171] Fix | Delete
owner_text = color.red('Issue')
[172] Fix | Delete
else:
[173] Fix | Delete
owner_text = ''
[174] Fix | Delete
usrtable.add_row(['Owner', acct_summ['owner'], owner_text])
[175] Fix | Delete
[176] Fix | Delete
# 'Contact' row
[177] Fix | Delete
usrtable.add_row(['cPanel Contact', acct_summ['email'], ''])
[178] Fix | Delete
[179] Fix | Delete
# 'Account Size' row
[180] Fix | Delete
usrtable.add_row(['Account Size', conv_size(acct_summ['diskused']), ''])
[181] Fix | Delete
[182] Fix | Delete
# 'MySQL Databases' row
[183] Fix | Delete
usrtable.add_row(['MySQL Databases', count_databases(user), ''])
[184] Fix | Delete
[185] Fix | Delete
# 'IP' row
[186] Fix | Delete
if acct_summ['ip'] in shared_ips:
[187] Fix | Delete
ip_text = 'Shared'
[188] Fix | Delete
else:
[189] Fix | Delete
ip_text = color.red('Dedicated')
[190] Fix | Delete
usrtable.add_row(['IP', acct_summ['ip'], ip_text])
[191] Fix | Delete
[192] Fix | Delete
# 'SSL' rowdd
[193] Fix | Delete
usrtable.add_row(['SSL', ssl_text, ''])
[194] Fix | Delete
[195] Fix | Delete
# 'Docroot' row
[196] Fix | Delete
if udata.primary.docroot == os.path.join('/home', user, 'public_html'):
[197] Fix | Delete
docroot_text = 'Standard'
[198] Fix | Delete
else:
[199] Fix | Delete
docroot_text = color.red('Custom')
[200] Fix | Delete
usrtable.add_row(['Docroot', udata.primary.docroot, docroot_text])
[201] Fix | Delete
[202] Fix | Delete
# 'Modsec' row
[203] Fix | Delete
if check_modsec_custom(user):
[204] Fix | Delete
modsec_text = color.red('Modified')
[205] Fix | Delete
else:
[206] Fix | Delete
modsec_text = 'Enabled'
[207] Fix | Delete
usrtable.add_row(['Modsec', modsec_text, ''])
[208] Fix | Delete
[209] Fix | Delete
# 'Homedir' row
[210] Fix | Delete
if check_homedir(user):
[211] Fix | Delete
homedir_text = os.path.expanduser("~%s" % user)
[212] Fix | Delete
else:
[213] Fix | Delete
homedir_text = color.red('Missing')
[214] Fix | Delete
usrtable.add_row(['Homedir', homedir_text, ''])
[215] Fix | Delete
[216] Fix | Delete
# We print out our own fake header, not the one supplied by prettytable
[217] Fix | Delete
header = '{0.user} / {0.primary.domain} / {1[plan]}'.format(
[218] Fix | Delete
udata, acct_summ
[219] Fix | Delete
)
[220] Fix | Delete
fake_header(usrtable, header)
[221] Fix | Delete
print(usrtable)
[222] Fix | Delete
[223] Fix | Delete
# Suspension notice
[224] Fix | Delete
if acct_summ['suspended']:
[225] Fix | Delete
print(color.red('Suspended:'), acct_summ['suspendreason'].strip())
[226] Fix | Delete
else:
[227] Fix | Delete
print('Suspended: No')
[228] Fix | Delete
[229] Fix | Delete
# Check for outgoing email suspension
[230] Fix | Delete
if check_email_suspension(user):
[231] Fix | Delete
print(color.red('Outgoing Email Suspended: Yes'))
[232] Fix | Delete
else:
[233] Fix | Delete
print('Outgoing Email Suspended: No')
[234] Fix | Delete
[235] Fix | Delete
# Print Addon/Parked/Sub domains
[236] Fix | Delete
# This is all handled by the same table to align them all the same
[237] Fix | Delete
cols = [
[238] Fix | Delete
'labelcol',
[239] Fix | Delete
'domlabel',
[240] Fix | Delete
'dom',
[241] Fix | Delete
'rootlabel',
[242] Fix | Delete
'root',
[243] Fix | Delete
'ssllabel',
[244] Fix | Delete
'ssl',
[245] Fix | Delete
]
[246] Fix | Delete
dom_table = PrettyTable(cols)
[247] Fix | Delete
dom_table.border = False
[248] Fix | Delete
dom_table.header = False
[249] Fix | Delete
dom_table.align['labelcol'] = 'r'
[250] Fix | Delete
dom_table.align['dom'] = 'l'
[251] Fix | Delete
dom_table.align['root'] = 'l'
[252] Fix | Delete
table_labels = {'Addon': 'addons', 'Parked': 'parked', 'Sub': 'subs'}
[253] Fix | Delete
for label, lblkey in table_labels.items():
[254] Fix | Delete
if len(getattr(udata, lblkey)) == 0:
[255] Fix | Delete
continue
[256] Fix | Delete
# the fake "header" to display between each type of domain
[257] Fix | Delete
head_row = [
[258] Fix | Delete
color.bold(label),
[259] Fix | Delete
color.bold('Domains:'),
[260] Fix | Delete
'',
[261] Fix | Delete
'',
[262] Fix | Delete
'',
[263] Fix | Delete
'',
[264] Fix | Delete
'',
[265] Fix | Delete
]
[266] Fix | Delete
dom_table.add_row(['', '', '', '', '', '', ''])
[267] Fix | Delete
dom_table.add_row(head_row)
[268] Fix | Delete
[269] Fix | Delete
# iterate over each domain of this type
[270] Fix | Delete
for dom in getattr(udata, lblkey):
[271] Fix | Delete
if label == 'Parked':
[272] Fix | Delete
ssl_label = ''
[273] Fix | Delete
ssl_out = ''
[274] Fix | Delete
elif dom.has_ssl:
[275] Fix | Delete
ssl_label = color.magenta('Has SSL:')
[276] Fix | Delete
ssl_out = 'Yes'
[277] Fix | Delete
else:
[278] Fix | Delete
ssl_label = color.magenta('Has SSL:')
[279] Fix | Delete
ssl_out = 'No'
[280] Fix | Delete
row = [
[281] Fix | Delete
' ' * 4,
[282] Fix | Delete
color.magenta('Domain:'),
[283] Fix | Delete
dom.domain,
[284] Fix | Delete
color.magenta('Docroot:'),
[285] Fix | Delete
dom.docroot,
[286] Fix | Delete
ssl_label,
[287] Fix | Delete
ssl_out,
[288] Fix | Delete
]
[289] Fix | Delete
dom_table.add_row(row)
[290] Fix | Delete
print(dom_table)
[291] Fix | Delete
[292] Fix | Delete
# Reseller Info Table
[293] Fix | Delete
reseller = None
[294] Fix | Delete
try:
[295] Fix | Delete
reseller = user in whmapi1("listresellers")['data']['reseller']
[296] Fix | Delete
except Exception as e:
[297] Fix | Delete
errprint(f'Error obtaining reseller list from WHM API. {e}', fatal=True)
[298] Fix | Delete
if not reseller:
[299] Fix | Delete
return
[300] Fix | Delete
try:
[301] Fix | Delete
res_stats = whmapi1('resellerstats', {"user": user})['data']['reseller']
[302] Fix | Delete
except BAD_API:
[303] Fix | Delete
errprint('Error running "resellerstats" API function', fatal=True)
[304] Fix | Delete
res_table = PrettyTable(['1', '2', '3'])
[305] Fix | Delete
res_table.header = False
[306] Fix | Delete
res_table.align['1'] = 'r'
[307] Fix | Delete
res_table.align['2'] = 'l'
[308] Fix | Delete
res_table.align['3'] = 'l'
[309] Fix | Delete
res_table.add_row(['Child Count', len(res_stats['acct']), ''])
[310] Fix | Delete
if acct_summ['owner'] != user:
[311] Fix | Delete
try:
[312] Fix | Delete
diskused = float(acct_summ['diskused'][:-1])
[313] Fix | Delete
except ValueError:
[314] Fix | Delete
diskused = None
[315] Fix | Delete
used_raw = acct_summ['diskused']
[316] Fix | Delete
errprint(
[317] Fix | Delete
'Unexpected value for "diskused" in accountsummary for', user
[318] Fix | Delete
)
[319] Fix | Delete
errprint(rf"Expcted to match regex '^\d+M$' but got {used_raw}")
[320] Fix | Delete
if diskused is None:
[321] Fix | Delete
combined = 'error'
[322] Fix | Delete
else:
[323] Fix | Delete
combined = conv_size(res_stats['diskused'] + diskused)
[324] Fix | Delete
res_table.add_row(['Combined Size', combined, ''])
[325] Fix | Delete
else:
[326] Fix | Delete
res_table.add_row(
[327] Fix | Delete
['Combined Size', conv_size(res_stats['diskused']), '']
[328] Fix | Delete
)
[329] Fix | Delete
for index, (nsname, nstext) in enumerate(get_nameservers(user)):
[330] Fix | Delete
res_table.add_row([f'Nameserver {index + 1}', nsname, nstext])
[331] Fix | Delete
for index, (dip, diptext) in enumerate(get_ip_pool(user, shared_ips)):
[332] Fix | Delete
res_table.add_row([f'Pool IP {index + 1}', dip, diptext])
[333] Fix | Delete
print()
[334] Fix | Delete
fake_header(res_table, f'Reseller Stats for {user}')
[335] Fix | Delete
print(res_table)
[336] Fix | Delete
[337] Fix | Delete
# Child Accounts Table
[338] Fix | Delete
child_table = PrettyTable(
[339] Fix | Delete
['Child', 'Domain', 'Size', 'Suspended', 'Deleted']
[340] Fix | Delete
)
[341] Fix | Delete
child_table.align['Domain'] = 'l'
[342] Fix | Delete
child_table.align['Size'] = 'r'
[343] Fix | Delete
is_deleted = False
[344] Fix | Delete
for acct in res_stats['acct']:
[345] Fix | Delete
if acct['suspended']:
[346] Fix | Delete
susp_text = color.red('yes')
[347] Fix | Delete
else:
[348] Fix | Delete
if check_email_suspension(acct['user']):
[349] Fix | Delete
susp_text = color.red('Outbound Email')
[350] Fix | Delete
else:
[351] Fix | Delete
susp_text = 'no'
[352] Fix | Delete
if acct['deleted']:
[353] Fix | Delete
del_text = color.red('yes†')
[354] Fix | Delete
is_deleted = True
[355] Fix | Delete
else:
[356] Fix | Delete
del_text = 'no'
[357] Fix | Delete
if user == acct['user']:
[358] Fix | Delete
user_text = color.yellow(user)
[359] Fix | Delete
else:
[360] Fix | Delete
user_text = acct['user']
[361] Fix | Delete
child_table.add_row(
[362] Fix | Delete
[
[363] Fix | Delete
user_text,
[364] Fix | Delete
acct['domain'],
[365] Fix | Delete
conv_size(acct['diskused']),
[366] Fix | Delete
susp_text,
[367] Fix | Delete
del_text,
[368] Fix | Delete
]
[369] Fix | Delete
)
[370] Fix | Delete
print()
[371] Fix | Delete
fake_header(child_table, f'Child accounts of {user}')
[372] Fix | Delete
print(child_table)
[373] Fix | Delete
if is_deleted:
[374] Fix | Delete
print(
[375] Fix | Delete
color.red('†')
[376] Fix | Delete
+ "Deleted accounts cannot be recovered without a backup."
[377] Fix | Delete
)
[378] Fix | Delete
[379] Fix | Delete
[380] Fix | Delete
def get_ip_pool(user, shared_ips):
[381] Fix | Delete
"""Get IP pool for a reseller and status text for each"""
[382] Fix | Delete
dips_path = os.path.join('/var/cpanel/dips', user)
[383] Fix | Delete
try:
[384] Fix | Delete
with open(dips_path) as file:
[385] Fix | Delete
dips = file.read().split()
[386] Fix | Delete
except OSError:
[387] Fix | Delete
return []
[388] Fix | Delete
others = set()
[389] Fix | Delete
for reseller in os.listdir('/var/cpanel/dips'):
[390] Fix | Delete
if reseller == user:
[391] Fix | Delete
continue
[392] Fix | Delete
other_path = os.path.join('/var/cpanel/dips', reseller)
[393] Fix | Delete
try:
[394] Fix | Delete
with open(other_path) as file:
[395] Fix | Delete
others.update(file.read().split())
[396] Fix | Delete
except OSError:
[397] Fix | Delete
errprint('Could not read', other_path)
[398] Fix | Delete
res_main_path = os.path.join('/var/cpanel/mainips', user)
[399] Fix | Delete
try:
[400] Fix | Delete
with open(res_main_path) as file:
[401] Fix | Delete
res_main = file.read().split()
[402] Fix | Delete
except OSError:
[403] Fix | Delete
errprint('Could not read', res_main_path)
[404] Fix | Delete
res_main = []
[405] Fix | Delete
ip_pool = []
[406] Fix | Delete
for dip in dips:
[407] Fix | Delete
ip_msgs = []
[408] Fix | Delete
if dip in res_main:
[409] Fix | Delete
ip_msgs.append('Pool Main')
[410] Fix | Delete
if dip in others:
[411] Fix | Delete
ip_msgs.append(color.red('Reseller Conflict'))
[412] Fix | Delete
if dip in shared_ips:
[413] Fix | Delete
ip_msgs.append(color.red('Server Main'))
[414] Fix | Delete
ip_pool.append([dip, '\n'.join(ip_msgs)])
[415] Fix | Delete
return ip_pool
[416] Fix | Delete
[417] Fix | Delete
[418] Fix | Delete
def get_nameservers(user):
[419] Fix | Delete
"""Get nameservers for a reseller and status text for each"""
[420] Fix | Delete
try:
[421] Fix | Delete
with open('/var/cpanel/resellers-nameservers') as file:
[422] Fix | Delete
data = file.read().splitlines()
[423] Fix | Delete
except OSError:
[424] Fix | Delete
errprint('could not read /var/cpanel/resellers-nameservers')
[425] Fix | Delete
return []
[426] Fix | Delete
starter = f'{user}:'
[427] Fix | Delete
for line in data:
[428] Fix | Delete
if not line.startswith(starter):
[429] Fix | Delete
continue
[430] Fix | Delete
raw_nsnames = line[len(starter) :].strip().split(',')
[431] Fix | Delete
nsnames = []
[432] Fix | Delete
for nsname in raw_nsnames:
[433] Fix | Delete
nsname = nsname.strip()
[434] Fix | Delete
if len(nsname) > 0:
[435] Fix | Delete
nsnames.append(nsname)
[436] Fix | Delete
nsinfo = []
[437] Fix | Delete
for nsname in nsnames:
[438] Fix | Delete
nsinfo.append([nsname, ns_custom(nsname)])
[439] Fix | Delete
return nsinfo
[440] Fix | Delete
errprint('user missing from /var/cpanel/resellers-nameservers')
[441] Fix | Delete
return []
[442] Fix | Delete
[443] Fix | Delete
[444] Fix | Delete
def ns_custom(nsname):
[445] Fix | Delete
"""Try to determine if a nameserver is custom"""
[446] Fix | Delete
if nsname not in STANDARD_NS:
[447] Fix | Delete
return color.red('Custom')
[448] Fix | Delete
fqdn = platform.node()
[449] Fix | Delete
if len(fqdn.split('.')) != 3:
[450] Fix | Delete
return color.yellow('Custom? Server fqdn setup wrong')
[451] Fix | Delete
fqdn_split = fqdn.split('.')
[452] Fix | Delete
fqdn_split[0] = ''
[453] Fix | Delete
dom = '.'.join(fqdn_split)
[454] Fix | Delete
if nsname.endswith(dom):
[455] Fix | Delete
return 'Standard'
[456] Fix | Delete
return color.yellow('Server FQDN mismatch')
[457] Fix | Delete
[458] Fix | Delete
[459] Fix | Delete
def cpanel_display_user(users):
[460] Fix | Delete
"""Main loop - run display_user on each user"""
[461] Fix | Delete
with open('/var/cpanel/mainip') as handle:
[462] Fix | Delete
shared_ips = [handle.read().strip()]
[463] Fix | Delete
try:
[464] Fix | Delete
with open('/var/cpanel/mainips/root') as handle:
[465] Fix | Delete
shared_ips.extend(handle.read().split())
[466] Fix | Delete
except OSError:
[467] Fix | Delete
pass # this file may not exist; that is okay
[468] Fix | Delete
[469] Fix | Delete
for user in users:
[470] Fix | Delete
display_user(user, shared_ips)
[471] Fix | Delete
[472] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function