summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2017-08-22 01:00:15 +0200
committerBastien Nocera <hadess@hadess.net>2017-08-22 13:09:22 +0200
commit6013e767636f0447cf60ef595aae6c84ae3d5b76 (patch)
tree3c2f73f1f3d1f5018014f29798068115e3ad3734
parent25fff6aa4a645d41aad1f6a69fc3058258192a8f (diff)
downloadgnome-desktop-6013e767636f0447cf60ef595aae6c84ae3d5b76.tar.gz
thumbnailer: Fix left-over files in /tmp
The fd that bwrap copies from the --file argument needs to be cleaned up as well, otherwise the temporary file as well as the directory containing it will be left on disk. https://bugzilla.gnome.org/show_bug.cgi?id=786584
-rw-r--r--libgnome-desktop/gnome-desktop-thumbnail-script.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libgnome-desktop/gnome-desktop-thumbnail-script.c b/libgnome-desktop/gnome-desktop-thumbnail-script.c
index c319d0e9..f9a0184d 100644
--- a/libgnome-desktop/gnome-desktop-thumbnail-script.c
+++ b/libgnome-desktop/gnome-desktop-thumbnail-script.c
@@ -48,6 +48,7 @@ typedef struct {
GArray *fd_array;
/* Input/output file paths outside the sandbox */
char *infile;
+ char *infile_tmp; /* the host version of /tmp/gnome-desktop-file-to-thumbnail.* */
char *outfile;
char *outdir; /* outdir is outfile's parent dir, if it needs to be deleted */
/* I/O file paths inside the sandbox */
@@ -647,6 +648,11 @@ script_exec_free (ScriptExec *exec)
return;
g_free (exec->infile);
+ if (exec->infile_tmp)
+ {
+ g_unlink (exec->infile_tmp);
+ g_free (exec->infile_tmp);
+ }
if (exec->outfile)
{
g_unlink (exec->outfile);
@@ -703,6 +709,7 @@ script_exec_new (const char *uri,
{
char *tmpl;
g_autofree char *ext = NULL;
+ g_autofree char *infile = NULL;
exec->fd_array = g_array_new (FALSE, TRUE, sizeof (int));
g_array_set_clear_func (exec->fd_array, clear_fd);
@@ -716,10 +723,12 @@ script_exec_new (const char *uri,
goto bail;
}
exec->outfile = g_build_filename (exec->outdir, "gnome-desktop-thumbnailer.png", NULL);
-
ext = get_extension (exec->infile);
- exec->s_infile = g_strdup_printf ("/tmp/gnome-desktop-file-to-thumbnail.%s", ext);
- exec->s_outfile = g_strdup ("/tmp/gnome-desktop-thumbnailer.png");
+ infile = g_strdup_printf ("gnome-desktop-file-to-thumbnail.%s", ext);
+ exec->infile_tmp = g_build_filename (exec->outdir, infile, NULL);
+
+ exec->s_infile = g_build_filename ("/tmp/", infile, NULL);
+ exec->s_outfile = g_build_filename ("/tmp/", "gnome-desktop-thumbnailer.png", NULL);
}
else
#endif