[gnome-desktop] thumbnail: Throw a warning if thumbnailer leaves dangling files



commit 842b59aaabc41fa57ea494f10d976c108d36bfbd
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Aug 22 13:01:55 2017 +0200

    thumbnail: Throw a warning if thumbnailer leaves dangling files
    
    When running sandboxed, we could make use "--tmpfs /tmp" to make
    /tmp disappear along with the thumbnailer, but that would just paper
    over the fact that those same discarded temporary files would be left in
    /tmp (RAM if tmpfs) when not sandboxed.
    
    So warn about badly behaved thumbnailers.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785238

 libgnome-desktop/gnome-desktop-thumbnail-script.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/libgnome-desktop/gnome-desktop-thumbnail-script.c 
b/libgnome-desktop/gnome-desktop-thumbnail-script.c
index f9a0184..6002f23 100644
--- a/libgnome-desktop/gnome-desktop-thumbnail-script.c
+++ b/libgnome-desktop/gnome-desktop-thumbnail-script.c
@@ -45,6 +45,7 @@
 
 typedef struct {
   gboolean sandbox;
+  char *thumbnailer_name;
   GArray *fd_array;
   /* Input/output file paths outside the sandbox */
   char *infile;
@@ -556,6 +557,8 @@ expand_thumbnailing_cmd (const char  *cmd,
   if (!g_shell_parse_argv (cmd, NULL, &cmd_elems, error))
     return NULL;
 
+  script->thumbnailer_name = g_strdup (cmd_elems[0]);
+
   array = g_ptr_array_new_with_free_func (g_free);
 
 #ifdef HAVE_BWRAP
@@ -647,6 +650,7 @@ script_exec_free (ScriptExec *exec)
   if (exec == NULL)
     return;
 
+  g_free (exec->thumbnailer_name);
   g_free (exec->infile);
   if (exec->infile_tmp)
     {
@@ -660,7 +664,11 @@ script_exec_free (ScriptExec *exec)
     }
   if (exec->outdir)
     {
-      g_rmdir (exec->outdir);
+      if (g_rmdir (exec->outdir) < 0)
+        {
+          g_warning ("Could not remove %s, thumbnailer %s left files in directory",
+                     exec->outdir, exec->thumbnailer_name);
+        }
       g_free (exec->outdir);
     }
   g_free (exec->s_infile);


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