diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-10-28 13:40:44 +0100 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-10-28 13:40:44 +0100 |
commit | 872781a121687e62c0238aee67436a8a21db70a5 (patch) | |
tree | 7404ca2b52a51d36654ba41d349007e104fbfda6 | |
parent | be0c8d7252ae74610d885e21f47e454f8538898f (diff) | |
parent | e9ef9f0adc1f0c949cafa47c4f082494a289eb11 (diff) | |
download | abrt-872781a121687e62c0238aee67436a8a21db70a5.tar.gz abrt-872781a121687e62c0238aee67436a8a21db70a5.tar.xz abrt-872781a121687e62c0238aee67436a8a21db70a5.zip |
Merge branch 'master' of git://git.fedorahosted.org/git/abrt
-rw-r--r-- | abrt.spec | 15 | ||||
-rw-r--r-- | inc/abrtlib.h | 4 | ||||
-rw-r--r-- | lib/Plugins/Bugzilla.cpp | 90 | ||||
-rw-r--r-- | lib/Plugins/Bugzilla.h | 6 | ||||
-rw-r--r-- | lib/Plugins/Catcut.conf | 8 | ||||
-rw-r--r-- | lib/Plugins/Catcut.cpp | 365 | ||||
-rw-r--r-- | lib/Plugins/Catcut.h | 26 | ||||
-rw-r--r-- | lib/Plugins/FileTransfer.cpp | 5 | ||||
-rw-r--r-- | lib/Plugins/Makefile.am | 15 | ||||
-rw-r--r-- | lib/Utils/Makefile.am | 9 | ||||
-rw-r--r-- | lib/Utils/encbase64.cpp | 78 | ||||
-rw-r--r-- | src/Gui/settings_wizard.glade | 2 |
12 files changed, 546 insertions, 77 deletions
@@ -148,6 +148,14 @@ Requires: %{name} = %{version}-%{release} %description plugin-bugzilla Plugin to report bugs into the bugzilla. +%package plugin-catcut +Summary: %{name}'s catcut plugin +Group: System Environment/Libraries +Requires: %{name} = %{version}-%{release} + +%description plugin-catcut +Plugin to report bugs into the catcut. + %package plugin-ticketuploader Summary: %{name}'s ticketuploader plugin Group: System Environment/Libraries @@ -331,6 +339,13 @@ fi %{_libdir}/%{name}/Bugzilla.GTKBuilder %{_mandir}/man7/%{name}-Bugzilla.7.gz +%files plugin-catcut +%defattr(-,root,root,-) +%config(noreplace) %{_sysconfdir}/%{name}/plugins/Catcut.conf +%{_libdir}/%{name}/libCatcut.so* +#%{_libdir}/%{name}/Catcut.GTKBuilder +#%{_mandir}/man7/%{name}-Catcut.7.gz + %files plugin-ticketuploader %defattr(-,root,root,-) %config(noreplace) %{_sysconfdir}/%{name}/plugins/TicketUploader.conf diff --git a/inc/abrtlib.h b/inc/abrtlib.h index d98be0b6..2d4ef1c0 100644 --- a/inc/abrtlib.h +++ b/inc/abrtlib.h @@ -193,6 +193,10 @@ char* xmalloc_sockaddr2dotted(const struct sockaddr *sa); char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa); +/* Returns malloc'ed block */ +char *encode_base64(const void *src, int length); + + /* C++ style stuff */ std::string ssprintf(const char *format, ...); diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index d6f6c0c7..be81ebcc 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -1,3 +1,5 @@ +#include <xmlrpc-c/base.h> +#include <xmlrpc-c/client.h> #include "abrtlib.h" #include "Bugzilla.h" @@ -45,7 +47,9 @@ static void throw_if_fault_occurred(xmlrpc_env* e) { if (e->fault_occurred) { - throw CABRTException(EXCEP_PLUGIN, ssprintf("XML-RPC Fault: %s(%d)", e->fault_string, e->fault_code));; + std::string errmsg = ssprintf("XML-RPC Fault: %s(%d)", e->fault_string, e->fault_code); + error_msg("%s", errmsg.c_str()); // show error in daemon log + throw CABRTException(EXCEP_PLUGIN, errmsg); } } @@ -85,33 +89,13 @@ static void destroy_xmlrpc_client() CReporterBugzilla::CReporterBugzilla() : m_bNoSSLVerify(false), - m_bLoggedIn(false), m_sBugzillaURL("https://bugzilla.redhat.com"), - m_sBugzillaXMLRPC("https://bugzilla.redhat.com" + std::string(XML_RPC_SUFFIX)) + m_sBugzillaXMLRPC("https://bugzilla.redhat.com"XML_RPC_SUFFIX) {} CReporterBugzilla::~CReporterBugzilla() {} -#if 1 -PRInt32 CReporterBugzilla::Base64Encode_cb(void *arg, const char *obuf, PRInt32 size) -#else -static PRint32 base64_encode_cb(void *arg, const char* obuff, PRInt32 size) -#endif -{ - CReporterBugzilla* bz = static_cast<CReporterBugzilla*>(arg); - int ii; - for (ii = 0; ii < size; ii++) - { - if (isprint(obuf[ii])) - { - bz->m_sAttchmentInBase64 += obuf[ii]; - } - } - return 1; -} - - static void login(const char* login, const char* passwd) { xmlrpc_value* result = NULL; @@ -275,7 +259,7 @@ static void create_new_bug_description(const map_crash_report_t& pCrashReport, s } if (pCrashReport.find(CD_COMMENT) != pCrashReport.end()) { - comment = "\n\nComment\n" + comment = "\n\nComment\n" "-----\n" + pCrashReport.find(CD_COMMENT)->second[CD_CONTENT]; } @@ -285,8 +269,8 @@ static void create_new_bug_description(const map_crash_report_t& pCrashReport, s "\n\nAdditional information\n" "======\n"; - map_crash_report_t::const_iterator it; - for (it = pCrashReport.begin(); it != pCrashReport.end(); it++) + map_crash_report_t::const_iterator it = pCrashReport.begin(); + for (; it != pCrashReport.end(); it++) { if (it->second[CD_TYPE] == CD_TXT) { @@ -309,9 +293,8 @@ static void create_new_bug_description(const map_crash_report_t& pCrashReport, s } else if (it->second[CD_TYPE] == CD_BIN) { - char buffer[1024]; - snprintf(buffer, 1024, _("Binary file %s will not be reported."), it->first.c_str()); - warn_client(std::string(buffer)); + std::string msg = ssprintf(_("Binary file %s will not be reported."), it->first.c_str()); + warn_client(msg); //update_client(_("Binary file ")+it->first+_(" will not be reported.")); } } @@ -350,28 +333,23 @@ static void get_product_and_version(const std::string& pRelease, static uint32_t new_bug(const map_crash_report_t& pCrashReport) { - xmlrpc_value* param = NULL; - xmlrpc_value* result = NULL; - xmlrpc_value* id = NULL; - - xmlrpc_int bug_id = -1; - std::string package = pCrashReport.find(FILENAME_PACKAGE)->second[CD_CONTENT]; std::string component = pCrashReport.find(FILENAME_COMPONENT)->second[CD_CONTENT]; std::string release = pCrashReport.find(FILENAME_RELEASE)->second[CD_CONTENT]; std::string arch = pCrashReport.find(FILENAME_ARCHITECTURE)->second[CD_CONTENT]; std::string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT]; - std::string description; - std::string product; - std::string version; std::string summary = "[abrt] crash detected in " + package; std::string status_whiteboard = "abrt_hash:" + uuid; + std::string description; create_new_bug_description(pCrashReport, description); + + std::string product; + std::string version; get_product_and_version(release, product, version); - param = xmlrpc_build_value(&env, "({s:s,s:s,s:s,s:s,s:s,s:s,s:s})", + xmlrpc_value* param = xmlrpc_build_value(&env, "({s:s,s:s,s:s,s:s,s:s,s:s,s:s})", "product", product.c_str(), "component", component.c_str(), "version", version.c_str(), @@ -382,12 +360,15 @@ static uint32_t new_bug(const map_crash_report_t& pCrashReport) ); throw_if_fault_occurred(&env); + xmlrpc_value* result; xmlrpc_client_call2(&env, client, server_info, "Bug.create", param, &result); throw_if_fault_occurred(&env); + xmlrpc_value* id; xmlrpc_struct_find_value(&env, result, "id", &id); throw_if_fault_occurred(&env); + xmlrpc_int bug_id = -1; if (id) { xmlrpc_read_int(&env, id, &bug_id); @@ -400,38 +381,26 @@ static uint32_t new_bug(const map_crash_report_t& pCrashReport) return bug_id; } -void CReporterBugzilla::AddAttachments(const std::string& pBugId, const map_crash_report_t& pCrashReport) +static void add_attachments(const std::string& pBugId, const map_crash_report_t& pCrashReport) { - xmlrpc_value* param = NULL; xmlrpc_value* result = NULL; - NSSBase64Encoder* base64 = NULL; - map_crash_report_t::const_iterator it; - for (it = pCrashReport.begin(); it != pCrashReport.end(); it++) + map_crash_report_t::const_iterator it = pCrashReport.begin(); + for (; it != pCrashReport.end(); it++) { if (it->second[CD_TYPE] == CD_ATT) { - m_sAttchmentInBase64 = ""; - base64 = NSSBase64Encoder_Create(Base64Encode_cb, this); - if (!base64) - { - throw CABRTException(EXCEP_PLUGIN, "CReporterBugzilla::AddAttachemnt(): cannot initialize base64."); - } - - NSSBase64Encoder_Update(base64, - reinterpret_cast<const unsigned char*>(it->second[CD_CONTENT].c_str()), - it->second[CD_CONTENT].length()); - NSSBase64Encoder_Destroy(base64, PR_FALSE); - - std::string description = "File: " + it->first; - param = xmlrpc_build_value(&env,"(s{s:s,s:s,s:s,s:s})", + const std::string& to_encode = it->second[CD_CONTENT]; + char *encoded64 = encode_base64(to_encode.c_str(), to_encode.length()); + xmlrpc_value* param = xmlrpc_build_value(&env,"(s{s:s,s:s,s:s,s:s})", pBugId.c_str(), "description", description.c_str(), "filename", it->first.c_str(), "contenttype", "text/plain", - "data", m_sAttchmentInBase64.c_str() + "data", encoded64 ); + free(encoded64); throw_if_fault_occurred(&env); xmlrpc_client_call2(&env, client, server_info, "bugzilla.addAttachment", param, &result); @@ -474,7 +443,7 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, co update_client(_("Creating new bug...")); bug_id = new_bug(pCrashReport); - AddAttachments(to_string(bug_id), pCrashReport); + add_attachments(to_string(bug_id), pCrashReport); update_client(_("Logging out...")); logout(); @@ -484,7 +453,6 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, co { destroy_xmlrpc_client(); throw CABRTException(EXCEP_PLUGIN, std::string("CReporterBugzilla::Report(): ") + e.what()); - return ""; } destroy_xmlrpc_client(); @@ -519,7 +487,7 @@ void CReporterBugzilla::SetSettings(const map_plugin_settings_t& pSettings) m_sBugzillaURL.erase(--m_sBugzillaURL.end()); } */ - m_sBugzillaXMLRPC = m_sBugzillaURL + std::string(XML_RPC_SUFFIX); + m_sBugzillaXMLRPC = m_sBugzillaURL + XML_RPC_SUFFIX; } if (pSettings.find("Login") != pSettings.end()) { diff --git a/lib/Plugins/Bugzilla.h b/lib/Plugins/Bugzilla.h index 1fccbe47..17864650 100644 --- a/lib/Plugins/Bugzilla.h +++ b/lib/Plugins/Bugzilla.h @@ -3,17 +3,11 @@ #include "Plugin.h" #include "Reporter.h" -#include <nssb64.h> -#include <xmlrpc-c/base.h> -#include <xmlrpc-c/client.h> class CReporterBugzilla : public CReporter { private: bool m_bNoSSLVerify; - bool m_bLoggedIn; - static PRInt32 Base64Encode_cb(void *arg, const char *obuf, PRInt32 size); - void AddAttachments(const std::string& pBugId, const map_crash_report_t& pCrashReport); std::string m_sBugzillaURL; std::string m_sBugzillaXMLRPC; diff --git a/lib/Plugins/Catcut.conf b/lib/Plugins/Catcut.conf new file mode 100644 index 00000000..456d7f82 --- /dev/null +++ b/lib/Plugins/Catcut.conf @@ -0,0 +1,8 @@ +# Catcut URL +CatcutURL = http://127.0.0.1:8080/catcut/xmlrpc +# yes means that ssl certificates will not be checked +NoSSLVerify = no +# your login has to exist, if you don have any, please create one +Login = gavin +# your password +Password = junk diff --git a/lib/Plugins/Catcut.cpp b/lib/Plugins/Catcut.cpp new file mode 100644 index 00000000..ad55b2af --- /dev/null +++ b/lib/Plugins/Catcut.cpp @@ -0,0 +1,365 @@ +#include <xmlrpc-c/base.h> +#include <xmlrpc-c/client.h> + +#include "abrtlib.h" +#include "Catcut.h" +#include "CrashTypes.h" +#include "DebugDump.h" +#include "ABRTException.h" +#include "CommLayerInner.h" +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +using namespace std; + +static xmlrpc_env env; +static xmlrpc_client* client = NULL; +static struct xmlrpc_clientparms clientParms; +static struct xmlrpc_curl_xportparms curlParms; +static xmlrpc_server_info* server_info = NULL; + + +static string login(const char* login, const char* passwd); +//static void logout(); +static void new_xmlrpc_client(const char* url, bool no_ssl_verify); +static void destroy_xmlrpc_client(); +static void create_new_bug_description(const map_crash_report_t& pCrashReport, string& pDescription); +static void get_product_and_version(const string& pRelease, + string& pProduct, + string& pVersion); + + +static void throw_if_xml_fault_occurred() +{ + if (env.fault_occurred) + { + string errmsg = ssprintf("XML-RPC Fault: %s(%d)", env.fault_string, env.fault_code); + error_msg("%s", errmsg.c_str()); // show error in daemon log + throw CABRTException(EXCEP_PLUGIN, errmsg); + } +} + +static void new_xmlrpc_client(const char* url, bool no_ssl_verify) +{ + xmlrpc_env_init(&env); + xmlrpc_client_setup_global_const(&env); + + curlParms.network_interface = NULL; + curlParms.no_ssl_verifypeer = no_ssl_verify; + curlParms.no_ssl_verifyhost = no_ssl_verify; +#ifdef VERSION + curlParms.user_agent = PACKAGE_NAME"/"VERSION; +#else + curlParms.user_agent = "abrt"; +#endif + + clientParms.transport = "curl"; + clientParms.transportparmsP = &curlParms; + clientParms.transportparm_size = XMLRPC_CXPSIZE(user_agent); + + xmlrpc_client_create(&env, XMLRPC_CLIENT_NO_FLAGS, PACKAGE_NAME, VERSION, &clientParms, XMLRPC_CPSIZE(transportparm_size), + &client); + throw_if_xml_fault_occurred(); + + server_info = xmlrpc_server_info_new(&env, url); + throw_if_xml_fault_occurred(); +} + +static void destroy_xmlrpc_client() +{ + xmlrpc_server_info_free(server_info); + xmlrpc_env_clean(&env); + xmlrpc_client_destroy(client); + xmlrpc_client_teardown_global_const(); +} + +static string login(const char* login, const char* passwd) +{ + xmlrpc_value* param = xmlrpc_build_value(&env, "(ss)", login, passwd); + throw_if_xml_fault_occurred(); + + xmlrpc_value* result; + xmlrpc_client_call2(&env, client, server_info, "Catcut.auth", param, &result); + throw_if_xml_fault_occurred(); + xmlrpc_DECREF(param); + + xmlrpc_value *cookie_xml; + const char *cookie; + string cookie_str; + xmlrpc_struct_find_value(&env, result, "cookie", &cookie_xml); + throw_if_xml_fault_occurred(); + xmlrpc_read_string(&env, cookie_xml, &cookie); + throw_if_xml_fault_occurred(); + cookie_str = cookie; + xmlrpc_DECREF(cookie_xml); + + xmlrpc_DECREF(result); + + return cookie_str; +} + +// catcut does not have it (yet?) +//static void logout() +//{ +// xmlrpc_value* param = xmlrpc_build_value(&env, "(s)", ""); +// throw_if_xml_fault_occurred(); +// +// xmlrpc_value* result = NULL; /* paranoia */ +// xmlrpc_client_call2(&env, client, server_info, "User.logout", param, &result); +// throw_if_xml_fault_occurred(); +//} + +static void create_new_bug_description(const map_crash_report_t& pCrashReport, string& pDescription) +{ + string howToReproduce; + string comment; + + if (pCrashReport.find(CD_REPRODUCE) != pCrashReport.end()) + { + howToReproduce = "\n\nHow to reproduce\n" + "-----\n" + + pCrashReport.find(CD_REPRODUCE)->second[CD_CONTENT]; + } + if (pCrashReport.find(CD_COMMENT) != pCrashReport.end()) + { + comment = "\n\nComment\n" + "-----\n" + + pCrashReport.find(CD_COMMENT)->second[CD_CONTENT]; + } + pDescription = "\nabrt detected a crash.\n" + + howToReproduce + + comment + + "\n\nAdditional information\n" + "======\n"; + + map_crash_report_t::const_iterator it; + for (it = pCrashReport.begin(); it != pCrashReport.end(); it++) + { + if (it->second[CD_TYPE] == CD_TXT) + { + if (it->first != CD_UUID && + it->first != FILENAME_ARCHITECTURE && + it->first != FILENAME_RELEASE && + it->first != CD_REPRODUCE && + it->first != CD_COMMENT) + { + pDescription += "\n" + it->first + "\n"; + pDescription += "-----\n"; + pDescription += it->second[CD_CONTENT] + "\n\n"; + } + } + else if (it->second[CD_TYPE] == CD_ATT) + { + pDescription += "\n\nAttached files\n" + "----\n"; + pDescription += it->first + "\n"; + } + else if (it->second[CD_TYPE] == CD_BIN) + { + string msg = ssprintf(_("Binary file %s will not be reported."), it->first.c_str()); + warn_client(msg); + //update_client(_("Binary file ")+it->first+_(" will not be reported.")); + } + } +} + +static void get_product_and_version(const string& pRelease, + string& pProduct, + string& pVersion) +{ + if (pRelease.find("Rawhide") != string::npos) + { + pProduct = "Fedora"; + pVersion = "rawhide"; + return; + } + if (pRelease.find("Fedora") != string::npos) + { + pProduct = "Fedora"; + } + else if (pRelease.find("Red Hat Enterprise Linux") != string::npos) + { + pProduct = "Red Hat Enterprise Linux "; + } + string::size_type pos = pRelease.find("release"); + pos = pRelease.find(" ", pos) + 1; + while (pRelease[pos] != ' ') + { + pVersion += pRelease[pos]; + if (pProduct == "Red Hat Enterprise Linux ") + { + pProduct += pRelease[pos]; + } + pos++; + } +} + +static string new_bug(const char *auth_cookie, const map_crash_report_t& pCrashReport) +{ + string package = pCrashReport.find(FILENAME_PACKAGE)->second[CD_CONTENT]; + string component = pCrashReport.find(FILENAME_COMPONENT)->second[CD_CONTENT]; + string release = pCrashReport.find(FILENAME_RELEASE)->second[CD_CONTENT]; + string arch = pCrashReport.find(FILENAME_ARCHITECTURE)->second[CD_CONTENT]; + string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT]; + + string summary = "[abrt] crash detected in " + package; + string status_whiteboard = "abrt_hash:" + uuid; + + string description; + create_new_bug_description(pCrashReport, description); + + string product; + string version; + get_product_and_version(release, product, version); + + xmlrpc_value *param = xmlrpc_build_value(&env, "(s{s:s,s:s,s:s,s:s,s:s,s:s,s:s})", + auth_cookie, + "product", product.c_str(), + "component", component.c_str(), + "version", version.c_str(), + "summary", summary.c_str(), + "description", description.c_str(), + "status_whiteboard", status_whiteboard.c_str(), + "platform", arch.c_str() + ); + throw_if_xml_fault_occurred(); + + xmlrpc_value *result; + xmlrpc_client_call2(&env, client, server_info, "Catcut.createTicket", param, &result); + throw_if_xml_fault_occurred(); + xmlrpc_DECREF(param); + + xmlrpc_value *bug_id_xml; + const char *bug_id; + string bug_id_str; + xmlrpc_struct_find_value(&env, result, "ticket", &bug_id_xml); + throw_if_xml_fault_occurred(); + xmlrpc_read_string(&env, bug_id_xml, &bug_id); + throw_if_xml_fault_occurred(); + bug_id_str = bug_id; + log("New bug id: %s", bug_id); + update_client(_("New bug id: ") + bug_id_str); + xmlrpc_DECREF(bug_id_xml); + + xmlrpc_DECREF(result); + + return bug_id_str; +} + +//static +//void add_attachments(const string& pBugId, const map_crash_report_t& pCrashReport) +//{ +// xmlrpc_value* result = NULL; +// +// map_crash_report_t::const_iterator it = pCrashReport.begin(); +// for (; it != pCrashReport.end(); it++) +// { +// if (it->second[CD_TYPE] == CD_ATT) +// { +// string description = "File: " + it->first; +// const string& to_encode = it->second[CD_CONTENT]; +// char *encoded64 = encode_base64(to_encode.c_str(), to_encode.length()); +// xmlrpc_value* param = xmlrpc_build_value(&env,"(s{s:s,s:s,s:s,s:s})", +// pBugId.c_str(), +// "description", description.c_str(), +// "filename", it->first.c_str(), +// "contenttype", "text/plain", +// "data", encoded64 +// ); +// free(encoded64); +// throw_if_xml_fault_occurred(); +// +//// catcut has this API: +//// struct response requestUpload(string cookie, string ticket, string filename, string description) +////response MUST include "errno", "errmsg" members; if an upload is approved, +////a "URL" MUST be returned in the response. The description string +////should include a brief description of the file. +//// +////The client should upload the file via HTTP PUT to the provided +////URL. The provided URL may be absolute or relative, if relative it must +////be combined with the base URL of the XML-RPC server using the usual +////rules for relative URL's (RFC 3986). +// xmlrpc_client_call2(&env, client, server_info, "catcut.addAttachment", param, &result); +// throw_if_xml_fault_occurred(); +// } +// } +//} + +CReporterCatcut::CReporterCatcut() : + m_sCatcutURL("http://127.0.0.1:8080/catcut/xmlrpc"), + m_bNoSSLVerify(false) +{} + +CReporterCatcut::~CReporterCatcut() +{} + +string CReporterCatcut::Report(const map_crash_report_t& pCrashReport, const string& pArgs) +{ + update_client(_("Creating new bug...")); + try + { + new_xmlrpc_client(m_sCatcutURL.c_str(), m_bNoSSLVerify); + string auth_cookie = login(m_sLogin.c_str(), m_sPassword.c_str()); + string bug_id = (auth_cookie != "") ? new_bug(auth_cookie.c_str(), pCrashReport) : ""; +// add_attachments(to_string(bug_id), pCrashReport); +// update_client(_("Logging out...")); +// logout(); + destroy_xmlrpc_client(); + return "New catcut bug ID: " + bug_id; + + } + catch (CABRTException& e) + { + destroy_xmlrpc_client(); + throw CABRTException(EXCEP_PLUGIN, string("CReporterCatcut::Report(): ") + e.what()); + } +} + +void CReporterCatcut::SetSettings(const map_plugin_settings_t& pSettings) +{ + map_plugin_settings_t::const_iterator it; + map_plugin_settings_t::const_iterator end = pSettings.end(); + + it = pSettings.find("CatcutURL"); + if (it != end) + { + m_sCatcutURL = it->second; + } + it = pSettings.find("Login"); + if (it != end) + { + m_sLogin = it->second; + } + it = pSettings.find("Password"); + if (it != end) + { + m_sPassword = it->second; + } + it = pSettings.find("NoSSLVerify"); + if (it != end) + { + m_bNoSSLVerify = it->second == "yes"; + } +} + +map_plugin_settings_t CReporterCatcut::GetSettings() +{ + map_plugin_settings_t ret; + + ret["CatcutURL"] = m_sCatcutURL; + ret["Login"] = m_sLogin; + ret["Password"] = m_sPassword; + ret["NoSSLVerify"] = m_bNoSSLVerify ? "yes" : "no"; + + return ret; +} + +PLUGIN_INFO(REPORTER, + CReporterCatcut, + "Catcut", + "0.0.1", + "Test plugin to report bugs to catcut and if not, report it.", + "dvlasenk@redhat.com", + "https://fedorahosted.org/abrt/wiki", + PLUGINS_LIB_DIR"/Catcut.GTKBuilder"); diff --git a/lib/Plugins/Catcut.h b/lib/Plugins/Catcut.h new file mode 100644 index 00000000..69380387 --- /dev/null +++ b/lib/Plugins/Catcut.h @@ -0,0 +1,26 @@ +#ifndef CATCUT_H_ +#define CATCUT_H_ + +#include "Plugin.h" +#include "Reporter.h" + +class CReporterCatcut : public CReporter +{ + private: + std::string m_sCatcutURL; + std::string m_sLogin; + std::string m_sPassword; + bool m_bNoSSLVerify; + + public: + CReporterCatcut(); + virtual ~CReporterCatcut(); + + virtual void SetSettings(const map_plugin_settings_t& pSettings); + virtual map_plugin_settings_t GetSettings(); + + virtual std::string Report(const map_crash_report_t& pCrashReport, + const std::string& pArgs); +}; + +#endif /* CATCUT_H_ */ diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp index 3492156f..0573c511 100644 --- a/lib/Plugins/FileTransfer.cpp +++ b/lib/Plugins/FileTransfer.cpp @@ -77,9 +77,8 @@ void CFileTransfer::SendFile(const std::string& pURL, } } - char buffer[1024]; - snprintf(buffer, 1024, _("Sending archive %s via %s"), pFilename.c_str(), protocol.c_str()); - update_client(buffer); + std::string msg = ssprintf(_("Sending archive %s via %s"), pFilename.c_str(), protocol.c_str()); + update_client(msg.c_str()); std::string wholeURL; if (pURL[len-1] == '/') diff --git a/lib/Plugins/Makefile.am b/lib/Plugins/Makefile.am index a5c5a461..9165f63c 100644 --- a/lib/Plugins/Makefile.am +++ b/lib/Plugins/Makefile.am @@ -10,19 +10,22 @@ pluginslib_LTLIBRARIES = libCCpp.la \ libRunApp.la \ libSOSreport.la \ libBugzilla.la \ + libCatcut.la \ libTicketUploader.la \ libPython.la \ libFileTransfer.la dist_pluginslib_DATA = KerneloopsReporter.GTKBuilder Logger.GTKBuilder Mailx.GTKBuilder Bugzilla.GTKBuilder TicketUploader.GTKBuilder +# + Catcut.GTKBuilder? pluginsconfdir=$(PLUGINS_CONF_DIR) -dist_pluginsconf_DATA = CCpp.conf Mailx.conf SQLite3.conf Logger.conf KerneloopsScanner.conf KerneloopsReporter.conf Bugzilla.conf TicketUploader.conf FileTransfer.conf +dist_pluginsconf_DATA = CCpp.conf Mailx.conf SQLite3.conf Logger.conf KerneloopsScanner.conf KerneloopsReporter.conf Bugzilla.conf Catcut.conf TicketUploader.conf FileTransfer.conf man_MANS = abrt-FileTransfer.7 abrt-Bugzilla.7 abrt-KerneloopsReporter.7\ abrt-KerneloopsScanner.7 abrt-Logger.7 abrt-Mailx.7 abrt-plugins.7\ abrt-SQLite3.7 abrt-RunApp.7 abrt-TicketUploader.7 +# + abrt-Catcut.7 EXTRA_DIST = $(man_MANS) @@ -80,9 +83,15 @@ libSOSreport_la_LDFLAGS = -avoid-version # Bugzilla libBugzilla_la_SOURCES = Bugzilla.h Bugzilla.cpp -libBugzilla_la_LIBADD = $(XMLRPC_LIBS) $(XMLRPC_CLIENT_LIBS) $(NSS_LIBS) +libBugzilla_la_LIBADD = $(XMLRPC_LIBS) $(XMLRPC_CLIENT_LIBS) libBugzilla_la_LDFLAGS = -avoid-version -libBugzilla_la_CPPFLAGS = $(XMLRPC_CFLAGS) $(XMLRPC_CLIENT_CFLAGS) $(NSS_CFLAGS) -I$(srcdir)/../../inc -I$(srcdir)/../Utils -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" +libBugzilla_la_CPPFLAGS = $(XMLRPC_CFLAGS) $(XMLRPC_CLIENT_CFLAGS) -I$(srcdir)/../../inc -I$(srcdir)/../Utils -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" + +# Catcut +libCatcut_la_SOURCES = Catcut.h Catcut.cpp +libCatcut_la_LIBADD = $(XMLRPC_LIBS) $(XMLRPC_CLIENT_LIBS) +libCatcut_la_LDFLAGS = -avoid-version +libCatcut_la_CPPFLAGS = $(XMLRPC_CFLAGS) $(XMLRPC_CLIENT_CFLAGS) -I$(srcdir)/../../inc -I$(srcdir)/../Utils -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" # TicketUploader libTicketUploader_la_SOURCES = TicketUploader.h TicketUploader.cpp diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am index d24afa72..3c510851 100644 --- a/lib/Utils/Makefile.am +++ b/lib/Utils/Makefile.am @@ -1,10 +1,13 @@ lib_LTLIBRARIES = libABRTUtils.la +# Not used just yet: +# time.cpp +# xconnect.cpp +# skip_whitespace.cpp + libABRTUtils_la_SOURCES = \ - time.cpp \ xfuncs.cpp \ - xconnect.cpp \ - skip_whitespace.cpp \ + encbase64.cpp \ read_write.cpp \ logging.cpp \ copyfd.cpp \ diff --git a/lib/Utils/encbase64.cpp b/lib/Utils/encbase64.cpp new file mode 100644 index 00000000..6a6f1f75 --- /dev/null +++ b/lib/Utils/encbase64.cpp @@ -0,0 +1,78 @@ +/* + * Copyright 2006 Rob Landley <rob@landley.net> + * + * Licensed under GPLv2 or later. + */ +#include "abrtlib.h" /* xmalloc */ + +/* Conversion table for base 64 */ +static const char tbl_base64[65 /*+ 2*/] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '+', '/', + '=' /* termination character */, + // '\n', '\0' /* needed for uudecode.c */ +}; + +/* Conversion table for uuencode +const char tbl_uuencode[65] ALIGN1 = { + '`', '!', '"', '#', '$', '%', '&', '\'', + '(', ')', '*', '+', ',', '-', '.', '/', + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', ':', ';', '<', '=', '>', '?', + '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', + 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', + '`' +}; +*/ + +/* + * Encode bytes at S of length LENGTH. + * Result will be 0-terminated, and must point to a writable + * buffer of at least 1+BASE64_LENGTH(length) bytes, + * where BASE64_LENGTH(len) = 4 * ((LENGTH + 2) / 3) + */ +static void encode_64bit(char *p, const void *src, int length, const char *tbl) +{ + const unsigned char *s = (const unsigned char *)src; + + /* Transform the 3x8 bits to 4x6 bits */ + while (length > 0) { + unsigned s1, s2; + + /* Are s[1], s[2] valid or should be assumed 0? */ + s1 = s2 = 0; + length -= 3; /* can be >=0, -1, -2 */ + if (length >= -1) { + s1 = s[1]; + if (length >= 0) + s2 = s[2]; + } + *p++ = tbl[s[0] >> 2]; + *p++ = tbl[((s[0] & 3) << 4) + (s1 >> 4)]; + *p++ = tbl[((s1 & 0xf) << 2) + (s2 >> 6)]; + *p++ = tbl[s2 & 0x3f]; + s += 3; + } + /* Zero-terminate */ + *p = '\0'; + /* If length is -2 or -1, pad last char or two */ + while (length) { + *--p = tbl[64]; + length++; + } +} + +char *encode_base64(const void *src, int length) +{ + char *dst = (char *)xmalloc(4 * ((length + 2) / 3) + 1); + encode_64bit(dst, src, length, tbl_base64); + return dst; +} diff --git a/src/Gui/settings_wizard.glade b/src/Gui/settings_wizard.glade index 2af5d77d..feab4351 100644 --- a/src/Gui/settings_wizard.glade +++ b/src/Gui/settings_wizard.glade @@ -19,7 +19,7 @@ <child> <object class="GtkLabel" id="lWrongSettingsWarning"> <property name="visible">True</property> - <property name="label" translatable="yes"><b>WARNING:</b> Wrong settings detected for some of the enabled reporter plugins, please use the buttons bellow to open respective configuration and fix it before you proceed, otherwise the reporting process can fail. + <property name="label" translatable="yes"><b>WARNING:</b> Wrong settings detected for some of the enabled reporter plugins, please use the buttons below to open respective configuration and fix it before you proceed, otherwise the reporting process can fail. </property> <property name="use_markup">True</property> <property name="wrap">True</property> |