diff options
| author | Karel Klic <kklic@redhat.com> | 2009-11-30 15:07:45 +0100 |
|---|---|---|
| committer | Karel Klic <kklic@redhat.com> | 2009-11-30 15:07:45 +0100 |
| commit | c6fef68305a7bc2df55afc4d682317a05a8dfe97 (patch) | |
| tree | 0332579a85acd6530b8b9dcbf29dc56187b565ea /lib | |
| parent | f58611ea5957462e6be40950684a56579a2459a6 (diff) | |
| parent | f0bd70b3f68835983a10052337fc316a9f861811 (diff) | |
| download | abrt-c6fef68305a7bc2df55afc4d682317a05a8dfe97.tar.gz abrt-c6fef68305a7bc2df55afc4d682317a05a8dfe97.tar.xz abrt-c6fef68305a7bc2df55afc4d682317a05a8dfe97.zip | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Plugins/Bugzilla.cpp | 4 | ||||
| -rw-r--r-- | lib/Plugins/CCpp.conf | 11 | ||||
| -rw-r--r-- | lib/Plugins/CCpp.cpp | 2 | ||||
| -rw-r--r-- | lib/Plugins/Catcut.cpp | 18 | ||||
| -rw-r--r-- | lib/Plugins/Kerneloops.conf | 2 | ||||
| -rw-r--r-- | lib/Plugins/KerneloopsReporter.cpp | 2 | ||||
| -rw-r--r-- | lib/Utils/DebugDump.cpp | 47 | ||||
| -rw-r--r-- | lib/Utils/DebugDump.h | 8 | ||||
| -rw-r--r-- | lib/Utils/Makefile.am | 8 | ||||
| -rw-r--r-- | lib/Utils/dirsize.cpp | 100 | ||||
| -rw-r--r-- | lib/Utils/parse_release.cpp | 2 | ||||
| -rw-r--r-- | lib/Utils/xfuncs.cpp | 11 |
12 files changed, 178 insertions, 37 deletions
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; +} + |
