Blame 0074-lib-allow-creating-root-owned-problem-directories-fr.patch

3a204fb
From 9669e34df23959fa18c2ce8920140e717440947f Mon Sep 17 00:00:00 2001
3a204fb
From: Jakub Filak <jfilak@redhat.com>
3a204fb
Date: Thu, 23 Apr 2015 16:33:00 +0200
3a204fb
Subject: [PATCH] lib: allow creating root owned problem directories from
3a204fb
 problem data
3a204fb
3a204fb
Without this patch libreport sets the owner of new problem directory
3a204fb
according to FILENAME_UID. This approach is not sufficient because ABRT
3a204fb
has introduced PrivateReports that should ensure that all problem
3a204fb
directories are owned by root. So ABRT needs a way to tell libreport to
3a204fb
create the new problem directory with uid=0.
3a204fb
3a204fb
Signed-off-by: Jakub Filak <jfilak@redhat.com>
3a204fb
---
3a204fb
 src/include/problem_data.h |  1 +
3a204fb
 src/lib/create_dump_dir.c  | 14 +++++++++++---
3a204fb
 2 files changed, 12 insertions(+), 3 deletions(-)
3a204fb
3a204fb
diff --git a/src/include/problem_data.h b/src/include/problem_data.h
3a204fb
index 9722562..5e271d3 100644
3a204fb
--- a/src/include/problem_data.h
3a204fb
+++ b/src/include/problem_data.h
3a204fb
@@ -140,6 +140,7 @@ problem_data_t *create_problem_data_for_reporting(const char *dump_dir_name);
3a204fb
   @param base_dir_name Location to store the problem data
3a204fb
 */
3a204fb
 struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name);
3a204fb
+struct dump_dir *create_dump_dir_from_problem_data_ext(problem_data_t *problem_data, const char *base_dir_name, uid_t uid);
3a204fb
 
3a204fb
 /**
3a204fb
   @brief Saves the problem data object in opened dump directory
3a204fb
diff --git a/src/lib/create_dump_dir.c b/src/lib/create_dump_dir.c
3a204fb
index d2cdd29..dec75fa 100644
3a204fb
--- a/src/lib/create_dump_dir.c
3a204fb
+++ b/src/lib/create_dump_dir.c
3a204fb
@@ -85,7 +85,8 @@ struct dump_dir *create_dump_dir(const char *base_dir_name, const char *type, ui
3a204fb
      * reporting from anaconda where we can't read /etc/{system,redhat}-release
3a204fb
      * and os_release is taken from anaconda
3a204fb
      */
3a204fb
-    dd_create_basic_files(dd, uid, NULL);
3a204fb
+    const uid_t crashed_uid = dd_exist(dd, FILENAME_UID) ? /*uid already saved*/-1 : uid;
3a204fb
+    dd_create_basic_files(dd, crashed_uid, NULL);
3a204fb
 
3a204fb
     problem_id[strlen(problem_id) - strlen(NEW_PD_SUFFIX)] = '\0';
3a204fb
     char* new_path = concat_path_file(base_dir_name, problem_id);
3a204fb
@@ -125,7 +126,7 @@ int save_problem_data_in_dump_dir(struct dump_dir *dd, problem_data_t *problem_d
3a204fb
     return 0;
3a204fb
 }
3a204fb
 
3a204fb
-struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name)
3a204fb
+struct dump_dir *create_dump_dir_from_problem_data_ext(problem_data_t *problem_data, const char *base_dir_name, uid_t uid)
3a204fb
 {
3a204fb
     INITIALIZE_LIBREPORT();
3a204fb
 
3a204fb
@@ -143,6 +144,13 @@ struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data,
3a204fb
         return NULL;
3a204fb
     }
3a204fb
 
3a204fb
+    return create_dump_dir(base_dir_name, type, uid, (save_data_call_back)save_problem_data_in_dump_dir, problem_data);
3a204fb
+}
3a204fb
+
3a204fb
+struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name)
3a204fb
+{
3a204fb
+    INITIALIZE_LIBREPORT();
3a204fb
+
3a204fb
     uid_t uid = (uid_t)-1L;
3a204fb
     char *uid_str = problem_data_get_content_or_NULL(problem_data, FILENAME_UID);
3a204fb
 
3a204fb
@@ -161,5 +169,5 @@ struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data,
3a204fb
         uid = (uid_t)val;
3a204fb
     }
3a204fb
 
3a204fb
-    return create_dump_dir(base_dir_name, type, uid, (save_data_call_back)save_problem_data_in_dump_dir, problem_data);
3a204fb
+    return create_dump_dir_from_problem_data_ext(problem_data, base_dir_name, uid);
3a204fb
 }
3a204fb
-- 
3a204fb
2.1.0
3a204fb