summaryrefslogtreecommitdiffstats
path: root/src/daemon
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-04-20 18:23:56 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2011-04-20 18:23:56 +0200
commit0274b29916883efac50e0961c0a3b49ce8a11f1f (patch)
tree30f88847461ef58b90e7fe42cbdca8740dbc5cc7 /src/daemon
parent3572f658c5829492da1c99eae33b1e9ca9d4518c (diff)
downloadabrt-0274b29916883efac50e0961c0a3b49ce8a11f1f.zip
abrt-0274b29916883efac50e0961c0a3b49ce8a11f1f.tar.gz
abrt-0274b29916883efac50e0961c0a3b49ce8a11f1f.tar.xz
delete ugly parse_conf(), use load_abrt_conf() instead
Therefore moved abrt_conf.* to libreport Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/CommLayerServerDBus.c1
-rw-r--r--src/daemon/Makefile.am2
-rw-r--r--src/daemon/MiddleWare.c1
-rw-r--r--src/daemon/abrt-action-save-package-data.c1
-rw-r--r--src/daemon/abrt-server.c14
-rw-r--r--src/daemon/abrt_conf.c167
-rw-r--r--src/daemon/abrt_conf.h43
-rw-r--r--src/daemon/abrtd.c2
8 files changed, 10 insertions, 221 deletions
diff --git a/src/daemon/CommLayerServerDBus.c b/src/daemon/CommLayerServerDBus.c
index dd03d98..05f7df9 100644
--- a/src/daemon/CommLayerServerDBus.c
+++ b/src/daemon/CommLayerServerDBus.c
@@ -21,7 +21,6 @@
#include "abrt_dbus.h"
#include "comm_layer_inner.h"
#include "MiddleWare.h"
-#include "abrt_conf.h"
#include "CommLayerServerDBus.h"
/*
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
index f57f85f..6bb71b7 100644
--- a/src/daemon/Makefile.am
+++ b/src/daemon/Makefile.am
@@ -12,7 +12,6 @@ sbin_PROGRAMS = \
abrtd_SOURCES = \
MiddleWare.h MiddleWare.c \
CommLayerServerDBus.h CommLayerServerDBus.c \
- abrt_conf.h abrt_conf.c \
comm_layer_inner.h comm_layer_inner.c \
abrtd.c
abrtd_CPPFLAGS = \
@@ -75,7 +74,6 @@ abrt_handle_crashdump_LDADD = \
abrt_action_save_package_data_SOURCES = \
rpm.h rpm.c \
- abrt_conf.h abrt_conf.c \
abrt-action-save-package-data.c
abrt_action_save_package_data_CPPFLAGS = \
-I$(srcdir)/../include/report -I$(srcdir)/../include \
diff --git a/src/daemon/MiddleWare.c b/src/daemon/MiddleWare.c
index d337668..fb943b1 100644
--- a/src/daemon/MiddleWare.c
+++ b/src/daemon/MiddleWare.c
@@ -19,7 +19,6 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "abrtlib.h"
-#include "abrt_conf.h"
#include "comm_layer_inner.h"
#include "CommLayerServerDBus.h"
#include "MiddleWare.h"
diff --git a/src/daemon/abrt-action-save-package-data.c b/src/daemon/abrt-action-save-package-data.c
index af63ff2..9335099 100644
--- a/src/daemon/abrt-action-save-package-data.c
+++ b/src/daemon/abrt-action-save-package-data.c
@@ -18,7 +18,6 @@
*/
#include <fnmatch.h>
#include "abrtlib.h"
-#include "abrt_conf.h"
#include "rpm.h"
#include "parse_options.h"
diff --git a/src/daemon/abrt-server.c b/src/daemon/abrt-server.c
index 4626d5d..53bb5fb 100644
--- a/src/daemon/abrt-server.c
+++ b/src/daemon/abrt-server.c
@@ -147,12 +147,16 @@ static void create_debug_dump()
log("Saved %s crash dump of pid %u to %s", analyzer, pid, path);
/* Trim old crash dumps if necessary */
- unsigned maxCrashReportsSize = 0;
- parse_conf(NULL, &maxCrashReportsSize, NULL, NULL);
- if (maxCrashReportsSize > 0)
+ load_abrt_conf();
+ free_abrt_conf_data(); /* can do this because we need only g_settings_nMaxCrashReportsSize */
+ /* x1.25: go a bit up, so that usual in-daemon trimming
+ * kicks in first, and we don't "fight" with it:
+ */
+ g_settings_nMaxCrashReportsSize += g_settings_nMaxCrashReportsSize / 4;
+ if (g_settings_nMaxCrashReportsSize > 0)
{
- check_free_space(maxCrashReportsSize);
- trim_debug_dumps(DEBUG_DUMPS_DIR, maxCrashReportsSize * (double)(1024*1024), path);
+ check_free_space(g_settings_nMaxCrashReportsSize);
+ trim_debug_dumps(DEBUG_DUMPS_DIR, g_settings_nMaxCrashReportsSize * (double)(1024*1024), path);
}
free(path);
diff --git a/src/daemon/abrt_conf.c b/src/daemon/abrt_conf.c
deleted file mode 100644
index 46d8f44..0000000
--- a/src/daemon/abrt_conf.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 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"
-#include "abrt_conf.h"
-
-bool g_settings_bOpenGPGCheck = false;
-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;
-
-
-void free_abrt_conf_data()
-{
- list_free_with_free(g_settings_setOpenGPGPublicKeys);
- g_settings_setOpenGPGPublicKeys = NULL;
-
- list_free_with_free(g_settings_setBlackListedPkgs);
- g_settings_setBlackListedPkgs = NULL;
-
- list_free_with_free(g_settings_setBlackListedPaths);
- g_settings_setBlackListedPaths = NULL;
-
- free(g_settings_sWatchCrashdumpArchiveDir);
- g_settings_sWatchCrashdumpArchiveDir = NULL;
-}
-
-static GList *parse_list(const char* list)
-{
- struct strbuf *item = strbuf_new();
- GList *l = NULL;
-
- char *trim_item = NULL;
-
- for (unsigned ii = 0; list[ii]; ii++)
- {
- if (list[ii] == ',')
- {
- trim_item = strtrim(item->buf);
- l = g_list_append(l, xstrdup(trim_item));
- strbuf_clear(item);
- }
- else
- strbuf_append_char(item, list[ii]);
- }
-
- if (item->len > 0)
- {
- trim_item = strtrim(item->buf);
- l = g_list_append(l, xstrdup(trim_item));
- }
-
- strbuf_free(item);
-
- return l;
-}
-
-static void ParseCommon(map_string_h *settings, const char *conf_filename)
-{
- char *value;
-
- value = g_hash_table_lookup(settings, "OpenGPGCheck");
- if (value)
- {
- g_settings_bOpenGPGCheck = string_to_bool(value);
- g_hash_table_remove(settings, "OpenGPGCheck");
- }
-
- value = g_hash_table_lookup(settings, "BlackList");
- if (value)
- {
- g_settings_setBlackListedPkgs = parse_list(value);
- g_hash_table_remove(settings, "BlackList");
- }
-
- value = g_hash_table_lookup(settings, "BlackListedPaths");
- if (value)
- {
- g_settings_setBlackListedPaths = parse_list(value);
- g_hash_table_remove(settings, "BlackListedPaths");
- }
-
- value = g_hash_table_lookup(settings, "WatchCrashdumpArchiveDir");
- if (value)
- {
- g_settings_sWatchCrashdumpArchiveDir = xstrdup(value);
- g_hash_table_remove(settings, "WatchCrashdumpArchiveDir");
- }
-
- value = g_hash_table_lookup(settings, "MaxCrashReportsSize");
- if (value)
- {
-//FIXME: dont die
- g_settings_nMaxCrashReportsSize = xatoi_positive(value);
- g_hash_table_remove(settings, "MaxCrashReportsSize");
- }
-
- value = g_hash_table_lookup(settings, "ProcessUnpackaged");
- if (value)
- {
- g_settings_bProcessUnpackaged = string_to_bool(value);
- g_hash_table_remove(settings, "ProcessUnpackaged");
- }
-
- GHashTableIter iter;
- char *name;
- /*char *value; - already declared */
- g_hash_table_iter_init(&iter, settings);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
- {
- error_msg("Unrecognized variable '%s' in '%s'", name, conf_filename);
- }
-}
-
-static void LoadGPGKeys()
-{
- FILE *fp = fopen(CONF_DIR"/gpg_keys", "r");
- if (fp)
- {
- /* every line is one key
- * FIXME: make it more robust, it doesn't handle comments
- */
- char *line;
- while ((line = xmalloc_fgetline(fp)) != NULL)
- {
- if (line[0] == '/') // probably the beginning of a path, so let's handle it as a key
- g_settings_setOpenGPGPublicKeys = g_list_append(g_settings_setOpenGPGPublicKeys, line);
- else
- free(line);
- }
- fclose(fp);
- }
-}
-
-int load_abrt_conf()
-{
- free_abrt_conf_data();
-
- map_string_h *settings = new_map_string();
- if (!load_conf_file(CONF_DIR"/abrt.conf", settings, /*skip key w/o values:*/ false))
- error_msg("Can't open '%s'", CONF_DIR"/abrt.conf");
-
- ParseCommon(settings, CONF_DIR"/abrt.conf");
- free_map_string(settings);
-
- LoadGPGKeys();
-
- return 0;
-}
diff --git a/src/daemon/abrt_conf.h b/src/daemon/abrt_conf.h
deleted file mode 100644
index 2208e13..0000000
--- a/src/daemon/abrt_conf.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 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.
-*/
-#ifndef SETTINGS_H_
-#define SETTINGS_H_
-
-#include "abrt_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern GList * g_settings_setOpenGPGPublicKeys;
-extern GList * g_settings_setBlackListedPkgs;
-extern GList * g_settings_setBlackListedPaths;
-extern unsigned int g_settings_nMaxCrashReportsSize;
-extern bool g_settings_bOpenGPGCheck;
-extern bool g_settings_bProcessUnpackaged;
-extern char * g_settings_sWatchCrashdumpArchiveDir;
-
-int load_abrt_conf();
-void free_abrt_conf_data();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/daemon/abrtd.c b/src/daemon/abrtd.c
index 08c95f2..d18265f 100644
--- a/src/daemon/abrtd.c
+++ b/src/daemon/abrtd.c
@@ -23,9 +23,9 @@
#include <syslog.h>
#include <sys/inotify.h>
#include <sys/ioctl.h> /* ioctl(FIONREAD) */
+
#include "abrtlib.h"
#include "comm_layer_inner.h"
-#include "abrt_conf.h"
#include "CommLayerServerDBus.h"
#include "MiddleWare.h"
#include "parse_options.h"