|
|
a60cd7 |
From a169b05a10f242b19beab749458e86d7d7aa4f7b Mon Sep 17 00:00:00 2001
|
|
|
a60cd7 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
a60cd7 |
Date: Tue, 21 Oct 2014 14:57:10 +0200
|
|
|
a60cd7 |
Subject: [ABRT PATCH 72/72] applet: ensure writable dump directory before
|
|
|
a60cd7 |
reporting
|
|
|
a60cd7 |
|
|
|
a60cd7 |
Related to rhbz#1084027
|
|
|
a60cd7 |
|
|
|
a60cd7 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
a60cd7 |
|
|
|
a60cd7 |
Conflicts:
|
|
|
a60cd7 |
src/applet/applet.c
|
|
|
a60cd7 |
---
|
|
|
a60cd7 |
src/applet/applet.c | 62 ++++++++++++++++++++++++++++++++++-------------------
|
|
|
a60cd7 |
1 file changed, 40 insertions(+), 22 deletions(-)
|
|
|
a60cd7 |
|
|
|
a60cd7 |
diff --git a/src/applet/applet.c b/src/applet/applet.c
|
|
|
a60cd7 |
index bd95666..8c339a4 100644
|
|
|
a60cd7 |
--- a/src/applet/applet.c
|
|
|
a60cd7 |
+++ b/src/applet/applet.c
|
|
|
a60cd7 |
@@ -309,6 +309,7 @@ typedef struct problem_info {
|
|
|
a60cd7 |
bool incomplete;
|
|
|
a60cd7 |
bool reported;
|
|
|
a60cd7 |
bool was_announced;
|
|
|
a60cd7 |
+ bool is_writable;
|
|
|
a60cd7 |
} problem_info_t;
|
|
|
a60cd7 |
|
|
|
a60cd7 |
static void push_to_deferred_queue(problem_info_t *pi)
|
|
|
a60cd7 |
@@ -326,6 +327,36 @@ static void problem_info_set_dir(problem_info_t *pi, const char *dir)
|
|
|
a60cd7 |
problem_data_add_text_noteditable(pi->problem_data, CD_DUMPDIR, dir);
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
|
|
|
a60cd7 |
+static bool problem_info_ensure_writable(problem_info_t *pi)
|
|
|
a60cd7 |
+{
|
|
|
a60cd7 |
+ if (pi->is_writable)
|
|
|
a60cd7 |
+ return true;
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ /* chown the directory in any case, because kernel oopses are not foreign */
|
|
|
a60cd7 |
+ /* but their dump directories are not writable without chowning them or */
|
|
|
a60cd7 |
+ /* stealing them. The stealing is deprecated as it breaks the local */
|
|
|
a60cd7 |
+ /* duplicate search and root cannot see them */
|
|
|
a60cd7 |
+ const int res = chown_dir_over_dbus(problem_info_get_dir(pi));
|
|
|
a60cd7 |
+ if (pi->foreign && res != 0)
|
|
|
a60cd7 |
+ {
|
|
|
a60cd7 |
+ error_msg(_("Can't take ownership of '%s'"), problem_info_get_dir(pi));
|
|
|
a60cd7 |
+ return false;
|
|
|
a60cd7 |
+ }
|
|
|
a60cd7 |
+ pi->foreign = false;
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ struct dump_dir *dd = open_directory_for_writing(problem_info_get_dir(pi), /* don't ask */ NULL);
|
|
|
a60cd7 |
+ if (!dd)
|
|
|
a60cd7 |
+ {
|
|
|
a60cd7 |
+ error_msg(_("Can't open directory for writing '%s'"), problem_info_get_dir(pi));
|
|
|
a60cd7 |
+ return false;
|
|
|
a60cd7 |
+ }
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ problem_info_set_dir(pi, dd->dd_dirname);
|
|
|
a60cd7 |
+ pi->is_writable = true;
|
|
|
a60cd7 |
+ dd_close(dd);
|
|
|
a60cd7 |
+ return true;
|
|
|
a60cd7 |
+}
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
static problem_info_t *problem_info_new(const char *dir)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
problem_info_t *pi = xzalloc(sizeof(*pi));
|
|
|
a60cd7 |
@@ -601,8 +632,13 @@ static pid_t spawn_event_handler_child(const char *dump_dir_name, const char *ev
|
|
|
a60cd7 |
return child;
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
|
|
|
a60cd7 |
-static void run_report_from_applet(const char *dirname)
|
|
|
a60cd7 |
+static void run_report_from_applet(problem_info_t *pi)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
+ if (!problem_info_ensure_writable(pi))
|
|
|
a60cd7 |
+ return;
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ const char *dirname = problem_info_get_dir(pi);
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
fflush(NULL); /* paranoia */
|
|
|
a60cd7 |
pid_t pid = fork();
|
|
|
a60cd7 |
if (pid < 0)
|
|
|
a60cd7 |
@@ -642,7 +678,7 @@ static void action_report(NotifyNotification *notification, gchar *action, gpoin
|
|
|
a60cd7 |
if (strcmp(A_REPORT_REPORT, action) == 0)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
#endif//RHBZ_1067114_NO_UREPORT
|
|
|
a60cd7 |
- run_report_from_applet(problem_info_get_dir(pi));
|
|
|
a60cd7 |
+ run_report_from_applet(pi);
|
|
|
a60cd7 |
problem_info_free(pi);
|
|
|
a60cd7 |
#ifndef RHBZ_1067114_NO_UREPORT
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
@@ -1113,7 +1149,7 @@ static gboolean handle_event_output_cb(GIOChannel *gio, GIOCondition condition,
|
|
|
a60cd7 |
if (pi->known || !(state->flags & REPORT_UNKNOWN_PROBLEM_IMMEDIATELY))
|
|
|
a60cd7 |
notify_problem(pi);
|
|
|
a60cd7 |
else
|
|
|
a60cd7 |
- run_report_from_applet(problem_info_get_dir(pi));
|
|
|
a60cd7 |
+ run_report_from_applet(pi);
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
else
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
@@ -1174,29 +1210,11 @@ static void export_event_configuration(const char *event_name)
|
|
|
a60cd7 |
|
|
|
a60cd7 |
static void run_event_async(problem_info_t *pi, const char *event_name, int flags)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
- /* chown the directory in any case, because kernel oopses are not foreign */
|
|
|
a60cd7 |
- /* but their dump directories are not writable without chowning them or */
|
|
|
a60cd7 |
- /* stealing them. The stealing is deprecated as it breaks the local */
|
|
|
a60cd7 |
- /* duplicate search and root cannot see them */
|
|
|
a60cd7 |
- const int res = chown_dir_over_dbus(problem_info_get_dir(pi));
|
|
|
a60cd7 |
- if (pi->foreign && res != 0)
|
|
|
a60cd7 |
+ if (!problem_info_ensure_writable(pi))
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
- error_msg(_("Can't take ownership of '%s'"), problem_info_get_dir(pi));
|
|
|
a60cd7 |
problem_info_free(pi);
|
|
|
a60cd7 |
return;
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
- pi->foreign = false;
|
|
|
a60cd7 |
-
|
|
|
a60cd7 |
- struct dump_dir *dd = open_directory_for_writing(problem_info_get_dir(pi), /* don't ask */ NULL);
|
|
|
a60cd7 |
- if (!dd)
|
|
|
a60cd7 |
- {
|
|
|
a60cd7 |
- error_msg(_("Can't open directory for writing '%s'"), problem_info_get_dir(pi));
|
|
|
a60cd7 |
- problem_info_free(pi);
|
|
|
a60cd7 |
- return;
|
|
|
a60cd7 |
- }
|
|
|
a60cd7 |
-
|
|
|
a60cd7 |
- problem_info_set_dir(pi, dd->dd_dirname);
|
|
|
a60cd7 |
- dd_close(dd);
|
|
|
a60cd7 |
|
|
|
a60cd7 |
export_event_configuration(event_name);
|
|
|
a60cd7 |
|
|
|
a60cd7 |
--
|
|
|
a60cd7 |
1.8.3.1
|
|
|
a60cd7 |
|