summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNikola Pajkovsky <npajkovs@redhat.com>2010-02-15 18:09:55 +0100
committerNikola Pajkovsky <npajkovs@redhat.com>2010-02-15 18:09:55 +0100
commitd93fc21129f08a149d7a1bb042179942485fcedb (patch)
tree72ec4eb636b15d8e2385f068881f86a6aa88db2b /lib
parentdeef343e0372b0a167f1d35f9ef9d18694aa9a0e (diff)
parent3a0729e697b24d4d30e3a1a008f83ca605aaad5d (diff)
downloadabrt-d93fc21129f08a149d7a1bb042179942485fcedb.tar.gz
abrt-d93fc21129f08a149d7a1bb042179942485fcedb.tar.xz
abrt-d93fc21129f08a149d7a1bb042179942485fcedb.zip
Merge branch 'master' into bugzilla
Diffstat (limited to 'lib')
-rw-r--r--lib/Plugins/Bugzilla.conf2
-rw-r--r--lib/Plugins/Makefile.am30
-rw-r--r--lib/Plugins/Python.cpp23
-rw-r--r--lib/Plugins/Python_hash.cpp17
-rw-r--r--lib/Utils/Plugin.cpp69
-rw-r--r--lib/Utils/Plugin.h18
-rw-r--r--lib/Utils/make_descr.cpp1
-rw-r--r--lib/Utils/xfuncs.cpp2
8 files changed, 142 insertions, 20 deletions
diff --git a/lib/Plugins/Bugzilla.conf b/lib/Plugins/Bugzilla.conf
index 14fc92c..ff2f828 100644
--- a/lib/Plugins/Bugzilla.conf
+++ b/lib/Plugins/Bugzilla.conf
@@ -1,4 +1,4 @@
-Enabled = 1
+Enabled = yes
# Bugzilla URL
BugzillaURL = https://bugzilla.redhat.com/
# yes means that ssl certificates will not be checked
diff --git a/lib/Plugins/Makefile.am b/lib/Plugins/Makefile.am
index 4fc0efe..fe3969f 100644
--- a/lib/Plugins/Makefile.am
+++ b/lib/Plugins/Makefile.am
@@ -7,6 +7,7 @@ pluginslib_LTLIBRARIES = \
libLogger.la \
libKerneloopsScanner.la\
libKerneloops.la \
+ libKerneloopsReporter.la \
libRunApp.la \
libSOSreport.la \
libBugzilla.la \
@@ -18,8 +19,11 @@ pluginslib_LTLIBRARIES = \
dist_pluginslib_DATA = \
Logger.GTKBuilder \
- Mailx.GTKBuilder Bugzilla.GTKBuilder \
- TicketUploader.GTKBuilder Catcut.GTKBuilder
+ Mailx.GTKBuilder \
+ Bugzilla.GTKBuilder \
+ TicketUploader.GTKBuilder \
+ Catcut.GTKBuilder \
+ KerneloopsReporter.GTKBuilder
pluginsconfdir = $(PLUGINS_CONF_DIR)
dist_pluginsconf_DATA = \
@@ -35,9 +39,17 @@ dist_pluginsconf_DATA = \
Python.conf \
SOSreport.conf
-man_MANS = abrt-FileTransfer.7 abrt-Bugzilla.7 \
- abrt-KerneloopsScanner.7 abrt-Logger.7 abrt-Mailx.7 abrt-plugins.7 \
- abrt-SQLite3.7 abrt-RunApp.7 abrt-TicketUploader.7
+man_MANS = \
+ abrt-FileTransfer.7 \
+ abrt-Bugzilla.7 \
+ abrt-KerneloopsScanner.7 \
+ abrt-KerneloopsReporter.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)
@@ -78,10 +90,10 @@ libKerneloops_la_LDFLAGS = -avoid-version
libKerneloops_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../Utils
# KerneloopsReporter
-#libKerneloopsReporter_la_SOURCES = KerneloopsReporter.cpp KerneloopsReporter.h
-#libKerneloopsReporter_la_LDFLAGS = -avoid-version
-#libKerneloopsReporter_la_LIBADD = $(CURL_LIBS)
-#libKerneloopsReporter_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../Utils $(CURL_CFLAGS) -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\"
+libKerneloopsReporter_la_SOURCES = KerneloopsReporter.cpp KerneloopsReporter.h
+libKerneloopsReporter_la_LDFLAGS = -avoid-version
+libKerneloopsReporter_la_LIBADD = $(CURL_LIBS)
+libKerneloopsReporter_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../Utils $(CURL_CFLAGS) -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\"
# KerneloopsScanner
libKerneloopsScanner_la_SOURCES = KerneloopsScanner.cpp KerneloopsScanner.h KerneloopsSysLog.cpp KerneloopsSysLog.h
diff --git a/lib/Plugins/Python.cpp b/lib/Plugins/Python.cpp
index d6a3084..12cc47e 100644
--- a/lib/Plugins/Python.cpp
+++ b/lib/Plugins/Python.cpp
@@ -38,7 +38,27 @@ string CAnalyzerPython::GetLocalUUID(const char *pDebugDumpDir)
unsigned char hash2[MD5_RESULT_LEN];
md5_ctx_t md5ctx;
md5_begin(&md5ctx);
- md5_hash(bt_str, bt_end - bt_str, &md5ctx);
+ // Better:
+ // "example.py:1:<module>:ZeroDivisionError: integer division or modulo by zero"
+ //md5_hash(bt_str, bt_end - bt_str, &md5ctx);
+ // For now using compat version:
+ {
+ char *copy = xstrndup(bt_str, bt_end - bt_str);
+ char *s = copy;
+ char *d = copy;
+ unsigned colon_cnt = 0;
+ while (*s && colon_cnt < 3) {
+ if (*s != ':')
+ *d++ = *s;
+ else
+ colon_cnt++;
+ s++;
+ }
+ // "example.py1<module>"
+ md5_hash(copy, d - copy, &md5ctx);
+//*d = '\0'; log("str:'%s'", copy);
+ free(copy);
+ }
md5_end(hash2, &md5ctx);
// Hash is MD5_RESULT_LEN bytes long, but we use only first 4
@@ -56,7 +76,6 @@ string CAnalyzerPython::GetLocalUUID(const char *pDebugDumpDir)
//log("hash2:%s str:'%.*s'", hash_str, (int)(bt_end - bt_str), bt_str);
return hash_str;
-
}
string CAnalyzerPython::GetGlobalUUID(const char *pDebugDumpDir)
{
diff --git a/lib/Plugins/Python_hash.cpp b/lib/Plugins/Python_hash.cpp
index ae246b3..36ddacd 100644
--- a/lib/Plugins/Python_hash.cpp
+++ b/lib/Plugins/Python_hash.cpp
@@ -14,6 +14,7 @@
*/
#include "abrtlib.h"
#include "Python_hash.h"
+#include <byteswap.h>
#if defined(__BIG_ENDIAN__) && __BIG_ENDIAN__
# define MD5_BIG_ENDIAN 1
@@ -28,6 +29,16 @@
# error "Can't determine endianness"
#endif
+/* SWAP_LEnn means "convert CPU<->little_endian if needed (by swapping bytes)" */
+#if MD5_BIG_ENDIAN
+# define SWAP_BE32(x) (x)
+# define SWAP_LE32(x) bswap_32(x)
+#else
+# define SWAP_BE32(x) bswap_32(x)
+# define SWAP_LE32(x) (x)
+#endif
+
+
/* 0: fastest, 3: smallest */
#define MD5_SIZE_VS_SPEED 3
@@ -123,11 +134,7 @@ static void md5_hash_block(const void *buffer, md5_ctx_t *ctx)
uint32_t temp;
for (i = 0; i < 16; i++) {
-#if MD5_BIG_ENDIAN
- cwp[i] = bswap_32(words[i]);
-#else
- cwp[i] = words[i];
-#endif
+ cwp[i] = SWAP_LE32(words[i]);
}
words += 16;
diff --git a/lib/Utils/Plugin.cpp b/lib/Utils/Plugin.cpp
index 2865027..40cd2a0 100644
--- a/lib/Utils/Plugin.cpp
+++ b/lib/Utils/Plugin.cpp
@@ -17,6 +17,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "Plugin.h"
+#include "abrtlib.h"
CPlugin::CPlugin() {}
@@ -33,3 +34,71 @@ const map_plugin_settings_t& CPlugin::GetSettings()
{
return m_pSettings;
}
+
+bool LoadPluginSettings(const char *pPath, map_plugin_settings_t& pSettings,
+ bool skipKeysWithoutValue /*= true*/)
+{
+ FILE *fp = fopen(pPath, "r");
+ if (!fp)
+ return false;
+
+ char line[512];
+ while (fgets(line, sizeof(line), fp))
+ {
+ strchrnul(line, '\n')[0] = '\0';
+ unsigned ii;
+ bool is_value = false;
+ bool valid = false;
+ bool in_quote = false;
+ std::string key;
+ std::string value;
+ for (ii = 0; line[ii] != '\0'; ii++)
+ {
+ if (line[ii] == '"')
+ {
+ in_quote = !in_quote;
+ }
+ if (isspace(line[ii]) && !in_quote)
+ {
+ continue;
+ }
+ if (line[ii] == '#' && !in_quote && key == "")
+ {
+ break;
+ }
+ if (line[ii] == '=' && !in_quote)
+ {
+ is_value = true;
+ valid = true;
+ continue;
+ }
+ if (!is_value)
+ {
+ key += line[ii];
+ }
+ else
+ {
+ value += line[ii];
+ }
+ }
+
+ /* Skip broken or empty lines. */
+ if (!valid)
+ continue;
+
+ /* Skip lines with empty key. */
+ if (key.length() == 0)
+ continue;
+
+ if (skipKeysWithoutValue && value.length() == 0)
+ continue;
+
+ /* Skip lines with unclosed quotes. */
+ if (in_quote)
+ continue;
+
+ pSettings[key] = value;
+ }
+ fclose(fp);
+ return true;
+}
diff --git a/lib/Utils/Plugin.h b/lib/Utils/Plugin.h
index 1eefac6..3ae3d62 100644
--- a/lib/Utils/Plugin.h
+++ b/lib/Utils/Plugin.h
@@ -118,10 +118,26 @@ typedef struct SPluginInfo
PLUGINS_MAGIC_NUMBER,\
};
-/* helper finctions */
+/* helper functions */
std::string make_description_bz(const map_crash_data_t& pCrashData);
std::string make_description_reproduce_comment(const map_crash_data_t& pCrashData);
std::string make_description_logger(const map_crash_data_t& pCrashData);
std::string make_description_catcut(const map_crash_data_t& pCrashData);
+/**
+ * Loads settings and stores it in second parameter. On success it
+ * returns true, otherwise returns false.
+ *
+ * @param path A path of config file.
+ * Config file consists of "key=value" lines.
+ * @param settings A readed plugin's settings.
+ * @param skipKeysWithoutValue
+ * If true, lines in format "key=" (without value) are skipped.
+ * Otherwise empty value "" is inserted into pSettings.
+ * @return if it success it returns true, otherwise it returns false.
+ */
+extern bool LoadPluginSettings(const char *pPath,
+ map_plugin_settings_t& pSettings,
+ bool skipKeysWithoutValue = true);
+
#endif
diff --git a/lib/Utils/make_descr.cpp b/lib/Utils/make_descr.cpp
index d04bf95..8019896 100644
--- a/lib/Utils/make_descr.cpp
+++ b/lib/Utils/make_descr.cpp
@@ -71,7 +71,6 @@ static void add_content(bool &was_multiline, string& description, const char *he
static const char *const blacklisted_items_bz[] = {
FILENAME_TIME ,
FILENAME_UID ,
- FILENAME_UUID ,
FILENAME_ANALYZER ,
FILENAME_COREDUMP ,
FILENAME_DESCRIPTION, /* package description - basically useless */
diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp
index 16f4cb0..7301d7f 100644
--- a/lib/Utils/xfuncs.cpp
+++ b/lib/Utils/xfuncs.cpp
@@ -252,7 +252,7 @@ void xstat(const char *name, struct stat *stat_buf)
perror_msg_and_die("can't stat '%s'", name);
}
-std::string get_home_dir(int uid)
+std::string get_home_dir(uid_t uid)
{
struct passwd* pw = getpwuid(uid);
return pw ? pw->pw_dir : "";