You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

109 lines
4.0 KiB

From 41ec59db3e6e2f19adc128d8fbd4526976ee2ca2 Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Thu, 23 Apr 2015 16:33:00 +0200
Subject: [LIBREPORT PATCH] lib: allow creating root owned problem directories
from problem data
Without this patch libreport sets the owner of new problem directory
according to FILENAME_UID. This approach is not sufficient because ABRT
has introduced PrivateReports that should ensure that all problem
directories are owned by root. So ABRT needs a way to tell libreport to
create the new problem directory with uid=0.
Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
src/include/problem_data.h | 1 +
src/lib/create_dump_dir.c | 47 +++++++++++++++++++++++++++-------------------
2 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/src/include/problem_data.h b/src/include/problem_data.h
index 7a65d6c..02c945c 100644
--- a/src/include/problem_data.h
+++ b/src/include/problem_data.h
@@ -131,6 +131,7 @@ problem_data_t *create_problem_data_for_reporting(const char *dump_dir_name);
@param base_dir_name Location to store the problem data
*/
struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name);
+struct dump_dir *create_dump_dir_from_problem_data_ext(problem_data_t *problem_data, const char *base_dir_name, uid_t uid);
#ifdef __cplusplus
}
diff --git a/src/lib/create_dump_dir.c b/src/lib/create_dump_dir.c
index 989a50c..45c248d 100644
--- a/src/lib/create_dump_dir.c
+++ b/src/lib/create_dump_dir.c
@@ -30,7 +30,7 @@ static struct dump_dir *try_dd_create(const char *base_dir_name, const char *dir
return dd;
}
-struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name)
+struct dump_dir *create_dump_dir_from_problem_data_ext(problem_data_t *problem_data, const char *base_dir_name, uid_t uid)
{
INITIALIZE_LIBREPORT();
@@ -48,23 +48,8 @@ struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data,
return NULL;
}
- uid_t uid = (uid_t)-1L;
- char *uid_str = problem_data_get_content_or_NULL(problem_data, FILENAME_UID);
-
- if (uid_str)
- {
- char *endptr;
- errno = 0;
- long val = strtol(uid_str, &endptr, 10);
-
- if (errno != 0 || endptr == uid_str || *endptr != '\0' || INT_MAX < val)
- {
- error_msg(_("uid value is not valid: '%s'"), uid_str);
- return NULL;
- }
-
- uid = (uid_t)val;
- }
+ if (uid == (uid_t)-1L)
+ uid = 0;
struct timeval tv;
if (gettimeofday(&tv, NULL) < 0)
@@ -139,7 +124,8 @@ struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data,
* reporting from anaconda where we can't read /etc/{system,redhat}-release
* and os_release is taken from anaconda
*/
- dd_create_basic_files(dd, uid, NULL);
+ const uid_t crashed_uid = problem_data_get_content_or_NULL(problem_data, FILENAME_UID) == NULL ? uid : /*uid already saved*/-1;
+ dd_create_basic_files(dd, crashed_uid, NULL);
problem_id[strlen(problem_id) - strlen(NEW_PD_SUFFIX)] = '\0';
char* new_path = concat_path_file(base_dir_name, problem_id);
@@ -150,3 +136,26 @@ struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data,
free(problem_id);
return dd;
}
+
+struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name)
+{
+ uid_t uid = (uid_t)-1L;
+ char *uid_str = problem_data_get_content_or_NULL(problem_data, FILENAME_UID);
+
+ if (uid_str)
+ {
+ char *endptr;
+ errno = 0;
+ long val = strtol(uid_str, &endptr, 10);
+
+ if (errno != 0 || endptr == uid_str || *endptr != '\0' || INT_MAX < val)
+ {
+ error_msg(_("uid value is not valid: '%s'"), uid_str);
+ return NULL;
+ }
+
+ uid = (uid_t)val;
+ }
+
+ return create_dump_dir_from_problem_data_ext(problem_data, base_dir_name, uid);
+}
--
1.8.3.1