summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2009-11-30 15:07:45 +0100
committerKarel Klic <kklic@redhat.com>2009-11-30 15:07:45 +0100
commitc6fef68305a7bc2df55afc4d682317a05a8dfe97 (patch)
tree0332579a85acd6530b8b9dcbf29dc56187b565ea
parentf58611ea5957462e6be40950684a56579a2459a6 (diff)
parentf0bd70b3f68835983a10052337fc316a9f861811 (diff)
downloadabrt-c6fef68305a7bc2df55afc4d682317a05a8dfe97.tar.gz
abrt-c6fef68305a7bc2df55afc4d682317a05a8dfe97.tar.xz
abrt-c6fef68305a7bc2df55afc4d682317a05a8dfe97.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
-rw-r--r--abrt.spec25
-rw-r--r--inc/abrtlib.h6
-rw-r--r--lib/Plugins/Bugzilla.cpp4
-rw-r--r--lib/Plugins/CCpp.conf11
-rw-r--r--lib/Plugins/CCpp.cpp2
-rw-r--r--lib/Plugins/Catcut.cpp18
-rw-r--r--lib/Plugins/Kerneloops.conf2
-rw-r--r--lib/Plugins/KerneloopsReporter.cpp2
-rw-r--r--lib/Utils/DebugDump.cpp47
-rw-r--r--lib/Utils/DebugDump.h8
-rw-r--r--lib/Utils/Makefile.am8
-rw-r--r--lib/Utils/dirsize.cpp100
-rw-r--r--lib/Utils/parse_release.cpp2
-rw-r--r--lib/Utils/xfuncs.cpp11
-rw-r--r--src/Daemon/CrashWatcher.cpp7
-rw-r--r--src/Daemon/Daemon.cpp80
-rw-r--r--src/Daemon/MiddleWare.cpp56
-rw-r--r--src/Daemon/MiddleWare.h8
-rw-r--r--src/Hooks/CCpp.cpp263
-rw-r--r--src/Hooks/Makefile.am2
-rw-r--r--src/Hooks/sitecustomize.py1
21 files changed, 510 insertions, 153 deletions
diff --git a/abrt.spec b/abrt.spec
index 055a3fb..66c958c 100644
--- a/abrt.spec
+++ b/abrt.spec
@@ -28,7 +28,8 @@ BuildRequires: libzip-devel, libtar-devel, bzip2-devel, zlib-devel
BuildRequires: intltool
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: %{name}-libs = %{version}-%{release}
-Requires(pre): /usr/sbin/groupadd
+Requires(pre): /usr/sbin/groupadd
+Obsoletes: abrt-plugin-sqlite3
%description
%{name} is a tool to help users to detect defects in applications and
@@ -99,21 +100,13 @@ Requires: curl
Requires: %{name} = %{version}-%{release}
Obsoletes: kerneloops
Obsoletes: abrt-plugin-kerneloops
+Obsoletes: abrt-plugin-kerneloopsreporter
%description addon-kerneloops
This package contains plugins for kernel crashes information collecting and
reporter plugin, that sends, collected by %{name}'s kerneloops
addon, information about kernel crashes to specified server, e.g. kerneloops.org.
-%package plugin-sqlite3
-Summary: %{name}'s SQLite3 database plugin
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description plugin-sqlite3
-This package contains SQLite3 database plugin. It is used for storing the data
-required for creating a bug report.
-
%package plugin-logger
Summary: %{name}'s logger reporter plugin
Group: System Environment/Libraries
@@ -203,7 +196,7 @@ the sockets.
Summary: Virtual package to install all necessary packages for usage from desktop environment
Group: User Interface/Desktops
Requires: %{name} = %{version}-%{release}
-Requires: %{name}-plugin-sqlite3, %{name}-plugin-bugzilla, %{name}-plugin-logger
+Requires: %{name}-plugin-bugzilla, %{name}-plugin-logger
#workaround for broken upgrade, remove!
#Requires: %{name}-gui
Requires: %{name}-addon-kerneloops
@@ -276,7 +269,6 @@ fi
%doc README COPYING
%{_sbindir}/%{name}d
%{_bindir}/%{name}-debuginfo-install
-%{_bindir}/%{name}-backtrace
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/dbus-%{name}.conf
%{_initrddir}/%{name}d
@@ -292,6 +284,9 @@ fi
%{_mandir}/man7/%{name}-plugins.7.gz
%{_datadir}/polkit-1/actions/org.fedoraproject.abrt.policy
%{_datadir}/dbus-1/system-services/com.redhat.abrt.service
+%config(noreplace) %{_sysconfdir}/%{name}/plugins/SQLite3.conf
+%{_libdir}/%{name}/libSQLite3.so*
+%{_mandir}/man7/%{name}-SQLite3.7.gz
%files libs
%defattr(-,root,root,-)
@@ -331,12 +326,6 @@ fi
%{_libdir}/%{name}/KerneloopsReporter.GTKBuilder
%{_mandir}/man7/%{name}-KerneloopsReporter.7.gz
-%files plugin-sqlite3
-%defattr(-,root,root,-)
-%config(noreplace) %{_sysconfdir}/%{name}/plugins/SQLite3.conf
-%{_libdir}/%{name}/libSQLite3.so*
-%{_mandir}/man7/%{name}-SQLite3.7.gz
-
%files plugin-logger
%defattr(-,root,root,-)
%config(noreplace) %{_sysconfdir}/%{name}/plugins/Logger.conf
diff --git a/inc/abrtlib.h b/inc/abrtlib.h
index 257f557..257f4c7 100644
--- a/inc/abrtlib.h
+++ b/inc/abrtlib.h
@@ -193,6 +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);
/* Random utility functions */
@@ -208,6 +209,11 @@ bool string_to_bool(const char *s);
std::string ssprintf(const char *format, ...);
std::string get_home_dir(int uid);
std::string concat_path_file(const char *path, const char *filename);
+double get_dirsize(const char *pPath);
+double get_dirsize_find_largest_dir(
+ const char *pPath,
+ std::string *worst_dir = NULL,
+ const char *excluded = NULL);
template <class T>
std::string
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp
index 5734238..f17f9a7 100644
--- a/lib/Plugins/Bugzilla.cpp
+++ b/lib/Plugins/Bugzilla.cpp
@@ -226,7 +226,7 @@ uint32_t ctx::new_bug(const map_crash_report_t& pCrashReport)
std::string arch = pCrashReport.find(FILENAME_ARCHITECTURE)->second[CD_CONTENT];
std::string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT];
- std::string summary = "[abrt] crash detected in " + package;
+ std::string summary = "[abrt] crash in " + package;
std::string status_whiteboard = "abrt_hash:" + uuid;
std::string description = "abrt "VERSION" detected a crash.\n\n";
@@ -363,7 +363,7 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport,
if ((Login == "") && (Password == ""))
{
VERB3 log("Empty login and password");
- throw CABRTException(EXCEP_PLUGIN, std::string(_("Empty login and password. Please check Bugzilla.conf")));
+ throw CABRTException(EXCEP_PLUGIN, _("Empty login and password. Please check Bugzilla.conf"));
}
bz_server.login(Login.c_str(), Password.c_str());
diff --git a/lib/Plugins/CCpp.conf b/lib/Plugins/CCpp.conf
index 459dff8..e5ba5ad 100644
--- a/lib/Plugins/CCpp.conf
+++ b/lib/Plugins/CCpp.conf
@@ -1,8 +1,13 @@
-# Configuration file for CCpp add-on
-# generate memory map too (IGNORED FOR NOW)
+# Configuration file for CCpp hook and plugin
+
+# If you also want to dump file named "core"
+# in crashed process' current dir, set to "yes"
+MakeCompatCore = no
+
+# Generate memory map too (IGNORED FOR NOW)
MemoryMap = no
-# how to get debug-info: install, mount
+# How to get debug-info: install, mount
## install - download and install debug-info packages
## mount - mount fedora NFS with debug info
## (IGNORED FOR NOW)
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index d83d9b5..01f4eb1 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -932,7 +932,7 @@ void CAnalyzerCCpp::CreateReport(const char *pDebugDumpDir, int force)
GetBacktrace(pDebugDumpDir, m_sDebugInfoDirs.c_str(), backtrace);
dd.Open(pDebugDumpDir);
- dd.SaveText(FILENAME_BACKTRACE, (build_ids + backtrace).c_str());
+ dd.SaveText(FILENAME_BACKTRACE, (backtrace + build_ids).c_str());
if (m_bMemoryMap)
{
dd.SaveText(FILENAME_MEMORYMAP, "memory map of the crashed C/C++ application, not implemented yet");
diff --git a/lib/Plugins/Catcut.cpp b/lib/Plugins/Catcut.cpp
index e353cbe..7add58c 100644
--- a/lib/Plugins/Catcut.cpp
+++ b/lib/Plugins/Catcut.cpp
@@ -21,7 +21,7 @@ put_stream(const char *pURL, FILE* f, size_t content_length)
CURL* curl = curl_easy_init();
if (!curl)
{
- throw CABRTException(EXCEP_PLUGIN, "put_stream: Curl library error.");
+ throw CABRTException(EXCEP_PLUGIN, "put_stream: can't initialize curl library");
}
/* enable uploading */
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
@@ -31,7 +31,7 @@ put_stream(const char *pURL, FILE* f, size_t content_length)
curl_easy_setopt(curl, CURLOPT_READDATA, f);
/* get file size */
curl_easy_setopt(curl, CURLOPT_INFILESIZE, content_length);
- /*everything is done here; result 0 means success*/
+ /* everything is done here; result 0 means success */
int result = curl_easy_perform(curl);
/* goodbye */
curl_easy_cleanup(curl);
@@ -56,7 +56,7 @@ send_string(const char *pURL,
FILE* f = fmemopen((void*)pContent, content_length, "r");
if (!f)
{
- throw CABRTException(EXCEP_PLUGIN, "send_string: could not open string stream");
+ throw CABRTException(EXCEP_PLUGIN, "send_string: can't open string stream");
}
int result = put_stream(pURL, f, content_length);
fclose(f);
@@ -67,7 +67,7 @@ send_string(const char *pURL,
/*retry the upload if not succesful, wait a bit before next try*/
while (--retryCount != 0 && (sleep(retryDelaySeconds), 1));
- throw CABRTException(EXCEP_PLUGIN, "send_string: could not send string");
+ throw CABRTException(EXCEP_PLUGIN, "send_string: can't send string");
}
static void
@@ -89,7 +89,7 @@ send_file(const char *pURL,
FILE* f = fopen(pFilename, "r");
if (!f)
{
- throw CABRTException(EXCEP_PLUGIN, "send_file: could not open string stream");
+ throw CABRTException(EXCEP_PLUGIN, "send_file: can't open string stream");
}
struct stat buf;
fstat(fileno(f), &buf); /* can't fail */
@@ -103,7 +103,7 @@ send_file(const char *pURL,
/*retry the upload if not succesful, wait a bit before next try*/
while (--retryCount != 0 && (sleep(retryDelaySeconds), 1));
- throw CABRTException(EXCEP_PLUGIN, "send_file: could not send file");
+ throw CABRTException(EXCEP_PLUGIN, "send_file: can't send file");
}
static string
@@ -268,7 +268,7 @@ ctx::new_bug(const char *auth_cookie, const map_crash_report_t& pCrashReport)
string arch = pCrashReport.find(FILENAME_ARCHITECTURE)->second[CD_CONTENT];
string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT];
- string summary = "[abrt] crash detected in " + package;
+ string summary = "[abrt] crash in " + package;
string status_whiteboard = "abrt_hash:" + uuid;
string description = make_description_catcut(pCrashReport);
@@ -462,12 +462,12 @@ string CReporterCatcut::Report(const map_crash_report_t& pCrashReport,
}
else
{
- message = "Error could not create ticket";
+ message = "Error: can't create ticket";
}
}
else
{
- message = "Error could not create ticket";
+ message = "Error: can't create ticket";
}
return message;
}
diff --git a/lib/Plugins/Kerneloops.conf b/lib/Plugins/Kerneloops.conf
index 08dacd0..a014153 100644
--- a/lib/Plugins/Kerneloops.conf
+++ b/lib/Plugins/Kerneloops.conf
@@ -1,6 +1,8 @@
# compatibility with kerneloops.org tool
InformAllUsers = yes
+AutoReportUIDs = root
+
# KerneloopsReporter configuration. Reports kernel crashes collected by the addon.
################################################################################
diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp
index f38f503..a1fd3f1 100644
--- a/lib/Plugins/KerneloopsReporter.cpp
+++ b/lib/Plugins/KerneloopsReporter.cpp
@@ -113,7 +113,7 @@ std::string CKerneloopsReporter::Report(const map_crash_report_t& pCrashReport,
/* FIXME: be more informative */
throw CABRTException(EXCEP_PLUGIN, std::string("CKerneloopsReporter::Report(): Report has not been sent..."));
}
- return "Kernel oops report was uploaded to: " + m_sSubmitURL;
+ return "Kernel oops report was uploaded.";
}
void CKerneloopsReporter::SetSettings(const map_plugin_settings_t& pSettings)
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp
index fff4695..3e226f9 100644
--- a/lib/Utils/DebugDump.cpp
+++ b/lib/Utils/DebugDump.cpp
@@ -46,7 +46,19 @@ static std::string RemoveBackSlashes(const char *pDir)
return std::string(pDir, len);
}
-static bool ExistFileDir(const char* pPath);
+static bool ExistFileDir(const char *pPath)
+{
+ struct stat buf;
+ if (stat(pPath, &buf) == 0)
+ {
+ if (S_ISDIR(buf.st_mode) || S_ISREG(buf.st_mode))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
static void LoadTextFile(const char *pPath, std::string& pData);
CDebugDump::CDebugDump() :
@@ -60,12 +72,12 @@ void CDebugDump::Open(const char *pDir)
{
if (m_bOpened)
{
- throw CABRTException(EXCEP_ERROR, "CDebugDump::CDebugDump(): DebugDump is already opened.");
+ throw CABRTException(EXCEP_ERROR, "CDebugDump is already opened");
}
m_sDebugDumpDir = RemoveBackSlashes(pDir);
if (!ExistFileDir(m_sDebugDumpDir.c_str()))
{
- throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::CDebugDump(): " + m_sDebugDumpDir + " does not exist.");
+ throw CABRTException(EXCEP_DD_OPEN, m_sDebugDumpDir + " does not exist");
}
Lock();
m_bOpened = true;
@@ -77,20 +89,6 @@ bool CDebugDump::Exist(const char* pPath)
return ExistFileDir(fullPath.c_str());
}
-
-static bool ExistFileDir(const char* pPath)
-{
- struct stat buf;
- if (stat(pPath, &buf) == 0)
- {
- if (S_ISDIR(buf.st_mode) || S_ISREG(buf.st_mode))
- {
- return true;
- }
- }
- return false;
-}
-
static bool GetAndSetLock(const char* pLockFile, const char* pPID)
{
while (symlink(pPID, pLockFile) != 0)
@@ -429,3 +427,18 @@ bool CDebugDump::GetNextFile(std::string *short_name, std::string *full_name)
m_pGetNextFileDir = NULL;
return false;
}
+
+/* Utility function */
+void delete_debug_dump_dir(const char *pDebugDumpDir)
+{
+ try
+ {
+ CDebugDump dd;
+ dd.Open(pDebugDumpDir);
+ dd.Delete();
+ }
+ catch (CABRTException& e)
+ {
+ /* Ignoring "directory already deleted" and such */
+ }
+}
diff --git a/lib/Utils/DebugDump.h b/lib/Utils/DebugDump.h
index d753353..7dfe61e 100644
--- a/lib/Utils/DebugDump.h
+++ b/lib/Utils/DebugDump.h
@@ -76,4 +76,10 @@ class CDebugDump
bool GetNextFile(std::string *short_name, std::string *full_name);
};
-#endif /*DEBUGDUMP_H_*/
+/**
+ * Deletes particular debugdump directory.
+ * @param pDebugDumpDir A debugdump directory.
+ */
+void delete_debug_dump_dir(const char *pDebugDumpDir);
+
+#endif
diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am
index f0b4481..427e437 100644
--- a/lib/Utils/Makefile.am
+++ b/lib/Utils/Makefile.am
@@ -1,5 +1,5 @@
# ABRTUtils has small set of deps. This reduces deps of smaller abrt binaries
-# ABRTdUtils has more. It is used by daemon and plugins only
+# ABRTdUtils has much more. It is used by daemon and plugins only
lib_LTLIBRARIES = libABRTUtils.la libABRTdUtils.la
# Not used just yet:
@@ -8,7 +8,6 @@ lib_LTLIBRARIES = libABRTUtils.la libABRTdUtils.la
# removed: CrashTypesSocket.cpp
libABRTUtils_la_SOURCES = \
- stringops.cpp \
xfuncs.cpp \
encbase64.cpp \
read_write.cpp \
@@ -16,6 +15,8 @@ libABRTUtils_la_SOURCES = \
copyfd.cpp \
skip_whitespace.cpp \
popen_and_save_output.cpp \
+ stringops.cpp \
+ dirsize.cpp \
DebugDump.h DebugDump.cpp
libABRTUtils_la_CPPFLAGS = \
-Wall -Werror \
@@ -35,10 +36,11 @@ libABRTUtils_la_LIBADD =
libABRTdUtils_la_SOURCES = \
parse_release.cpp \
+ make_descr.cpp \
CommLayerInner.h CommLayerInner.cpp \
abrt_dbus.h abrt_dbus.cpp \
abrt_xmlrpc.h abrt_xmlrpc.cpp \
- Plugin.h Plugin.cpp make_descr.cpp \
+ Plugin.h Plugin.cpp \
Polkit.h Polkit.cpp \
Action.h Database.h Reporter.h Analyzer.h \
Observer.h \
diff --git a/lib/Utils/dirsize.cpp b/lib/Utils/dirsize.cpp
new file mode 100644
index 0000000..739b6b7
--- /dev/null
+++ b/lib/Utils/dirsize.cpp
@@ -0,0 +1,100 @@
+/*
+ Copyright (C) 2009 Jiri Moskovcak (jmoskovc@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+#include "abrtlib.h"
+
+using namespace std;
+
+double get_dirsize(const char *pPath)
+{
+ DIR *dp = opendir(pPath);
+ if (dp == NULL)
+ return 0;
+
+ struct dirent *ep;
+ struct stat statbuf;
+ double size = 0;
+ while ((ep = readdir(dp)) != NULL)
+ {
+ if (dot_or_dotdot(ep->d_name))
+ continue;
+ string dname = concat_path_file(pPath, ep->d_name);
+ if (lstat(dname.c_str(), &statbuf) != 0)
+ continue;
+ if (S_ISDIR(statbuf.st_mode))
+ {
+ size += get_dirsize(dname.c_str());
+ }
+ else if (S_ISREG(statbuf.st_mode))
+ {
+ size += statbuf.st_size;
+ }
+ }
+ closedir(dp);
+ return size;
+}
+
+double get_dirsize_find_largest_dir(
+ const char *pPath,
+ string *worst_dir,
+ const char *excluded)
+{
+ DIR *dp = opendir(pPath);
+ if (dp == NULL)
+ return 0;
+
+ struct dirent *ep;
+ struct stat statbuf;
+ double size = 0;
+ double maxsz = 0;
+ while ((ep = readdir(dp)) != NULL)
+ {
+ if (dot_or_dotdot(ep->d_name))
+ continue;
+ string dname = concat_path_file(pPath, ep->d_name);
+ if (lstat(dname.c_str(), &statbuf) != 0)
+ continue;
+ if (S_ISDIR(statbuf.st_mode))
+ {
+ double sz = get_dirsize(dname.c_str());
+ size += sz;
+
+ if (worst_dir && (!excluded || strcmp(excluded, ep->d_name) != 0))
+ {
+ /* Calculate "weighted" size and age
+ * w = sz_kbytes * age_mins */
+ sz /= 1024;
+ long age = (time(NULL) - statbuf.st_mtime) / 60;
+ if (age > 0)
+ sz *= age;
+
+ if (sz > maxsz)
+ {
+ maxsz = sz;
+ *worst_dir = ep->d_name;
+ }
+ }
+ }
+ else if (S_ISREG(statbuf.st_mode))
+ {
+ size += statbuf.st_size;
+ }
+ }
+ closedir(dp);
+ return size;
+}
diff --git a/lib/Utils/parse_release.cpp b/lib/Utils/parse_release.cpp
index 33d3edb..b96cab7 100644
--- a/lib/Utils/parse_release.cpp
+++ b/lib/Utils/parse_release.cpp
@@ -11,6 +11,7 @@ void parse_release(const char *pRelease, string& pProduct, string& pVersion)
{
pProduct = "Fedora";
pVersion = "rawhide";
+ VERB3 log("%s:Version is '%s' and product is '%s'",__func__, pVersion.c_str(), pProduct.c_str());
return;
}
if (strstr(pRelease, "Fedora"))
@@ -35,4 +36,5 @@ void parse_release(const char *pRelease, string& pProduct, string& pVersion)
}
space++;
}
+ VERB3 log("%s:Version is '%s' and product is '%s'",__func__, pVersion.c_str(), pProduct.c_str());
}
diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp
index 97c2f76..4b208a9 100644
--- a/lib/Utils/xfuncs.cpp
+++ b/lib/Utils/xfuncs.cpp
@@ -368,3 +368,14 @@ bool string_to_bool(const char *s)
return true;
return false;
}
+
+bool xgetpwnam(const char* login, uid_t *uid)
+{
+ struct passwd* pwd = getpwnam(login);
+ if (pwd == NULL)
+ return false;
+
+ *uid = pwd->pw_uid;
+ return true;
+}
+
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp
index f859515..b82823c 100644
--- a/src/Daemon/CrashWatcher.cpp
+++ b/src/Daemon/CrashWatcher.cpp
@@ -20,6 +20,7 @@
#include "abrtlib.h"
#include "Daemon.h"
#include "ABRTException.h"
+#include "DebugDump.h"
#include "CrashWatcher.h"
void CCrashWatcher::Status(const char *pMessage, const char* peer, uint64_t pJobID)
@@ -75,7 +76,7 @@ vector_crash_infos_t GetCrashInfos(const char *pUID)
error_msg("Can't open file in dump directory for UUID %s, deleting", uuid);
{
std::string debugDumpDir = DeleteCrashInfo(uuid, uid);
- DeleteDebugDumpDir(debugDumpDir.c_str());
+ delete_debug_dump_dir(debugDumpDir.c_str());
}
break;
default:
@@ -132,7 +133,7 @@ map_crash_report_t GetJobResult(const char* pUUID, const char* pUID, int force)
default:
error_msg("Corrupted crash with UUID %s, deleting", pUUID);
std::string debugDumpDir = DeleteCrashInfo(pUUID, pUID);
- DeleteDebugDumpDir(debugDumpDir.c_str());
+ delete_debug_dump_dir(debugDumpDir.c_str());
break;
}
return crashReport;
@@ -211,7 +212,7 @@ bool DeleteDebugDump(const char *pUUID, const char *pUID)
try
{
std::string debugDumpDir = DeleteCrashInfo(pUUID, pUID);
- DeleteDebugDumpDir(debugDumpDir.c_str());
+ delete_debug_dump_dir(debugDumpDir.c_str());
}
catch (CABRTException& e)
{
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index 087d537..0e80c25 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -41,6 +41,7 @@
#include "abrtlib.h"
#include "ABRTException.h"
#include "CrashWatcher.h"
+#include "DebugDump.h"
#include "Daemon.h"
@@ -118,53 +119,6 @@ static bool s_exiting;
CCommLayerServer* g_pCommLayer;
-static double GetDirSize(const std::string &pPath, std::string *worst_dir = NULL, const char *excluded = NULL)
-{
- DIR *dp = opendir(pPath.c_str());
- if (dp == NULL)
- return 0;
-
- struct dirent *ep;
- struct stat stats;
- double size = 0;
- double maxsz = 0;
- while ((ep = readdir(dp)) != NULL)
- {
- if (dot_or_dotdot(ep->d_name))
- continue;
- std::string dname = pPath + "/" + ep->d_name;
- if (lstat(dname.c_str(), &stats) != 0)
- continue;
- if (S_ISDIR(stats.st_mode))
- {
- double sz = GetDirSize(dname);
- size += sz;
-
- if (worst_dir && strcmp(excluded, ep->d_name) != 0)
- {
- /* Calculate "weighted" size and age
- * w = sz_kbytes * age_mins */
- sz /= 1024;
- long age = (time(NULL) - stats.st_mtime) / 60;
- if (age > 0)
- sz *= age;
-
- if (sz > maxsz)
- {
- maxsz = sz;
- *worst_dir = ep->d_name;
- }
- }
- }
- else if (S_ISREG(stats.st_mode))
- {
- size += stats.st_size;
- }
- }
- closedir(dp);
- return size;
-}
-
static void cron_delete_callback_data_cb(gpointer data)
{
cron_callback_data_t* cronDeleteCallbackData = static_cast<cron_callback_data_t*>(data);
@@ -385,7 +339,7 @@ static void FindNewDumps(const char* pPath)
case MW_REPORTED:
case MW_OCCURED:
VERB1 log("Already saved crash %s, deleting", itt->c_str());
- DeleteDebugDumpDir(itt->c_str());
+ delete_debug_dump_dir(itt->c_str());
break;
case MW_BLACKLISTED:
case MW_CORRUPTED:
@@ -394,7 +348,7 @@ static void FindNewDumps(const char* pPath)
case MW_FILE_ERROR:
default:
log("Corrupted or bad crash %s (res:%d), deleting", itt->c_str(), (int)res);
- DeleteDebugDumpDir(itt->c_str());
+ delete_debug_dump_dir(itt->c_str());
break;
}
}
@@ -513,12 +467,12 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
std::string worst_dir;
while (g_settings_nMaxCrashReportsSize > 0
- && GetDirSize(DEBUG_DUMPS_DIR, &worst_dir, name) / (1024*1024) >= g_settings_nMaxCrashReportsSize
+ && get_dirsize_find_largest_dir(DEBUG_DUMPS_DIR, &worst_dir, name) / (1024*1024) >= g_settings_nMaxCrashReportsSize
&& worst_dir != ""
) {
log("Size of '%s' >= %u MB, deleting '%s'", DEBUG_DUMPS_DIR, g_settings_nMaxCrashReportsSize, worst_dir.c_str());
g_pCommLayer->QuotaExceed(_("Report size exceeded the quota. Please check system's MaxCrashReportsSize value in abrt.conf."));
- DeleteDebugDumpDir(concat_path_file(DEBUG_DUMPS_DIR, worst_dir.c_str()).c_str());
+ delete_debug_dump_dir(concat_path_file(DEBUG_DUMPS_DIR, worst_dir.c_str()).c_str());
worst_dir = "";
}
@@ -540,6 +494,28 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
log("Already saved crash, just sending dbus signal");
/* 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()))
+ {
+ map_crash_report_t crash_report;
+ VERB3 log("Create autoreport for user with uid %s",crashinfo[CD_UID][CD_CONTENT].c_str());
+ mw_result_t crash_result = CreateCrashReport(crashinfo[CD_UUID][CD_CONTENT].c_str(), crashinfo[CD_UID][CD_CONTENT].c_str(), 0, crash_report);
+ if (crash_result == MW_OK)
+ {
+ map_analyzer_actions_and_reporters_t::const_iterator it = g_settings_mapAnalyzerActionsAndReporters.find("Kerneloops");
+ map_analyzer_actions_and_reporters_t::const_iterator end = g_settings_mapAnalyzerActionsAndReporters.end();
+ if (it != end)
+ {
+ vector_pair_string_string_t keys = it->second;
+
+ uint32_t size = keys.size();
+ for (uint32_t ii = 0; ii < size; ii++)
+ {
+ autoreport(keys[ii], crash_report);
+ }
+ }
+ }
+ }
const char *uid_str = analyzer_has_InformAllUsers(crashinfo[CD_MWANALYZER][CD_CONTENT].c_str())
? NULL
: crashinfo[CD_UID][CD_CONTENT].c_str();
@@ -554,7 +530,7 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
case MW_FILE_ERROR:
default:
log("Corrupted or bad crash, deleting");
- DeleteDebugDumpDir(fullname.c_str());
+ delete_debug_dump_dir(fullname.c_str());
break;
}
}
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index f3c6bdf..69d36bf 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -520,13 +520,6 @@ report_status_t Report(const map_crash_report_t& pCrashReport,
return ret;
}
-void DeleteDebugDumpDir(const char *pDebugDumpDir)
-{
- CDebugDump dd;
- dd.Open(pDebugDumpDir);
- dd.Delete();
-}
-
std::string DeleteCrashInfo(const char *pUUID,
const char *pUID)
{
@@ -661,6 +654,55 @@ bool analyzer_has_InformAllUsers(const char *analyzer_name)
return string_to_bool(it->second.c_str());
}
+bool analyzer_has_AutoReportUIDs(const char *analyzer_name, const char* uid)
+{
+ CAnalyzer* analyzer = g_pPluginManager->GetAnalyzer(analyzer_name);
+ if (!analyzer)
+ {
+ VERB1 log("Strange, asked for analyzer %s but it doesn't exist?", analyzer_name);
+ return false;
+ }
+ map_plugin_settings_t settings = analyzer->GetSettings();
+ map_plugin_settings_t::const_iterator it = settings.find("AutoReportUIDs");
+ if (it == settings.end())
+ return false;
+
+ vector_string_t logins;
+ parse_args(it->second.c_str(), logins);
+
+ uint32_t size = logins.size();
+ 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))
+ continue;
+
+ if (strcmp(uid, to_string(id).c_str()) == 0)
+ return true;
+ }
+
+ return false;
+}
+
+void autoreport(const pair_string_string_t& reporter_options, const map_crash_report_t& crash_report)
+{
+ CReporter* reporter = g_pPluginManager->GetReporter(reporter_options.first.c_str());
+ if (!reporter)
+ {
+ VERB1 log("Strange, asked for reporter %s but it doesn't exist?", reporter_options.first.c_str());
+ return;
+ }
+
+ map_plugin_settings_t plugin_settings;
+ std::string res = reporter->Report(crash_report, plugin_settings, reporter_options.second);
+}
+
/**
* Execute all action plugins, which are associated to
* particular analyzer plugin.
diff --git a/src/Daemon/MiddleWare.h b/src/Daemon/MiddleWare.h
index ac042de..3de287b 100644
--- a/src/Daemon/MiddleWare.h
+++ b/src/Daemon/MiddleWare.h
@@ -105,11 +105,6 @@ report_status_t Report(const map_crash_report_t& pCrashReport,
std::string getDebugDumpDir( const char *pUUID,
const char *pUID);
/**
- * Deletes particular debugdump directory.
- * @param pDebugDumpDir A debugdump directory.
- */
-void DeleteDebugDumpDir(const char *pDebugDumpDir);
-/**
* Deletes a row from database. If a deleting is
* successfull, it returns a debugdump directort, which is not
* deleted. Otherwise, it returns empty string.
@@ -167,4 +162,7 @@ void AddActionOrReporter(const char *pActionOrReporter,
bool analyzer_has_InformAllUsers(const char *analyzer_name);
+bool analyzer_has_AutoReportUIDs(const char *analyzer_name, const char* uid);
+
+void autoreport(const pair_string_string_t& reporter_options, const map_crash_report_t& crash_report);
#endif /*MIDDLEWARE_H_*/
diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp
index 138d0d6..78a2471 100644
--- a/src/Hooks/CCpp.cpp
+++ b/src/Hooks/CCpp.cpp
@@ -17,7 +17,15 @@
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
+*/
+
+/* Make all file ops "large" and make off_t 64-bit.
+ * No need to use O_LORGEFILE anywhere
+ */
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+#define _FILE_OFFSET_BITS 64
+
#include "abrtlib.h"
#include "DebugDump.h"
#include "ABRTException.h"
@@ -29,13 +37,14 @@
#define VAR_RUN_PID_FILE VAR_RUN"/abrt.pid"
-static char* get_executable(pid_t pid)
+using namespace std;
+
+static char* malloc_readlink(const char *linkname)
{
char buf[PATH_MAX + 1];
int len;
- snprintf(buf, sizeof(buf), "/proc/%u/exe", (int)pid);
- len = readlink(buf, buf, sizeof(buf)-1);
+ len = readlink(linkname, buf, sizeof(buf)-1);
if (len >= 0)
{
buf[len] = '\0';
@@ -44,6 +53,22 @@ static char* get_executable(pid_t pid)
return NULL;
}
+static char* get_executable(pid_t pid)
+{
+ char buf[sizeof("/proc/%u/exe") + sizeof(int)*3];
+
+ sprintf(buf, "/proc/%u/exe", (int)pid);
+ return malloc_readlink(buf);
+}
+
+static char* get_cwd(pid_t pid)
+{
+ char buf[sizeof("/proc/%u/cwd") + sizeof(int)*3];
+
+ sprintf(buf, "/proc/%u/cwd", (int)pid);
+ return malloc_readlink(buf);
+}
+
static char *append_escaped(char *start, const char *s)
{
char hex_char_buf[] = "\\x00";
@@ -133,18 +158,18 @@ static char* get_cmdline(pid_t pid)
static int daemon_is_ok()
{
- char pid[sizeof(pid_t)*3 + 2];
- char path[PATH_MAX];
- struct stat buff;
int fd = open(VAR_RUN_PID_FILE, O_RDONLY);
if (fd < 0)
{
return 0;
}
+
+ char pid[sizeof(pid_t)*3 + 2];
int len = read(fd, pid, sizeof(pid)-1);
close(fd);
if (len <= 0)
return 0;
+
pid[len] = '\0';
*strchrnul(pid, '\n') = '\0';
/* paranoia: we don't want to check /proc//stat or /proc///stat */
@@ -152,8 +177,10 @@ static int daemon_is_ok()
return 0;
/* TODO: maybe readlink and check that it is "xxx/abrt"? */
- snprintf(path, sizeof(path), "/proc/%s/stat", pid);
- if (stat(path, &buff) == -1)
+ char path[sizeof("/proc/%s/stat") + sizeof(pid)];
+ sprintf(path, "/proc/%s/stat", pid);
+ struct stat sb;
+ if (stat(path, &sb) == -1)
{
return 0;
}
@@ -190,6 +217,10 @@ int main(int argc, char** argv)
{
error_msg_and_die("pid '%s' or uid '%s' are bogus", argv[2], argv[4]);
}
+
+ char *user_pwd = get_cwd(pid); /* may be NULL on error */
+ int core_fd = STDIN_FILENO;
+
if (!daemon_is_ok())
{
/* not an error, exit with exitcode 0 */
@@ -197,7 +228,7 @@ int main(int argc, char** argv)
"/proc/sys/kernel/core_pattern contains a stale value, "
"consider resetting it to 'core'"
);
- return 0;
+ goto create_user_core;
}
try
@@ -223,9 +254,9 @@ int main(int argc, char** argv)
* On the contrary, mere files are ignored by abrtd.
*/
snprintf(path, sizeof(path), "%s/abrtd-coredump", dddir);
- int fd = xopen3(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
- off_t size = copyfd_eof(STDIN_FILENO, fd);
- if (size < 0 || close(fd) != 0)
+ core_fd = xopen3(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ off_t size = copyfd_eof(STDIN_FILENO, core_fd);
+ if (size < 0 || close(core_fd) != 0)
{
unlink(path);
/* copyfd_eof logs the error including errno string,
@@ -236,16 +267,6 @@ int main(int argc, char** argv)
return 0;
}
- /* rhbz#539551: "abrt going crazy when crashing process is respawned".
- * Do we want to protect against or ameliorate this? How? Ideas:
- * (1) nice ourself?
- * (2) check total size of dump dir, if it overflows, either abort dump
- * or delete oldest/biggest dumps? [abort would be simpler,
- * abrtd already does "delete on overflow" thing]
- * (3) detect parallel dumps in progress and back off
- * (pause/renice further/??)
- */
-
char* cmdline = get_cmdline(pid); /* never NULL */
const char *signame = strsignal(atoi(signal_str));
char *reason = xasprintf("Process was terminated by signal %s (%s)", signal_str, signame ? signame : signal_str);
@@ -262,18 +283,19 @@ int main(int argc, char** argv)
snprintf(path + len, sizeof(path) - len, "/"FILENAME_COREDUMP);
/* We need coredumps to be readable by all, because
- * process producing backtraces is run under the same UID
+ * when abrt daemon processes coredump,
+ * process producing backtrace is run under the same UID
* as the crashed process.
* Thus 644, not 600 */
- int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if (fd < 0)
+ core_fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644);
+ if (core_fd < 0)
{
dd.Delete();
dd.Close();
perror_msg_and_die("can't open '%s'", path);
}
- off_t size = copyfd_eof(STDIN_FILENO, fd);
- if (size < 0 || close(fd) != 0)
+ off_t size = copyfd_eof(STDIN_FILENO, core_fd);
+ if (size < 0 || fsync(core_fd) != 0)
{
unlink(path);
dd.Delete();
@@ -282,10 +304,108 @@ int main(int argc, char** argv)
* but it does not log file name */
error_msg_and_die("error saving coredump to %s", path);
}
- /* free(executable); - why bother? */
- /* free(cmdline); */
+ lseek(core_fd, 0, SEEK_SET);
+ /* note: core_fd is still open, we may use it later to copy core to user's dir */
+ free(executable);
+ free(cmdline);
log("saved core dump of pid %u to %s (%llu bytes)", (int)pid, path, (long long)size);
- return 0;
+ path[len] = '\0'; /* path now contains directory name */
+
+ /* We close dumpdir before we start catering for crash storm case.
+ * Otherwise, delete_debug_dump_dir's from other concurrent
+ * CCpp's won't be able to delete our dump (their delete_debug_dump_dir
+ * will wait for us), and we won't be able to delete their dumps.
+ * Classic deadlock.
+ */
+ dd.Close();
+
+ /* Parse abrt.conf and plugins/CCpp.conf */
+ unsigned setting_MaxCrashReportsSize = 0;
+ bool setting_MakeCompatCore = false;
+ bool abrt_conf = true;
+ FILE *fp = fopen(CONF_DIR"/abrt.conf", "r");
+ if (fp)
+ {
+ char line[256];
+ while (1)
+ {
+ if (fgets(line, sizeof(line), fp) == NULL)
+ {
+ /* Next .conf file plz */
+ if (abrt_conf)
+ {
+ abrt_conf = false;
+ fp = fopen(CONF_DIR"/plugins/CCpp.conf", "r");
+ if (fp)
+ continue;
+ }
+ break;
+ }
+
+ unsigned len = strlen(line);
+ if (len > 0 && line[len-1] == '\n')
+ line[--len] = '\0';
+ const char *p = skip_whitespace(line);
+#undef DIRECTIVE
+#define DIRECTIVE "MaxCrashReportsSize"
+ if (strncmp(p, DIRECTIVE, sizeof(DIRECTIVE)-1) == 0)
+ {
+ p = skip_whitespace(p + sizeof(DIRECTIVE)-1);
+ if (*p != '=')
+ continue;
+ p = skip_whitespace(p + 1);
+ if (isdigit(*p))
+ /* x1.25: go a bit up, so that usual in-daemon trimming
+ * kicks in first, and we don't "fight" with it. */
+ setting_MaxCrashReportsSize = (unsigned long)atoi(p) * 5 / 4;
+ continue;
+ }
+#undef DIRECTIVE
+#define DIRECTIVE "MakeCompatCore"
+ if (strncmp(p, DIRECTIVE, sizeof(DIRECTIVE)-1) == 0)
+ {
+ p = skip_whitespace(p + sizeof(DIRECTIVE)-1);
+ if (*p != '=')
+ continue;
+ p = skip_whitespace(p + 1);
+ setting_MakeCompatCore = string_to_bool(p);
+ continue;
+ }
+#undef DIRECTIVE
+ /* add more 'if (strncmp(p, DIRECTIVE, sizeof(DIRECTIVE)-1) == 0)' here... */
+ }
+ fclose(fp);
+ }
+
+ /* rhbz#539551: "abrt going crazy when crashing process is respawned".
+ * Do we want to protect against or ameliorate this? How? Ideas:
+ * (1) nice ourself?
+ * (2) check total size of dump dir, if it overflows, either abort dump
+ * or delete oldest/biggest dumps? [abort would be simpler,
+ * abrtd already does "delete on overflow" thing]
+ * (3) detect parallel dumps in progress and back off
+ * (pause/renice further/??)
+ */
+
+ if (setting_MaxCrashReportsSize > 0)
+ {
+ string worst_dir;
+ while (1)
+ {
+ const char *base_dirname = strrchr(path, '/') + 1; /* never NULL */
+ /* We exclude our own dump from candidates for deletion (3rd param): */
+ double dirsize = get_dirsize_find_largest_dir(DEBUG_DUMPS_DIR, &worst_dir, base_dirname);
+ if (dirsize / (1024*1024) < setting_MaxCrashReportsSize || worst_dir == "")
+ break;
+ log("size of '%s' >= %u MB, deleting '%s'", DEBUG_DUMPS_DIR, setting_MaxCrashReportsSize, worst_dir.c_str());
+ delete_debug_dump_dir(concat_path_file(DEBUG_DUMPS_DIR, worst_dir.c_str()).c_str());
+ worst_dir = "";
+ }
+ }
+
+ if (!setting_MakeCompatCore)
+ return 0;
+ /* fall through to creating user core */
}
catch (CABRTException& e)
{
@@ -295,5 +415,86 @@ int main(int argc, char** argv)
{
error_msg_and_die("%s", e.what());
}
+
+ create_user_core:
+ /* Write a core file for user */
+
+ errno = 0;
+ if (setuid(uid) != 0
+ || user_pwd == NULL
+ || chdir(user_pwd) != 0
+ ) {
+ perror_msg_and_die("can't cd to %s", user_pwd);
+ }
+
+ /* 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);
+ if (fd >= 0)
+ {
+ read(fd, buf, sizeof(buf));
+ close(fd);
+ }
+ if (strcmp(buf, "1\n") == 0)
+ {
+ sprintf(core_basename, "core.%u", (int)pid);
+ }
+
+ /* man core:
+ * There are various circumstances in which a core dump file
+ * is not produced:
+ *
+ * [skipped obvious ones]
+ * The process does not have permission to write the core file.
+ * ...if a file with the same name exists and is not writable
+ * or is not a regular file (e.g., it is a directory or a symbolic link).
+ *
+ * A file with the same name already exists, but there is more
+ * than one hard link to that file.
+ *
+ * The file system where the core dump file would be created is full;
+ * or has run out of inodes; or is mounted read-only;
+ * or the user has reached their quota for the file system.
+ *
+ * The RLIMIT_CORE or RLIMIT_FSIZE resource limits for the process
+ * are set to zero.
+ * [shouldn't it be checked by kernel? 2.6.30.9-96 doesn't, still
+ * calls us even if "ulimit -c 0"]
+ *
+ * The binary being executed by the process does not have
+ * read permission enabled. [how we can check it here?]
+ *
+ * The process is executing a set-user-ID (set-group-ID) program
+ * that is owned by a user (group) other than the real
+ * user (group) ID of the process. [TODO?]
+ * (However, see the description of the prctl(2) PR_SET_DUMPABLE operation,
+ * and the description of the /proc/sys/fs/suid_dumpable file in proc(5).)
+ */
+
+ /* 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)
+ || sb.st_nlink != 1
+ /* kernel internal dumper checks this too: if (inode->i_uid != current->fsuid) <fail>, need to mimic? */
+ ) {
+ perror_msg_and_die("%s/%s is not a regular file with link count 1", user_pwd, core_basename);
+ }
+
+ if (ftruncate(usercore_fd, 0) != 0
+ || copyfd_eof(core_fd, usercore_fd) < 0
+ || close(usercore_fd) != 0
+ ) {
+ /* perror first, otherwise unlink may trash errno */
+ perror_msg("write error writing %s/%s", user_pwd, core_basename);
+ unlink(core_basename);
+ return 1;
+ }
+ log("saved core dump of pid %u to %s/%s", (int)pid, user_pwd, core_basename);
+
return 0;
}
diff --git a/src/Hooks/Makefile.am b/src/Hooks/Makefile.am
index 026d4cf..c643b24 100644
--- a/src/Hooks/Makefile.am
+++ b/src/Hooks/Makefile.am
@@ -8,6 +8,7 @@ hookCCpp_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 = \
@@ -38,6 +39,7 @@ abrt_pyhook_helper_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
abrt_pyhook_helper_LDADD = \
diff --git a/src/Hooks/sitecustomize.py b/src/Hooks/sitecustomize.py
index 5787c03..71d8c4e 100644
--- a/src/Hooks/sitecustomize.py
+++ b/src/Hooks/sitecustomize.py
@@ -21,6 +21,7 @@ try:
# this should strip
line = config.readline().lower().replace(' ','').strip('\n').split('=')
conf[line[0]] = line[1]
+ config.close()
except:
# Ignore silently everything, because we don't want to bother user
# if this hook doesn't work.