0
我對Python很新,但需要在插件服務中修補這個毛刺/漏洞。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
的工作?
請刪除額外的代碼,以便只保留最小的測試用例和問題。包含代碼以根據需要構建樣本(例如失敗)數據。 – 2012-09-18 20:53:29
print'Param0.replace('*','')'...它幾乎就像你沒有嘗試任何東西... –
我在想這可能是更理想的阻止變化? –