From dc3c5b79ba1ee6fd7a98842fde43d072e004f93b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 8 Dec 2010 16:07:31 +0100 Subject: add abrt_ prefixes to abrt-internal functions in libabrt.so Signed-off-by: Denys Vlasenko --- src/daemon/Settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/daemon/Settings.cpp') diff --git a/src/daemon/Settings.cpp b/src/daemon/Settings.cpp index 5b9972ba..abdd0324 100644 --- a/src/daemon/Settings.cpp +++ b/src/daemon/Settings.cpp @@ -207,7 +207,7 @@ static int ParseCommon() it = s_mapSectionCommon.find("MaxCrashReportsSize"); if (it != end) { - g_settings_nMaxCrashReportsSize = xatoi_u(it->second.c_str()); + g_settings_nMaxCrashReportsSize = xatoi_positive(it->second.c_str()); } it = s_mapSectionCommon.find("ProcessUnpackaged"); if (it != end) -- cgit From e796e95a4efbfeb04223f61c600c7712da7b500f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 17 Jan 2011 16:39:11 +0100 Subject: replace KerneloopsScanner plugin and dumpoops with abrt-dump-oops, use it in abrtd Patch adds new tool: $ abrt-dump-oops Usage: abrt-dump-oops [-vsrdow] FILE Extract oops from syslog/dmesg file -v, --verbose Be verbose -s Log to syslog -r Parse kernel's message buffer before parsing FILE -d Create ABRT dump for every oops found -o Print found oopses on standard output -w Do not exit, watch the file for new oopses It extends dumpoops. Extensions: * it can watch the syslog using -w option (uses inotify) * it can scan dmesg buffer too In this way, it also becomes a replacement for KerneloopsScanner plugin: oops-detecting logic is taken verbatim from KerneloopsScanner source. abrtd is changed to start it if it sees this directive in abrt.conf: [ LogScanners ] abrt-dump-oops = abrt-dump-oops -drw /var/log/messages Default abrt.conf is changed to have such line. Patch doesn't remove KerneloopsScanner plugin and dumpoops binary yet, I will do it in a separate trivial patch. Signed-off-by: Denys Vlasenko --- src/daemon/Settings.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/daemon/Settings.cpp') diff --git a/src/daemon/Settings.cpp b/src/daemon/Settings.cpp index abdd0324..63453933 100644 --- a/src/daemon/Settings.cpp +++ b/src/daemon/Settings.cpp @@ -19,8 +19,9 @@ #include "abrtlib.h" #include "Settings.h" -#define SECTION_COMMON "Common" -#define SECTION_CRON "Cron" +#define SECTION_COMMON "Common" +#define SECTION_LOG_SCANNERS "LogScanners" +#define SECTION_CRON "Cron" /* Conf file has this format: * [ section_name1 ] @@ -47,13 +48,16 @@ static map_string_t s_mapSectionCron; /* one line: "OpenGPGCheck = value" */ bool g_settings_bOpenGPGCheck = false; /* one line: "OpenGPGPublicKeys = value1,value2" */ -GList *g_settings_setOpenGPGPublicKeys = NULL; -GList *g_settings_setBlackListedPkgs = NULL; -GList *g_settings_setBlackListedPaths = NULL; -char *g_settings_sWatchCrashdumpArchiveDir = NULL; +GList * g_settings_setOpenGPGPublicKeys = NULL; +GList * g_settings_setBlackListedPkgs = NULL; +GList * g_settings_setBlackListedPaths = NULL; +char * g_settings_sWatchCrashdumpArchiveDir = NULL; unsigned int g_settings_nMaxCrashReportsSize = 1000; bool g_settings_bProcessUnpackaged = false; +/* [ LogScanners ] */ +char * g_settings_sLogScanners = NULL; + /* [ Cron ] */ /* many lines, one per key: "map_key = aa_first,bb_first(bb_second),cc_first" */ map_cron_t g_settings_mapCron; @@ -277,7 +281,7 @@ static int ReadConfigurationFromFile(FILE *fp) value += line[ii]; continue; } - if (isspace(line[ii]) && !is_quote) + if (isspace(line[ii]) && !is_quote && is_key) { continue; } @@ -304,8 +308,9 @@ static int ReadConfigurationFromFile(FILE *fp) section += line[ii]; continue; } - if (line[ii] == '=' && !is_quote) + if (is_key && line[ii] == '=' && !is_quote) { + while (isspace(line[ii + 1])) ii++; is_key = false; key = value; value = ""; @@ -351,6 +356,10 @@ static int ReadConfigurationFromFile(FILE *fp) s_mapSectionCommon[key] += ","; s_mapSectionCommon[key] += value; } + else if (section == SECTION_LOG_SCANNERS) + { + g_settings_sLogScanners = xstrdup(value.c_str()); + } else if (section == SECTION_CRON) { if (s_mapSectionCron[key] != "") -- cgit From b3330ba6dccd65f4d0bef843e092f4c0f2c56c7f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 17 Jan 2011 17:41:59 +0100 Subject: remove [ Cron ] handling Signed-off-by: Denys Vlasenko --- src/daemon/Settings.cpp | 131 ------------------------------------------------ 1 file changed, 131 deletions(-) (limited to 'src/daemon/Settings.cpp') diff --git a/src/daemon/Settings.cpp b/src/daemon/Settings.cpp index 63453933..d155b4ec 100644 --- a/src/daemon/Settings.cpp +++ b/src/daemon/Settings.cpp @@ -21,7 +21,6 @@ #define SECTION_COMMON "Common" #define SECTION_LOG_SCANNERS "LogScanners" -#define SECTION_CRON "Cron" /* Conf file has this format: * [ section_name1 ] @@ -38,8 +37,6 @@ * If the same name found on more than one line, * the values are appended, separated by comma: map["name"] = "value1,value2" */ static map_string_t s_mapSectionCommon; -/* ... from [ Cron ] */ -static map_string_t s_mapSectionCron; /* Public data */ /* Written out exactly in this order by SaveSettings() */ @@ -58,10 +55,6 @@ bool g_settings_bProcessUnpackaged = false; /* [ LogScanners ] */ char * g_settings_sLogScanners = NULL; -/* [ Cron ] */ -/* many lines, one per key: "map_key = aa_first,bb_first(bb_second),cc_first" */ -map_cron_t g_settings_mapCron; - /* * Loading @@ -90,101 +83,6 @@ static GList *parse_list(const char* list) return l; } -/* Format: name, name(param),name("param with spaces \"and quotes\"") */ -static vector_pair_string_string_t ParseListWithArgs(const char *pValue, int *err) -{ - VERB3 log(" ParseListWithArgs(%s)", pValue); - - vector_pair_string_string_t pluginsWithArgs; - std::string item; - std::string action; - bool is_quote = false; - bool is_arg = false; - for (int ii = 0; pValue[ii]; ii++) - { - if (is_quote && pValue[ii] == '\\' && pValue[ii + 1]) - { - ii++; - item += pValue[ii]; - continue; - } - if (pValue[ii] == '"') - { - is_quote = !is_quote; - /*item += pValue[ii]; - wrong! name("param") must be == name(param) */ - continue; - } - if (is_quote) - { - item += pValue[ii]; - continue; - } - if (pValue[ii] == '(') - { - if (!is_arg) - { - action = item; - item = ""; - is_arg = true; - } - else - { - *err = 1; - error_msg("Parser error: Invalid syntax on column %d in \"%s\"", ii, pValue); - } - - continue; - } - if (pValue[ii] == ')') - { - if (is_arg) - { - VERB3 log(" adding (%s,%s)", action.c_str(), item.c_str()); - pluginsWithArgs.push_back(make_pair(action, item)); - item = ""; - is_arg = false; - action = ""; - } - else - { - *err = 1; - error_msg("Parser error: Invalid syntax on column %d in \"%s\"", ii, pValue); - } - - continue; - } - if (pValue[ii] == ',' && !is_arg) - { - if (item != "") - { - VERB3 log(" adding (%s,%s)", item.c_str(), ""); - pluginsWithArgs.push_back(make_pair(item, "")); - item = ""; - } - continue; - } - item += pValue[ii]; - } - - if (is_quote) - { - *err = 1; - error_msg("Parser error: Unclosed quote in \"%s\"", pValue); - } - - if (is_arg) - { - *err = 1; - error_msg("Parser error: Unclosed argument in \"%s\"", pValue); - } - else if (item != "") - { - VERB3 log(" adding (%s,%s)", item.c_str(), ""); - pluginsWithArgs.push_back(make_pair(item, "")); - } - return pluginsWithArgs; -} - static int ParseCommon() { map_string_t::const_iterator end = s_mapSectionCommon.end(); @@ -221,20 +119,6 @@ static int ParseCommon() return 0; /* no error */ } -static int ParseCron() -{ - map_string_t::iterator it = s_mapSectionCron.begin(); - for (; it != s_mapSectionCron.end(); it++) - { - int err = 0; - vector_pair_string_string_t actionsAndReporters = ParseListWithArgs(it->second.c_str(), &err); - if (err) - return err; - g_settings_mapCron[it->first] = actionsAndReporters; - } - return 0; /* no error */ -} - static void LoadGPGKeys() { FILE *fp = fopen(CONF_DIR"/gpg_keys", "r"); @@ -360,12 +244,6 @@ static int ReadConfigurationFromFile(FILE *fp) { g_settings_sLogScanners = xstrdup(value.c_str()); } - else if (section == SECTION_CRON) - { - if (s_mapSectionCron[key] != "") - s_mapSectionCron[key] += ","; - s_mapSectionCron[key] += value; - } else { error_msg("abrt.conf: Ignoring entry in invalid section [%s]", section.c_str()); @@ -396,8 +274,6 @@ int LoadSettings() if (err == 0) err = ParseCommon(); - if (err == 0) - err = ParseCron(); if (err == 0) { @@ -420,7 +296,6 @@ map_abrt_settings_t GetSettings() map_abrt_settings_t ABRTSettings; ABRTSettings[SECTION_COMMON] = s_mapSectionCommon; - ABRTSettings[SECTION_CRON] = s_mapSectionCron; return ABRTSettings; } @@ -435,12 +310,6 @@ void SetSettings(const map_abrt_settings_t& pSettings, const char *dbus_sender) s_mapSectionCommon = it->second; ParseCommon(); } - it = pSettings.find(SECTION_CRON); - if (it != end) - { - s_mapSectionCron = it->second; - ParseCron(); - } } void settings_free() -- cgit From 006e7e8dd2592c949c4f986473a8bfe975aa8264 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 20 Jan 2011 16:39:20 +0100 Subject: convert abrt-action-save-package-data.cpp to C The conversion is trivial: a few tweaks to one header file Signed-off-by: Denys Vlasenko --- src/daemon/Settings.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/daemon/Settings.cpp') diff --git a/src/daemon/Settings.cpp b/src/daemon/Settings.cpp index d155b4ec..5b5b18dd 100644 --- a/src/daemon/Settings.cpp +++ b/src/daemon/Settings.cpp @@ -39,7 +39,6 @@ static map_string_t s_mapSectionCommon; /* Public data */ -/* Written out exactly in this order by SaveSettings() */ /* [ Common ] */ /* one line: "OpenGPGCheck = value" */ -- cgit From 21b7afb11405bc7ff24b43e6f441a40faff3a539 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 20 Jan 2011 17:19:18 +0100 Subject: disable SetSettings dbus call code Signed-off-by: Denys Vlasenko --- src/daemon/Settings.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/daemon/Settings.cpp') diff --git a/src/daemon/Settings.cpp b/src/daemon/Settings.cpp index 5b5b18dd..b8f8751e 100644 --- a/src/daemon/Settings.cpp +++ b/src/daemon/Settings.cpp @@ -299,17 +299,17 @@ map_abrt_settings_t GetSettings() return ABRTSettings; } -/* dbus call to change some .conf file data */ -void SetSettings(const map_abrt_settings_t& pSettings, const char *dbus_sender) -{ - map_abrt_settings_t::const_iterator it = pSettings.find(SECTION_COMMON); - map_abrt_settings_t::const_iterator end = pSettings.end(); - if (it != end) - { - s_mapSectionCommon = it->second; - ParseCommon(); - } -} +///* dbus call to change some .conf file data */ +//void SetSettings(const map_abrt_settings_t& pSettings, const char *dbus_sender) +//{ +// map_abrt_settings_t::const_iterator it = pSettings.find(SECTION_COMMON); +// map_abrt_settings_t::const_iterator end = pSettings.end(); +// if (it != end) +// { +// s_mapSectionCommon = it->second; +// ParseCommon(); +// } +//} void settings_free() { -- cgit From d7d62ea5ee19f5cad52dcfb2f2a49d8d36fa1228 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 20 Jan 2011 18:34:08 +0100 Subject: introduce and use new helper function list_free_with_free Signed-off-by: Denys Vlasenko --- src/daemon/Settings.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/daemon/Settings.cpp') diff --git a/src/daemon/Settings.cpp b/src/daemon/Settings.cpp index b8f8751e..ff9062fc 100644 --- a/src/daemon/Settings.cpp +++ b/src/daemon/Settings.cpp @@ -31,7 +31,7 @@ */ /* Static data */ -/* Filled by LoadSettings() */ +/* Filled by load_settings() */ /* map["name"] = "value" strings from [ Common ] section. * If the same name found on more than one line, @@ -258,7 +258,7 @@ static int ReadConfigurationFromFile(FILE *fp) } /* abrt daemon loads .conf file */ -int LoadSettings() +int load_settings() { int err = 0; @@ -311,26 +311,20 @@ map_abrt_settings_t GetSettings() // } //} -void settings_free() +void free_settings() { - for (GList *li = g_settings_setOpenGPGPublicKeys; li != NULL; li = g_list_next(li)) - free((char*)li->data); - - g_list_free(g_settings_setOpenGPGPublicKeys); + list_free_with_free(g_settings_setOpenGPGPublicKeys); g_settings_setOpenGPGPublicKeys = NULL; - for (GList *li = g_settings_setBlackListedPkgs; li != NULL; li = g_list_next(li)) - free((char*)li->data); - - g_list_free(g_settings_setBlackListedPkgs); + list_free_with_free(g_settings_setBlackListedPkgs); g_settings_setBlackListedPkgs = NULL; - for (GList *li = g_settings_setBlackListedPaths; li != NULL; li = g_list_next(li)) - free((char*)li->data); - - g_list_free(g_settings_setBlackListedPaths); + list_free_with_free(g_settings_setBlackListedPaths); g_settings_setBlackListedPaths = NULL; free(g_settings_sWatchCrashdumpArchiveDir); g_settings_sWatchCrashdumpArchiveDir = NULL; + + free(g_settings_sLogScanners); + g_settings_sLogScanners = NULL; } -- cgit From a0dc58e8355a0d4b98b9c88e0f26172b1418d7c9 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 20 Jan 2011 21:32:58 +0100 Subject: add OPT_LIST mechanism to handle multiply occurring options This allowed to convert abrt-action-bugzilla, abrt-action-rhtsupport and abrt-action-kerneloops to parse_opts() Signed-off-by: Denys Vlasenko --- src/daemon/Settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/daemon/Settings.cpp') diff --git a/src/daemon/Settings.cpp b/src/daemon/Settings.cpp index ff9062fc..e25b7959 100644 --- a/src/daemon/Settings.cpp +++ b/src/daemon/Settings.cpp @@ -76,7 +76,7 @@ static GList *parse_list(const char* list) } if (item->len > 0) - l = g_list_append(l, xstrdup(item->buf)); + l = g_list_append(l, xstrdup(item->buf)); strbuf_free(item); return l; -- cgit