summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2009-11-30 16:43:13 +0100
committerKarel Klic <kklic@redhat.com>2009-11-30 16:43:13 +0100
commit49c4d359ff6d5332f60c090ad2c26a9a39086014 (patch)
tree7f8ff0bd74fc842b5578d27399511aa6c2ec6d58 /src
parent277c2b79dd8d4bfa9eac979bcb51dc050ff1627b (diff)
parentccffe86678210568449c6a6345ae5d6dc20ef104 (diff)
downloadabrt-49c4d359ff6d5332f60c090ad2c26a9a39086014.tar.gz
abrt-49c4d359ff6d5332f60c090ad2c26a9a39086014.tar.xz
abrt-49c4d359ff6d5332f60c090ad2c26a9a39086014.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src')
-rw-r--r--src/Daemon/Daemon.cpp2
-rw-r--r--src/Daemon/MiddleWare.cpp12
-rw-r--r--src/Hooks/CCpp.cpp42
-rw-r--r--src/Hooks/Makefile.am8
4 files changed, 48 insertions, 16 deletions
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index 0e80c25b..666a7562 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -495,7 +495,7 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
/* Send dbus signal */
{
// I don't see any usable usecase for other plugin to be able automatic report.
- if (analyzer_has_AutoReportUIDs(/*crashinfo[CD_MWANALYZER][CD_CONTENT].c_str()*/"Kerneloops",crashinfo[CD_UID][CD_CONTENT].c_str()))
+ if (analyzer_has_AutoReportUIDs(crashinfo[CD_MWANALYZER][CD_CONTENT].c_str(), crashinfo[CD_UID][CD_CONTENT].c_str()))
{
map_crash_report_t crash_report;
VERB3 log("Create autoreport for user with uid %s",crashinfo[CD_UID][CD_CONTENT].c_str());
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index 69d36bfc..7b0eea54 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -656,6 +656,7 @@ bool analyzer_has_InformAllUsers(const char *analyzer_name)
bool analyzer_has_AutoReportUIDs(const char *analyzer_name, const char* uid)
{
+
CAnalyzer* analyzer = g_pPluginManager->GetAnalyzer(analyzer_name);
if (!analyzer)
{
@@ -667,6 +668,10 @@ bool analyzer_has_AutoReportUIDs(const char *analyzer_name, const char* uid)
if (it == settings.end())
return false;
+ if ((strcmp(analyzer_name, "Kerneloops") == 0) && (strcmp(uid, "-1") == 0))
+ return true;
+
+/*
vector_string_t logins;
parse_args(it->second.c_str(), logins);
@@ -674,19 +679,16 @@ bool analyzer_has_AutoReportUIDs(const char *analyzer_name, const char* uid)
if (size == 0)
return false;
- if ((strcmp(analyzer_name, "Kerneloops") == 0) && (strcmp(uid, "-1") == 0))
- return true;
-
uid_t id;
for (uint32_t ii = 0; ii < size; ii++)
{
- if (!xgetpwnam(logins[ii].c_str(), &id))
+ if (!getuidbyname(logins[ii].c_str(), &id))
continue;
if (strcmp(uid, to_string(id).c_str()) == 0)
return true;
}
-
+*/
return false;
}
diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp
index 78a24711..ea616860 100644
--- a/src/Hooks/CCpp.cpp
+++ b/src/Hooks/CCpp.cpp
@@ -190,6 +190,9 @@ static int daemon_is_ok()
int main(int argc, char** argv)
{
+ int fd;
+ struct stat sb;
+
const char* program_name = argv[0];
if (argc < 4)
{
@@ -238,7 +241,7 @@ int main(int argc, char** argv)
{
error_msg_and_die("can't read /proc/%u/exe link", (int)pid);
}
- if (strstr(executable, "/hookCCpp"))
+ if (strstr(executable, "/abrt-hook-ccpp"))
{
error_msg_and_die("pid %u is '%s', not dumping it to avoid recursion",
(int)pid, executable);
@@ -246,12 +249,40 @@ int main(int argc, char** argv)
char path[PATH_MAX];
+ /* Check /var/cache/abrt/last-ccpp marker, do not dump repeated crashes
+ * if they happen too often. Else, write new marker value.
+ */
+ snprintf(path, sizeof(path), "%s/last-ccpp", dddir);
+ fd = open(path, O_RDWR | O_CREAT, 0666);
+ if (fd >= 0)
+ {
+ int sz;
+ fstat(fd, &sb); /* !paranoia. this can't fail. */
+
+ if (sb.st_size != 0 /* if it wasn't created by us just now... */
+ && (unsigned)(time(NULL) - sb.st_mtime) < 20 /* and is relatively new [is 20 sec ok?] */
+ ) {
+ sz = read(fd, path, sizeof(path)-1); /* (ab)using path as scratch buf */
+ if (sz > 0)
+ {
+ path[sz] = '\0';
+ if (strcmp(executable, path) == 0)
+ error_msg_and_die("not dumping repeating crash in '%s'", executable);
+ }
+ lseek(fd, 0, SEEK_SET);
+ }
+ sz = write(fd, executable, strlen(executable));
+ if (sz >= 0)
+ ftruncate(fd, sz);
+ close(fd);
+ }
+
if (strstr(executable, "/abrtd"))
{
/* If abrtd crashes, we don't want to create a _directory_,
* since that can make new copy of abrtd to process it,
* and maybe crash again...
- * On the contrary, mere files are ignored by abrtd.
+ * Unlike dirs, mere files are ignored by abrtd.
*/
snprintf(path, sizeof(path), "%s/abrtd-coredump", dddir);
core_fd = xopen3(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
@@ -263,7 +294,7 @@ int main(int argc, char** argv)
* but it does not log file name */
error_msg_and_die("error saving coredump to %s", path);
}
- log("saved core dump of pid %u to %s (%llu bytes)", (int)pid, path, (long long)size);
+ log("saved core dump of pid %u (%s) to %s (%llu bytes)", (int)pid, executable, path, (long long)size);
return 0;
}
@@ -306,9 +337,9 @@ int main(int argc, char** argv)
}
lseek(core_fd, 0, SEEK_SET);
/* note: core_fd is still open, we may use it later to copy core to user's dir */
+ log("saved core dump of pid %u (%s) to %s (%llu bytes)", (int)pid, executable, path, (long long)size);
free(executable);
free(cmdline);
- log("saved core dump of pid %u to %s (%llu bytes)", (int)pid, path, (long long)size);
path[len] = '\0'; /* path now contains directory name */
/* We close dumpdir before we start catering for crash storm case.
@@ -430,7 +461,7 @@ int main(int argc, char** argv)
/* Mimic "core.PID" if requested */
char core_basename[sizeof("core.%u") + sizeof(int)*3] = "core";
char buf[] = "0\n";
- int fd = open("/proc/sys/kernel/core_uses_pid", O_RDONLY);
+ fd = open("/proc/sys/kernel/core_uses_pid", O_RDONLY);
if (fd >= 0)
{
read(fd, buf, sizeof(buf));
@@ -475,7 +506,6 @@ int main(int argc, char** argv)
/* Do not O_TRUNC: if later checks fail, we do not want to have file already modified here */
errno = 0;
int usercore_fd = open(core_basename, O_WRONLY | O_CREAT | O_NOFOLLOW, 0600); /* kernel makes 0600 too */
- struct stat sb;
if (usercore_fd < 0
|| fstat(usercore_fd, &sb) != 0
|| !S_ISREG(sb.st_mode)
diff --git a/src/Hooks/Makefile.am b/src/Hooks/Makefile.am
index c643b248..21569570 100644
--- a/src/Hooks/Makefile.am
+++ b/src/Hooks/Makefile.am
@@ -1,17 +1,17 @@
-libexec_PROGRAMS = hookCCpp
+libexec_PROGRAMS = abrt-hook-ccpp
bin_PROGRAMS = dumpoops abrt-pyhook-helper
# CCpp
-hookCCpp_SOURCES = \
+abrt_hook_ccpp_SOURCES = \
CCpp.cpp
-hookCCpp_CPPFLAGS = \
+abrt_hook_ccpp_CPPFLAGS = \
-I$(srcdir)/../../inc \
-I$(srcdir)/../../lib/Utils \
-DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \
-DCONF_DIR=\"$(CONF_DIR)\" \
-DVAR_RUN=\"$(VAR_RUN)\" \
-D_GNU_SOURCE
-hookCCpp_LDADD = \
+abrt_hook_ccpp_LDADD = \
../../lib/Utils/libABRTUtils.la
# dumpoops