소스 검색

Require typing name of VM to remove

It is too easy to accidentally delete the wrong VM if you use lots
of short-term (but longer than disposable) VMs and have built
muscle memory of just clicking "Ok" in the deletion confirmation box.

This patch requires you to type the full name of the VM, inspired by
repo deletion confirmation on GitHub.
Jean-Philippe Ouellet 7 년 전
부모
커밋
86d5825464
1개의 변경된 파일15개의 추가작업 그리고 5개의 파일을 삭제
  1. 15 5
      qubesmanager/main.py

+ 15 - 5
qubesmanager/main.py

@@ -1011,15 +1011,25 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
 
                 return
 
-        reply = QMessageBox.question(
+        (requested_name, ok) = QInputDialog.getText(
             None, "VM Removal Confirmation",
             "Are you sure you want to remove the VM <b>'{0}'</b>?<br>"
-            "<small>All data on this VM's private storage will be lost!</small>"
-            .format(vm.name),
-            QMessageBox.Yes | QMessageBox.Cancel)
+            "All data on this VM's private storage will be lost!<br><br>"
+            "Type the name of the VM (<b>{1}</b>) below to confirm:"
+            .format(vm.name, vm.name))
 
-        if reply == QMessageBox.Yes:
+        if not ok:
+            # user clicked cancel
+            return
 
+        elif requested_name != vm.name:
+            # name did not match
+            QMessageBox.warning(None, "VM removal confirmation failed",
+                "Entered name did not match! Not removing {0}.".format(vm.name))
+            return
+
+        else:
+            # remove the VM
             thread_monitor = ThreadMonitor()
             thread = threading.Thread(target=self.do_remove_vm,
                                       args=(vm, thread_monitor))