Merge remote-tracking branch 'qubesos/pr/72'

* qubesos/pr/72:
  Don't allow VM name ending in -dm
This commit is contained in:
Marek Marczykowski-Górecki 2016-11-25 03:01:15 +01:00
commit fe470dade9
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -312,7 +312,7 @@ class QubesVm(object):
if not self.verify_name(self.name): if not self.verify_name(self.name):
msg = ("'%s' is invalid VM name (invalid characters, over 31 chars long, " msg = ("'%s' is invalid VM name (invalid characters, over 31 chars long, "
"or one of 'none', 'true', 'false')") % self.name "ends with '-dm', or one of 'none', 'true', 'false')") % self.name
if 'xml_element' in kwargs: if 'xml_element' in kwargs:
print >>sys.stderr, "WARNING: %s" % msg print >>sys.stderr, "WARNING: %s" % msg
else: else:
@ -569,6 +569,9 @@ class QubesVm(object):
# avoid conflict when /var/lib/qubes/appvms is mounted on # avoid conflict when /var/lib/qubes/appvms is mounted on
# separate partition # separate partition
return False return False
if name.endswith('-dm'):
# avoid conflict with device model stubdomain names for HVMs
return False
return re.match(r"^[a-zA-Z][a-zA-Z0-9_.-]*$", name) is not None return re.match(r"^[a-zA-Z][a-zA-Z0-9_.-]*$", name) is not None
def pre_rename(self, new_name): def pre_rename(self, new_name):
@ -585,7 +588,7 @@ class QubesVm(object):
raise QubesException("Cannot change name of running VM!") raise QubesException("Cannot change name of running VM!")
if not self.verify_name(name): if not self.verify_name(name):
raise QubesException("Invalid characters in VM name") raise QubesException("Invalid VM name")
if self.installed_by_rpm: if self.installed_by_rpm:
raise QubesException("Cannot rename VM installed by RPM -- first clone VM and then use yum to remove package.") raise QubesException("Cannot rename VM installed by RPM -- first clone VM and then use yum to remove package.")