summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-11-05 17:21:11 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-11-05 17:21:11 +0100
commit64c5d35aebc38f93ce5c086c15c15de5acb21b2f (patch)
tree51113a991ff0111cddcf65bca90ac995e2173c1b /src
parent01f36609ba1631751e492784d95b0e6b0706cf45 (diff)
downloadabrt-64c5d35aebc38f93ce5c086c15c15de5acb21b2f.tar.gz
abrt-64c5d35aebc38f93ce5c086c15c15de5acb21b2f.tar.xz
abrt-64c5d35aebc38f93ce5c086c15c15de5acb21b2f.zip
InformAllUsers support. enabled by default for Kerneloops. Tested wuth CCpp.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r--src/Applet/Applet.cpp23
-rw-r--r--src/Daemon/CommLayerServer.h2
-rw-r--r--src/Daemon/CommLayerServerDBus.cpp24
-rw-r--r--src/Daemon/CommLayerServerDBus.h2
-rw-r--r--src/Daemon/Daemon.cpp50
-rw-r--r--src/Daemon/abrt.conf15
6 files changed, 61 insertions, 55 deletions
diff --git a/src/Applet/Applet.cpp b/src/Applet/Applet.cpp
index 327e24f5..2eed556a 100644
--- a/src/Applet/Applet.cpp
+++ b/src/Applet/Applet.cpp
@@ -49,13 +49,12 @@ static void Crash(DBusMessage* signal)
dbus_message_iter_init(signal, &in_iter);
const char* progname;
r = load_val(&in_iter, progname);
- if (r != ABRT_DBUS_MORE_FIELDS)
+ /* Optional 2nd param: uid */
+ const char* uid_str = NULL;
+ if (r == ABRT_DBUS_MORE_FIELDS)
{
- error_msg("dbus signal %s: parameter type mismatch", __func__);
- return;
+ r = load_val(&in_iter, uid_str);
}
- const char* uid_str;
- r = load_val(&in_iter, uid_str);
if (r != ABRT_DBUS_LAST_FIELD)
{
error_msg("dbus signal %s: parameter type mismatch", __func__);
@@ -66,13 +65,17 @@ static void Crash(DBusMessage* signal)
// return;
// uid_t uid_num = atol(uid_str);
- char* endptr;
- int64_t uid_num = strtoll(uid_str,&endptr, 10);
-
- if ((uid_num != getuid()) && (uid_num != -1))
+ if (uid_str != NULL)
{
- return;
+ char *end;
+ errno = 0;
+ unsigned long uid_num = strtoul(uid_str, &end, 10);
+ if (errno || *end != '\0' || uid_num != getuid())
+ {
+ return;
+ }
}
+
const char* message = _("A crash in package %s has been detected");
//applet->AddEvent(uid, progname);
applet->SetIconTooltip(message, progname);
diff --git a/src/Daemon/CommLayerServer.h b/src/Daemon/CommLayerServer.h
index 6ede5815..21c1b304 100644
--- a/src/Daemon/CommLayerServer.h
+++ b/src/Daemon/CommLayerServer.h
@@ -13,7 +13,7 @@ class CCommLayerServer {
virtual ~CCommLayerServer();
/* just stubs to be called when not implemented in specific comm layer */
- virtual void Crash(const std::string& progname, const std::string& uid) {}
+ virtual void Crash(const char *progname, const char *uid_str) {}
virtual void JobDone(const char* pDest, const char* pUUID) = 0;
virtual void QuotaExceed(const char* str) {}
diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp
index 2483942d..e53e0873 100644
--- a/src/Daemon/CommLayerServerDBus.cpp
+++ b/src/Daemon/CommLayerServerDBus.cpp
@@ -46,16 +46,24 @@ static void send_flush_and_unref(DBusMessage* msg)
}
/* Notify the clients (UI) about a new crash */
-void CCommLayerServerDBus::Crash(const std::string& progname, const std::string& uid)
+void CCommLayerServerDBus::Crash(const char *progname, const char *uid_str)
{
DBusMessage* msg = new_signal_msg("Crash");
- const char* c_progname = progname.c_str();
- const char* c_uid = uid.c_str();
- dbus_message_append_args(msg,
- DBUS_TYPE_STRING, &c_progname,
- DBUS_TYPE_STRING, &c_uid,
- DBUS_TYPE_INVALID);
- VERB2 log("Sending signal Crash('%s','%s')", c_progname, c_uid);
+ if (uid_str)
+ {
+ dbus_message_append_args(msg,
+ DBUS_TYPE_STRING, &progname,
+ DBUS_TYPE_STRING, &uid_str,
+ DBUS_TYPE_INVALID);
+ VERB2 log("Sending signal Crash('%s','%s')", progname, uid_str);
+ }
+ else
+ {
+ dbus_message_append_args(msg,
+ DBUS_TYPE_STRING, &progname,
+ DBUS_TYPE_INVALID);
+ VERB2 log("Sending signal Crash('%s')", progname);
+ }
send_flush_and_unref(msg);
}
diff --git a/src/Daemon/CommLayerServerDBus.h b/src/Daemon/CommLayerServerDBus.h
index 7b2e31d7..f159c732 100644
--- a/src/Daemon/CommLayerServerDBus.h
+++ b/src/Daemon/CommLayerServerDBus.h
@@ -11,7 +11,7 @@ class CCommLayerServerDBus
virtual ~CCommLayerServerDBus();
/* DBus signal senders */
- virtual void Crash(const std::string& progname, const std::string& uid);
+ virtual void Crash(const char *progname, const char *uid_str);
virtual void JobDone(const char* pDest, const char* pUUID);
virtual void QuotaExceed(const char* str);
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index 175efe93..fd7951f5 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -165,6 +165,18 @@ static double GetDirSize(const std::string &pPath, std::string *worst_dir = NULL
return size;
}
+static bool analyzer_has_InformAllUsers(const char *analyzer_name)
+{
+ CAnalyzer* analyzer = g_pPluginManager->GetAnalyzer(analyzer_name);
+ if (!analyzer)
+ return false;
+ map_plugin_settings_t settings = analyzer->GetSettings();
+ map_plugin_settings_t::const_iterator it = settings.find("InformAllUsers");
+ if (it == settings.end())
+ return false;
+ return string_to_bool(it->second.c_str());
+}
+
static void cron_delete_callback_data_cb(gpointer data)
{
cron_callback_data_t* cronDeleteCallbackData = static_cast<cron_callback_data_t*>(data);
@@ -369,8 +381,7 @@ static void FindNewDumps(const char* pPath)
map_crash_info_t crashinfo;
try
{
- mw_result_t res;
- res = SaveDebugDump(*itt, crashinfo);
+ mw_result_t res = SaveDebugDump(*itt, crashinfo);
switch (res)
{
case MW_OK:
@@ -522,38 +533,23 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
map_crash_info_t crashinfo;
try
{
- mw_result_t res;
- res = SaveDebugDump(std::string(DEBUG_DUMPS_DIR) + "/" + name, crashinfo);
+ mw_result_t res = SaveDebugDump(std::string(DEBUG_DUMPS_DIR) + "/" + name, crashinfo);
switch (res)
{
case MW_OK:
- log("New crash, saving...");
+ log("New crash, saving");
RunActionsAndReporters(crashinfo[CD_MWDDD][CD_CONTENT]);
- /* Send dbus signal */
- if(crashinfo[CD_MWANALYZER][CD_CONTENT] == "Kerneloops")
- {
- // When Kerneloops comes it will be sent uid with -1
- // Applet will detected and show normal user
- g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT], to_string("-1"));
- }
- else
- {
- g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT], crashinfo[CD_UID][CD_CONTENT]);
- }
- break;
+ /* Fall through to "send dbus signal" */
case MW_REPORTED:
case MW_OCCURED:
- log("Already saved crash, deleting...");
+ if (res != MW_OK)
+ log("Already saved crash, just sending dbus signal");
/* Send dbus signal */
- if(crashinfo[CD_MWANALYZER][CD_CONTENT] == "Kerneloops")
- {
- // When Kerneloops comes it will be sent uid with -1
- // Applet will detected and show normal user
- g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT], to_string("-1"));
- }
- else
{
- g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT], crashinfo[CD_UID][CD_CONTENT]);
+ const char *uid_str = analyzer_has_InformAllUsers(crashinfo[CD_MWANALYZER][CD_CONTENT].c_str())
+ ? NULL
+ : crashinfo[CD_UID][CD_CONTENT].c_str();
+ g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT].c_str(), uid_str);
}
//DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name);
break;
@@ -564,7 +560,7 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
case MW_IN_DB:
case MW_FILE_ERROR:
default:
- log("Corrupted or bad crash, deleting...");
+ log("Corrupted or bad crash, deleting");
DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name);
break;
}
diff --git a/src/Daemon/abrt.conf b/src/Daemon/abrt.conf
index a02cef44..e9845e58 100644
--- a/src/Daemon/abrt.conf
+++ b/src/Daemon/abrt.conf
@@ -1,32 +1,31 @@
# test conf file. it will be generated in the future
-# common abrt settings
+# Common abrt settings
[ Common ]
# With this option set to "yes",
# only crashes in signed packages will be analyzed.
OpenGPGCheck = no
# GPG keys
OpenGPGPublicKeys = /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
-# blacklisted packages
+# Blacklisted packages
BlackList = nspluginwrapper
-# enabled plugins
-# there has to be exactly one database plugin
+# Enabled plugins. There has to be exactly one database plugin
EnabledPlugins = SQLite3, CCpp, Logger, Kerneloops, KerneloopsScanner, KerneloopsReporter, Bugzilla, Python
# Database
Database = SQLite3
-# max size for crash storage [MiB]
+# Max size for crash storage [MiB]
MaxCrashReportsSize = 1000
-# vector of actions and reporters which are activated immediately after a crash occurs
+# Vector of actions and reporters which are activated immediately after a crash occurs
# ActionsAndReporters = Mailx("[abrt] new crash was detected")
-# reporters association with analyzers
+# Reporters association with analyzers
[ AnalyzerActionsAndReporters ]
Kerneloops = KerneloopsReporter
CCpp = Bugzilla, Logger
Python = Bugzilla, Logger
# CCpp : xorg-x11-apps = RunApp("date", "RunApp")
-# repeated calling of Action plugins
+# Repeated calling of Action plugins
[ Cron ]
# h:m - at h:m an action plugin is activated
# s - every s seconds is an action plugin activated