core: improve VM name validation
Do not allow 'special' names.
This commit is contained in:
parent
a4d1ede69b
commit
8dda7cf884
@ -225,7 +225,8 @@ class QubesVm(object):
|
||||
assert self.name is not None
|
||||
|
||||
if not self.verify_name(self.name):
|
||||
raise QubesException("Invalid characters in VM name")
|
||||
raise QubesException("Invalid VM name (invalid characters, "
|
||||
"or one of 'none', 'true', 'false')")
|
||||
|
||||
if self.netvm is not None:
|
||||
self.netvm.connected_vms[self.qid] = self
|
||||
@ -407,6 +408,8 @@ class QubesVm(object):
|
||||
return False
|
||||
|
||||
def verify_name(self, name):
|
||||
if not isinstance(self.__basic_parse_xml_attr(name), str):
|
||||
return False
|
||||
return re.match(r"^[a-zA-Z][a-zA-Z0-9_-]*$", name) is not None
|
||||
|
||||
def pre_rename(self, new_name):
|
||||
|
Loading…
Reference in New Issue
Block a user