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

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