[gnome-disk-utility/kailueke/no-wipe-after-auth-dismissed] restore: do not wipe disk after error if it's a dismissed auth error




commit 96ce80f6ed81bd8184fccde83a1372e699343155
Author: Kai Lüke <kailueke riseup net>
Date:   Thu Apr 29 23:50:04 2021 +0200

    restore: do not wipe disk after error if it's a dismissed auth error
    
    The wiping does not need privileges in contrast to opening the disk for
    arbitrary operations. That means that the wiping that was done on error
    was succeeding even though the user canceled the polkit auth process.
    This is confusing and may lead to the user thinking that they could
    accidentially wipe anything because it happens after canceling the auth
    process - but it is also good to not wipe if the user changes the mind
    after confirming the first dialog and it's nice to give a second chance
    when the auth dialog comes.
    Detect the dismissed auth error to distinguish it from other errors
    happening during the operation and only wipe the disk after those
    errors were encountered but not for the dismissed auth error coming
    from canceling the polkit auth process.
    
    Originally reported in
    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=987671

 src/disks/gdurestorediskimagedialog.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/disks/gdurestorediskimagedialog.c b/src/disks/gdurestorediskimagedialog.c
index 1110bc5c..2f0e044a 100644
--- a/src/disks/gdurestorediskimagedialog.c
+++ b/src/disks/gdurestorediskimagedialog.c
@@ -844,6 +844,13 @@ copy_thread_func (gpointer user_data)
 
   if (error != NULL)
     {
+      gboolean wipe_after_error = TRUE;
+
+      if (error->domain == UDISKS_ERROR && error->code == UDISKS_ERROR_NOT_AUTHORIZED_DISMISSED)
+        {
+          wipe_after_error = FALSE;
+        }
+
       /* show error in GUI */
       if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED))
         {
@@ -853,7 +860,7 @@ copy_thread_func (gpointer user_data)
       g_clear_error (&error);
 
       /* Wipe the device */
-      if (!udisks_block_call_format_sync (data->block,
+      if (wipe_after_error && !udisks_block_call_format_sync (data->block,
                                           "empty",
                                           g_variant_new ("a{sv}", NULL), /* options */
                                           NULL, /* cancellable */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]