diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-11-26 13:21:07 +0100 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-11-26 13:21:07 +0100 |
commit | 7ca9930ec1fc0aef059a2d8e81f7db6b3c1085ce (patch) | |
tree | f08ad3a408d5ae61b8ea6e483016cf45d722a491 /src/lib | |
parent | 286312ff8017b4d0c0521a3f7c595c85b6f57c52 (diff) | |
download | abrt-7ca9930ec1fc0aef059a2d8e81f7db6b3c1085ce.tar.gz abrt-7ca9930ec1fc0aef059a2d8e81f7db6b3c1085ce.tar.xz abrt-7ca9930ec1fc0aef059a2d8e81f7db6b3c1085ce.zip |
reorganize libraries
This patch does not change any code per se,
it renames libABRTfoo -> libabrt_bar and moves a few functions around.
After the patch, we are left with the following libs:
libabrt - the stuff shared among most of abrt (like xmalloc, logging)
libabrt_daemon - only daemon-related things are here
(should probably be just moved into daemon - later)
libabrt_dbus - daemon, cli and applet use this
libabrt_web - abrt-action-foo where foo deals with network/web/ftp/...
As a result, we have following reductions in dependent libs:
/usr/libexec/abrt-hook-ccpp:
linux-vdso.so.1 => ()
- libABRTUtils.so.0 => /usr/lib64/libABRTUtils.so.0 ()
+ libabrt.so.0 => /usr/lib64/libabrt.so.0 ()
libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 ()
- libdbus-1.so.3 => /lib64/libdbus-1.so.3 ()
- libpthread.so.0 => /lib64/libpthread.so.0 ()
- librt.so.1 => /lib64/librt.so.1 ()
- libdl.so.2 => /lib64/libdl.so.2 ()
/usr/libexec/abrt-action-upload:
linux-vdso.so.1 => ()
libtar.so.1 => /usr/lib64/libtar.so.1 ()
libcurl.so.4 => /usr/lib64/libcurl.so.4 ()
- libABRTdUtils.so.0 => /usr/lib64/libABRTdUtils.so.0 ()
- libABRTUtils.so.0 => /usr/lib64/libABRTUtils.so.0 ()
+ libabrt.so.0 => /usr/lib64/libabrt.so.0 ()
libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 ()
- libdbus-1.so.3 => /lib64/libdbus-1.so.3 ()
Similar savings are in almost every abrt-action-foo.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Makefile.am | 81 | ||||
-rw-r--r-- | src/lib/Plugin.cpp | 75 | ||||
-rw-r--r-- | src/lib/abrt_packages.h | 33 | ||||
-rw-r--r-- | src/lib/daemon_is_ok.c (renamed from src/lib/abrt_packages.c) | 50 | ||||
-rw-r--r-- | src/lib/get_cmdline.c (renamed from src/lib/daemon.c) | 34 | ||||
-rw-r--r-- | src/lib/load_plugin_settings.cpp | 94 | ||||
-rw-r--r-- | src/lib/make_descr.cpp | 2 |
7 files changed, 174 insertions, 195 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 0561e316..92f5e645 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -1,10 +1,13 @@ -# ABRTUtils has small set of deps. This reduces deps of smaller abrt binaries -# ABRTdUtils has much more. It is used by daemon and plugins only -# ABRT_web_utils is used only by some abrt-action-foo programs, not by daemon +# libabrt - the stuff shared among most of abrt (like xmalloc, logging) +# libabrt_daemon - only daemon/server/dbus related things are here +# libabrt_dbus - daemon, cli and applet use this +# libabrt_web - abrt-action-foo where foo deals with network/web/ftp/... lib_LTLIBRARIES = \ - libABRTUtils.la \ - libABRTdUtils.la \ - libABRT_web_utils.la + libabrt.la \ + libabrt_daemon.la \ + libabrt_dbus.la \ + libabrt_web.la + HEADER_DIR = $(srcdir)/../include AM_CPPFLAGS = -I$(HEADER_DIR) @@ -12,11 +15,8 @@ AM_CPPFLAGS = -I$(HEADER_DIR) # time.cpp # xconnect.cpp -libABRTUtils_la_SOURCES = \ +libabrt_la_SOURCES = \ xfuncs.c \ - concat_path_file.c \ - append_to_malloced_string.c \ - overlapping_strcpy.c \ encbase64.c \ stdio_helpers.c \ hash_md5.c hash_md5.h \ @@ -24,22 +24,44 @@ libABRTUtils_la_SOURCES = \ read_write.c read_write.h \ logging.c logging.h \ copyfd.c \ - daemon.c \ + concat_path_file.c \ + append_to_malloced_string.c \ + overlapping_strcpy.c \ skip_whitespace.c \ + stringops.cpp \ + strbuf.c strbuf.h \ xatonum.c numtoa.cpp \ spawn.c \ - stringops.cpp \ dirsize.c \ dump_dir.c \ - strbuf.c strbuf.h \ - abrt_dbus.c abrt_dbus.h \ + get_cmdline.c \ + daemon_is_ok.c \ + load_plugin_settings.cpp \ + make_descr.cpp \ + run_event.c \ CrashTypes.cpp \ ABRTException.cpp \ - run_event.c \ - abrt_packages.c abrt_packages.h \ hooklib.c hooklib.h \ + parse_release.cpp \ parse_options.c parse_options.h -libABRTUtils_la_CPPFLAGS = \ +libabrt_la_CPPFLAGS = \ + -Wall -Werror \ + -I$(srcdir)/../include \ + -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \ + -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \ + -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \ + -DCONF_DIR=\"$(CONF_DIR)\" \ + -DVAR_RUN=\"$(VAR_RUN)\" \ + $(GLIB_CFLAGS) \ + -D_GNU_SOURCE +libabrt_la_LDFLAGS = \ + -version-info 0:1:0 +libabrt_la_LIBADD = \ + $(GLIB_LIBS) + +libabrt_dbus_la_SOURCES = \ + abrt_dbus.c abrt_dbus.h +libabrt_dbus_la_CPPFLAGS = \ -Wall -Werror \ -I$(srcdir)/../include \ -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \ @@ -50,19 +72,16 @@ libABRTUtils_la_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) \ -D_GNU_SOURCE -libABRTUtils_la_LDFLAGS = \ +libabrt_dbus_la_LDFLAGS = \ -version-info 0:1:0 -libABRTUtils_la_LIBADD = \ +libabrt_dbus_la_LIBADD = \ $(GLIB_LIBS) \ - $(DBUS_LIBS) \ - -ldl + $(DBUS_LIBS) -libABRTdUtils_la_SOURCES = \ - parse_release.cpp \ - make_descr.cpp \ +libabrt_daemon_la_SOURCES = \ $(HEADER_DIR)/comm_layer_inner.h CommLayerInner.cpp \ $(HEADER_DIR)/plugin.h Plugin.cpp -libABRTdUtils_la_CPPFLAGS = \ +libabrt_daemon_la_CPPFLAGS = \ -Wall \ -I$(srcdir)/../include \ -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \ @@ -71,15 +90,15 @@ libABRTdUtils_la_CPPFLAGS = \ -DCONF_DIR=\"$(CONF_DIR)\" \ -DVAR_RUN=\"$(VAR_RUN)\" \ -D_GNU_SOURCE -libABRTdUtils_la_LDFLAGS = \ +libabrt_daemon_la_LDFLAGS = \ -version-info 0:1:0 -libABRTdUtils_la_LIBADD = \ +libabrt_daemon_la_LIBADD = \ -ldl -libABRT_web_utils_la_SOURCES = \ +libabrt_web_la_SOURCES = \ abrt_curl.h abrt_curl.c \ abrt_xmlrpc.h abrt_xmlrpc.cpp -libABRT_web_utils_la_CPPFLAGS = \ +libabrt_web_la_CPPFLAGS = \ -Wall -Werror \ -I$(srcdir)/../include \ -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \ @@ -91,9 +110,9 @@ libABRT_web_utils_la_CPPFLAGS = \ $(LIBXML_CFLAGS) \ $(XMLRPC_CFLAGS) $(XMLRPC_CLIENT_CFLAGS) \ -D_GNU_SOURCE -libABRT_web_utils_la_LDFLAGS = \ +libabrt_web_la_LDFLAGS = \ -version-info 0:1:0 -libABRT_web_utils_la_LIBADD = \ +libabrt_web_la_LIBADD = \ $(CURL_LIBS) \ $(LIBXML_LIBS) \ $(XMLRPC_LIBS) $(XMLRPC_CLIENT_LIBS) diff --git a/src/lib/Plugin.cpp b/src/lib/Plugin.cpp index bf237959..0c2137f5 100644 --- a/src/lib/Plugin.cpp +++ b/src/lib/Plugin.cpp @@ -39,78 +39,3 @@ void CPlugin::SetSettings(const map_plugin_settings_t& pSettings) } } } - -bool LoadPluginSettings(const char *pPath, map_plugin_settings_t& pSettings, - bool skipKeysWithoutValue /*= true*/) -{ - FILE *fp = stdin; - if (strcmp(pPath, "-") != 0) - { - fp = fopen(pPath, "r"); - if (!fp) - return false; - } - - char *line; - while ((line = xmalloc_fgetline(fp)) != NULL) - { - 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) - goto free_line; - - /* Skip lines with empty key. */ - if (key.length() == 0) - goto free_line; - - if (skipKeysWithoutValue && value.length() == 0) - goto free_line; - - /* Skip lines with unclosed quotes. */ - if (in_quote) - goto free_line; - - pSettings[key] = value; - free_line: - free(line); - } - - if (fp != stdin) - fclose(fp); - return true; -} diff --git a/src/lib/abrt_packages.h b/src/lib/abrt_packages.h deleted file mode 100644 index 6a952f5e..00000000 --- a/src/lib/abrt_packages.h +++ /dev/null @@ -1,33 +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 ABRT_PACKAGES_H -#define ABRT_PACKAGES_H - -#ifdef __cplusplus -extern "C" { -#endif - -char* get_package_name_from_NVR_or_NULL(const char* packageNVR); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/lib/abrt_packages.c b/src/lib/daemon_is_ok.c index bbf0e729..dc1e94c9 100644 --- a/src/lib/abrt_packages.c +++ b/src/lib/daemon_is_ok.c @@ -1,6 +1,5 @@ /* - Copyright (C) 2010 ABRT team - Copyright (C) 2010 RedHat Inc + Copyright (C) 2009 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 @@ -18,26 +17,35 @@ */ #include "abrtlib.h" -/* cuts the name from the NVR format: foo-1.2.3-1.el6 - returns a newly allocated string -*/ -char* get_package_name_from_NVR_or_NULL(const char* packageNVR) +int daemon_is_ok() { - char* package_name = NULL; - if (packageNVR != NULL) + int fd = open(VAR_RUN"/abrtd.pid", O_RDONLY); + if (fd < 0) + { + return 0; + } + + char pid[sizeof(pid_t)*3 + 2]; + int len = read(fd, pid, sizeof(pid)-1); + close(fd); + if (len <= 0) + return 0; + + pid[len] = '\0'; + *strchrnul(pid, '\n') = '\0'; + /* paranoia: we don't want to check /proc//stat or /proc///stat */ + if (pid[0] == '\0' || pid[0] == '/') + return 0; + + char path[sizeof("/proc/%s/stat") + sizeof(pid)]; + sprintf(path, "/proc/%s/stat", pid); + struct stat sb; + if (stat(path, &sb) == -1) { - VERB1 log("packageNVR %s", packageNVR); - package_name = xstrdup(packageNVR); - char *pos = strrchr(package_name, '-'); - if (pos != NULL) - { - *pos = 0; - pos = strrchr(package_name, '-'); - if (pos != NULL) - { - *pos = 0; - } - } + return 0; } - return package_name; + + /* TODO: maybe readlink /proc/PID/exe and check that it is "xxx/abrt"? */ + + return 1; } diff --git a/src/lib/daemon.c b/src/lib/get_cmdline.c index 944aef0c..9855eb3c 100644 --- a/src/lib/daemon.c +++ b/src/lib/get_cmdline.c @@ -17,8 +17,6 @@ */ #include "abrtlib.h" -#define VAR_RUN_PID_FILE VAR_RUN"/abrtd.pid" - static char *append_escaped(char *start, const char *s) { char hex_char_buf[] = "\\x00"; @@ -105,35 +103,3 @@ char* get_cmdline(pid_t pid) return xstrdup(escaped_cmdline + 1); /* +1 skips extraneous leading space */ } - -int daemon_is_ok() -{ - int fd = open(VAR_RUN_PID_FILE, O_RDONLY); - if (fd < 0) - { - return 0; - } - - char pid[sizeof(pid_t)*3 + 2]; - int len = read(fd, pid, sizeof(pid)-1); - close(fd); - if (len <= 0) - return 0; - - pid[len] = '\0'; - *strchrnul(pid, '\n') = '\0'; - /* paranoia: we don't want to check /proc//stat or /proc///stat */ - if (pid[0] == '\0' || pid[0] == '/') - return 0; - - /* TODO: maybe readlink and check that it is "xxx/abrt"? */ - char path[sizeof("/proc/%s/stat") + sizeof(pid)]; - sprintf(path, "/proc/%s/stat", pid); - struct stat sb; - if (stat(path, &sb) == -1) - { - return 0; - } - - return 1; -} diff --git a/src/lib/load_plugin_settings.cpp b/src/lib/load_plugin_settings.cpp new file mode 100644 index 00000000..1052f19e --- /dev/null +++ b/src/lib/load_plugin_settings.cpp @@ -0,0 +1,94 @@ +/* + Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) + Copyright (C) 2009 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" + +bool LoadPluginSettings(const char *pPath, map_plugin_settings_t& pSettings, + bool skipKeysWithoutValue /*= true*/) +{ + FILE *fp = stdin; + if (strcmp(pPath, "-") != 0) + { + fp = fopen(pPath, "r"); + if (!fp) + return false; + } + + char *line; + while ((line = xmalloc_fgetline(fp)) != NULL) + { + 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) + goto free_line; + + /* Skip lines with empty key. */ + if (key.length() == 0) + goto free_line; + + if (skipKeysWithoutValue && value.length() == 0) + goto free_line; + + /* Skip lines with unclosed quotes. */ + if (in_quote) + goto free_line; + + pSettings[key] = value; + free_line: + free(line); + } + + if (fp != stdin) + fclose(fp); + return true; +} diff --git a/src/lib/make_descr.cpp b/src/lib/make_descr.cpp index 90c73667..a0cb5691 100644 --- a/src/lib/make_descr.cpp +++ b/src/lib/make_descr.cpp @@ -75,7 +75,7 @@ static const char *const blacklisted_items[] = { NULL }; -char* make_dsc_mailx(const map_crash_data_t & crash_data) +char* make_description_mailx(const map_crash_data_t & crash_data) { struct strbuf *buf_dsc = strbuf_new(); struct strbuf *buf_additional_files = strbuf_new(); |