Skip to content

Commit

Permalink
Improve CDROM device validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Qubad786 committed May 13, 2024
1 parent c1ef176 commit 0c80379
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/middlewared/middlewared/plugins/vm/devices/cdrom.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def _validate(self, device, verrors, old=None, vm_instance=None, update=True):
path = device['attributes']['path']
if not os.path.exists(path):
verrors.add('attributes.path', f'Unable to locate CDROM device at {path!r}')
elif not path.startswith('/mnt/'):
verrors.add('attributes.path', f'Path {path!r} should be under `/mnt/` dir')
elif not os.path.isfile(path):
verrors.add('attributes.path', f'Path {path!r} is not a file')
elif not self.middleware.call_sync('vm.device.disk_uniqueness_integrity_check', device, vm_instance):
verrors.add(
'attributes.path',
Expand Down

0 comments on commit 0c80379

Please sign in to comment.