Blame SOURCES/0254-daemon-send-base-names-from-abrt-server-to-abrtd.patch

a60cd7
From 4bba01e5bc60b4827a007f7d401b1e34f0944b70 Mon Sep 17 00:00:00 2001
a60cd7
From: Jakub Filak <jfilak@redhat.com>
a60cd7
Date: Fri, 26 Aug 2016 12:22:24 +0200
a60cd7
Subject: [PATCH] daemon: send  base names from abrt-server to abrtd
a60cd7
a60cd7
The /creation_notification method accepts arbitrary file system path and
a60cd7
it might cause abrtd some troubles if the path is not in canonical form.
a60cd7
a60cd7
ABRT enforces the notified paths to be directories in /var/spool/abrt
a60cd7
but ignores number of slash occurrences as it is not security relevant.
a60cd7
a60cd7
Switching to base names will assure that the problems associated with file
a60cd7
system path forms will be gone and no new problems will be introduced.
a60cd7
a60cd7
The other option is to use realpath() but this function resolves
a60cd7
symbolic links and if /var/spool is a symbolic link, we will be in
a60cd7
trouble.
a60cd7
a60cd7
Related: rhbz#1132459
a60cd7
a60cd7
Signed-off-by: Jakub Filak <jfilak@redhat.com>
a60cd7
---
a60cd7
 src/daemon/abrt-server.c | 2 +-
a60cd7
 src/daemon/abrtd.c       | 6 +++---
a60cd7
 2 files changed, 4 insertions(+), 4 deletions(-)
a60cd7
a60cd7
diff --git a/src/daemon/abrt-server.c b/src/daemon/abrt-server.c
a60cd7
index 9a1361b..76186db 100644
a60cd7
--- a/src/daemon/abrt-server.c
a60cd7
+++ b/src/daemon/abrt-server.c
a60cd7
@@ -273,7 +273,7 @@ static int run_post_create(const char *dirname)
a60cd7
     log_debug("Creating glib main loop");
a60cd7
     struct waiting_context context = {0};
a60cd7
     context.main_loop = g_main_loop_new(NULL, FALSE);
a60cd7
-    context.dirname = dirname;
a60cd7
+    context.dirname = strrchr(dirname, '/') + 1;
a60cd7
 
a60cd7
     log_debug("Setting up a signal handler");
a60cd7
     /* Set up signal pipe */
a60cd7
diff --git a/src/daemon/abrtd.c b/src/daemon/abrtd.c
a60cd7
index ff0565c..fc4f01e 100644
a60cd7
--- a/src/daemon/abrtd.c
a60cd7
+++ b/src/daemon/abrtd.c
a60cd7
@@ -174,16 +174,15 @@ static void queue_post_craete_process(struct abrt_server_proc *proc)
a60cd7
            && worst_dir)
a60cd7
     {
a60cd7
         const char *kind = "old";
a60cd7
-        char *deleted = concat_path_file(g_settings_dump_location, worst_dir);
a60cd7
 
a60cd7
         GList *proc_of_deleted_item = NULL;
a60cd7
-        if (proc != NULL && strcmp(deleted, proc->dirname) == 0)
a60cd7
+        if (proc != NULL && strcmp(worst_dir, proc->dirname) == 0)
a60cd7
         {
a60cd7
             kind = "new";
a60cd7
             stop_abrt_server(proc);
a60cd7
             proc = NULL;
a60cd7
         }
a60cd7
-        else if ((proc_of_deleted_item = g_list_find_custom(s_dir_queue, deleted, (GCompareFunc)abrt_server_compare_dirname)))
a60cd7
+        else if ((proc_of_deleted_item = g_list_find_custom(s_dir_queue, worst_dir, (GCompareFunc)abrt_server_compare_dirname)))
a60cd7
         {
a60cd7
             kind = "unprocessed";
a60cd7
             struct abrt_server_proc *removed_proc = (struct abrt_server_proc *)proc_of_deleted_item->data;
a60cd7
@@ -195,6 +194,7 @@ static void queue_post_craete_process(struct abrt_server_proc *proc)
a60cd7
                 g_settings_dump_location, g_settings_nMaxCrashReportsSize,
a60cd7
                 kind, worst_dir);
a60cd7
 
a60cd7
+        char *deleted = concat_path_file(g_settings_dump_location, worst_dir);
a60cd7
         free(worst_dir);
a60cd7
         worst_dir = NULL;
a60cd7
 
a60cd7
-- 
a60cd7
1.8.3.1
a60cd7