From 8dda7cf884f7a3fa2a7cc39ab8fa6351806b9c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 21 Jan 2014 00:41:01 +0100 Subject: [PATCH] core: improve VM name validation Do not allow 'special' names. --- core-modules/000QubesVm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core-modules/000QubesVm.py b/core-modules/000QubesVm.py index 323ca6ec..18789a87 100644 --- a/core-modules/000QubesVm.py +++ b/core-modules/000QubesVm.py @@ -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):