qvm-prefs: fix validation of 'timezone' property

This should be done in QubesVm class (property setter). But since we're
going to rewrite both qvm-prefs and QubesVm, settle on smaller change
for now.

QubesOS/qubes-issues#1184
This commit is contained in:
Marek Marczykowski-Górecki 2015-10-05 05:56:16 +02:00
parent d2617917be
commit 28cc933c4c
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -473,9 +473,12 @@ def set_timezone(vms, vm, args):
print >> sys.stderr, "Missing value ('localtime' or timeoffset in seconds)!"
return False
if not args[0].isdigit() and args[0].lower() == 'localtime':
print >> sys.stderr, "Invalid timezone value!"
return False
try:
int(args[0])
except ValueError:
if args[0].lower() != 'localtime':
print >> sys.stderr, "Invalid timezone value!"
return False
vm.timezone = args[0]
return True