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