我对 Python 很陌生,但需要在插件服务中修补这个故障/漏洞。
我的代码如下所示:
#!/usr/bin/env python
import subprocess
import sys
import os
import yaml
from xml.dom import minidom
sys.path.append('/scripts')
import createvhosts
doc = minidom.parse(sys.stdin)
param0taglist = doc.getElementsByTagName('param0')
param1taglist = doc.getElementsByTagName('param1')
param0 = param0taglist[0].childNodes[0].toxml()
param1 = param1taglist[0].childNodes[0].toxml()
domain = param0 + '.' + param1
usertaglist = doc.getElementsByTagName('USER')
user = usertaglist[0].childNodes[0].toxml()
f = open('/var/cpanel/userdata/' + user + '/main')
ydata = yaml.load(f)
f.close()
sublist = ydata['sub_domains']
addondict = ydata['addon_domains']
parkedlist = ydata['parked_domains']
mainlist = ydata['main_domain']
serverip = createvhosts.getmainip()
if len(sublist) != 0:
slcont = 0
while slcont < len(sublist):
domain = sublist[slcont]
docroot, yip, alias = createvhosts.getvars(sublist[slcont])
if yip == serverip:
createvhosts.writeconfshared(user, domain, docroot, yip, alias)
else:
createvhosts.writeconfded(user, domain, docroot, yip, alias)
slcont = slcont + 1
proc = subprocess.Popen("/etc/init.d/nginx restart > /dev/null 2>&1", shell=True)
问题是当您在 CPanel 中添加带有 * 的子域时,它会使服务器崩溃,因为显然 nginx 似乎不允许并接受它。我需要帮助做的是弄清楚如何替换/阻止 * 所以它不会进入。
类似的东西有用Param0.find( "*" ) !=-1
吗?