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