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

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