diff options
author | Karel Klic <kklic@redhat.com> | 2009-12-18 19:12:50 +0100 |
---|---|---|
committer | Karel Klic <kklic@redhat.com> | 2009-12-18 19:12:50 +0100 |
commit | e7661d7e411172ddad8838040ded025ad6bfbb14 (patch) | |
tree | f2451b553b4fcf959bd2bfc29172f9fb855e5fdd | |
parent | ce1904e24b576a7356488852a240d777717b2598 (diff) | |
parent | 46b2fb8df8d4e025f5bbdd9f53be1f658a9e82c6 (diff) | |
download | abrt-e7661d7e411172ddad8838040ded025ad6bfbb14.tar.gz abrt-e7661d7e411172ddad8838040ded025ad6bfbb14.tar.xz abrt-e7661d7e411172ddad8838040ded025ad6bfbb14.zip |
Merge branch 'master' of git://git.fedorahosted.org/git/abrt
36 files changed, 728 insertions, 487 deletions
@@ -3,7 +3,7 @@ %{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} Summary: Automatic bug detection and reporting tool Name: abrt -Version: 1.0.1 +Version: 1.0.2 Release: 1%{?dist} License: GPLv2+ Group: Applications/System @@ -398,6 +398,21 @@ fi %defattr(-,root,root,-) %changelog +* Mon Dec 14 2009 Jiri Moskovcak <jmoskovc@redhat.com> 1.0.2-1 +- disabled GPG check again (jmoskovc@redhat.com) +- abrt-pyhook-helper rename (vda.linux@googlemail.com) +- abrt-cli: report success/failure of reporting. closes bug 71 (vda.linux@googlemail.com) +- less logging (vda.linux@googlemail.com) +- mkde abrt-gui --help and --version behave as expected. closes bug 85 (vda.linux@googlemail.com) +- dbus lib: fix parsing of 0-element arrays. Fixes bug 95 (vda.linux@googlemail.com) +- make "abrt-cli --delete randomuuid" report that deletion failed. closes bug 59 (vda.linux@googlemail.com) +- applet: make animation stop after 1 minute. (closes bug 108) (vda.linux@googlemail.com) +- show comment and how to reproduce fields, when BT rating > 3 (jmoskovc@redhat.com) +- Gui: make report status window's text wrap. Fixes bug 82 (vda.linux@googlemail.com) +- CCpp analyzer: added "info sharedlib" (https://fedorahosted.org/abrt/ticket/90) (vda.linux@googlemail.com) +- added link to bugzilla new account page to Bugzilla config dialog (jmoskovc@redhat.com) +- GUI: added log window (jmoskovc@redhat.com) + * Tue Dec 8 2009 Jiri Moskovcak <jmoskovc@redhat.com> 1.0.1-1 - PyHook: better logic for checking if abrtd is running rhbz#539987 (jmoskovc@redhat.com) - re-enabled gpg sign checking (jmoskovc@redhat.com) diff --git a/configure.ac b/configure.ac index 7ba2c671..5893c841 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([abrt], [1.0.1], [crash-catcher@fedorahosted.org]) +AC_INIT([abrt], [1.0.2], [crash-catcher@fedorahosted.org]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) @@ -10,6 +10,10 @@ AC_ARG_ENABLE(debug, AC_DISABLE_STATIC AC_PROG_LIBTOOL AC_PROG_CXX + +AC_SYS_LARGEFILE +CXXFLAGS="$CXXFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" + AC_CHECK_PROGS(YACC, 'bison -y', [no]) [if test "$YACC" = "no"] [then] diff --git a/inc/abrtlib.h b/inc/abrtlib.h index 17bd5429..28140d80 100644 --- a/inc/abrtlib.h +++ b/inc/abrtlib.h @@ -102,6 +102,15 @@ char* xstrndup(const char *s, int n); char* skip_whitespace(const char *s); char* skip_non_whitespace(const char *s); +unsigned xatou(const char *numstr); +int xatoi(const char *numstr); +/* Using xatoi() instead of naive atoi() is not always convenient - + * in many places people want *non-negative* values, but store them + * in signed int. Therefore we need this one: + * dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc */ +int xatoi_u(const char *numstr); + + extern ssize_t safe_read(int fd, void *buf, size_t count); // NB: will return short read on error, not -1, // if some data was read before error occurred @@ -201,6 +210,16 @@ char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa); /* Random utility functions */ uid_t getuidbyname(const char* login); +/* Returns command line of running program. + * Caller is responsible to free() the returned value. + * If the pid is not valid or command line can not be obtained, + * empty string is returned. + */ +char* get_cmdline(pid_t pid); + +/* Returns 1 if abrtd daemon is running, 0 otherwise. */ +int daemon_is_ok(); + /* Returns malloc'ed block */ char *encode_base64(const void *src, int length); bool dot_or_dotdot(const char *filename); diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 37a2c8bc..99c1c770 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -37,7 +37,7 @@ using namespace std; #define CORE_PATTERN_IFACE "/proc/sys/kernel/core_pattern" -#define CORE_PATTERN "|"CCPP_HOOK_PATH" "DEBUG_DUMPS_DIR" %p %s %u" +#define CORE_PATTERN "|"CCPP_HOOK_PATH" "DEBUG_DUMPS_DIR" %p %s %u %c" #define FILENAME_COREDUMP "coredump" #define FILENAME_BACKTRACE "backtrace" @@ -96,7 +96,7 @@ static string concat_str_vector(char **strings) } /* Returns status. See `man 2 wait` for status information. */ -static int ExecVP(char **pArgs, uid_t uid, string& pOutput) +static int ExecVP(char **pArgs, uid_t uid, int redirect_stderr, string& pOutput) { int pipeout[2]; pid_t child; @@ -114,8 +114,6 @@ static int ExecVP(char **pArgs, uid_t uid, string& pOutput) xmove_fd(pipeout[1], STDOUT_FILENO); /* Make sure stdin is safely open to nothing */ xmove_fd(xopen("/dev/null", O_RDONLY), STDIN_FILENO); - /* Not a good idea, we won't see any error messages */ - /* close(STDERR_FILENO); */ struct passwd* pw = getpwuid(uid); gid_t gid = pw ? pw->pw_gid : uid; @@ -136,6 +134,11 @@ static int ExecVP(char **pArgs, uid_t uid, string& pOutput) unsetenv("LC_NUMERIC"); unsetenv("LC_TIME"); + if (redirect_stderr) + { + /* We want parent to see errors in the same stream */ + xdup2(STDOUT_FILENO, STDERR_FILENO); + } execvp(pArgs[0], pArgs); /* VERB1 since sometimes we expect errors here */ VERB1 perror_msg("Can't execute '%s'", pArgs[0]); @@ -309,7 +312,7 @@ static void GetBacktrace(const char *pDebugDumpDir, args[11] = (char*)"info sharedlib"; args[12] = NULL; - ExecVP(args, atoi(UID.c_str()), pBacktrace); + ExecVP(args, xatoi_u(UID.c_str()), /*redirect_stderr:*/ 1, pBacktrace); } static void GetIndependentBuildIdPC(const char *unstrip_n_output, @@ -355,7 +358,7 @@ static string run_unstrip_n(const char *pDebugDumpDir) args[3] = NULL; string output; - ExecVP(args, atoi(UID.c_str()), output); + ExecVP(args, xatoi_u(UID.c_str()), /*redirect_stderr:*/ 0, output); free(args[1]); @@ -386,18 +389,18 @@ static void InstallDebugInfos(const char *pDebugDumpDir, close(pipeout[0]); xmove_fd(pipeout[1], STDOUT_FILENO); xmove_fd(xopen("/dev/null", O_RDONLY), STDIN_FILENO); - /* Not a good idea, we won't see any error messages */ - /*close(STDERR_FILENO);*/ - - setsid(); char *coredump = xasprintf("%s/"FILENAME_COREDUMP, pDebugDumpDir); /* SELinux guys are not happy with /tmp, using /var/run/abrt */ char *tempdir = xasprintf(LOCALSTATEDIR"/run/abrt/tmp-%u-%lu", (int)getpid(), (long)time(NULL)); /* log() goes to stderr/syslog, it's ok to use it here */ VERB1 log("Executing: %s %s %s %s", "abrt-debuginfo-install", coredump, tempdir, debuginfo_dirs); + /* We want parent to see errors in the same stream */ + xdup2(STDOUT_FILENO, STDERR_FILENO); execlp("abrt-debuginfo-install", "abrt-debuginfo-install", coredump, tempdir, debuginfo_dirs, NULL); - exit(1); + perror_msg("Can't execute '%s'", "abrt-debuginfo-install"); + /* Serious error (1 means "some debuginfos not found") */ + exit(2); } close(pipeout[1]); @@ -436,9 +439,20 @@ static void InstallDebugInfos(const char *pDebugDumpDir, update_client("%s", buff); } } - fclose(pipeout_fp); - wait(NULL); + + int status = 0; + while (waitpid(child, &status, 0) < 0 && errno == EINTR) + continue; + if (WIFEXITED(status)) + { + if (WEXITSTATUS(status) > 1) + error_msg("%s exited with %u", "abrt-debuginfo-install", (int)WEXITSTATUS(status)); + } + else + { + error_msg("%s killed by signal %u", "abrt-debuginfo-install", (int)WTERMSIG(status)); + } } static double get_dir_size(const char *dirname, @@ -564,7 +578,7 @@ string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir) close(pipeout[0]); /* read side of the pipe */ /* abrt-backtrace is executed under the user's uid and gid. */ - uid_t uid = atoi(uid_str.c_str()); + uid_t uid = xatoi_u(uid_str.c_str()); struct passwd* pw = getpwuid(uid); gid_t gid = pw ? pw->pw_gid : uid; setgroups(1, &gid); @@ -659,7 +673,7 @@ void CAnalyzerCCpp::CreateReport(const char *pDebugDumpDir, int force) dd.Close(); /* do not keep dir locked longer than needed */ string build_ids; - if (m_bInstallDebugInfo && DebuginfoCheckPolkit(atoi(UID.c_str()))) + if (m_bInstallDebugInfo && DebuginfoCheckPolkit(xatoi_u(UID.c_str()))) { if (m_nDebugInfoCacheMB > 0) { @@ -750,7 +764,7 @@ void CAnalyzerCCpp::SetSettings(const map_plugin_settings_t& pSettings) it = pSettings.find("DebugInfoCacheMB"); if (it != end) { - m_nDebugInfoCacheMB = atoi(it->second.c_str()); + m_nDebugInfoCacheMB = xatou(it->second.c_str()); } it = pSettings.find("InstallDebugInfo"); if (it == end) //compat, remove after 0.0.11 diff --git a/lib/Plugins/Catcut.cpp b/lib/Plugins/Catcut.cpp index ebddfdd3..a56015d2 100644 --- a/lib/Plugins/Catcut.cpp +++ b/lib/Plugins/Catcut.cpp @@ -1,6 +1,3 @@ -#include <xmlrpc-c/base.h> -#include <xmlrpc-c/client.h> -#include <curl/curl.h> #include "abrtlib.h" #include "abrt_xmlrpc.h" #include "Catcut.h" @@ -18,11 +15,7 @@ using namespace std; static int put_stream(const char *pURL, FILE* f, size_t content_length) { - CURL* curl = curl_easy_init(); - if (!curl) - { - throw CABRTException(EXCEP_PLUGIN, "put_stream: can't initialize curl library"); - } + CURL* curl = xcurl_easy_init(); /* enable uploading */ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); /* specify target */ @@ -510,12 +503,12 @@ void CReporterCatcut::SetSettings(const map_plugin_settings_t& pSettings) it = pSettings.find("RetryCount"); if (it != end) { - m_nRetryCount = atoi(it->second.c_str()); + m_nRetryCount = xatoi_u(it->second.c_str()); } it = pSettings.find("RetryDelay"); if (it != end) { - m_nRetryDelay = atoi(it->second.c_str()); + m_nRetryDelay = xatoi_u(it->second.c_str()); } } diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp index c98645cf..60e1e66b 100644 --- a/lib/Plugins/FileTransfer.cpp +++ b/lib/Plugins/FileTransfer.cpp @@ -35,8 +35,8 @@ #include <libtar.h> #include <bzlib.h> #include <zlib.h> -#include <curl/curl.h> #include "abrtlib.h" +#include "abrt_xmlrpc.h" /* for xcurl_easy_init */ #include "FileTransfer.h" #include "DebugDump.h" #include "ABRTException.h" @@ -85,11 +85,7 @@ void CFileTransfer::SendFile(const char *pURL, const char *pFilename) fclose(f); throw CABRTException(EXCEP_PLUGIN, "Can't stat archive file '%s'", pFilename); } - curl = curl_easy_init(); - if (!curl) - { - throw CABRTException(EXCEP_PLUGIN, "Curl library init error"); - } + curl = xcurl_easy_init(); /* enable uploading */ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); /* specify target */ @@ -388,13 +384,13 @@ void CFileTransfer::SetSettings(const map_plugin_settings_t& pSettings) it = pSettings.find("RetryCount"); if (it != end) { - m_nRetryCount = atoi(it->second.c_str()); + m_nRetryCount = xatoi_u(it->second.c_str()); } it = pSettings.find("RetryDelay"); if (it != end) { - m_nRetryDelay = atoi(it->second.c_str()); + m_nRetryDelay = xatoi_u(it->second.c_str()); } it = pSettings.find("ArchiveType"); diff --git a/lib/Plugins/Firefox.cpp b/lib/Plugins/Firefox.cpp index bcc59485..2bb7f9c5 100644 --- a/lib/Plugins/Firefox.cpp +++ b/lib/Plugins/Firefox.cpp @@ -281,7 +281,7 @@ static void GetBacktrace(const char *pDebugDumpDir, std::string& pBacktrace) args[9] = (char*)"thread apply all backtrace full"; args[10] = NULL; - ExecVP(args, atoi(UID.c_str()), pBacktrace); + ExecVP(args, xatoi_u(UID.c_str()), pBacktrace); free(args[5]); free(args[7]); @@ -454,7 +454,7 @@ static std::string run_unstrip_n(const char *pDebugDumpDir) args[3] = NULL; std::string output; - ExecVP(args, atoi(UID.c_str()), output); + ExecVP(args, xatoi_u(UID.c_str()), output); free(args[1]); @@ -886,7 +886,7 @@ void CAnalyzerFirefox::CreateReport(const char *pDebugDumpDir, int force) dd.Close(); /* do not keep dir locked longer than needed */ std::string build_ids; - if (m_bInstallDebugInfo && DebuginfoCheckPolkit(atoi(UID.c_str()))) { + if (m_bInstallDebugInfo && DebuginfoCheckPolkit(xatoi_u(UID.c_str()))) { if (m_nDebugInfoCacheMB > 0) trim_debuginfo_cache(m_nDebugInfoCacheMB); InstallDebugInfos(pDebugDumpDir, build_ids); @@ -974,7 +974,7 @@ void CAnalyzerFirefox::SetSettings(const map_plugin_settings_t& pSettings) it = pSettings.find("DebugInfoCacheMB"); if (it != end) { - m_nDebugInfoCacheMB = atoi(it->second.c_str()); + m_nDebugInfoCacheMB = xatou(it->second.c_str()); } it = pSettings.find("InstallDebugInfo"); if (it == end) //compat, remove after 0.0.11 diff --git a/lib/Plugins/Kerneloops.conf b/lib/Plugins/Kerneloops.conf index a0141533..56235969 100644 --- a/lib/Plugins/Kerneloops.conf +++ b/lib/Plugins/Kerneloops.conf @@ -1,15 +1,17 @@ -# compatibility with kerneloops.org tool +# Do we want kernel oopses to be visible to any user? +# Set to "yes" for compatibility with kerneloops.org tool. InformAllUsers = yes +# Automatically perform reporting. +# With default abrt.conf, it invokes KerneloopsReporter +# and thus reports oops to kerneloops.org. +# ("root" because all oopses are filed by abrt with user "root") AutoReportUIDs = root -# KerneloopsReporter configuration. Reports kernel crashes collected by the addon. -################################################################################ +# Kerneloops Scanner configuration +################################## +SysLogFile = /var/log/messages -# kerneloops.org +# KerneloopsReporter configuration +################################## SubmitURL = http://submit.kerneloops.org/submitoops.php - -# Kerneloops Scanner configuration. -################################################################################ - -SysLogFile = /var/log/messages diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp index 26430be6..5cb525bc 100644 --- a/lib/Plugins/KerneloopsReporter.cpp +++ b/lib/Plugins/KerneloopsReporter.cpp @@ -25,9 +25,9 @@ */ #include "abrtlib.h" +#include "abrt_xmlrpc.h" /* for xcurl_easy_init */ #include "KerneloopsReporter.h" #include "CommLayerInner.h" -#include <curl/curl.h> #include "ABRTException.h" #define FILENAME_KERNELOOPS "kerneloops" @@ -64,7 +64,7 @@ static int http_post_to_kerneloops_site(const char *url, const char *oopsdata) struct curl_httppost *post = NULL; struct curl_httppost *last = NULL; - handle = curl_easy_init(); + handle = xcurl_easy_init(); curl_easy_setopt(handle, CURLOPT_URL, url); curl_formadd(&post, &last, diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index b06edebb..6904c169 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -163,7 +163,7 @@ std::string CMailx::Report(const map_crash_report_t& pCrashReport, update_client(_("Sending an email...")); const char *uid_str = pCrashReport.find(CD_MWUID)->second[CD_CONTENT].c_str(); - exec_and_feed_input(atoi(uid_str), emailBody.c_str(), args); + exec_and_feed_input(xatoi_u(uid_str), emailBody.c_str(), args); while (*args) { diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp index d95c273b..1979f246 100644 --- a/lib/Plugins/SQLite3.cpp +++ b/lib/Plugins/SQLite3.cpp @@ -198,9 +198,9 @@ static bool check_table(sqlite3 *db) if (pos != string::npos) { string tableVersion = tableName.substr(pos + 2); - if (atoi(tableVersion.c_str()) < ABRT_TABLE_VERSION) + if (xatoi_u(tableVersion.c_str()) < ABRT_TABLE_VERSION) { - update_from_old_ver(db, atoi(tableVersion.c_str())); + update_from_old_ver(db, xatoi_u(tableVersion.c_str())); } return true; } @@ -238,7 +238,18 @@ CSQLite3::CSQLite3() : CSQLite3::~CSQLite3() { - DisConnect(); + /* Paranoia. In C++, destructor will abort() if it was called while unwinding + * the stack and it throws an exception. + */ + try + { + DisConnect(); + m_sDBPath.clear(); + } + catch (...) + { + error_msg_and_die("Internal error"); + } } void CSQLite3::DisConnect() @@ -262,7 +273,7 @@ void CSQLite3::Connect() { if (ret != SQLITE_CANTOPEN) { - throw CABRTException(EXCEP_PLUGIN, "Can't open database: %s", sqlite3_errmsg(m_pDB)); + throw CABRTException(EXCEP_PLUGIN, "Can't open database '%s': %s", m_sDBPath.c_str(), sqlite3_errmsg(m_pDB)); } ret = sqlite3_open_v2(m_sDBPath.c_str(), @@ -272,7 +283,7 @@ void CSQLite3::Connect() ); if (ret != SQLITE_OK) { - throw CABRTException(EXCEP_PLUGIN, "Can't create database: %s", sqlite3_errmsg(m_pDB)); + throw CABRTException(EXCEP_PLUGIN, "Can't create database '%s': %s", m_sDBPath.c_str(), sqlite3_errmsg(m_pDB)); } } diff --git a/lib/Plugins/TicketUploader.cpp b/lib/Plugins/TicketUploader.cpp index 06b6cde8..a4fe0e87 100644 --- a/lib/Plugins/TicketUploader.cpp +++ b/lib/Plugins/TicketUploader.cpp @@ -20,8 +20,8 @@ #include <string> #include <fstream> #include <sstream> -#include <curl/curl.h> #include "abrtlib.h" +#include "abrt_xmlrpc.h" /* for xcurl_easy_init */ #include "TicketUploader.h" #include "DebugDump.h" #include "ABRTException.h" @@ -124,11 +124,7 @@ void CTicketUploader::SendFile(const char *pURL, const char *pFilename) { throw CABRTException(EXCEP_PLUGIN, "Can't stat archive file '%s'", pFilename); } - CURL* curl = curl_easy_init(); - if (!curl) - { - throw CABRTException(EXCEP_PLUGIN, "Curl library init error"); - } + CURL* curl = xcurl_easy_init(); /* enable uploading */ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); /* specify target */ @@ -394,12 +390,12 @@ void CTicketUploader::SetSettings(const map_plugin_settings_t& pSettings) it = pSettings.find("RetryCount"); if (it != end) { - m_nRetryCount = atoi(it->second.c_str()); + m_nRetryCount = xatoi_u(it->second.c_str()); } it = pSettings.find("RetryDelay"); if (it != end) { - m_nRetryDelay = atoi(it->second.c_str()); + m_nRetryDelay = xatoi_u(it->second.c_str()); } } diff --git a/lib/Utils/CrashTypesSocket.cpp b/lib/Utils/CrashTypesSocket.cpp index f16e2a9a..3525c6a5 100644 --- a/lib/Utils/CrashTypesSocket.cpp +++ b/lib/Utils/CrashTypesSocket.cpp @@ -114,7 +114,7 @@ static int get_number_from_string(const std::string& pMessage, int& len) } } len = ii + 1; - return atoi(sNumber.c_str()); + return xatoi(sNumber.c_str()); } //TODO: remove constant 4 and place it in a message diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp index 765b5146..b4c3ee49 100644 --- a/lib/Utils/DebugDump.cpp +++ b/lib/Utils/DebugDump.cpp @@ -68,6 +68,22 @@ CDebugDump::CDebugDump() : m_bLocked(false) {} +CDebugDump::~CDebugDump() +{ + /* Paranoia. In C++, destructor will abort() if it was called while unwinding + * the stack and it throws an exception. + */ + try + { + Close(); + m_sDebugDumpDir.clear(); + } + catch (...) + { + error_msg_and_die("Internal error"); + } +} + void CDebugDump::Open(const char *pDir) { if (m_bOpened) diff --git a/lib/Utils/DebugDump.h b/lib/Utils/DebugDump.h index 7dfe61ea..c59552e9 100644 --- a/lib/Utils/DebugDump.h +++ b/lib/Utils/DebugDump.h @@ -41,6 +41,8 @@ #define FILENAME_COMMENT "comment" #define FILENAME_REPRODUCE "reproduce" #define FILENAME_RATING "rating" +#define FILENAME_CMDLINE "cmdline" + class CDebugDump { @@ -57,7 +59,7 @@ class CDebugDump public: CDebugDump(); - ~CDebugDump() { Close(); } + ~CDebugDump(); void Open(const char *pDir); void Create(const char *pDir, int64_t uid); diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am index 9618751a..d5e9d98b 100644 --- a/lib/Utils/Makefile.am +++ b/lib/Utils/Makefile.am @@ -13,7 +13,9 @@ libABRTUtils_la_SOURCES = \ read_write.cpp \ logging.cpp \ copyfd.cpp \ + daemon.cpp \ skip_whitespace.cpp \ + xatonum.cpp \ popen_and_save_output.cpp \ stringops.cpp \ dirsize.cpp \ diff --git a/lib/Utils/abrt_xmlrpc.cpp b/lib/Utils/abrt_xmlrpc.cpp index 7205316c..ae1d098e 100644 --- a/lib/Utils/abrt_xmlrpc.cpp +++ b/lib/Utils/abrt_xmlrpc.cpp @@ -5,6 +5,16 @@ #include "abrt_xmlrpc.h" #include "ABRTException.h" +CURL* xcurl_easy_init() +{ + CURL* curl = curl_easy_init(); + if (!curl) + { + error_msg_and_die("Can't create curl handle"); + } + return curl; +} + void throw_if_xml_fault_occurred(xmlrpc_env *env) { if (env->fault_occurred) diff --git a/lib/Utils/abrt_xmlrpc.h b/lib/Utils/abrt_xmlrpc.h index e67ab19a..352e80ca 100644 --- a/lib/Utils/abrt_xmlrpc.h +++ b/lib/Utils/abrt_xmlrpc.h @@ -1,6 +1,7 @@ #ifndef ABRT_XMLRPC_H_ #define ABRT_XMLRPC_H_ 1 +#include <curl/curl.h> #include <xmlrpc-c/base.h> #include <xmlrpc-c/client.h> @@ -15,13 +16,15 @@ struct abrt_xmlrpc_conn { xmlrpc_server_info* m_pServer_info; abrt_xmlrpc_conn(const char* url, bool no_ssl_verify) { new_xmlrpc_client(url, no_ssl_verify); } + /* this never throws exceptions - calls C functions only */ ~abrt_xmlrpc_conn() { destroy_xmlrpc_client(); } void new_xmlrpc_client(const char* url, bool no_ssl_verify); void destroy_xmlrpc_client(); }; -/* Utility function */ +/* Utility functions */ void throw_if_xml_fault_occurred(xmlrpc_env *env); +CURL* xcurl_easy_init(); #endif diff --git a/lib/Utils/daemon.cpp b/lib/Utils/daemon.cpp new file mode 100644 index 00000000..7aa891c2 --- /dev/null +++ b/lib/Utils/daemon.cpp @@ -0,0 +1,139 @@ +/* + 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" +#define FILENAME_CMDLINE "cmdline" +#define VAR_RUN_PID_FILE VAR_RUN"/abrt.pid" + +static char *append_escaped(char *start, const char *s) +{ + char hex_char_buf[] = "\\x00"; + + *start++ = ' '; + char *dst = start; + const unsigned char *p = (unsigned char *)s; + + while (1) + { + const unsigned char *old_p = p; + while (*p > ' ' && *p <= 0x7e && *p != '\"' && *p != '\'' && *p != '\\') + p++; + if (dst == start) + { + if (p != (unsigned char *)s && *p == '\0') + { + /* entire word does not need escaping and quoting */ + strcpy(dst, s); + dst += strlen(s); + return dst; + } + *dst++ = '\''; + } + + strncpy(dst, s, (p - old_p)); + dst += (p - old_p); + + if (*p == '\0') + { + *dst++ = '\''; + *dst = '\0'; + return dst; + } + const char *a; + switch (*p) + { + case '\r': a = "\\r"; break; + case '\n': a = "\\n"; break; + case '\t': a = "\\t"; break; + case '\'': a = "\\\'"; break; + case '\"': a = "\\\""; break; + case '\\': a = "\\\\"; break; + case ' ': a = " "; break; + default: + hex_char_buf[2] = "0123456789abcdef"[*p >> 4]; + hex_char_buf[3] = "0123456789abcdef"[*p & 0xf]; + a = hex_char_buf; + } + strcpy(dst, a); + dst += strlen(a); + p++; + } +} + +// taken from kernel +#define COMMAND_LINE_SIZE 2048 +char* get_cmdline(pid_t pid) +{ + char path[sizeof("/proc/%u/cmdline") + sizeof(int)*3]; + char cmdline[COMMAND_LINE_SIZE]; + char escaped_cmdline[COMMAND_LINE_SIZE*4 + 4]; + + escaped_cmdline[1] = '\0'; + sprintf(path, "/proc/%u/cmdline", (int)pid); + int fd = open(path, O_RDONLY); + if (fd >= 0) + { + int len = read(fd, cmdline, sizeof(cmdline) - 1); + close(fd); + + if (len > 0) + { + cmdline[len] = '\0'; + char *src = cmdline; + char *dst = escaped_cmdline; + while ((src - cmdline) < len) + { + dst = append_escaped(dst, src); + src += strlen(src) + 1; + } + } + } + + return xstrdup(escaped_cmdline + 1); /* +1 skips extraneous leading space */ +} + +int daemon_is_ok() +{ + 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 */ + if (pid[0] == '\0' || pid[0] == '/') + return 0; + + /* TODO: maybe readlink and check that it is "xxx/abrt"? */ + char path[sizeof("/proc/%s/stat") + sizeof(pid)]; + sprintf(path, "/proc/%s/stat", pid); + struct stat sb; + if (stat(path, &sb) == -1) + { + return 0; + } + + return 1; +} diff --git a/lib/Utils/xatonum.cpp b/lib/Utils/xatonum.cpp new file mode 100644 index 00000000..b096ca89 --- /dev/null +++ b/lib/Utils/xatonum.cpp @@ -0,0 +1,50 @@ +/* + * Utility routines. + * + * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> + * + * Licensed under GPLv2, see file LICENSE in this tarball for details. + */ +#include "abrtlib.h" + +unsigned xatou(const char *numstr) +{ + unsigned r; + int old_errno; + char *e; + + if (*numstr < '0' || *numstr > '9') + goto inval; + + old_errno = errno; + errno = 0; + r = strtoul(numstr, &e, 10); + if (errno || numstr == e || *e != '\0') + goto inval; /* error / no digits / illegal trailing chars */ + errno = old_errno; /* Ok. So restore errno. */ + return r; + + inval: + error_msg_and_die("invalid number '%s'", numstr); +} + +int xatoi_u(const char *numstr) +{ + unsigned r = xatou(numstr); + if (r > (unsigned)INT_MAX) + error_msg_and_die("invalid number '%s'", numstr); + return r; +} + +int xatoi(const char *numstr) +{ + unsigned r; + + if (*numstr != '-') + return xatoi_u(numstr); + + r = xatou(numstr + 1); + if (r > (unsigned)INT_MAX + 1) + error_msg_and_die("invalid number '%s'", numstr); + return - (int)r; +} @@ -1,14 +1,16 @@ # Fedora Spanish translation of abrt.master +# This file is distributed under the same license as the abrt.master package. # # Gladys Guerrero Lozano <gguerrer@redhat.com>, 2009. # Fernando Gonzalez <fgonz@fedoraproject.org>, 2009. # Héctor Daniel Cabrera <logan@fedoraproject.org> +# msgid "" msgstr "" "Project-Id-Version: abrt.master.es\n" "Report-Msgid-Bugs-To: jmoskovc@redhat.com\n" -"POT-Creation-Date: 2009-12-11 08:18+0000\n" -"PO-Revision-Date: 2009-12-11 10:26-0300\n" +"POT-Creation-Date: 2009-12-15 10:52+0000\n" +"PO-Revision-Date: 2009-12-15 11:51-0300\n" "Last-Translator: Héctor Daniel Cabrera <logan@fedoraproject.org>\n" "Language-Team: Fedora Spanish <fedora-trans-es@redhat.com>\n" "MIME-Version: 1.0\n" @@ -429,7 +431,7 @@ msgstr "Ver e informar el cuelgue de una aplicación" msgid "A crash in package %s has been detected" msgstr "Ha sido detectado una caída en el paquete %s." -#: ../src/Applet/Applet.cpp:253 +#: ../src/Applet/Applet.cpp:254 msgid "ABRT service is not running" msgstr "El servicio ABRT no se está ejecutando" @@ -479,17 +481,13 @@ msgstr "Saliendo..." msgid "Getting local universal unique identification" msgstr "Obteniendo la identificación única universal local" -#: ../lib/Plugins/CCpp.cpp:264 -msgid "Getting backtrace..." -msgstr "Obteniendo el backtrace..." - -#: ../lib/Plugins/CCpp.cpp:382 -msgid "Searching for debug-info packages..." -msgstr "Buscando paquetes de información del depurador..." +#: ../lib/Plugins/CCpp.cpp:254 +msgid "Generating backtrace" +msgstr "Generando seguimiento..." -#: ../lib/Plugins/CCpp.cpp:416 -msgid "Downloading and installing debug-info packages..." -msgstr "Descargando e instalando paquetes de información del depurador..." +#: ../lib/Plugins/CCpp.cpp:372 +msgid "Starting debuginfo installation" +msgstr "Iniciando la instalación de la información de depuración" #: ../lib/Plugins/CCpp.cpp:524 msgid "Getting local universal unique identification..." @@ -499,7 +497,7 @@ msgstr "Obteniendo la identificación única universal local..." msgid "Getting global universal unique identification..." msgstr "Obteniendo la identificación única universal global..." -#: ../lib/Plugins/CCpp.cpp:691 +#: ../lib/Plugins/CCpp.cpp:685 msgid "Skipping debuginfo installation" msgstr "Omita la instalación de la información de depuración" @@ -507,12 +505,13 @@ msgstr "Omita la instalación de la información de depuración" msgid "Creating and submitting a report..." msgstr "Creando y enviando un informe..." -#: ../lib/Plugins/Logger.cpp:66 -msgid "Creating a report..." -msgstr "Creando un informe..." +#: ../lib/Plugins/Logger.cpp:82 +#, c-format +msgid "Writing report to '%s'" +msgstr "Escribiendo reporte en '%s'" #: ../lib/Plugins/FileTransfer.cpp:63 -#: ../lib/Plugins/FileTransfer.cpp:384 +#: ../lib/Plugins/FileTransfer.cpp:385 msgid "FileTransfer: URL not specified" msgstr "Transferencia de archivo: URL no especificada" @@ -521,16 +520,16 @@ msgstr "Transferencia de archivo: URL no especificada" msgid "Sending archive %s to %s" msgstr "Enviando archivo %s a %s" -#: ../lib/Plugins/FileTransfer.cpp:309 +#: ../lib/Plugins/FileTransfer.cpp:310 msgid "File Transfer: Creating a report..." msgstr "Transferencia de archivo: Creando un informe..." -#: ../lib/Plugins/FileTransfer.cpp:334 +#: ../lib/Plugins/FileTransfer.cpp:335 #, c-format msgid "Can't create and send an archive: %s" msgstr "No se puede crear y enviar un archivo: %s" -#: ../lib/Plugins/FileTransfer.cpp:359 +#: ../lib/Plugins/FileTransfer.cpp:360 #, c-format msgid "Can't create and send an archive %s" msgstr "No se puede crear y enviar un archivo %s" @@ -539,7 +538,7 @@ msgstr "No se puede crear y enviar un archivo %s" msgid "Creating kernel oops crash reports..." msgstr "Creando un informe de cuelgue de kernel oops..." -#: ../lib/Plugins/Mailx.cpp:165 +#: ../lib/Plugins/Mailx.cpp:164 msgid "Sending an email..." msgstr "Enviando un correo..." @@ -556,6 +555,12 @@ msgstr "ejecutando sosreport: %s" msgid "done running sosreport" msgstr "Sosreport corriendo" +#~ msgid "Searching for debug-info packages..." +#~ msgstr "Buscando paquetes de información del depurador..." +#~ msgid "Downloading and installing debug-info packages..." +#~ msgstr "Descargando e instalando paquetes de información del depurador..." +#~ msgid "Creating a report..." +#~ msgstr "Creando un informe..." #~ msgid "Starting report creation..." #~ msgstr "Iniciando la creación del informe..." #~ msgid "<span color=\"white\">Description</span>" @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: ABRT\n" "Report-Msgid-Bugs-To: jmoskovc@redhat.com\n" -"POT-Creation-Date: 2009-12-12 08:18+0000\n" +"POT-Creation-Date: 2009-12-17 10:27+0000\n" "PO-Revision-Date: \n" "Last-Translator: Elad <el.il@doom.co.il>\n" "Language-Team: Hebrew <fedora-he-list@redhat.com>\n" @@ -167,7 +167,7 @@ msgstr "" "%s" #. there is something wrong with the daemon if we cant get the dumplist -#: ../src/Gui/CCMainWindow.py:184 +#: ../src/Gui/CCMainWindow.py:187 #, python-format msgid "" "Error while loading the dumplist.\n" @@ -176,15 +176,15 @@ msgstr "" "שגיאה במהלך טעינת dumplist.\n" "%s" -#: ../src/Gui/CCMainWindow.py:221 +#: ../src/Gui/CCMainWindow.py:224 msgid "<b>This crash has been reported:</b>\n" msgstr "<b>הקריסה הזאת דווחה:</b>\n" -#: ../src/Gui/CCMainWindow.py:231 +#: ../src/Gui/CCMainWindow.py:234 msgid "<b>Not reported!</b>" msgstr "<b>לא דווח!</b>" -#: ../src/Gui/CCMainWindow.py:280 +#: ../src/Gui/CCMainWindow.py:283 msgid "" "Unable to get report!\n" "Debuginfo is missing?" @@ -192,7 +192,7 @@ msgstr "" "לא ניתן להשיג דיווח\n" "מידע ניפוי שגיאות חסר?" -#: ../src/Gui/CCMainWindow.py:299 +#: ../src/Gui/CCMainWindow.py:302 #, python-format msgid "" "Reporting failed!\n" @@ -201,8 +201,8 @@ msgstr "" "הדיווח נכשל!\n" "%s" -#: ../src/Gui/CCMainWindow.py:318 -#: ../src/Gui/CCMainWindow.py:345 +#: ../src/Gui/CCMainWindow.py:321 +#: ../src/Gui/CCMainWindow.py:348 #, python-format msgid "Error getting the report: %s" msgstr "שגיאה בקבלת הדיווח: %s" @@ -470,27 +470,23 @@ msgstr "מתנתק..." msgid "Getting local universal unique identification" msgstr "מקבל זהות מקומית ייחודית" -#: ../lib/Plugins/CCpp.cpp:264 -msgid "Getting backtrace..." -msgstr "מקבל מידע קריסה..." +#: ../lib/Plugins/CCpp.cpp:257 +msgid "Generating backtrace" +msgstr "יוצר מידע קריסה" -#: ../lib/Plugins/CCpp.cpp:382 -msgid "Searching for debug-info packages..." -msgstr "מחפש חבילות debug-info..." +#: ../lib/Plugins/CCpp.cpp:375 +msgid "Starting debuginfo installation" +msgstr "מתחיל התקנת מידע ניפוי שגיאות" -#: ../lib/Plugins/CCpp.cpp:416 -msgid "Downloading and installing debug-info packages..." -msgstr "מוריד ומתקין חבילות מידע ניפוי באגים..." - -#: ../lib/Plugins/CCpp.cpp:524 +#: ../lib/Plugins/CCpp.cpp:525 msgid "Getting local universal unique identification..." msgstr "מקבל זהות מקומית ייחודית..." -#: ../lib/Plugins/CCpp.cpp:543 +#: ../lib/Plugins/CCpp.cpp:544 msgid "Getting global universal unique identification..." msgstr "מקבל זהות גלובלית ייחודית..." -#: ../lib/Plugins/CCpp.cpp:691 +#: ../lib/Plugins/CCpp.cpp:686 msgid "Skipping debuginfo installation" msgstr "מדלג על התקנת מידע ניפוי שגיאות" @@ -504,7 +500,7 @@ msgid "Writing report to '%s'" msgstr "כותב דיווח ל'%s'" #: ../lib/Plugins/FileTransfer.cpp:63 -#: ../lib/Plugins/FileTransfer.cpp:384 +#: ../lib/Plugins/FileTransfer.cpp:381 msgid "FileTransfer: URL not specified" msgstr "העברת קובץ: כתובת לא צוינה" @@ -513,16 +509,16 @@ msgstr "העברת קובץ: כתובת לא צוינה" msgid "Sending archive %s to %s" msgstr "שולח ארכיון %s ל-%s" -#: ../lib/Plugins/FileTransfer.cpp:309 +#: ../lib/Plugins/FileTransfer.cpp:306 msgid "File Transfer: Creating a report..." msgstr "העברת קובץ: יוצר דיווח..." -#: ../lib/Plugins/FileTransfer.cpp:334 +#: ../lib/Plugins/FileTransfer.cpp:331 #, c-format msgid "Can't create and send an archive: %s" msgstr "לא יכול ליצור ולשלוח ארכיון: %s" -#: ../lib/Plugins/FileTransfer.cpp:359 +#: ../lib/Plugins/FileTransfer.cpp:356 #, c-format msgid "Can't create and send an archive %s" msgstr "לא יכול ליצור ולשלוח ארכיון %s" @@ -531,7 +527,7 @@ msgstr "לא יכול ליצור ולשלוח ארכיון %s" msgid "Creating kernel oops crash reports..." msgstr "יוצר דיווחי קריסה של kernel oops..." -#: ../lib/Plugins/Mailx.cpp:165 +#: ../lib/Plugins/Mailx.cpp:164 msgid "Sending an email..." msgstr "שולח דוא\"ל" @@ -548,6 +544,10 @@ msgstr "מריץ sosreport: %s" msgid "done running sosreport" msgstr "הרצת sosreport הסתיימה" +#~ msgid "Searching for debug-info packages..." +#~ msgstr "מחפש חבילות debug-info..." +#~ msgid "Downloading and installing debug-info packages..." +#~ msgstr "מוריד ומתקין חבילות מידע ניפוי באגים..." #~ msgid "Creating a report..." #~ msgstr "יוצר דיווח" #~ msgid "Starting report creation..." @@ -1,4 +1,4 @@ -# translation of ja.po to Japanese +# translation of abrt.ja.po to Japanese # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # @@ -7,10 +7,10 @@ # Hyu_gabaru Ryu_ichi <hyu_gabaru@yahoo.co.jp>, 2009. msgid "" msgstr "" -"Project-Id-Version: ja\n" +"Project-Id-Version: abrt.ja\n" "Report-Msgid-Bugs-To: jmoskovc@redhat.com\n" -"POT-Creation-Date: 2009-12-12 08:18+0000\n" -"PO-Revision-Date: 2009-12-14 09:37+0900\n" +"POT-Creation-Date: 2009-12-15 22:00+0000\n" +"PO-Revision-Date: 2009-12-16 10:39+0900\n" "Last-Translator: Kiyoto Hashida <khashida@redhat.com>\n" "Language-Team: Japanese <jp@li.org>\n" "MIME-Version: 1.0\n" @@ -25,6 +25,7 @@ msgstr "" "\n" "\n" "\n" +"\n" #: ../src/Gui/ABRTExceptions.py:6 msgid "Another client is already running, trying to wake it." @@ -192,7 +193,7 @@ msgstr "" "%s" #. there is something wrong with the daemon if we cant get the dumplist -#: ../src/Gui/CCMainWindow.py:184 +#: ../src/Gui/CCMainWindow.py:187 #, python-format msgid "" "Error while loading the dumplist.\n" @@ -201,15 +202,15 @@ msgstr "" "dumplist のロード中にエラーが発生。\n" " %s" -#: ../src/Gui/CCMainWindow.py:221 +#: ../src/Gui/CCMainWindow.py:224 msgid "<b>This crash has been reported:</b>\n" msgstr "<b>このクラッシュは報告済みです:</b>\n" -#: ../src/Gui/CCMainWindow.py:231 +#: ../src/Gui/CCMainWindow.py:234 msgid "<b>Not reported!</b>" msgstr "<b>報告がありません!</b>" -#: ../src/Gui/CCMainWindow.py:280 +#: ../src/Gui/CCMainWindow.py:283 msgid "" "Unable to get report!\n" "Debuginfo is missing?" @@ -217,7 +218,7 @@ msgstr "" "報告を取得できません\n" "Debuginfo が無いですか ?" -#: ../src/Gui/CCMainWindow.py:299 +#: ../src/Gui/CCMainWindow.py:302 #, python-format msgid "" "Reporting failed!\n" @@ -226,7 +227,7 @@ msgstr "" "報告が失敗しました!\n" "%s" -#: ../src/Gui/CCMainWindow.py:318 ../src/Gui/CCMainWindow.py:345 +#: ../src/Gui/CCMainWindow.py:321 ../src/Gui/CCMainWindow.py:348 #, python-format msgid "Error getting the report: %s" msgstr "報告の取得中にエラーです: %s" @@ -498,27 +499,23 @@ msgstr "ログアウトしています..." msgid "Getting local universal unique identification" msgstr "ローカルで普遍的な独特の識別を取得しています" -#: ../lib/Plugins/CCpp.cpp:264 -msgid "Getting backtrace..." -msgstr "バックトレース取得中..." - -#: ../lib/Plugins/CCpp.cpp:382 -msgid "Searching for debug-info packages..." -msgstr "debug-info パッケージを探しています..." +#: ../lib/Plugins/CCpp.cpp:254 +msgid "Generating backtrace" +msgstr "バックトレース生成中" -#: ../lib/Plugins/CCpp.cpp:416 -msgid "Downloading and installing debug-info packages..." -msgstr "debug-info パッケージをダウンロードしてインストール中..." +#: ../lib/Plugins/CCpp.cpp:372 +msgid "Starting debuginfo installation" +msgstr "debuginfo のインストールをスタート中" -#: ../lib/Plugins/CCpp.cpp:524 +#: ../lib/Plugins/CCpp.cpp:522 msgid "Getting local universal unique identification..." msgstr "ローカルで普遍的な独特の識別を取得しています..." -#: ../lib/Plugins/CCpp.cpp:543 +#: ../lib/Plugins/CCpp.cpp:541 msgid "Getting global universal unique identification..." msgstr "グローバルで普遍的な独特の識別を取得しています..." -#: ../lib/Plugins/CCpp.cpp:691 +#: ../lib/Plugins/CCpp.cpp:683 msgid "Skipping debuginfo installation" msgstr "debuginfo のインストールをスキップします" @@ -531,7 +528,7 @@ msgstr "報告の作成と提出をしています..." msgid "Writing report to '%s'" msgstr " %s へのレポートを書き込み中" -#: ../lib/Plugins/FileTransfer.cpp:63 ../lib/Plugins/FileTransfer.cpp:384 +#: ../lib/Plugins/FileTransfer.cpp:63 ../lib/Plugins/FileTransfer.cpp:385 msgid "FileTransfer: URL not specified" msgstr "ファイル転送: URL が示されていません" @@ -540,16 +537,16 @@ msgstr "ファイル転送: URL が示されていません" msgid "Sending archive %s to %s" msgstr "アーカイブ %s を %s に送信中" -#: ../lib/Plugins/FileTransfer.cpp:309 +#: ../lib/Plugins/FileTransfer.cpp:310 msgid "File Transfer: Creating a report..." msgstr "ファイル転送: 報告を作成中..." -#: ../lib/Plugins/FileTransfer.cpp:334 +#: ../lib/Plugins/FileTransfer.cpp:335 #, c-format msgid "Can't create and send an archive: %s" msgstr "アーカイブを作成して送信できません: %s" -#: ../lib/Plugins/FileTransfer.cpp:359 +#: ../lib/Plugins/FileTransfer.cpp:360 #, c-format msgid "Can't create and send an archive %s" msgstr "アーカイブを作成して送信できません: %s" @@ -558,7 +555,7 @@ msgstr "アーカイブを作成して送信できません: %s" msgid "Creating kernel oops crash reports..." msgstr "カーネル oops クラッシュ報告を作成中..." -#: ../lib/Plugins/Mailx.cpp:165 +#: ../lib/Plugins/Mailx.cpp:164 msgid "Sending an email..." msgstr "電子メールを送信中..." @@ -12,8 +12,8 @@ msgid "" msgstr "" "Project-Id-Version: abrt.master\n" "Report-Msgid-Bugs-To: jmoskovc@redhat.com\n" -"POT-Creation-Date: 2009-12-11 08:18+0000\n" -"PO-Revision-Date: 2009-12-11 14:30+0100\n" +"POT-Creation-Date: 2009-12-15 16:54+0000\n" +"PO-Revision-Date: 2009-12-15 18:05+0100\n" "Last-Translator: Geert Warrink <geert.warrink@onsnet.nu>\n" "Language-Team: nl <fedora-trans-list@redhat.com>\n" "MIME-Version: 1.0\n" @@ -187,7 +187,7 @@ msgstr "" "%s" #. there is something wrong with the daemon if we cant get the dumplist -#: ../src/Gui/CCMainWindow.py:184 +#: ../src/Gui/CCMainWindow.py:187 #, python-format msgid "" "Error while loading the dumplist.\n" @@ -196,15 +196,15 @@ msgstr "" "Fout tijdens het laden van de dumplijst.\n" "%s" -#: ../src/Gui/CCMainWindow.py:221 +#: ../src/Gui/CCMainWindow.py:224 msgid "<b>This crash has been reported:</b>\n" msgstr "<b>Deze crash is gerapporteerd:</b>\n" -#: ../src/Gui/CCMainWindow.py:231 +#: ../src/Gui/CCMainWindow.py:234 msgid "<b>Not reported!</b>" msgstr "<b>Niet gerapporteerd!</b>" -#: ../src/Gui/CCMainWindow.py:280 +#: ../src/Gui/CCMainWindow.py:283 msgid "" "Unable to get report!\n" "Debuginfo is missing?" @@ -212,7 +212,7 @@ msgstr "" "Kan geen rapport krijgen!\n" "Mist debuginfo?" -#: ../src/Gui/CCMainWindow.py:299 +#: ../src/Gui/CCMainWindow.py:302 #, python-format msgid "" "Reporting failed!\n" @@ -221,7 +221,7 @@ msgstr "" "Rapporteren mislukte!\n" "%s" -#: ../src/Gui/CCMainWindow.py:318 ../src/Gui/CCMainWindow.py:345 +#: ../src/Gui/CCMainWindow.py:321 ../src/Gui/CCMainWindow.py:348 #, python-format msgid "Error getting the report: %s" msgstr "Fout tijdens het verkrijgen van het rapport: %s" @@ -442,7 +442,7 @@ msgstr "Bekijk en rapporteer crashes van toepassingen" msgid "A crash in package %s has been detected" msgstr "Een crash in pakket %s is ontdekt" -#: ../src/Applet/Applet.cpp:253 +#: ../src/Applet/Applet.cpp:254 msgid "ABRT service is not running" msgstr "ABRT service draait niet" @@ -496,27 +496,23 @@ msgstr "Uitloggen..." msgid "Getting local universal unique identification" msgstr "Verkrijgen van locale universele unieke identificatie" -#: ../lib/Plugins/CCpp.cpp:264 -msgid "Getting backtrace..." -msgstr "Backtrace ophalen..." +#: ../lib/Plugins/CCpp.cpp:254 +msgid "Generating backtrace" +msgstr "Aangemaakte backtrace" -#: ../lib/Plugins/CCpp.cpp:382 -msgid "Searching for debug-info packages..." -msgstr "Zoeken naar debug-info pakketten..." +#: ../lib/Plugins/CCpp.cpp:372 +msgid "Starting debuginfo installation" +msgstr "Start debuginfo installatie" -#: ../lib/Plugins/CCpp.cpp:416 -msgid "Downloading and installing debug-info packages..." -msgstr "Downloaden en installeren van debug-info pakketten..." - -#: ../lib/Plugins/CCpp.cpp:524 +#: ../lib/Plugins/CCpp.cpp:522 msgid "Getting local universal unique identification..." msgstr "Verkrijgen van locale universele unieke identificatie..." -#: ../lib/Plugins/CCpp.cpp:543 +#: ../lib/Plugins/CCpp.cpp:541 msgid "Getting global universal unique identification..." msgstr "Verkrijgen van golbale universele unieke identificatie..." -#: ../lib/Plugins/CCpp.cpp:691 +#: ../lib/Plugins/CCpp.cpp:683 msgid "Skipping debuginfo installation" msgstr "Sla debuginfo installatie over" @@ -524,11 +520,12 @@ msgstr "Sla debuginfo installatie over" msgid "Creating and submitting a report..." msgstr "Aanmaken en indienen van rapport..." -#: ../lib/Plugins/Logger.cpp:66 -msgid "Creating a report..." -msgstr "Rapport aanmaken..." +#: ../lib/Plugins/Logger.cpp:82 +#, c-format +msgid "Writing report to '%s'" +msgstr "Rapport schrijven naar: '%s'" -#: ../lib/Plugins/FileTransfer.cpp:63 ../lib/Plugins/FileTransfer.cpp:384 +#: ../lib/Plugins/FileTransfer.cpp:63 ../lib/Plugins/FileTransfer.cpp:385 msgid "FileTransfer: URL not specified" msgstr "Bestandsoverdracht: URL niet opgegeven" @@ -537,16 +534,16 @@ msgstr "Bestandsoverdracht: URL niet opgegeven" msgid "Sending archive %s to %s" msgstr "Versturen van archief %s naar %s" -#: ../lib/Plugins/FileTransfer.cpp:309 +#: ../lib/Plugins/FileTransfer.cpp:310 msgid "File Transfer: Creating a report..." msgstr "Bestandsoverdracht: Een rapport maken..." -#: ../lib/Plugins/FileTransfer.cpp:334 +#: ../lib/Plugins/FileTransfer.cpp:335 #, c-format msgid "Can't create and send an archive: %s" msgstr "Kan geen archief maken en versturen: %s" -#: ../lib/Plugins/FileTransfer.cpp:359 +#: ../lib/Plugins/FileTransfer.cpp:360 #, c-format msgid "Can't create and send an archive %s" msgstr "Kan archief %s niet aanmaken en versturen" @@ -555,7 +552,7 @@ msgstr "Kan archief %s niet aanmaken en versturen" msgid "Creating kernel oops crash reports..." msgstr "Aanmaken van kernel oops crash rapporten..." -#: ../lib/Plugins/Mailx.cpp:165 +#: ../lib/Plugins/Mailx.cpp:164 msgid "Sending an email..." msgstr "Versturen van email..." @@ -572,6 +569,15 @@ msgstr "sosreport draaien: %s" msgid "done running sosreport" msgstr "klaar met het draaien van sosreport" +#~ msgid "Searching for debug-info packages..." +#~ msgstr "Zoeken naar debug-info pakketten..." + +#~ msgid "Downloading and installing debug-info packages..." +#~ msgstr "Downloaden en installeren van debug-info pakketten..." + +#~ msgid "Creating a report..." +#~ msgstr "Rapport aanmaken..." + #~ msgid "Starting report creation..." #~ msgstr "Beginnen met rapport aanmaken..." diff --git a/src/Applet/CCApplet.cpp b/src/Applet/CCApplet.cpp index 5d13ab87..f9212b2a 100644 --- a/src/Applet/CCApplet.cpp +++ b/src/Applet/CCApplet.cpp @@ -320,7 +320,7 @@ void CApplet::animate_icon() if (m_iAnimator == 0) { m_iAnimator = g_timeout_add(100, update_icon, this); - m_iAnimCountdown = 10 * 60; /* 60 sec */ + m_iAnimCountdown = 10 * 30; /* 30 sec */ } } diff --git a/src/CLI/ABRTSocket.cpp b/src/CLI/ABRTSocket.cpp index d31c7a4f..13531342 100644 --- a/src/CLI/ABRTSocket.cpp +++ b/src/CLI/ABRTSocket.cpp @@ -13,7 +13,17 @@ CABRTSocket::CABRTSocket() : m_nSocket(-1) CABRTSocket::~CABRTSocket() { - Disconnect(); + /* Paranoia. In C++, destructor will abort() if it was called while unwinding + * the stack and it throws an exception. + */ + try + { + Disconnect(); + } + catch (...) + { + error_msg_and_die("Internal error"); + } } void CABRTSocket::Send(const std::string& pMessage) diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index c6cae5de..8038f75d 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -110,7 +110,7 @@ typedef struct cron_callback_data_t } cron_callback_data_t; -static uint8_t s_sig_caught; /* must be one byte */ +static volatile sig_atomic_t s_sig_caught; static int s_signal_pipe[2]; static int s_signal_pipe_write = -1; static unsigned s_timeout; @@ -216,14 +216,14 @@ static int SetUpCron() std::string sM = ""; sH = it_c->first.substr(0, pos); - nH = atoi(sH.c_str()); + nH = xatou(sH.c_str()); nH = nH > 23 ? 23 : nH; nH = nH < 0 ? 0 : nH; nM = nM > 59 ? 59 : nM; nM = nM < 0 ? 0 : nM; timeout += nH * 60 * 60; sM = it_c->first.substr(pos + 1); - nM = atoi(sM.c_str()); + nM = xatou(sM.c_str()); timeout += nM * 60; } else @@ -231,7 +231,7 @@ static int SetUpCron() std::string sS = ""; sS = it_c->first; - nS = atoi(sS.c_str()); + nS = xatou(sS.c_str()); nS = nS <= 0 ? 1 : nS; timeout = nS; } @@ -399,10 +399,15 @@ static int Lock() static void handle_fatal_signal(int signo) { - s_sig_caught = signo; - VERB3 log("Got signal %d", signo); + // Enable for debugging only, malloc/printf are unsafe in signal handlers + //VERB3 log("Got signal %d", signo); + + uint8_t l_sig_caught; + s_sig_caught = l_sig_caught = signo; + /* Using local copy of s_sig_caught so that concurrent signal + * won't change it under us */ if (s_signal_pipe_write >= 0) - write(s_signal_pipe_write, &s_sig_caught, 1); + write(s_signal_pipe_write, &l_sig_caught, 1); } /* Signal pipe handler */ diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp index b597a411..6b8bfcce 100644 --- a/src/Daemon/MiddleWare.cpp +++ b/src/Daemon/MiddleWare.cpp @@ -477,7 +477,7 @@ report_status_t Report(const map_crash_report_t& pCrashReport, if (pUID != "") { - home = get_home_dir(atoi(pUID.c_str())); + home = get_home_dir(xatoi_u(pUID.c_str())); if (home != "") { oldSettings = reporter->GetSettings(); @@ -563,11 +563,38 @@ void LoadOpenGPGPublicKey(const char* key) * @param pDebugDumpDir A debugdump dir containing all necessary data. * @return It return results of operation. See mw_result_t. */ -static mw_result_t SavePackageDescriptionToDebugDump(const char *pExecutable, - const char *pDebugDumpDir) +static char *get_argv1_if_full_path(const char* cmdline) +{ + char *argv1 = (char*) strchr(cmdline, ' '); + if (argv1 != NULL) + { + /* we found space in cmdline, so it might contain + * path to some script like: + * /usr/bin/python /usr/bin/system-control-network + */ + argv1++; + /* if the string following the space doesn't start + * with '/' it's probably not a full path to script + * and we can't use it to determine the package name + */ + if (*argv1 != '/') + { + return NULL; + } + int len = strchrnul(argv1, ' ') - argv1; + /* cut the cmdline arguments */ + argv1 = xstrndup(argv1, len); + } + return argv1; +} +static mw_result_t SavePackageDescriptionToDebugDump( + const char *pExecutable, + const char *cmdline, + const char *pDebugDumpDir) { std::string package; std::string packageName; + std::string scriptName; /* only if "interpreter /path/to/script" */ if (strcmp(pExecutable, "kernel") == 0) { @@ -582,6 +609,42 @@ static mw_result_t SavePackageDescriptionToDebugDump(const char *pExecutable, return MW_PACKAGE_ERROR; } + /* Check well-known interpreter names */ + + const char *basename = strrchr(pExecutable, '/'); + if (basename) basename++; else basename = pExecutable; + + /* Add "perl" and such as needed */ + if (strcmp(basename, "python") == 0) + { +// TODO: we don't verify that python executable is not modified +// or that python package is properly signed +// (see CheckFingerprint/CheckHash below) + + /* Try to find package for the script by looking at argv[1]. + * This will work only of the cmdline contains the whole path. + * Example: python /usr/bin/system-control-network + */ + char *script_name = get_argv1_if_full_path(cmdline); + if (script_name) + { + char *script_pkg = GetPackage(script_name); + if (script_pkg) + { + /* There is a well-formed script name in argv[1], + * and it does belong to some package. + * Replace interpreter's rpm_pkg and pExecutable + * with data pertaining to the script. + */ + free(rpm_pkg); + rpm_pkg = script_pkg; + scriptName = script_name; + pExecutable = scriptName.c_str(); + } + free(script_name); + } + } + package = rpm_pkg; packageName = package.substr(0, package.rfind("-", package.rfind("-") - 1)); VERB2 log("Package:'%s' short:'%s'", rpm_pkg, packageName.c_str()); @@ -610,10 +673,7 @@ static mw_result_t SavePackageDescriptionToDebugDump(const char *pExecutable, } std::string description = GetDescription(packageName.c_str()); -//TODO: if executable in /usr/bin/python, /bin/sh and such, -//we need to extract component using argv[1] std::string component = GetComponent(pExecutable); - try { CDebugDump dd; @@ -788,6 +848,7 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir, std::string time; std::string analyzer; std::string executable; + std::string cmdline; try { CDebugDump dd; @@ -796,6 +857,7 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir, dd.LoadText(FILENAME_UID, UID); dd.LoadText(FILENAME_ANALYZER, analyzer); dd.LoadText(FILENAME_EXECUTABLE, executable); + dd.LoadText(FILENAME_CMDLINE, cmdline); } catch (CABRTException& e) { @@ -811,7 +873,8 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir, { return MW_IN_DB; } - mw_result_t res = SavePackageDescriptionToDebugDump(executable.c_str(), pDebugDumpDir); + + mw_result_t res = SavePackageDescriptionToDebugDump(executable.c_str(), cmdline.c_str(), pDebugDumpDir); if (res != MW_OK) { return res; diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp index 82f22e85..b6a8b154 100644 --- a/src/Daemon/PluginManager.cpp +++ b/src/Daemon/PluginManager.cpp @@ -391,7 +391,7 @@ void CPluginManager::SetPluginSettings(const char *pName, return; } - std::string home = get_home_dir(atoi(pUID.c_str())); + std::string home = get_home_dir(xatoi_u(pUID.c_str())); if (home == "") { return; @@ -399,7 +399,7 @@ void CPluginManager::SetPluginSettings(const char *pName, std::string confDir = home + "/.abrt"; std::string confPath = confDir + "/" + pName + "."PLUGINS_CONF_EXTENSION; - uid_t uid = atoi(pUID.c_str()); + uid_t uid = xatoi_u(pUID.c_str()); struct passwd* pw = getpwuid(uid); gid_t gid = pw ? pw->pw_gid : uid; @@ -461,7 +461,7 @@ map_plugin_settings_t CPluginManager::GetPluginSettings(const char *pName, /* if (abrt_plugin->second->GetType() == REPORTER) { - std::string home = get_home_dir(atoi(pUID.c_str())); + std::string home = get_home_dir(xatoi_u(pUID.c_str())); if (home != "") { LoadPluginSettings(home + "/.abrt/" + pName + "."PLUGINS_CONF_EXTENSION, ret); diff --git a/src/Daemon/Settings.cpp b/src/Daemon/Settings.cpp index 327851f5..d89bebfd 100644 --- a/src/Daemon/Settings.cpp +++ b/src/Daemon/Settings.cpp @@ -176,7 +176,7 @@ static void ParseCommon() it = s_mapSectionCommon.find("MaxCrashReportsSize"); if (it != end) { - g_settings_nMaxCrashReportsSize = atoi(it->second.c_str()); + g_settings_nMaxCrashReportsSize = xatoi_u(it->second.c_str()); } it = s_mapSectionCommon.find("ActionsAndReporters"); if (it != end) diff --git a/src/Daemon/abrt-debuginfo-install b/src/Daemon/abrt-debuginfo-install index 6278b63c..dcd3addb 100755 --- a/src/Daemon/abrt-debuginfo-install +++ b/src/Daemon/abrt-debuginfo-install @@ -21,8 +21,7 @@ # Output goes to GUI as debuginfo install log. The script should be careful # to give useful, but not overly cluttered info to stdout. # Additionally, abrt daemon handles "MISSING:xxxx" messages specially: -# xxxx will be prepended to backtrace. This is used to inform about -# missing debuginfos. +# it is used to inform about missing debuginfos. # # Exitcodes: # 0 - all debuginfos are installed @@ -46,36 +45,22 @@ # For better debuggability, eu_unstrip.OUT, yum_provides.OUT etc files # are saved in TEMPDIR, and TEMPDIR is not deleted if we exit with exitcode 2 # ("serious problem"). -# -# In the future, we may want to use a separate CACHEDIR (say, /var/cache/abrt-di) -# and use it with this gdb command: -# set debug-file-directory /usr/lib/debug/.build-id:CACHEDIR/usr/lib/debug/.build-id -# but current gdb can't handle DIR1:DIR2. -# So, currently we are called with CACHEDIR set to "/", and don't pass -# "set debug-file-directory" to gdb. -# This is ugly, since it messes up /usr/lib/debug/.build-id over time -# by piling up debuginfos there without any means to control their amount, -# but it's the only way to make it work with current gdb. - - -core=$1 -tempdir=$2 + + +core="$1" +tempdir="$2" debuginfodirs="${3//:/ }" cachedir="${3%%:*}" debug=false -exec 2>&1 - -test -f "$core" || exit 2 -# cachedir is optional -test x"$cachedir" = x"" || test -d "$cachedir" || exit 2 -# tempdir must not exist -test -e "$tempdir" && exit 2 -mkdir -- "$tempdir" || exit 2 -cd "$tempdir" || exit 2 -$debug && echo "Installing rpms to $tempdir" +# stderr may be used for status messages too +exec 2>&1 +error_msg_and_die() { + echo "$*" + exit 2 +} count_words() { echo $# @@ -92,6 +77,9 @@ print_missing_build_ids() { build_id2=${build_id:2} file="usr/lib/debug/.build-id/$build_id1/$build_id2.debug" test -f "/$file" && continue + # On 2nd pass, we may already have some debuginfos in tempdir + test -f "$tempdir/$file" && continue + # Check cachedir if we have one for d in $debuginfodirs; do test -f "$d/$file" && continue 2 done @@ -99,6 +87,7 @@ print_missing_build_ids() { done } +# Note: it is run in `backticks`, use >&2 for error messages print_missing_debuginfos() { local build_id local build_id1 @@ -110,6 +99,9 @@ print_missing_debuginfos() { build_id2=${build_id:2} file="usr/lib/debug/.build-id/$build_id1/$build_id2.debug" test -f "/$file" && continue + # On 2nd pass, we may already have some debuginfos in tempdir + test -f "$tempdir/$file" && continue + # Check cachedir if we have one if test x"$cachedir" != x""; then for d in $debuginfodirs; do test -f "$d/$file" && continue 2 @@ -138,6 +130,7 @@ cleanup_and_report_missing() { } # $1: iteration (1,2...) +# Note: it is run in `backticks`, use >&2 for error messages print_package_names() { # We'll run something like: # yum --enablerepo=*debuginfo* --quiet provides \ @@ -154,8 +147,9 @@ print_package_names() { echo "$cmd" >"yum_provides.$1.OUT" local yum_provides_OUT="`$cmd 2>&1`" local err=$? - printf "%s\nexitcode:%s\n" "$yum_provides_OUT" $err >>"yum_provides.$1.OUT" - test $err = 0 || exit 2 + printf "%s\nyum exitcode:%s\n" "$yum_provides_OUT" $err >>"yum_provides.$1.OUT" + test $err = 0 || error_msg_and_die "yum provides... exited with $err: +`head yum_provides.$1.OUT`" >&2 # The output is pretty machine-unfriendly: # glibc-debuginfo-2.10.90-24.x86_64 : Debug information for package glibc @@ -190,7 +184,7 @@ download_packages() { ##yumdownloader --enablerepo=*debuginfo* --quiet $packages >yumdownloader.OUT 2>&1 ##err=$? ##echo "exitcode:$err" >>yumdownloader.OUT - ##test $err = 0 || exit 2 + ##test $err = 0 || error_msg_and_die ... >yumdownloader.OUT i=1 for pkg in $packages; do @@ -207,10 +201,11 @@ download_packages() { for file in *.rpm; do # Happens if no .rpm's were downloaded (yumdownloader problem) # In this case, $f is the literal "*.rpm" string - test -f "$file" || exit 2 + test -f "$file" || error_msg_and_die "not a rpm file: '$file'" echo "Unpacking: $file" echo "Processing: $file" >>unpack.OUT rpm2cpio <"$file" 2>>unpack.OUT | cpio -id >>unpack.OUT 2>&1 +#TODO: error check? done # Copy debuginfo files to cachedir @@ -235,6 +230,7 @@ download_packages() { # Note: this does not preserve symlinks. This is intentional $debug && echo Copying "$file" to "$cachedir/$file" >&2 cp --remove-destination "$file" "$cachedir/$file" +#TODO: error check? continue fi done @@ -242,6 +238,18 @@ download_packages() { } +# Sanity checking +test -f "$core" || error_msg_and_die "not a file: '$core'" +# cachedir is optional +test x"$cachedir" = x"" || test -d "$cachedir" || error_msg_and_die "bad cachedir '$cachedir'" +# tempdir must not exist +test -e "$tempdir" && error_msg_and_die "tempdir exists: '$tempdir'" + +mkdir -- "$tempdir" || exit 2 +cd "$tempdir" || exit 2 +$debug && echo "Installing rpms to $tempdir" + + # eu-unstrip output example: # 0x400000+0x209000 23c77451cf6adff77fc1f5ee2a01d75de6511dda@0x40024c - - [exe] # or @@ -254,8 +262,10 @@ echo "Getting list of build IDs" # eu-unstrip: /var/cache/abrt/ccpp-1256301004-2754/coredump: Callback returned failure eu_unstrip_OUT=`eu-unstrip "--core=$core" -n 2>eu_unstrip.ERR` err=$? -printf "%s\nexitcode:%s\n" "$eu_unstrip_OUT" $err >eu_unstrip.OUT -test $err = 0 || exit 2 +printf "%s\neu-unstrip exitcode:%s\n" "$eu_unstrip_OUT" $err >eu_unstrip.OUT +test $err = 0 || error_msg_and_die "eu-unstrip exited with $err: +`cat eu_unstrip.ERR` +`head eu_unstrip.OUT`" # Get space-separated list of all build-ids # There can be duplicates (observed in real world) @@ -283,6 +293,8 @@ iter=0 while test $((++iter)) -le 2; do # Analyze $build_ids and check which debuginfos are present missing_debuginfo_files=`print_missing_debuginfos` + # Did print_missing_debuginfos fail? + test $? = 0 || exit 2 $debug && echo "missing_debuginfo_files:$missing_debuginfo_files" test x"$missing_debuginfo_files" = x"" && break @@ -290,6 +302,8 @@ while test $((++iter)) -le 2; do # Map $missing_debuginfo_files to package names. # yum is run here. packages=`print_package_names $iter` + # Did print_package_names fail? + test $? = 0 || exit 2 $debug && echo "packages ($iter):$packages" # yum may return "" here if it found no packages (say, if coredump @@ -304,4 +318,5 @@ done cleanup_and_report_missing test x"$missing_build_ids" != x"" && exit 1 +echo "All needed debuginfos are present" exit 0 diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index e429908e..8544b240 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -167,7 +167,10 @@ class MainWindow(): self.wTree.get_widget("lStatus").set_text(message) buff = gtk.TextBuffer() buff.set_text(self.updates) - self.wTree.get_widget("tvUpdates").set_buffer(buff) + end = buff.get_insert() + tvUpdates = self.wTree.get_widget("tvUpdates") + tvUpdates.set_buffer(buff) + tvUpdates.scroll_mark_onscreen(end) # call to update the progressbar def progress_update_cb(self, *args): diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp index fd789cfb..3a133588 100644 --- a/src/Hooks/CCpp.cpp +++ b/src/Hooks/CCpp.cpp @@ -18,25 +18,14 @@ 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_LARGEFILE anywhere - */ -#define _LARGEFILE_SOURCE -#define _LARGEFILE64_SOURCE -#define _FILE_OFFSET_BITS 64 - #include "abrtlib.h" #include "DebugDump.h" #include "ABRTException.h" #include <syslog.h> #define FILENAME_EXECUTABLE "executable" -#define FILENAME_CMDLINE "cmdline" #define FILENAME_COREDUMP "coredump" -#define VAR_RUN_PID_FILE VAR_RUN"/abrt.pid" - using namespace std; static char* malloc_readlink(const char *linkname) @@ -69,157 +58,42 @@ static char* get_cwd(pid_t pid) return malloc_readlink(buf); } -static char *append_escaped(char *start, const char *s) -{ - char hex_char_buf[] = "\\x00"; - - *start++ = ' '; - char *dst = start; - const unsigned char *p = (unsigned char *)s; - - while (1) - { - const unsigned char *old_p = p; - while (*p > ' ' && *p <= 0x7e && *p != '\"' && *p != '\'' && *p != '\\') - p++; - if (dst == start) - { - if (p != (unsigned char *)s && *p == '\0') - { - /* entire word does not need escaping and quoting */ - strcpy(dst, s); - dst += strlen(s); - return dst; - } - *dst++ = '\''; - } - - strncpy(dst, s, (p - old_p)); - dst += (p - old_p); - - if (*p == '\0') - { - *dst++ = '\''; - *dst = '\0'; - return dst; - } - const char *a; - switch (*p) - { - case '\r': a = "\\r"; break; - case '\n': a = "\\n"; break; - case '\t': a = "\\t"; break; - case '\'': a = "\\\'"; break; - case '\"': a = "\\\""; break; - case '\\': a = "\\\\"; break; - case ' ': a = " "; break; - default: - hex_char_buf[2] = "0123456789abcdef"[*p >> 4]; - hex_char_buf[3] = "0123456789abcdef"[*p & 0xf]; - a = hex_char_buf; - } - strcpy(dst, a); - dst += strlen(a); - p++; - } -} - -// taken from kernel -#define COMMAND_LINE_SIZE 2048 -static char* get_cmdline(pid_t pid) -{ - char path[sizeof("/proc/%u/cmdline") + sizeof(int)*3]; - char cmdline[COMMAND_LINE_SIZE]; - char escaped_cmdline[COMMAND_LINE_SIZE*4 + 4]; - - escaped_cmdline[1] = '\0'; - sprintf(path, "/proc/%u/cmdline", (int)pid); - int fd = open(path, O_RDONLY); - if (fd >= 0) - { - int len = read(fd, cmdline, sizeof(cmdline) - 1); - close(fd); - - if (len > 0) - { - cmdline[len] = '\0'; - char *src = cmdline; - char *dst = escaped_cmdline; - while ((src - cmdline) < len) - { - dst = append_escaped(dst, src); - src += strlen(src) + 1; - } - } - } - - return xstrdup(escaped_cmdline + 1); /* +1 skips extraneous leading space */ -} - -static int daemon_is_ok() -{ - 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 */ - if (pid[0] == '\0' || pid[0] == '/') - return 0; - - /* TODO: maybe readlink and check that it is "xxx/abrt"? */ - char path[sizeof("/proc/%s/stat") + sizeof(pid)]; - sprintf(path, "/proc/%s/stat", pid); - struct stat sb; - if (stat(path, &sb) == -1) - { - return 0; - } - - return 1; -} - int main(int argc, char** argv) { int fd; struct stat sb; const char* program_name = argv[0]; - if (argc < 4) + if (argc < 5) { - error_msg_and_die("Usage: %s: <dddir> <pid> <signal> <uid>", program_name); + error_msg_and_die("Usage: %s: DUMPDIR PID SIGNO UID CORE_SIZE_LIMIT", program_name); } openlog("abrt", 0, LOG_DAEMON); logmode = LOGMODE_SYSLOG; + errno = 0; const char* dddir = argv[1]; - pid_t pid = atoi(argv[2]); + pid_t pid = xatoi_u(argv[2]); const char* signal_str = argv[3]; - int signal = atoi(argv[3]); - uid_t uid = atoi(argv[4]); - - if (signal != SIGQUIT - && signal != SIGILL - && signal != SIGABRT - && signal != SIGFPE - && signal != SIGSEGV + int signal_no = xatoi_u(argv[3]); + uid_t uid = xatoi_u(argv[4]); + off_t ulimit_c = strtoull(argv[5], NULL, 10); + off_t core_size = 0; + + if (errno || pid <= 0 || ulimit_c < 0) + { + error_msg_and_die("pid '%s' or limit '%s' is bogus", argv[2], argv[5]); + } + if (signal_no != SIGQUIT + && signal_no != SIGILL + && signal_no != SIGABRT + && signal_no != SIGFPE + && signal_no != SIGSEGV ) { /* not an error, exit silently */ return 0; } - if (pid <= 0 || (int)uid < 0) - { - 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; @@ -247,6 +121,65 @@ int main(int argc, char** argv) (int)pid, executable); } + /* 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)xatou(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); + } + + char path[PATH_MAX]; /* Check /var/cache/abrt/last-ccpp marker, do not dump repeated crashes @@ -267,7 +200,12 @@ int main(int argc, char** argv) { path[sz] = '\0'; if (strcmp(executable, path) == 0) - error_msg_and_die("not dumping repeating crash in '%s'", executable); + { + error_msg("not dumping repeating crash in '%s'", executable); + if (setting_MakeCompatCore) + goto create_user_core; + return 1; + } } lseek(fd, 0, SEEK_SET); } @@ -286,20 +224,20 @@ int main(int argc, char** argv) */ snprintf(path, sizeof(path), "%s/abrtd-coredump", dddir); 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) + core_size = copyfd_eof(STDIN_FILENO, core_fd); + if (core_size < 0 || close(core_fd) != 0) { unlink(path); /* copyfd_eof logs the error including errno string, * but it does not log file name */ error_msg_and_die("error saving coredump to %s", path); } - log("saved core dump of pid %u (%s) to %s (%llu bytes)", (int)pid, executable, path, (long long)size); + log("saved core dump of pid %u (%s) to %s (%llu bytes)", (int)pid, executable, path, (long long)core_size); return 0; } char* cmdline = get_cmdline(pid); /* never NULL */ - const char *signame = strsignal(atoi(signal_str)); + const char *signame = strsignal(signal_no); char *reason = xasprintf("Process was terminated by signal %s (%s)", signal_str, signame ? signame : signal_str); snprintf(path, sizeof(path), "%s/ccpp-%ld-%u", dddir, (long)time(NULL), (int)pid); @@ -325,8 +263,8 @@ int main(int argc, char** argv) dd.Close(); perror_msg_and_die("can't open '%s'", path); } - off_t size = copyfd_eof(STDIN_FILENO, core_fd); - if (size < 0 || fsync(core_fd) != 0) + core_size = copyfd_eof(STDIN_FILENO, core_fd); + if (core_size < 0 || fsync(core_fd) != 0) { unlink(path); dd.Delete(); @@ -337,7 +275,7 @@ 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); + log("saved core dump of pid %u (%s) to %s (%llu bytes)", (int)pid, executable, path, (long long)core_size); free(executable); free(cmdline); path[len] = '\0'; /* path now contains directory name */ @@ -350,64 +288,6 @@ int main(int argc, char** argv) */ 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? @@ -447,7 +327,12 @@ int main(int argc, char** argv) error_msg_and_die("%s", e.what()); } + create_user_core: + /* note: core_size may be == 0 ("unknown") */ + if (core_size > ulimit_c || ulimit_c == 0) + return 0; + /* Write a core file for user */ struct passwd* pw = getpwuid(uid); @@ -520,8 +405,10 @@ int main(int argc, char** argv) perror_msg_and_die("%s/%s is not a regular file with link count 1", user_pwd, core_basename); } + /* Note: we do not copy more than ulimit_c */ + off_t size; if (ftruncate(usercore_fd, 0) != 0 - || copyfd_eof(core_fd, usercore_fd) < 0 + || (size = copyfd_size(core_fd, usercore_fd, ulimit_c)) < 0 || close(usercore_fd) != 0 ) { /* perror first, otherwise unlink may trash errno */ @@ -529,7 +416,16 @@ int main(int argc, char** argv) unlink(core_basename); return 1; } - log("saved core dump of pid %u to %s/%s", (int)pid, user_pwd, core_basename); + if (size == ulimit_c && size != core_size) + { + /* We copied exactly ulimit_c bytes (and it doesn't accidentally match + * core_size (imagine exactly 1MB coredump with "ulimit -c 1M" - that'd be ok)), + * it means that core is larger than ulimit_c. Abort and delete the dump. + */ + unlink(core_basename); + return 1; + } + log("saved core dump of pid %u to %s/%s (%llu bytes)", (int)pid, user_pwd, core_basename, (long long)size); return 0; } diff --git a/src/Hooks/abrt-hook-python.cpp b/src/Hooks/abrt-hook-python.cpp index cd17e402..3f79d28a 100644 --- a/src/Hooks/abrt-hook-python.cpp +++ b/src/Hooks/abrt-hook-python.cpp @@ -34,21 +34,23 @@ static char *pid; static char *executable; static char *uuid; -static char *cmdline; int main(int argc, char** argv) { + // Error if daemon is not running. + if (!daemon_is_ok()) + error_msg_and_die("Daemon is not running."); + // Parse options static const struct option longopts[] = { // name , has_arg , flag, val { "pid" , required_argument, NULL, 'p' }, { "executable", required_argument, NULL, 'e' }, { "uuid" , required_argument, NULL, 'u' }, - { "cmdline" , required_argument, NULL, 'c' }, { 0 }, }; int opt; - while ((opt = getopt_long(argc, argv, "p:e:u:c:l:", longopts, NULL)) != -1) + while ((opt = getopt_long(argc, argv, "p:e:u:l:", longopts, NULL)) != -1) { switch (opt) { @@ -61,9 +63,6 @@ int main(int argc, char** argv) case 'u': uuid = optarg; break; - case 'c': - cmdline = optarg; - break; default: usage: error_msg_and_die( @@ -72,7 +71,6 @@ int main(int argc, char** argv) " -p,--pid PID PID of process that caused the crash\n" " -p,--executable PATH absolute path to the program that crashed\n" " -u,--uuid UUID hash generated from the backtrace\n" - " -c,--cmdline TEXT command line of the crashed program\n" ); } } @@ -103,8 +101,12 @@ int main(int argc, char** argv) dd.SaveText(FILENAME_ANALYZER, "Python"); if (executable) dd.SaveText(FILENAME_EXECUTABLE, executable); - if (cmdline) - dd.SaveText("cmdline", cmdline); + + pid_t pidt = xatoi(pid); + char *cmdline = get_cmdline(pidt); + dd.SaveText("cmdline", cmdline); + free(cmdline); + if (uuid) dd.SaveText("uuid", uuid); diff --git a/src/Hooks/abrt_exception_handler.py.in b/src/Hooks/abrt_exception_handler.py.in index b5ec35f3..a0b0519d 100644 --- a/src/Hooks/abrt_exception_handler.py.in +++ b/src/Hooks/abrt_exception_handler.py.in @@ -111,7 +111,6 @@ def write_dump(pid, tb_uuid, tb): command.append("--pid=%s" % pid) command.append("--executable=%s" % executable) command.append("--uuid=%s" % tb_uuid) - command.append("--cmdline=%s" % open("/proc/%s/cmdline" % pid).read().replace('\x00',' ')) helper = subprocess.Popen(command, stdin=subprocess.PIPE) helper.communicate(tb) diff --git a/src/Hooks/sitecustomize.py b/src/Hooks/sitecustomize.py index 8027726b..1a015745 100644 --- a/src/Hooks/sitecustomize.py +++ b/src/Hooks/sitecustomize.py @@ -5,41 +5,9 @@ # and python interpreter runs it automatically everytime # some python script is executed. -def abrt_daemon_ok(): - try: - #FIXME: make it relocable! this will work only when installed in default path - #pidfile = open(VAR_RUN_PID_FILE, "r"); - pidfile = open("/var/run/abrt.pid", "r") - except Exception, ex: - # log the exception? - return False - - pid = pidfile.readline() - pidfile.close() - if not pid: - return False - - try: - # pid[:-1] strips the trailing '\n' - cmdline = open("/proc/%s/cmdline" % pid[:-1], "r").readline() - except Exception, ex: - # can't read cmdline - return False - if not ("abrtd" in cmdline): - return False - - return True - -if abrt_daemon_ok(): - # Prevent abrt exception handler from running when the abrtd daemon is - # not active. - try: - from abrt_exception_handler import installExceptionHandler - - installExceptionHandler(debug = 1) - except Exception, e: - # FIXME: log errors? - pass -else: - #FIXME: log something? +try: + from abrt_exception_handler import installExceptionHandler + installExceptionHandler(debug = 1) +except Exception, e: + # FIXME: log errors? pass |