dom0/core: verify VM name for not-allowed characters (#656)
This commit is contained in:
parent
4fcaf3e7b7
commit
85565af560
@ -324,6 +324,9 @@ class QubesVm(object):
|
|||||||
assert self.__qid < qubes_max_qid, "VM id out of bounds!"
|
assert self.__qid < qubes_max_qid, "VM id out of bounds!"
|
||||||
assert self.name is not None
|
assert self.name is not None
|
||||||
|
|
||||||
|
if not self.verify_name(self.name):
|
||||||
|
raise QubesException("Invalid characters in VM name")
|
||||||
|
|
||||||
if self.netvm is not None:
|
if self.netvm is not None:
|
||||||
self.netvm.connected_vms[self.qid] = self
|
self.netvm.connected_vms[self.qid] = self
|
||||||
|
|
||||||
@ -491,6 +494,9 @@ class QubesVm(object):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def verify_name(self, name):
|
||||||
|
return re.match(r"^[a-zA-Z0-9-]*$", name) is not None
|
||||||
|
|
||||||
def pre_rename(self, new_name):
|
def pre_rename(self, new_name):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -498,6 +504,9 @@ class QubesVm(object):
|
|||||||
if self.is_running():
|
if self.is_running():
|
||||||
raise QubesException("Cannot change name of running VM!")
|
raise QubesException("Cannot change name of running VM!")
|
||||||
|
|
||||||
|
if not self.verify_name(name):
|
||||||
|
raise QubesException("Invalid characters in VM name")
|
||||||
|
|
||||||
self.pre_rename(name)
|
self.pre_rename(name)
|
||||||
|
|
||||||
new_conf = "%s/%s.conf" % (self.dir_path, name)
|
new_conf = "%s/%s.conf" % (self.dir_path, name)
|
||||||
|
Loading…
Reference in New Issue
Block a user