diff options
-rw-r--r-- | inc/analyzer.h | 7 | ||||
-rw-r--r-- | inc/crash_types.h | 1 | ||||
-rw-r--r-- | lib/plugins/CCpp.cpp | 161 | ||||
-rw-r--r-- | lib/plugins/CCpp.h | 1 | ||||
-rw-r--r-- | lib/plugins/Kerneloops.cpp | 54 | ||||
-rw-r--r-- | lib/plugins/Kerneloops.h | 2 | ||||
-rw-r--r-- | lib/plugins/Python.cpp | 62 | ||||
-rw-r--r-- | lib/plugins/Python.h | 4 | ||||
-rw-r--r-- | src/daemon/MiddleWare.cpp | 155 | ||||
-rw-r--r-- | src/daemon/MiddleWare.h | 2 | ||||
-rw-r--r-- | src/daemon/abrt-action-bugzilla.cpp | 31 | ||||
-rw-r--r-- | src/daemon/abrt-action-kerneloops.cpp | 22 | ||||
-rw-r--r-- | src/daemon/abrt-action-print.cpp | 21 | ||||
-rw-r--r-- | src/daemon/abrt-action-rhtsupport.cpp | 45 | ||||
-rw-r--r-- | src/daemon/abrt_event.conf | 4 |
15 files changed, 151 insertions, 421 deletions
diff --git a/inc/analyzer.h b/inc/analyzer.h index 3f2c6952..1d78d576 100644 --- a/inc/analyzer.h +++ b/inc/analyzer.h @@ -29,13 +29,6 @@ */ class CAnalyzer : public CPlugin { - public: - /** - * A method, which gets a global UUID of particular crash. - * @param pDebugDumpPath A debugdump dir containing all necessary data. - * @return A global UUID. - */ - virtual std::string GetGlobalUUID(const char *pDebugDumpDir) = 0; }; #endif /*ANALYZER_H_*/ diff --git a/inc/crash_types.h b/inc/crash_types.h index 96d05d38..9774de06 100644 --- a/inc/crash_types.h +++ b/inc/crash_types.h @@ -33,7 +33,6 @@ #define FILENAME_COREDUMP "coredump" #define FILENAME_BACKTRACE "backtrace" #define FILENAME_MEMORYMAP "memorymap" -// Used to cache GetGlobalUUID() calls #define FILENAME_DUPHASH "global_uuid" /* name is compat, to be renamed to "duphash" */ // Name of the function where the application crashed. // Optional. diff --git a/lib/plugins/CCpp.cpp b/lib/plugins/CCpp.cpp index ddc17206..fad9cf62 100644 --- a/lib/plugins/CCpp.cpp +++ b/lib/plugins/CCpp.cpp @@ -50,167 +50,6 @@ CAnalyzerCCpp::CAnalyzerCCpp() : m_nGdbTimeoutSec(60) {} -static void create_hash(char hash_str[SHA1_RESULT_LEN*2 + 1], const char *pInput) -{ - unsigned len; - unsigned char hash2[SHA1_RESULT_LEN]; - sha1_ctx_t sha1ctx; - - sha1_begin(&sha1ctx); - sha1_hash(pInput, strlen(pInput), &sha1ctx); - sha1_end(hash2, &sha1ctx); - len = SHA1_RESULT_LEN; - - char *d = hash_str; - unsigned char *s = hash2; - while (len) - { - *d++ = "0123456789abcdef"[*s >> 4]; - *d++ = "0123456789abcdef"[*s & 0xf]; - s++; - len--; - } - *d = '\0'; - //log("hash2:%s str:'%s'", hash_str, pInput); -} - -string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir) -{ - struct dump_dir *dd = dd_opendir(pDebugDumpDir, /*flags:*/ 0); - if (!dd) - return string(""); - - if (dd_exist(dd, FILENAME_DUPHASH)) - { - char *uuid = dd_load_text(dd, FILENAME_DUPHASH); - dd_close(dd); - string ret = uuid; - free(uuid); - return ret; - } - else - { - // Compatibility code. - // This whole block should be deleted for Fedora 14. - log(_("Getting global universal unique identification...")); - - string backtrace_path = concat_path_file(pDebugDumpDir, FILENAME_BACKTRACE); - char *executable = dd_load_text(dd, FILENAME_EXECUTABLE); - char *package = dd_load_text(dd, FILENAME_PACKAGE); - char *uid_str = m_bBacktrace ? dd_load_text(dd, CD_UID) : xstrdup(""); - - string independent_backtrace; - if (m_bBacktrace) - { - /* Run abrt-backtrace to get independent backtrace suitable - to UUID calculation. */ - char *backtrace_path = concat_path_file(pDebugDumpDir, FILENAME_BACKTRACE); - char *args[7]; - args[0] = (char*)"abrt-backtrace"; - args[1] = (char*)"--single-thread"; - args[2] = (char*)"--remove-exit-handlers"; - args[3] = (char*)"--frame-depth=5"; - args[4] = (char*)"--remove-noncrash-frames"; - args[5] = backtrace_path; - args[6] = NULL; - - int pipeout[2]; - xpipe(pipeout); /* stdout of abrt-backtrace */ - - fflush(NULL); - pid_t child = fork(); - if (child == -1) - perror_msg_and_die("fork"); - if (child == 0) - { - VERB1 log("Executing %s", args[0]); - - xmove_fd(pipeout[1], STDOUT_FILENO); - close(pipeout[0]); /* read side of the pipe */ - - /* abrt-backtrace is executed under the user's uid and gid. */ - uid_t uid = xatoi_u(uid_str); - struct passwd* pw = getpwuid(uid); - gid_t gid = pw ? pw->pw_gid : uid; - setgroups(1, &gid); - xsetregid(gid, gid); - xsetreuid(uid, uid); - - execvp(args[0], args); - VERB1 perror_msg("Can't execute '%s'", args[0]); - exit(1); - } - - free(backtrace_path); - close(pipeout[1]); /* write side of the pipe */ - - /* Read the result from abrt-backtrace. */ - int r; - char buff[1024]; - while ((r = safe_read(pipeout[0], buff, sizeof(buff) - 1)) > 0) - { - buff[r] = '\0'; - independent_backtrace += buff; - } - close(pipeout[0]); - - /* Wait until it exits, and check the exit status. */ - errno = 0; - int status; - waitpid(child, &status, 0); - if (!WIFEXITED(status)) - { - perror_msg("abrt-backtrace not executed properly, " - "status: %x signal: %d", status, WIFSIGNALED(status)); - } - else - { - int exit_status = WEXITSTATUS(status); - if (exit_status == 79) /* EX_PARSINGFAILED */ - { - /* abrt-backtrace returns alternative backtrace - representation in this case, so everything will work - as expected except worse duplication detection */ - log_msg("abrt-backtrace failed to parse the backtrace"); - } - else if (exit_status == 80) /* EX_THREADDETECTIONFAILED */ - { - /* abrt-backtrace returns backtrace with all threads - in this case, so everything will work as expected - except worse duplication detection */ - log_msg("abrt-backtrace failed to determine crash frame"); - } - else if (exit_status != 0) - { - /* this is unexpected problem and it should be investigated */ - error_msg("abrt-backtrace run failed, exit value: %d", - exit_status); - } - } - - /*VERB1 log("abrt-backtrace result: %s", independent_backtrace.c_str());*/ - } - /* else: no backtrace, independent_backtrace == "" - no backtrace => rating = 0 - */ - else - { - dd_save_text(dd, FILENAME_RATING, "0"); - } - dd_close(dd); - - char *hash_str = xasprintf("%s%s%s", package, executable, independent_backtrace.c_str()); - free(package); - free(executable); - - char hash_str2[SHA1_RESULT_LEN*2 + 1]; - create_hash(hash_str2, hash_str); - free(hash_str); - - return hash_str2; - } -} - /* this is just a workaround until kernel changes it's behavior when handling pipes in core_pattern diff --git a/lib/plugins/CCpp.h b/lib/plugins/CCpp.h index dcd80982..db372b01 100644 --- a/lib/plugins/CCpp.h +++ b/lib/plugins/CCpp.h @@ -41,7 +41,6 @@ class CAnalyzerCCpp : public CAnalyzer public: CAnalyzerCCpp(); - virtual std::string GetGlobalUUID(const char *pDebugDumpDir); virtual void Init(); virtual void DeInit(); virtual void SetSettings(const map_plugin_settings_t& pSettings); diff --git a/lib/plugins/Kerneloops.cpp b/lib/plugins/Kerneloops.cpp index 0a59681b..37cab992 100644 --- a/lib/plugins/Kerneloops.cpp +++ b/lib/plugins/Kerneloops.cpp @@ -21,60 +21,6 @@ #include "Kerneloops.h" #include "abrt_exception.h" -using namespace std; - -static string load(const char *dirname, const char *filename) -{ - string ret; - - struct dump_dir *dd = dd_opendir(dirname, /*flags:*/ 0); - if (!dd) - return ret; /* "" */ - char *s = dd_load_text(dd, filename); - dd_close(dd); - - if (!s[0]) - { - free(s); - - pid_t pid = fork(); - if (pid < 0) - { - perror_msg("fork"); - return ret; /* "" */ - } - if (pid == 0) /* child */ - { - char *argv[4]; /* abrt-action-analyze-oops -d DIR <NULL> */ - char **pp = argv; - *pp++ = (char*)"abrt-action-analyze-oops"; - *pp++ = (char*)"-d"; - *pp++ = (char*)dirname; - *pp = NULL; - - execvp(argv[0], argv); - perror_msg_and_die("Can't execute '%s'", argv[0]); - } - /* parent */ - waitpid(pid, NULL, 0); - - dd = dd_opendir(dirname, /*flags:*/ 0); - if (!dd) - return ret; /* "" */ - s = dd_load_text(dd, filename); - dd_close(dd); - } - - ret = s; - free(s); - return ret; -} - -string CAnalyzerKerneloops::GetGlobalUUID(const char *pDebugDumpDir) -{ - return load(pDebugDumpDir, FILENAME_DUPHASH); -} - PLUGIN_INFO(ANALYZER, CAnalyzerKerneloops, "Kerneloops", diff --git a/lib/plugins/Kerneloops.h b/lib/plugins/Kerneloops.h index af6bef0e..914f1fc8 100644 --- a/lib/plugins/Kerneloops.h +++ b/lib/plugins/Kerneloops.h @@ -33,8 +33,6 @@ class CAnalyzerKerneloops : public CAnalyzer { - public: - virtual std::string GetGlobalUUID(const char *pDebugDumpDir); }; #endif diff --git a/lib/plugins/Python.cpp b/lib/plugins/Python.cpp index 9d625a1c..e955b5fb 100644 --- a/lib/plugins/Python.cpp +++ b/lib/plugins/Python.cpp @@ -20,68 +20,6 @@ #include "Python.h" #include "abrt_exception.h" -using namespace std; - -static string load(const char *dirname, const char *filename) -{ - string ret; - - struct dump_dir *dd = dd_opendir(dirname, /*flags:*/ 0); - if (!dd) - return ret; /* "" */ - char *s = dd_load_text(dd, filename); - dd_close(dd); - - if (!s[0]) - { - free(s); - - pid_t pid = fork(); - if (pid < 0) - { - perror_msg("fork"); - return ret; /* "" */ - } - if (pid == 0) /* child */ - { - char *argv[4]; /* abrt-action-analyze-python -d DIR <NULL> */ - char **pp = argv; - *pp++ = (char*)"abrt-action-analyze-python"; - *pp++ = (char*)"-d"; - *pp++ = (char*)dirname; - *pp = NULL; - - execvp(argv[0], argv); - perror_msg_and_die("Can't execute '%s'", argv[0]); - } - /* parent */ - waitpid(pid, NULL, 0); - - dd = dd_opendir(dirname, /*flags:*/ 0); - if (!dd) - return ret; /* "" */ - s = dd_load_text(dd, filename); - dd_close(dd); - } - - ret = s; - free(s); - return ret; -} - -string CAnalyzerPython::GetGlobalUUID(const char *pDebugDumpDir) -{ - return load(pDebugDumpDir, FILENAME_DUPHASH); -} - -void CAnalyzerPython::Init() -{ -} - -void CAnalyzerPython::DeInit() -{ -} - PLUGIN_INFO(ANALYZER, CAnalyzerPython, "Python", diff --git a/lib/plugins/Python.h b/lib/plugins/Python.h index c862ad45..3f01d2c6 100644 --- a/lib/plugins/Python.h +++ b/lib/plugins/Python.h @@ -25,10 +25,6 @@ class CAnalyzerPython : public CAnalyzer { - public: - virtual std::string GetGlobalUUID(const char *pDebugDumpDir); - virtual void Init(); - virtual void DeInit(); }; #endif /* PYTHON_H_ */ diff --git a/src/daemon/MiddleWare.cpp b/src/daemon/MiddleWare.cpp index 2df49dc1..3ad2e9d6 100644 --- a/src/daemon/MiddleWare.cpp +++ b/src/daemon/MiddleWare.cpp @@ -18,11 +18,9 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <algorithm> /* for std::find */ #include "abrtlib.h" #include "Daemon.h" #include "Settings.h" -#include "rpm.h" #include "abrt_exception.h" #include "abrt_packages.h" #include "comm_layer_inner.h" @@ -83,23 +81,6 @@ static bool DebugDumpToCrashReport(const char *pDebugDumpDir, map_crash_data_t& return true; } -/** - * Get a global UUID from particular analyzer plugin. - * @param pAnalyzer A name of an analyzer plugin. - * @param pDebugDumpDir A debugdump dir containing all necessary data. - * @return A global UUID. - */ -static std::string GetGlobalUUID(const char *pAnalyzer, - const char *pDebugDumpDir) -{ - CAnalyzer* analyzer = g_pPluginManager->GetAnalyzer(pAnalyzer); - if (analyzer) - { - return analyzer->GetGlobalUUID(pDebugDumpDir); - } - throw CABRTException(EXCEP_PLUGIN, "Error running '%s'", pAnalyzer); -} - static char *do_log_and_update_client(char *log_line, void *param) { VERB1 log("%s", log_line); @@ -237,12 +218,26 @@ void RunActionsAndReporters(const char *pDebugDumpDir) } } +struct logging_state { + char *last_line; +}; + +static char *do_log_and_save_line(char *log_line, void *param) +{ + struct logging_state *l_state = (struct logging_state *)param; + + VERB1 log("%s", log_line); + update_client("%s", log_line); + free(l_state->last_line); + l_state->last_line = log_line; + return NULL; +} // Do not trust client_report here! // dbus handler passes it from user without checking report_status_t Report(const map_crash_data_t& client_report, const vector_string_t &reporters, - map_map_string_t& settings, + const map_map_string_t& settings, long caller_uid) { // Get ID fields @@ -271,7 +266,7 @@ report_status_t Report(const map_crash_data_t& client_report, caller_uid, crash_id.c_str()); } - const std::string& pDumpDir = get_crash_data_item_content(stored_report, CD_DUMPDIR); + const char *dump_dir_name = get_crash_data_item_content_or_NULL(stored_report, CD_DUMPDIR); // Save comment, "how to reproduce", backtrace //TODO: we should iterate through stored_report and modify all @@ -281,7 +276,7 @@ report_status_t Report(const map_crash_data_t& client_report, const char *backtrace = get_crash_data_item_content_or_NULL(client_report, FILENAME_BACKTRACE); if (comment || reproduce || backtrace) { - struct dump_dir *dd = dd_opendir(pDumpDir.c_str(), /*flags:*/ 0); + struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0); if (dd) { if (comment) @@ -322,14 +317,6 @@ report_status_t Report(const map_crash_data_t& client_report, its++; } - const std::string& analyzer = get_crash_data_item_content(stored_report, FILENAME_ANALYZER); - - std::string dup_hash = GetGlobalUUID(analyzer.c_str(), pDumpDir.c_str()); - VERB3 log(" DUPHASH:'%s'", dup_hash.c_str()); - add_to_crash_data_ext(stored_report, FILENAME_DUPHASH, CD_TXT, CD_ISNOTEDITABLE, dup_hash.c_str()); - - // Run reporters - VERB3 { log("Run reporters"); log_map_crash_data(client_report, " client_report"); @@ -337,65 +324,77 @@ report_status_t Report(const map_crash_data_t& client_report, } #define client_report client_report_must_not_be_used_below - map_crash_data_t::const_iterator its_PACKAGE = stored_report.find(FILENAME_PACKAGE); - std::string packageNVR = its_PACKAGE->second[CD_CONTENT]; - char * packageName = get_package_name_from_NVR_or_NULL(packageNVR.c_str()); - - // analyzer with package name (CCpp:xorg-x11-app) has higher priority - char* key = xasprintf("%s:%s",analyzer.c_str(),packageName); - free(packageName); - map_analyzer_actions_and_reporters_t::iterator end = s_mapAnalyzerActionsAndReporters.end(); - map_analyzer_actions_and_reporters_t::iterator keyPtr = s_mapAnalyzerActionsAndReporters.find(key); - if (keyPtr == end) + // Export overridden settings as environment variables + GList *env_list = NULL; + map_map_string_t::const_iterator reporter_settings = settings.begin(); + while (reporter_settings != settings.end()) { - VERB3 log("'%s' not found, looking for '%s'", key, analyzer.c_str()); - // if there is no such settings, then try default analyzer - keyPtr = s_mapAnalyzerActionsAndReporters.find(analyzer); + map_string_t::const_iterator var = reporter_settings->second.begin(); + while (var != reporter_settings->second.end()) + { + char *s = xasprintf("%s_%s=%s", reporter_settings->first.c_str(), var->first.c_str(), var->second.c_str()); + VERB3 log("Exporting '%s'", s); + putenv(s); + env_list = g_list_append(env_list, s); + var++; + } + reporter_settings++; } - free(key); + // Run reporters bool at_least_one_reporter_succeeded = false; report_status_t ret; std::string message; - if (keyPtr != end) + struct logging_state l_state; + struct run_event_state *run_state = new_run_event_state(); + run_state->logging_callback = do_log_and_save_line; + run_state->logging_param = &l_state; + for (unsigned i = 0; i < reporters.size(); i++) { - VERB2 log("Found AnalyzerActionsAndReporters for '%s'", analyzer.c_str()); + std::string plugin_name = "report_" + reporters[i]; - vector_pair_string_string_t::iterator it_r = keyPtr->second.begin(); - for (; it_r != keyPtr->second.end(); it_r++) + l_state.last_line = NULL; + int r = run_event(run_state, dump_dir_name, plugin_name.c_str()); + if (r == 0) { - const char *plugin_name = it_r->first.c_str(); - - /* Check if the reporter is in the input list of allowed reporters. */ - if (reporters.end() == std::find(reporters.begin(), reporters.end(), plugin_name)) - { - continue; - } + at_least_one_reporter_succeeded = true; + ret[plugin_name].push_back("1"); // REPORT_STATUS_IDX_FLAG + ret[plugin_name].push_back(l_state.last_line ? : "Reporting succeeded"); // REPORT_STATUS_IDX_MSG + if (message != "") + message += ";"; + message += (l_state.last_line ? : "Reporting succeeded"); + } + else + { + ret[plugin_name].push_back("0"); // REPORT_STATUS_IDX_FLAG + ret[plugin_name].push_back(l_state.last_line ? : "Error in reporting"); // REPORT_STATUS_IDX_MSG + update_client("Reporting via '%s' was not successful%s%s", + plugin_name.c_str(), + l_state.last_line ? ": " : "", + l_state.last_line ? l_state.last_line : "" + ); + } + free(l_state.last_line); + } + free_run_event_state(run_state); - try - { - if (g_pPluginManager->GetPluginType(plugin_name) == REPORTER) - { - CReporter* reporter = g_pPluginManager->GetReporter(plugin_name); /* can't be NULL */ - map_plugin_settings_t plugin_settings = settings[plugin_name]; - std::string res = reporter->Report(stored_report, plugin_settings, it_r->second.c_str()); - ret[plugin_name].push_back("1"); // REPORT_STATUS_IDX_FLAG - ret[plugin_name].push_back(res); // REPORT_STATUS_IDX_MSG - if (message != "") - message += ";"; - message += res; - at_least_one_reporter_succeeded = true; - } - } - catch (CABRTException& e) - { - ret[plugin_name].push_back("0"); // REPORT_STATUS_IDX_FLAG - ret[plugin_name].push_back(e.what()); // REPORT_STATUS_IDX_MSG - update_client("Reporting via '%s' was not successful: %s", plugin_name, e.what()); - } - } // for - } // if + // Unexport overridden settings + for (GList *li = env_list; li; li = g_list_next(li)) + { + char *s = (char*)li->data; + /* Need to make a copy: just cutting s at '=' and unsetenv'ing + * the result would be a bug! s _itself_ is in environment now, + * we must not modify it there! + */ + char *name = xstrndup(s, strchrnul(s, '=') - s); + VERB3 log("Unexporting '%s'", name); + unsetenv(name); + free(name); + free(s); + } + g_list_free(env_list); + // Save reporting results to database if (at_least_one_reporter_succeeded) { CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase); diff --git a/src/daemon/MiddleWare.h b/src/daemon/MiddleWare.h index efe354f2..8eb2759c 100644 --- a/src/daemon/MiddleWare.h +++ b/src/daemon/MiddleWare.h @@ -94,7 +94,7 @@ void RunActionsAndReporters(const char *pDebugDumpDir); */ report_status_t Report(const map_crash_data_t& crash_data, const vector_string_t& reporters, - map_map_string_t& settings, + const map_map_string_t& settings, long caller_uid); /** * Adds package name and description to debugdump dir. diff --git a/src/daemon/abrt-action-bugzilla.cpp b/src/daemon/abrt-action-bugzilla.cpp index f7a6081c..a3c2f0b0 100644 --- a/src/daemon/abrt-action-bugzilla.cpp +++ b/src/daemon/abrt-action-bugzilla.cpp @@ -577,28 +577,32 @@ static void report_to_bugzilla( load_crash_data_from_debug_dump(dd, pCrashData); dd_close(dd); + const char *env; const char *login; const char *password; const char *bugzilla_xmlrpc; const char *bugzilla_url; bool ssl_verify; - login = settings["Login"].c_str(); - password = settings["Password"].c_str(); - bugzilla_url = settings["BugzillaURL"].c_str(); - if (!bugzilla_url[0]) - bugzilla_url = "https://bugzilla.redhat.com"; - bugzilla_xmlrpc = settings["BugzillaXMLRPC"].c_str(); - if (!bugzilla_xmlrpc[0]) - bugzilla_xmlrpc = xasprintf("%s"XML_RPC_SUFFIX, bugzilla_url); - ssl_verify = string_to_bool(settings["SSLVerify"].c_str()); - + env = getenv("Bugzilla_Login"); + login = env ? env : settings["Login"].c_str(); + env = getenv("Bugzilla_Password"); + password = env ? env : settings["Password"].c_str(); if (!login[0] || !password[0]) { VERB3 log("Empty login and password"); throw CABRTException(EXCEP_PLUGIN, _("Empty login or password, please check %s"), PLUGINS_CONF_DIR"/Bugzilla.conf"); } + env = getenv("Bugzilla_BugzillaURL"); + bugzilla_url = env ? env : settings["BugzillaURL"].c_str(); + if (!bugzilla_url[0]) + bugzilla_url = "https://bugzilla.redhat.com"; + bugzilla_xmlrpc = xasprintf("%s"XML_RPC_SUFFIX, bugzilla_url); + + env = getenv("Bugzilla_SSLVerify"); + ssl_verify = string_to_bool(env ? env : settings["SSLVerify"].c_str()); + const char *component = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_COMPONENT); const char *duphash = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_DUPHASH); const char *release = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_RELEASE); @@ -715,7 +719,7 @@ static void report_to_bugzilla( log(_("Logging out...")); bz_server.logout(); - printf("STATUS:Status: NEW %s/show_bug.cgi?id=%u\n", + log("Status: NEW %s/show_bug.cgi?id=%u", bugzilla_url, (int)bug_id ); @@ -812,7 +816,7 @@ static void report_to_bugzilla( log(_("Logging out...")); bz_server.logout(); - printf("STATUS:Status: %s%s%s %s/show_bug.cgi?id=%u\n", + log("Status: %s%s%s %s/show_bug.cgi?id=%u", bz.bug_status, bz.bug_resolution ? " " : "", bz.bug_resolution ? bz.bug_resolution : "", @@ -897,8 +901,7 @@ int main(int argc, char **argv) } catch (CABRTException& e) { - printf("EXCEPT:%s\n", e.what()); - return 1; + error_msg_and_die("%s", e.what()); } return 0; diff --git a/src/daemon/abrt-action-kerneloops.cpp b/src/daemon/abrt-action-kerneloops.cpp index 0d0b35c4..4c820081 100644 --- a/src/daemon/abrt-action-kerneloops.cpp +++ b/src/daemon/abrt-action-kerneloops.cpp @@ -87,21 +87,26 @@ static CURLcode http_post_to_kerneloops_site(const char *url, const char *oopsda static void report_to_kerneloops( const char *dump_dir_name, - /*const*/ map_plugin_settings_t& settings) + const map_plugin_settings_t& settings) { struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0); if (!dd) - throw CABRTException(EXCEP_PLUGIN, _("Can't open '%s'"), dump_dir_name); + exit(1); /* error msg is already logged */ + map_crash_data_t pCrashData; load_crash_data_from_debug_dump(dd, pCrashData); dd_close(dd); const char *backtrace = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_BACKTRACE); if (!backtrace) - throw CABRTException(EXCEP_PLUGIN, "Error sending kernel oops due to missing backtrace"); -//TODO: check that analyzer == "oops" too? + error_msg_and_die("Error sending kernel oops due to missing backtrace"); + + map_plugin_settings_t::const_iterator end = settings.end(); + map_plugin_settings_t::const_iterator it; - const char *submitURL = settings["SubmitURL"].c_str(); + const char *env = getenv("KerneloopsReporter_SubmitURL"); + it = settings.find("SubmitURL"); + const char *submitURL = (env ? env : it == end ? "" : it->second.c_str()); if (!submitURL[0]) submitURL = "http://submit.kerneloops.org/submitoops.php"; @@ -109,14 +114,14 @@ static void report_to_kerneloops( CURLcode ret = http_post_to_kerneloops_site(submitURL, backtrace); if (ret != CURLE_OK) - throw CABRTException(EXCEP_PLUGIN, "Kernel oops has not been sent due to %s", curl_easy_strerror(ret)); + error_msg_and_die("Kernel oops has not been sent due to %s", curl_easy_strerror(ret)); /* Server replies with: * 200 thank you for submitting the kernel oops information * RemoteIP: 34192fd15e34bf60fac6a5f01bba04ddbd3f0558 * - no URL or bug ID apparently... */ - printf("STATUS:Kernel oops report was uploaded\n"); + log("Kernel oops report was uploaded"); } int main(int argc, char **argv) @@ -185,8 +190,7 @@ int main(int argc, char **argv) } catch (CABRTException& e) { - printf("EXCEPT:%s\n", e.what()); - return 1; + error_msg_and_die("%s", e.what()); } return 0; diff --git a/src/daemon/abrt-action-print.cpp b/src/daemon/abrt-action-print.cpp index c6988921..75f5bd92 100644 --- a/src/daemon/abrt-action-print.cpp +++ b/src/daemon/abrt-action-print.cpp @@ -27,6 +27,7 @@ #define PROGNAME "abrt-action-print" static const char *dump_dir_name = "."; +static const char *output_file = NULL; int main(int argc, char **argv) { @@ -35,24 +36,38 @@ int main(int argc, char **argv) g_verbose = atoi(env_verbose); const char *program_usage = _( - PROGNAME" [-v] -d DIR\n" + PROGNAME" [-v] [-o FILE] -d DIR\n" "\n" "Print information about the crash to standard output"); enum { OPT_v = 1 << 0, OPT_d = 1 << 1, + OPT_o = 1 << 2, }; /* Keep enum above and order of options below in sync! */ struct options program_options[] = { OPT__VERBOSE(&g_verbose), - OPT_STRING('d', NULL, &dump_dir_name, "DIR", _("Crash dump directory")), + OPT_STRING('d', NULL, &dump_dir_name, "DIR" , _("Crash dump directory")), + OPT_STRING('o', NULL, &output_file , "FILE", _("Output file")), OPT_END() }; +//BITROT: restore handling of: +// $Logger_AppendLogs=yes +// $Logger_LogPath=/var/log/abrt.log + /*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage); putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose)); + if (output_file) + { + if (!freopen(output_file, "w", stdout)) + { + perror_msg_and_die("Can't open '%s'", output_file); + } + } + try { struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0); @@ -73,5 +88,7 @@ int main(int argc, char **argv) return 1; } + if (output_file) + log("The report was stored to %s", output_file); return 0; } diff --git a/src/daemon/abrt-action-rhtsupport.cpp b/src/daemon/abrt-action-rhtsupport.cpp index ee61dd59..d1854541 100644 --- a/src/daemon/abrt-action-rhtsupport.cpp +++ b/src/daemon/abrt-action-rhtsupport.cpp @@ -17,7 +17,6 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE 1 /* for stpcpy */ #include <libtar.h> #include "abrtlib.h" #include "abrt_curl.h" @@ -33,13 +32,12 @@ static void report_to_rhtsupport( const char *dump_dir_name, - /*const*/ map_plugin_settings_t& pSettings) + const map_plugin_settings_t& settings) { struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0); if (!dd) - { - throw CABRTException(EXCEP_PLUGIN, _("Can't open '%s'"), dump_dir_name); - } + exit(1); /* error msg is already logged by dd_opendir */ + map_crash_data_t pCrashData; load_crash_data_from_debug_dump(dd, pCrashData); dd_close(dd); @@ -58,19 +56,25 @@ static void report_to_rhtsupport( const char* reason; const char* package; - map_plugin_settings_t::const_iterator end = pSettings.end(); + char* env; + map_plugin_settings_t::const_iterator end = settings.end(); map_plugin_settings_t::const_iterator it; - it = pSettings.find("URL"); - char *url = xstrdup(it == end ? "https://api.access.redhat.com/rs" : it->second.c_str()); - it = pSettings.find("Login"); - char *login = xstrdup(it == end ? "" : it->second.c_str()); + env = getenv("RHTSupport_URL"); + it = settings.find("URL"); + char *url = xstrdup(env ? env : it == end ? "https://api.access.redhat.com/rs" : it->second.c_str()); - it = pSettings.find("Password"); - char *password = xstrdup(it == end ? "" : it->second.c_str()); + env = getenv("RHTSupport_Login"); + it = settings.find("Login"); + char *login = xstrdup(env ? env : it == end ? "" : it->second.c_str()); - it = pSettings.find("SSLVerify"); - bool ssl_verify = (it == end ? true : string_to_bool(it->second.c_str())); + env = getenv("RHTSupport_Password"); + it = settings.find("Password"); + char *password = xstrdup(env ? env : it == end ? "" : it->second.c_str()); + + env = getenv("RHTSupport_SSLVerify"); + it = settings.find("SSLVerify"); + bool ssl_verify = string_to_bool(env ? env : it == end ? "1" : it->second.c_str()); if (!login[0] || !password[0]) { @@ -224,12 +228,10 @@ static void report_to_rhtsupport( break; } /* Use sanitized string as error message */ - CABRTException e(EXCEP_PLUGIN, "%s", result); - free(result); - throw e; + error_msg_and_die("%s", result); } /* No error */ - printf("STATUS:%s\n", result); + log("%s", result); free(result); } @@ -252,9 +254,7 @@ static void report_to_rhtsupport( free(password); if (errmsg) - { - throw CABRTException(EXCEP_PLUGIN, "%s", errmsg); - } + error_msg_and_die("%s", errmsg); } int main(int argc, char **argv) @@ -331,8 +331,7 @@ int main(int argc, char **argv) } catch (CABRTException& e) { - printf("EXCEPT:%s\n", e.what()); - return 1; + error_msg_and_die("%s", e.what()); } return 0; diff --git a/src/daemon/abrt_event.conf b/src/daemon/abrt_event.conf index 377ef66c..22fda0ae 100644 --- a/src/daemon/abrt_event.conf +++ b/src/daemon/abrt_event.conf @@ -48,6 +48,6 @@ EVENT=reanalyze analyzer=CCpp abrt-action-generate-backtrace EVENT=report analyzer=oops abrt-action-kerneloops EVENT=report_Bugzilla analyzer=CCpp abrt-action-bugzilla -EVENT=report_Logger analyzer=CCpp abrt-action-print >/var/log/abrt.log +EVENT=report_Logger analyzer=CCpp abrt-action-print -o /var/log/abrt.log EVENT=report_Bugzilla analyzer=python abrt-action-bugzilla -EVENT=report_Logger analyzer=python abrt-action-print >/var/log/abrt.log +EVENT=report_Logger analyzer=python abrt-action-print -o /var/log/abrt.log |