summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2010-02-02 12:56:03 +0100
committerJiri Moskovcak <jmoskovc@redhat.com>2010-02-02 12:56:03 +0100
commit94c71201b0c64204e16cb6b5f7d2cc90cb4cf1c6 (patch)
tree042e2258aecbf06e316a304aa9b6f1e96f564ae3 /lib
parentb026e372e6f18ef34d1e23abecd584c2914b1cf1 (diff)
downloadabrt-94c71201b0c64204e16cb6b5f7d2cc90cb4cf1c6.tar.gz
abrt-94c71201b0c64204e16cb6b5f7d2cc90cb4cf1c6.tar.xz
abrt-94c71201b0c64204e16cb6b5f7d2cc90cb4cf1c6.zip
merge conflict
Diffstat (limited to 'lib')
-rw-r--r--lib/Plugins/CCpp.cpp90
-rw-r--r--lib/Plugins/Makefile.am6
2 files changed, 94 insertions, 2 deletions
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index b6305a23..0adfc7c0 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -746,7 +746,92 @@ void CAnalyzerCCpp::CreateReport(const char *pDebugDumpDir, int force)
dd.SaveText(FILENAME_RATING, to_string(rate_backtrace(backtrace.c_str())).c_str());
dd.Close();
}
+/*
+ this is just a workaround until kernel changes it's behavior
+ when handling pipes in core_pattern
+*/
+#ifdef HOSTILE_KERNEL
+#define CORE_SIZE_PATTERN "Max core file size=1:unlimited"
+static char *skip_whitespace(char *str)
+{
+ while (*str) {
+ if (*str != ' ' && *str != '\t')
+ return str;
+ str++;
+ }
+ return str;
+}
+static char *skip_non_whitespace(char *str)
+{
+ while (*str) {
+ if (*str == ' ' || *str == '\t')
+ return str;
+ str++;
+ }
+ return str;
+}
+
+static int isdigit_str(char *str)
+{
+ do {
+ if (*str < '0' || *str > '9')
+ return 0;
+ } while (*++str);
+ return 1;
+}
+
+static int set_limits()
+{
+ DIR *dir = opendir("/proc");
+ if (!dir) {
+ /* this shouldn't fail, but to be safe.. */
+ return 1;
+ }
+
+ struct dirent *ent;
+ while ((ent = readdir(dir)) != NULL) {
+ if (!isdigit_str(ent->d_name))
+ continue;
+
+ char limits_name[sizeof("/proc/%s/limits") + sizeof(int)];
+ snprintf(limits_name, sizeof(limits_name), "/proc/%s/limits", ent->d_name);
+ FILE *limits_fp = fopen(limits_name, "r");
+ if (!limits_fp) {
+ break;
+ }
+
+ char line[128];
+ char *ulimit_c = NULL;
+ while (1) {
+ if (fgets(line, sizeof(line)-1, limits_fp) == NULL)
+ break;
+ if (strncmp(line, "Max core file size", sizeof("Max core file size")-1) == 0) {
+ ulimit_c = skip_whitespace(line + sizeof("Max core file size")-1);
+ skip_non_whitespace(ulimit_c)[0] = '\0';
+ break;
+ }
+ }
+ fclose(limits_fp);
+ if (!ulimit_c || ulimit_c[0] != '0' || ulimit_c[1] != '\0') {
+ /*process has nonzero ulimit -c, so need to modify it*/
+ return 0;
+ }
+ /* echo -n 'Max core file size=1:unlimited' >/proc/PID/limits */
+ int fd = open(limits_name, O_WRONLY);
+ if (fd >= 0) {
+ errno = 0;
+ /*full_*/
+ ssize_t n = write(fd, CORE_SIZE_PATTERN, sizeof(CORE_SIZE_PATTERN)-1);
+ if(n < sizeof(CORE_SIZE_PATTERN)-1)
+ log("warning: can't write limit to: %s", limits_name);
+ close(fd);
+ }
+ }
+ return 0;
+}
+
+#endif /* HOSTILE_KERNEL */
void CAnalyzerCCpp::Init()
{
ifstream fInCorePattern;
@@ -773,6 +858,11 @@ void CAnalyzerCCpp::Init()
CORE_PATTERN_IFACE, CORE_PATTERN);
}
}
+#ifdef HOSTILE_KERNEL
+ if(set_limits() != 0)
+ log("warning: failed to set core_size limit, ABRT won't detect crashes in"
+ "compiled apps");
+#endif
ofstream fOutCorePattern;
fOutCorePattern.open(CORE_PATTERN_IFACE);
diff --git a/lib/Plugins/Makefile.am b/lib/Plugins/Makefile.am
index df35416f..d823eea4 100644
--- a/lib/Plugins/Makefile.am
+++ b/lib/Plugins/Makefile.am
@@ -33,7 +33,8 @@ dist_pluginsconf_DATA = \
Catcut.conf \
TicketUploader.conf \
FileTransfer.conf \
- Python.conf
+ Python.conf \
+ SOSreport.conf
man_MANS = abrt-FileTransfer.7 abrt-Bugzilla.7 abrt-KerneloopsReporter.7 \
abrt-KerneloopsScanner.7 abrt-Logger.7 abrt-Mailx.7 abrt-plugins.7 \
@@ -58,7 +59,8 @@ libCCpp_la_LDFLAGS = -avoid-version
libCCpp_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../Utils \
-DCCPP_HOOK_PATH=\"${libexecdir}/abrt-hook-ccpp\" \
-DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \
- -DLOCALSTATEDIR='"$(localstatedir)"'
+ -DLOCALSTATEDIR='"$(localstatedir)"' \
+ -DHOSTILE_KERNEL
# Firefox - disabled for now