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