storage/lvm: fix listing volume revisions when VM name include volume name

some-vm-root is a valid VM name, and in that case it's volume can be
named some-vm-root-private. Do not let it confuse revision listing,
check for unexpected '-' in volume revision number.

The proper solution would be to use different separator, that is not
allowed in VM names. But that would require migration code that is
undesired in the middle of stable release life cycle.

Fixes QubesOS/qubes-issues#4680
This commit is contained in:
Marek Marczykowski-Górecki 2019-01-05 05:27:32 +01:00
parent dbd85c75e2
commit 4e5a14774a
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -327,6 +327,9 @@ class ThinVolume(qubes.storage.Volume):
if not revision_vid.endswith('-back'):
continue
revision_vid = revision_vid[len(name_prefix):]
if revision_vid.count('-') > 1:
# VM+volume name is a prefix of another VM, see #4680
continue
# get revision without suffix
seconds = int(revision_vid.split('-')[0])
iso_date = qubes.storage.isodate(seconds).split('.', 1)[0]