core: reject VM names longer than 31 chars

This commit is contained in:
Marek Marczykowski-Górecki 2014-07-28 00:52:51 +02:00
parent 7a5fc1357b
commit 98540ac513

View File

@ -287,7 +287,8 @@ class QubesVm(object):
if not self.verify_name(self.name):
raise QubesException("Invalid VM name (invalid characters, "
"or one of 'none', 'true', 'false')")
"over 31 chars long, or one of 'none', "
"'true', 'false')")
if self.netvm is not None:
self.netvm.connected_vms[self.qid] = self
@ -492,6 +493,8 @@ class QubesVm(object):
def verify_name(self, name):
if not isinstance(self.__basic_parse_xml_attr(name), str):
return False
if len(name) > 31:
return False
return re.match(r"^[a-zA-Z][a-zA-Z0-9_-]*$", name) is not None
def pre_rename(self, new_name):