[gnome-autoar/wip/oholy/extractor-readonly-folders: 2/3] extractor: Fix extraction of readonly folders




commit ae1ca4229f9f74dc9e085dca0ba232bce1645504
Author: Ondrej Holy <oholy redhat com>
Date:   Wed Mar 24 17:23:48 2021 +0100

    extractor: Fix extraction of readonly folders
    
    If archive contains read-only folders, the extraction of their children
    fails with the "Permissions denied" error. This is because the folder
    permissions are restored immediately before writing their children.
    Let's do not restore unix mode before writing the children to fix
    this issue.
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-autoar/-/issues/10

 gnome-autoar/autoar-extractor.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gnome-autoar/autoar-extractor.c b/gnome-autoar/autoar-extractor.c
index fd2dfd5..eb707fe 100644
--- a/gnome-autoar/autoar-extractor.c
+++ b/gnome-autoar/autoar-extractor.c
@@ -1204,8 +1204,12 @@ autoar_extractor_do_write_entry (AutoarExtractor      *self,
         }
 
         fileandinfo.file = g_object_ref (dest);
-        fileandinfo.info = g_object_ref (info);
+        fileandinfo.info = g_file_info_dup (info);
         g_array_append_val (self->extracted_dir_list, fileandinfo);
+
+        /* Unset folder permissions for now to be sure it is writable. */
+        g_file_info_set_attribute (info, G_FILE_ATTRIBUTE_UNIX_MODE,
+                                   G_FILE_ATTRIBUTE_TYPE_INVALID, NULL);
       }
       break;
     case AE_IFLNK:


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