bug 9472: when get vnc port for a vm, check if the port is really used by this vm for security

status 9472: resolved fixed
This commit is contained in:
anthony 2011-04-15 12:42:32 -07:00
parent 7f473dad6f
commit 054f6b0199
1 changed files with 14 additions and 6 deletions

View File

@ -46,15 +46,23 @@ def getvncport(session, args):
domid = args['domID']
hvm = args['hvm']
if hvm == 'true':
path = "/local/domain/" + domid + "/console/vnc-port"
path1 = "/local/domain/" + domid + "/qemu-pid"
path2 = "/local/domain/" + domid + "/console/vnc-port"
else:
path = "/local/domain/" + domid + "/serial/0/vnc-port"
path1 = "/local/domain/" + domid + "/serial/0/vncterm-pid"
path2 = "/local/domain/" + domid + "/serial/0/vnc-port"
try:
cmd = ["xenstore-read", path]
txt = util.pread2(cmd)
cmd = ["xenstore-read", path1]
pid = util.pread2(cmd)
pid = pid.strip()
cmd = ["ps", pid]
util.pread2(cmd)
cmd = ["xenstore-read", path2]
vncport = util.pread2(cmd)
vncport = vncport.strip()
return vncport
except:
txt = ''
return txt
return ''
@echo
def getgateway(session, args):