vm/qubesvm: revert backup_timestamp to '%s' format
Human readable format `str(datetime.datetime)` is a nightmare for Admin API level communication. Especially setting the property in a format that it was read was not supported, and handling such format in untrusted input handling code is a bad idea. Revert to a simple intiger format.
This commit is contained in:
parent
be7b278032
commit
85e80f2329
@ -819,7 +819,8 @@ class Backup(object):
|
||||
# Save date of last backup, only when backup succeeded
|
||||
for qid, vm_info in files_to_backup.items():
|
||||
if vm_info.vm:
|
||||
vm_info.vm.backup_timestamp = datetime.datetime.now()
|
||||
vm_info.vm.backup_timestamp = \
|
||||
int(datetime.datetime.now().strftime('%s'))
|
||||
|
||||
self.app.save()
|
||||
|
||||
|
@ -513,12 +513,12 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase):
|
||||
timestamp = datetime.datetime(2016, 1, 1, 12, 14, 2)
|
||||
timestamp_str = timestamp.strftime('%s')
|
||||
self.assertPropertyDefaultValue(vm, 'backup_timestamp', None)
|
||||
self.assertPropertyValue(vm, 'backup_timestamp', timestamp,
|
||||
timestamp, timestamp_str)
|
||||
self.assertPropertyValue(vm, 'backup_timestamp', int(timestamp_str),
|
||||
int(timestamp_str), timestamp_str)
|
||||
del vm.backup_timestamp
|
||||
self.assertPropertyDefaultValue(vm, 'backup_timestamp', None)
|
||||
self.assertPropertyValue(vm, 'backup_timestamp', timestamp_str,
|
||||
timestamp)
|
||||
int(timestamp_str))
|
||||
|
||||
def test_401_backup_timestamp_invalid(self):
|
||||
vm = self.get_vm()
|
||||
|
@ -476,13 +476,9 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
||||
type=bool, setter=qubes.property.bool,
|
||||
doc='If this domain is to be included in default backup.')
|
||||
|
||||
# format got changed from %s to str(datetime.datetime)
|
||||
backup_timestamp = qubes.property('backup_timestamp', default=None,
|
||||
setter=(lambda self, prop, value:
|
||||
value if isinstance(value, datetime.datetime) else
|
||||
datetime.datetime.fromtimestamp(int(value))),
|
||||
saver=(lambda self, prop, value: value.strftime('%s')),
|
||||
doc='FIXME')
|
||||
type=int,
|
||||
doc='Time of last backup of the qube, in seconds since unix epoch')
|
||||
|
||||
default_dispvm = qubes.VMProperty('default_dispvm',
|
||||
load_stage=4,
|
||||
|
Loading…
Reference in New Issue
Block a user