doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

Blame SOURCES/0116-daemon-dbus-allow-only-root-to-create-CCpp-Koops-vmc.patch

8ec399
From 7417505e1d93cc95ec648b74e3c801bc67aacb9f Mon Sep 17 00:00:00 2001
8ec399
From: Jakub Filak <jfilak@redhat.com>
8ec399
Date: Thu, 7 May 2015 11:07:12 +0200
8ec399
Subject: [ABRT PATCH] daemon, dbus: allow only root to create CCpp, Koops,
8ec399
 vmcore and xorg
8ec399
MIME-Version: 1.0
8ec399
Content-Type: text/plain; charset=UTF-8
8ec399
Content-Transfer-Encoding: 8bit
8ec399
8ec399
Florian Weimer <fweimer@redhat.com>:
8ec399
    This prevents users from feeding things that are not actually
8ec399
    coredumps and excerpts from /proc to these analyzers.
8ec399
8ec399
    For example, it should not be possible to trigger a rule with
8ec399
    “EVENT=post-create analyzer=CCpp” using NewProblem
8ec399
8ec399
Related: #1212861
8ec399
8ec399
Signed-off-by: Jakub Filak <jfilak@redhat.com>
8ec399
---
8ec399
 src/daemon/abrt-server.c |  2 +-
8ec399
 src/dbus/abrt-dbus.c     | 10 +++++++++-
8ec399
 src/include/libabrt.h    |  2 ++
8ec399
 src/lib/hooklib.c        | 24 ++++++++++++++++++++++++
8ec399
 4 files changed, 36 insertions(+), 2 deletions(-)
8ec399
8ec399
diff --git a/src/daemon/abrt-server.c b/src/daemon/abrt-server.c
8ec399
index d3fa1b5..afd9fd3 100644
8ec399
--- a/src/daemon/abrt-server.c
8ec399
+++ b/src/daemon/abrt-server.c
8ec399
@@ -487,7 +487,7 @@ static gboolean key_value_ok(gchar *key, gchar *value)
8ec399
         }
8ec399
     }
8ec399
 
8ec399
-    return TRUE;
8ec399
+    return allowed_new_user_problem_entry(client_uid, key, value);
8ec399
 }
8ec399
 
8ec399
 /* Handles a message received from client over socket. */
8ec399
diff --git a/src/dbus/abrt-dbus.c b/src/dbus/abrt-dbus.c
8ec399
index 6de15e9..bef95bd 100644
8ec399
--- a/src/dbus/abrt-dbus.c
8ec399
+++ b/src/dbus/abrt-dbus.c
8ec399
@@ -168,6 +168,7 @@ bool allowed_problem_dir(const char *dir_name)
8ec399
 
8ec399
 static char *handle_new_problem(GVariant *problem_info, uid_t caller_uid, char **error)
8ec399
 {
8ec399
+    char *problem_id = NULL;
8ec399
     problem_data_t *pd = problem_data_new();
8ec399
 
8ec399
     GVariantIter *iter;
8ec399
@@ -175,6 +176,12 @@ static char *handle_new_problem(GVariant *problem_info, uid_t caller_uid, char *
8ec399
     gchar *key, *value;
8ec399
     while (g_variant_iter_loop(iter, "{ss}", &key, &value))
8ec399
     {
8ec399
+        if (allowed_new_user_problem_entry(caller_uid, key, value) == false)
8ec399
+        {
8ec399
+            *error = xasprintf("You are not allowed to create element '%s' containing '%s'", key, value);
8ec399
+            goto finito;
8ec399
+        }
8ec399
+
8ec399
         problem_data_add_text_editable(pd, key, value);
8ec399
     }
8ec399
 
8ec399
@@ -189,12 +196,13 @@ static char *handle_new_problem(GVariant *problem_info, uid_t caller_uid, char *
8ec399
     /* At least it should generate local problem identifier UUID */
8ec399
     problem_data_add_basics(pd);
8ec399
 
8ec399
-    char *problem_id = problem_data_save(pd);
8ec399
+    problem_id = problem_data_save(pd);
8ec399
     if (problem_id)
8ec399
         notify_new_path(problem_id);
8ec399
     else if (error)
8ec399
         *error = xasprintf("Cannot create a new problem");
8ec399
 
8ec399
+finito:
8ec399
     problem_data_free(pd);
8ec399
     return problem_id;
8ec399
 }
8ec399
diff --git a/src/include/libabrt.h b/src/include/libabrt.h
8ec399
index 5bf2397..3749a31 100644
8ec399
--- a/src/include/libabrt.h
8ec399
+++ b/src/include/libabrt.h
8ec399
@@ -51,6 +51,8 @@ char *get_backtrace(const char *dump_dir_name, unsigned timeout_sec, const char
8ec399
 bool dir_is_in_dump_location(const char *dir_name);
8ec399
 #define dir_has_correct_permissions abrt_dir_has_correct_permissions
8ec399
 bool dir_has_correct_permissions(const char *dir_name);
8ec399
+#define allowed_new_user_problem_entry abrt_allowed_new_user_problem_entry
8ec399
+bool allowed_new_user_problem_entry(uid_t uid, const char *name, const char *value);
8ec399
 
8ec399
 #define g_settings_nMaxCrashReportsSize abrt_g_settings_nMaxCrashReportsSize
8ec399
 extern unsigned int  g_settings_nMaxCrashReportsSize;
8ec399
diff --git a/src/lib/hooklib.c b/src/lib/hooklib.c
8ec399
index 4b20025..8e93663 100644
8ec399
--- a/src/lib/hooklib.c
8ec399
+++ b/src/lib/hooklib.c
8ec399
@@ -483,3 +483,27 @@ bool dir_has_correct_permissions(const char *dir_name)
8ec399
     }
8ec399
     return true;
8ec399
 }
8ec399
+
8ec399
+bool allowed_new_user_problem_entry(uid_t uid, const char *name, const char *value)
8ec399
+{
8ec399
+    /* Allow root to create everything */
8ec399
+    if (uid == 0)
8ec399
+        return true;
8ec399
+
8ec399
+    /* Permit non-root users to create everything except: analyzer and type */
8ec399
+    if (strcmp(name, FILENAME_ANALYZER) != 0
8ec399
+     && strcmp(name, FILENAME_TYPE) != 0
8ec399
+     /* compatibility value used in abrt-server */
8ec399
+     && strcmp(name, "basename") != 0)
8ec399
+        return true;
8ec399
+
8ec399
+    /* Permit non-root users to create all types except: C/C++, Koops, vmcore and xorg */
8ec399
+     if (strcmp(value, "CCpp") != 0
8ec399
+      && strcmp(value, "Kerneloops") != 0
8ec399
+      && strcmp(value, "vmcore") != 0
8ec399
+      && strcmp(value, "xorg") != 0)
8ec399
+        return true;
8ec399
+
8ec399
+    error_msg("Only root is permitted to create element '%s' containing '%s'", name, value);
8ec399
+    return false;
8ec399
+}
8ec399
-- 
8ec399
1.8.3.1
8ec399