Skip to content

Commit

Permalink
Refuse to delete an entire volume group
Browse files Browse the repository at this point in the history
LVM will happily delete the entire contents of a volume group if the
command line requests it, even if it is not empty.  There is typically
a prompt for this, but but Qubes OS disables it with --force.

To prevent accidentally wiping user's systems, check (with an assertion)
that the volume to be deleted is not a bare volume group.
  • Loading branch information
DemiMarie committed Oct 17, 2022
1 parent c177aac commit e14956a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions qubes/storage/lvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ def _get_lvm_cmdline(cmd):
if action == 'remove':
assert len(cmd) == 2, 'wrong number of arguments for remove'
assert not cmd[1].startswith('/'), 'absolute path to ‘remove’???'
assert '/' in cmd[1], 'refusing to delete entire volume group'
lvm_cmd = ['lvremove', '--force', '--', cmd[1]]
elif action == 'clone':
assert len(cmd) == 3, 'wrong number of arguments for clone'
Expand Down

0 comments on commit e14956a

Please sign in to comment.