diff options
| author | Karel Klic <kklic@redhat.com> | 2009-11-30 16:43:13 +0100 |
|---|---|---|
| committer | Karel Klic <kklic@redhat.com> | 2009-11-30 16:43:13 +0100 |
| commit | 49c4d359ff6d5332f60c090ad2c26a9a39086014 (patch) | |
| tree | 7f8ff0bd74fc842b5578d27399511aa6c2ec6d58 | |
| parent | 277c2b79dd8d4bfa9eac979bcb51dc050ff1627b (diff) | |
| parent | ccffe86678210568449c6a6345ae5d6dc20ef104 (diff) | |
| download | abrt-49c4d359ff6d5332f60c090ad2c26a9a39086014.tar.gz abrt-49c4d359ff6d5332f60c090ad2c26a9a39086014.tar.xz abrt-49c4d359ff6d5332f60c090ad2c26a9a39086014.zip | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | abrt.spec | 2 | ||||
| -rw-r--r-- | doc/DESIGN | 4 | ||||
| -rw-r--r-- | inc/abrtlib.h | 2 | ||||
| -rw-r--r-- | lib/Plugins/Makefile.am | 4 | ||||
| -rw-r--r-- | lib/Utils/xfuncs.cpp | 2 | ||||
| -rw-r--r-- | src/Daemon/Daemon.cpp | 2 | ||||
| -rw-r--r-- | src/Daemon/MiddleWare.cpp | 12 | ||||
| -rw-r--r-- | src/Hooks/CCpp.cpp | 42 | ||||
| -rw-r--r-- | src/Hooks/Makefile.am | 8 |
10 files changed, 56 insertions, 24 deletions
@@ -50,6 +50,6 @@ src/Daemon/abrtd src/Gui/abrt.desktop src/Hooks/abrt_exception_handler.py src/Hooks/dumpoops -src/Hooks/hookCCpp +src/Hooks/abrt-hook-ccpp src/Hooks/abrt-pyhook-helper stamp-h1 @@ -311,7 +311,7 @@ fi %defattr(-,root,root,-) %config(noreplace) %{_sysconfdir}/%{name}/plugins/CCpp.conf %{_libdir}/%{name}/libCCpp.so* -%{_libexecdir}/hookCCpp +%{_libexecdir}/abrt-hook-ccpp #%files plugin-firefox #%{_libdir}/%{name}/libFirefox.so* @@ -53,9 +53,9 @@ which processes it according to configuration in /etc/abrt/*.conf. In order to catch binary crashes, we install a handler for it in /proc/sys/kernel/core_pattern (by setting it to -"|/usr/libexec/hookCCpp /var/cache/abrt %p %s %u"). +"|/usr/libexec/abrt-hook-ccpp /var/cache/abrt %p %s %u"). When process dumps core, the dump is written into /var/cache/abrt/DIR. -After this, hookCCpp spawns "abrt-process -d /var/cache/abrt/DIR" +After this, abrt-hook-ccpp spawns "abrt-process -d /var/cache/abrt/DIR" and terminates. When python program crashes, it invokes internel python subroutine diff --git a/inc/abrtlib.h b/inc/abrtlib.h index 257f4c7..345b26b 100644 --- a/inc/abrtlib.h +++ b/inc/abrtlib.h @@ -193,7 +193,7 @@ char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa); char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa); char* xmalloc_sockaddr2dotted(const struct sockaddr *sa); char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa); -bool xgetpwnam(const char* login, uid_t *uid); +bool getuidbyname(const char* login, uid_t *uid); /* Random utility functions */ diff --git a/lib/Plugins/Makefile.am b/lib/Plugins/Makefile.am index 97da220..58f1334 100644 --- a/lib/Plugins/Makefile.am +++ b/lib/Plugins/Makefile.am @@ -52,7 +52,7 @@ libCCpp_la_SOURCES = CCpp.cpp CCpp.h libCCpp_la_LDFLAGS = -avoid-version libCCpp_la_LIBADD = $(NSS_LIBS) libCCpp_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../Utils \ - -DCCPP_HOOK_PATH=\"${libexecdir}/hookCCpp\" \ + -DCCPP_HOOK_PATH=\"${libexecdir}/abrt-hook-ccpp\" \ -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \ -DLOCALSTATEDIR='"$(localstatedir)"' \ $(NSS_CFLAGS) @@ -63,7 +63,7 @@ libCCpp_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../Utils \ #libFirefox_la_LDFLAGS = -avoid-version #libFirefox_la_LIBADD = $(NSS_LIBS) #libFirefox_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../Utils \ -# -DCCPP_HOOK_PATH=\"${libexecdir}/hookCCpp\" \ +# -DCCPP_HOOK_PATH=\"${libexecdir}/abrt-hook-ccpp\" \ # -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \ # -DLOCALSTATEDIR='"$(localstatedir)"' \ # $(NSS_CFLAGS) diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp index 4b208a9..c4b6dd6 100644 --- a/lib/Utils/xfuncs.cpp +++ b/lib/Utils/xfuncs.cpp @@ -369,7 +369,7 @@ bool string_to_bool(const char *s) return false; } -bool xgetpwnam(const char* login, uid_t *uid) +bool getuidbyname(const char* login, uid_t *uid) { struct passwd* pwd = getpwnam(login); if (pwd == NULL) diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index 0e80c25..666a756 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 69d36bf..7b0eea5 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 78a2471..ea61686 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 c643b24..2156957 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 |
