This patch does not change any code per se,
it renames libABRTfoo -> libabrt_bar and moves a few functions around.
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/...
/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.
--
vda
diff -x '*.po' -d -urpN abrt.0/src/applet/Makefile.am abrt.1/src/applet/Makefile.am
--- abrt.0/src/applet/Makefile.am 2010-11-15 15:26:40.000000000 +0100
+++ abrt.1/src/applet/Makefile.am 2010-11-25 16:10:50.175689754 +0100
@@ -22,14 +22,13 @@ abrt_applet_CPPFLAGS = \
# $(LIBNOTIFY_CFLAGS)
# $(DBUS_GLIB_CFLAGS)
abrt_applet_LDADD = \
- ../lib/libABRTUtils.la \
+ ../lib/libabrt.la \
+ ../lib/libabrt_dbus.la \
-lglib-2.0 \
-lgthread-2.0 \
$(DBUS_LIBS) \
$(LIBNOTIFY_LIBS) \
$(GTK_LIBS)
-# ../../lib/Utils/libABRTdUtils.la
-# $(DL_LIBS)
DEFS = -DLOCALEDIR="$(localedir)" @DEFS@
diff -x '*.po' -d -urpN abrt.0/src/btparser/Makefile.am abrt.1/src/btparser/Makefile.am
--- abrt.0/src/btparser/Makefile.am 2010-11-15 15:27:06.000000000 +0100
+++ abrt.1/src/btparser/Makefile.am 2010-11-25 16:11:27.215689428 +0100
@@ -15,7 +15,7 @@ libbtparser_la_SOURCES = \
utils.h utils.c
libbtparser_la_CFLAGS = -Wall -Werror -D_GNU_SOURCE -I../lib
libbtparser_la_LDFLAGS = -version-info 1:1:0
-libbtparser_la_LIBADD = ../lib/libABRTUtils.la
+libbtparser_la_LIBADD = ../lib/libabrt.la
# From
http://www.seul.org/docs/autotut/
# Version consists 3 numbers: CURRENT, REVISION, AGE.
diff -x '*.po' -d -urpN abrt.0/src/cli/Makefile.am abrt.1/src/cli/Makefile.am
--- abrt.0/src/cli/Makefile.am 2010-11-15 15:26:53.000000000 +0100
+++ abrt.1/src/cli/Makefile.am 2010-11-25 16:27:42.437689615 +0100
@@ -16,8 +16,8 @@ abrt_cli_CPPFLAGS = \
# $(GTK_CFLAGS)
abrt_cli_LDADD = \
- ../lib/libABRTUtils.la \
- ../lib/libABRTdUtils.la \
+ ../lib/libabrt.la \
+ ../lib/libabrt_dbus.la \
$(GLIB_LIBS)
man_MANS = abrt-cli.1
diff -x '*.po' -d -urpN abrt.0/src/cli/report.cpp abrt.1/src/cli/report.cpp
--- abrt.0/src/cli/report.cpp 2010-11-23 15:49:41.000000000 +0100
+++ abrt.1/src/cli/report.cpp 2010-11-26 13:03:55.657895296 +0100
@@ -21,7 +21,6 @@
#include "run-command.h"
#include "dbus.h"
#include "abrtlib.h"
-#include "plugin.h" // LoadPluginSettings
/* Field separator for the crash report file that is edited by user. */
#define FIELD_SEP "%----"
@@ -534,7 +533,7 @@ static void get_reporter_plugin_settings
{
map_string_t single_plugin_settings;
std::string path = std::string(homedir) + "/.abrt/"
- + it->first + "."PLUGINS_CONF_EXTENSION;
+ + it->first + ".conf";
/* Load plugin config in the home dir. Do not skip lines with empty value (but containing a "key="),
because user may want to override password from /etc/abrt/plugins/*.conf, but he prefers to
enter it every time he reports. */
diff -x '*.po' -d -urpN abrt.0/src/daemon/Makefile.am abrt.1/src/daemon/Makefile.am
--- abrt.0/src/daemon/Makefile.am 2010-11-23 13:35:00.000000000 +0100
+++ abrt.1/src/daemon/Makefile.am 2010-11-25 16:33:24.152439347 +0100
@@ -36,8 +36,9 @@ abrtd_CPPFLAGS = \
abrtd_LDADD = \
$(DL_LIBS) \
$(DBUS_LIBS) \
- ../lib/libABRTUtils.la \
- ../lib/libABRTdUtils.la
+ ../lib/libabrt.la \
+ ../lib/libabrt_daemon.la \
+ ../lib/libabrt_dbus.la
abrt_server_SOURCES = \
abrt-server.c
@@ -54,7 +55,7 @@ abrt_server_CPPFLAGS = \
-D_GNU_SOURCE \
-Wall -Werror
abrt_server_LDADD = \
- ../lib/libABRTUtils.la
+ ../lib/libabrt.la
abrt_handle_crashdump_SOURCES = \
abrt-handle-crashdump.c
@@ -73,7 +74,7 @@ abrt_handle_crashdump_CPPFLAGS = \
-D_GNU_SOURCE \
-Wall -Werror
abrt_handle_crashdump_LDADD = \
- ../lib/libABRTUtils.la
+ ../lib/libabrt.la
abrt_action_save_package_data_SOURCES = \
rpm.h rpm.c \
@@ -95,8 +96,7 @@ abrt_action_save_package_data_CPPFLAGS =
-Wall -Werror
abrt_action_save_package_data_LDADD = \
$(RPM_LIBS) \
- ../lib/libABRTdUtils.la \
- ../lib/libABRTUtils.la
+ ../lib/libabrt.la
dbusabrtconfdir = ${sysconfdir}/dbus-1/system.d/
dist_dbusabrtconf_DATA = dbus-abrt.conf
diff -x '*.po' -d -urpN abrt.0/src/daemon/rpm.c abrt.1/src/daemon/rpm.c
--- abrt.0/src/daemon/rpm.c 2010-11-10 00:12:48.000000000 +0100
+++ abrt.1/src/daemon/rpm.c 2010-11-25 16:24:40.294439222 +0100
@@ -26,6 +26,30 @@
static GList *list_fingerprints = NULL;
+/* 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)
+{
+ char* package_name = NULL;
+ if (packageNVR != NULL)
+ {
+ 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 package_name;
+}
+
void rpm_init()
{
int status = rpmReadConfigFiles((const char*)NULL, (const char*)NULL);
diff -x '*.po' -d -urpN abrt.0/src/daemon/rpm.h abrt.1/src/daemon/rpm.h
--- abrt.0/src/daemon/rpm.h 2010-11-10 00:12:48.000000000 +0100
+++ abrt.1/src/daemon/rpm.h 2010-11-25 16:24:56.404689348 +0100
@@ -80,6 +80,8 @@ char* rpm_get_package_nvr(const char* fi
*/
char* rpm_get_component(const char* filename);
+char* get_package_name_from_NVR_or_NULL(const char* packageNVR);
+
#ifdef __cplusplus
}
#endif
diff -x '*.po' -d -urpN abrt.0/src/hooks/Makefile.am abrt.1/src/hooks/Makefile.am
--- abrt.0/src/hooks/Makefile.am 2010-11-15 15:27:00.000000000 +0100
+++ abrt.1/src/hooks/Makefile.am 2010-11-25 16:34:25.945689356 +0100
@@ -12,7 +12,7 @@ abrt_hook_ccpp_CPPFLAGS = \
-DVAR_RUN="$(VAR_RUN)" \
-D_GNU_SOURCE
abrt_hook_ccpp_LDADD = \
- ../lib/libABRTUtils.la
+ ../lib/libabrt.la
# dumpoops
dumpoops_SOURCES = \
@@ -30,7 +30,8 @@ dumpoops_CPPFLAGS = \
-D_GNU_SOURCE
# build will succeed, but at runtime plugins do need ABRT*d*Utils
dumpoops_LDADD = \
- ../lib/libABRTUtils.la \
+ ../lib/libabrt_daemon.la \
+ ../lib/libabrt.la \
$(GLIB_FLAGS)
python_PYTHON = abrt.pth abrt_exception_handler.py
diff -x '*.po' -d -urpN abrt.0/src/include/abrtlib.h abrt.1/src/include/abrtlib.h
--- abrt.0/src/include/abrtlib.h 2010-11-15 16:58:12.000000000 +0100
+++ abrt.1/src/include/abrtlib.h 2010-11-25 16:06:37.132439142 +0100
@@ -80,7 +80,6 @@ int vdprintf(int d, const char *format,
#include "crash_types.h"
#include "dump_dir.h"
#include "abrt_types.h"
-#include "abrt_packages.h"
#ifdef __cplusplus
@@ -254,6 +253,27 @@ std::string to_string(T x)
void parse_args(const char *psArgs, vector_string_t& pArgs, int quote = -1);
void parse_release(const char *pRelease, char **product, char **version);
+char* make_description_bz(const map_crash_data_t& pCrashData);
+char* make_description_reproduce_comment(const map_crash_data_t& pCrashData);
+char* make_description_logger(const map_crash_data_t& pCrashData);
+char* make_description_mailx(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);
+
// TODO: npajkovs: full rewrite ssprintf -> xasprintf
static inline std::string ssprintf(const char *format, ...)
{
diff -x '*.po' -d -urpN abrt.0/src/include/plugin.h abrt.1/src/include/plugin.h
--- abrt.0/src/include/plugin.h 2010-11-10 00:12:48.000000000 +0100
+++ abrt.1/src/include/plugin.h 2010-11-25 15:34:16.636439338 +0100
@@ -110,26 +110,4 @@ typedef struct SPluginInfo
PLUGINS_MAGIC_NUMBER,\
};
-/* helper functions */
-char* make_description_bz(const map_crash_data_t& pCrashData);
-char* make_description_reproduce_comment(const map_crash_data_t& pCrashData);
-char* make_description_logger(const map_crash_data_t& pCrashData);
-char* make_dsc_mailx(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 -x '*.po' -d -urpN abrt.0/src/lib/abrt_packages.c abrt.1/src/lib/abrt_packages.c
--- abrt.0/src/lib/abrt_packages.c 2010-11-10 00:12:48.000000000 +0100
+++ abrt.1/src/lib/abrt_packages.c 1970-01-01 01:00:00.000000000 +0100
@@ -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.
-*/
-#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)
-{
- char* package_name = NULL;
- if (packageNVR != NULL)
- {
- 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 package_name;
-}
diff -x '*.po' -d -urpN abrt.0/src/lib/abrt_packages.h abrt.1/src/lib/abrt_packages.h
--- abrt.0/src/lib/abrt_packages.h 2010-11-10 00:12:48.000000000 +0100
+++ abrt.1/src/lib/abrt_packages.h 1970-01-01 01:00:00.000000000 +0100
@@ -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 -x '*.po' -d -urpN abrt.0/src/lib/daemon.c abrt.1/src/lib/daemon.c
--- abrt.0/src/lib/daemon.c 2010-11-10 00:12:48.000000000 +0100
+++ abrt.1/src/lib/daemon.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,139 +0,0 @@
-/*
- 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"
-
-#define VAR_RUN_PID_FILE VAR_RUN"/abrtd.pid"
-
-static char *append_escaped(char *start, const char *s)
-{
- char hex_char_buf[] = "\x00";
-
- *start++ = ' ';
- char *dst = start;
- const unsigned char *p = (unsigned char *)s;
-
- while (1)
- {
- const unsigned char *old_p = p;
- while (*p > ' ' && *p <= 0x7e && *p != '"' && *p != ''' && *p != '\')
- p++;
- if (dst == start)
- {
- if (p != (unsigned char *)s && *p == '\0')
- {
- /* entire word does not need escaping and quoting */
- strcpy(dst, s);
- dst += strlen(s);
- return dst;
- }
- *dst++ = ''';
- }
-
- strncpy(dst, (char *)old_p, (p - old_p));
- dst += (p - old_p);
-
- if (*p == '\0')
- {
- *dst++ = ''';
- *dst = '\0';
- return dst;
- }
- const char *a;
- switch (*p)
- {
- case '\r': a = "\r"; break;
- case '\n': a = "\n"; break;
- case '\t': a = "\t"; break;
- case ''': a = "\'"; break;
- case '"': a = "\""; break;
- case '\': a = "\\"; break;
- case ' ': a = " "; break;
- default:
- hex_char_buf[2] = "0123456789abcdef"[*p >> 4];
- hex_char_buf[3] = "0123456789abcdef"[*p & 0xf];
- a = hex_char_buf;
- }
- strcpy(dst, a);
- dst += strlen(a);
- p++;
- }
-}
-
-// taken from kernel
-#define COMMAND_LINE_SIZE 2048
-char* get_cmdline(pid_t pid)
-{
- char path[sizeof("/proc/%lu/cmdline") + sizeof(long)*3];
- char cmdline[COMMAND_LINE_SIZE];
- char escaped_cmdline[COMMAND_LINE_SIZE*4 + 4];
-
- escaped_cmdline[1] = '\0';
- sprintf(path, "/proc/%lu/cmdline", (long)pid);
- int fd = open(path, O_RDONLY);
- if (fd >= 0)
- {
- int len = read(fd, cmdline, sizeof(cmdline) - 1);
- close(fd);
-
- if (len > 0)
- {
- cmdline[len] = '\0';
- char *src = cmdline;
- char *dst = escaped_cmdline;
- while ((src - cmdline) < len)
- {
- dst = append_escaped(dst, src);
- src += strlen(src) + 1;
- }
- }
- }
-
- 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 -x '*.po' -d -urpN abrt.0/src/lib/daemon_is_ok.c abrt.1/src/lib/daemon_is_ok.c
--- abrt.0/src/lib/daemon_is_ok.c 1970-01-01 01:00:00.000000000 +0100
+++ abrt.1/src/lib/daemon_is_ok.c 2010-11-25 15:57:16.895689296 +0100
@@ -0,0 +1,51 @@
+/*
+ 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"
+
+int daemon_is_ok()
+{
+ 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)
+ {
+ return 0;
+ }
+
+ /* TODO: maybe readlink /proc/PID/exe and check that it is "xxx/abrt"? */
+
+ return 1;
+}
diff -x '*.po' -d -urpN abrt.0/src/lib/get_cmdline.c abrt.1/src/lib/get_cmdline.c
--- abrt.0/src/lib/get_cmdline.c 1970-01-01 01:00:00.000000000 +0100
+++ abrt.1/src/lib/get_cmdline.c 2010-11-25 15:56:11.184689452 +0100
@@ -0,0 +1,105 @@
+/*
+ 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"
+
+static char *append_escaped(char *start, const char *s)
+{
+ char hex_char_buf[] = "\x00";
+
+ *start++ = ' ';
+ char *dst = start;
+ const unsigned char *p = (unsigned char *)s;
+
+ while (1)
+ {
+ const unsigned char *old_p = p;
+ while (*p > ' ' && *p <= 0x7e && *p != '"' && *p != ''' && *p != '\')
+ p++;
+ if (dst == start)
+ {
+ if (p != (unsigned char *)s && *p == '\0')
+ {
+ /* entire word does not need escaping and quoting */
+ strcpy(dst, s);
+ dst += strlen(s);
+ return dst;
+ }
+ *dst++ = ''';
+ }
+
+ strncpy(dst, (char *)old_p, (p - old_p));
+ dst += (p - old_p);
+
+ if (*p == '\0')
+ {
+ *dst++ = ''';
+ *dst = '\0';
+ return dst;
+ }
+ const char *a;
+ switch (*p)
+ {
+ case '\r': a = "\r"; break;
+ case '\n': a = "\n"; break;
+ case '\t': a = "\t"; break;
+ case ''': a = "\'"; break;
+ case '"': a = "\""; break;
+ case '\': a = "\\"; break;
+ case ' ': a = " "; break;
+ default:
+ hex_char_buf[2] = "0123456789abcdef"[*p >> 4];
+ hex_char_buf[3] = "0123456789abcdef"[*p & 0xf];
+ a = hex_char_buf;
+ }
+ strcpy(dst, a);
+ dst += strlen(a);
+ p++;
+ }
+}
+
+// taken from kernel
+#define COMMAND_LINE_SIZE 2048
+char* get_cmdline(pid_t pid)
+{
+ char path[sizeof("/proc/%lu/cmdline") + sizeof(long)*3];
+ char cmdline[COMMAND_LINE_SIZE];
+ char escaped_cmdline[COMMAND_LINE_SIZE*4 + 4];
+
+ escaped_cmdline[1] = '\0';
+ sprintf(path, "/proc/%lu/cmdline", (long)pid);
+ int fd = open(path, O_RDONLY);
+ if (fd >= 0)
+ {
+ int len = read(fd, cmdline, sizeof(cmdline) - 1);
+ close(fd);
+
+ if (len > 0)
+ {
+ cmdline[len] = '\0';
+ char *src = cmdline;
+ char *dst = escaped_cmdline;
+ while ((src - cmdline) < len)
+ {
+ dst = append_escaped(dst, src);
+ src += strlen(src) + 1;
+ }
+ }
+ }
+
+ return xstrdup(escaped_cmdline + 1); /* +1 skips extraneous leading space */
+}
diff -x '*.po' -d -urpN abrt.0/src/lib/load_plugin_settings.cpp abrt.1/src/lib/load_plugin_settings.cpp
--- abrt.0/src/lib/load_plugin_settings.cpp 1970-01-01 01:00:00.000000000 +0100
+++ abrt.1/src/lib/load_plugin_settings.cpp 2010-11-25 15:33:15.964439263 +0100
@@ -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 -x '*.po' -d -urpN abrt.0/src/lib/make_descr.cpp abrt.1/src/lib/make_descr.cpp
--- abrt.0/src/lib/make_descr.cpp 2010-11-23 15:49:33.000000000 +0100
+++ abrt.1/src/lib/make_descr.cpp 2010-11-25 15:37:35.249689879 +0100
@@ -75,7 +75,7 @@ static const char *const blacklisted_ite
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();
diff -x '*.po' -d -urpN abrt.0/src/lib/Makefile.am abrt.1/src/lib/Makefile.am
--- abrt.0/src/lib/Makefile.am 2010-11-23 15:49:33.000000000 +0100
+++ abrt.1/src/lib/Makefile.am 2010-11-25 16:34:05.961439309 +0100
@@ -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 -x '*.po' -d -urpN abrt.0/src/lib/Plugin.cpp abrt.1/src/lib/Plugin.cpp
--- abrt.0/src/lib/Plugin.cpp 2010-11-10 00:12:48.000000000 +0100
+++ abrt.1/src/lib/Plugin.cpp 2010-11-25 15:33:05.595439713 +0100
@@ -39,78 +39,3 @@ void CPlugin::SetSettings(const map_plug
}
}
}
-
-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 -x '*.po' -d -urpN abrt.0/src/plugins/abrt-action-bugzilla.cpp abrt.1/src/plugins/abrt-action-bugzilla.cpp
--- abrt.0/src/plugins/abrt-action-bugzilla.cpp 2010-11-25 13:29:39.000000000 +0100
+++ abrt.1/src/plugins/abrt-action-bugzilla.cpp 2010-11-26 13:04:35.127894443 +0100
@@ -21,8 +21,6 @@
#include "crash_types.h"
#include "abrt_exception.h"
-#include "plugin.h" /* make_description_bz */
-
#define XML_RPC_SUFFIX "/xmlrpc.cgi"
#define MAX_HOPS 5
diff -x '*.po' -d -urpN abrt.0/src/plugins/abrt-action-kerneloops.cpp abrt.1/src/plugins/abrt-action-kerneloops.cpp
--- abrt.0/src/plugins/abrt-action-kerneloops.cpp 2010-11-11 09:27:28.000000000 +0100
+++ abrt.1/src/plugins/abrt-action-kerneloops.cpp 2010-11-26 13:04:13.082895364 +0100
@@ -22,8 +22,6 @@
#include "crash_types.h"
#include "abrt_exception.h"
-#include "plugin.h" /* LoadPluginSettings */
-
#define PROGNAME "abrt-action-kerneloops"
/* helpers */
diff -x '*.po' -d -urpN abrt.0/src/plugins/abrt-action-mailx.cpp abrt.1/src/plugins/abrt-action-mailx.cpp
--- abrt.0/src/plugins/abrt-action-mailx.cpp 2010-11-23 15:49:33.000000000 +0100
+++ abrt.1/src/plugins/abrt-action-mailx.cpp 2010-11-26 13:04:17.003895786 +0100
@@ -24,9 +24,6 @@
#include "crash_types.h"
#include "abrt_exception.h"
-#include "plugin.h" /* LoadPluginSettings */
-
-
#define PROGNAME "abrt-action-mailx"
static void exec_and_feed_input(uid_t uid, const char* text, char **args)
@@ -93,7 +90,7 @@ static void create_and_send_email(
unsigned arg_size = 0;
args = append_str_to_vector(args, arg_size, "/bin/mailx");
- char *dsc = make_dsc_mailx(pCrashData);
+ char *dsc = make_description_mailx(pCrashData);
if (send_binary_data)
{
diff -x '*.po' -d -urpN abrt.0/src/plugins/abrt-action-print.cpp abrt.1/src/plugins/abrt-action-print.cpp
--- abrt.0/src/plugins/abrt-action-print.cpp 2010-11-11 09:27:28.000000000 +0100
+++ abrt.1/src/plugins/abrt-action-print.cpp 2010-11-26 13:04:05.146895113 +0100
@@ -22,7 +22,6 @@
#include "parse_options.h"
#include "crash_types.h"
#include "abrt_exception.h"
-#include "plugin.h" /* make_description_logger */
#define PROGNAME "abrt-action-print"
diff -x '*.po' -d -urpN abrt.0/src/plugins/abrt-action-rhtsupport.cpp abrt.1/src/plugins/abrt-action-rhtsupport.cpp
--- abrt.0/src/plugins/abrt-action-rhtsupport.cpp 2010-11-23 15:49:33.000000000 +0100
+++ abrt.1/src/plugins/abrt-action-rhtsupport.cpp 2010-11-26 13:04:25.418644902 +0100
@@ -25,9 +25,6 @@
#include "crash_types.h"
#include "abrt_exception.h"
-#include "plugin.h" /* make_description_bz */
-
-
#define PROGNAME "abrt-action-rhtsupport"
static void report_to_rhtsupport(
diff -x '*.po' -d -urpN abrt.0/src/plugins/abrt-action-upload.cpp abrt.1/src/plugins/abrt-action-upload.cpp
--- abrt.0/src/plugins/abrt-action-upload.cpp 2010-11-23 15:49:33.000000000 +0100
+++ abrt.1/src/plugins/abrt-action-upload.cpp 2010-11-26 13:04:09.114644864 +0100
@@ -24,9 +24,6 @@
#include "crash_types.h"
#include "abrt_exception.h"
-#include "plugin.h" /* LoadPluginSettings */
-
-
#define PROGNAME "abrt-action-upload"
//TODO: use this for better logging
diff -x '*.po' -d -urpN abrt.0/src/plugins/Makefile.am abrt.1/src/plugins/Makefile.am
--- abrt.0/src/plugins/Makefile.am 2010-11-23 15:49:33.000000000 +0100
+++ abrt.1/src/plugins/Makefile.am 2010-11-25 16:14:39.409689455 +0100
@@ -90,7 +90,7 @@ abrt_action_analyze_c_CPPFLAGS = \
-D_GNU_SOURCE \
-Wall -Werror
abrt_action_analyze_c_LDADD = \
- ../lib/libABRTUtils.la
+ ../lib/libabrt.la
abrt_action_analyze_python_SOURCES = \
abrt-action-analyze-python.c
@@ -108,7 +108,7 @@ abrt_action_analyze_python_CPPFLAGS = \
-D_GNU_SOURCE \
-Wall -Werror
abrt_action_analyze_python_LDADD = \
- ../lib/libABRTUtils.la
+ ../lib/libabrt.la
abrt_action_analyze_oops_SOURCES = \
abrt-action-analyze-oops.c
@@ -126,7 +126,7 @@ abrt_action_analyze_oops_CPPFLAGS = \
-D_GNU_SOURCE \
-Wall -Werror
abrt_action_analyze_oops_LDADD = \
- ../lib/libABRTUtils.la
+ ../lib/libabrt.la
abrt_action_generate_backtrace_SOURCES = \
abrt-action-generate-backtrace.c
@@ -144,7 +144,7 @@ abrt_action_generate_backtrace_CPPFLAGS
-D_GNU_SOURCE \
-Wall -Werror
abrt_action_generate_backtrace_LDADD = \
- ../lib/libABRTUtils.la \
+ ../lib/libabrt.la \
../btparser/libbtparser.la
abrt_action_bugzilla_SOURCES = \
@@ -165,9 +165,8 @@ abrt_action_bugzilla_CPPFLAGS = \
-Wall -Werror
abrt_action_bugzilla_LDADD = \
$(GLIB_LIBS) \
- ../lib/libABRT_web_utils.la \
- ../lib/libABRTdUtils.la \
- ../lib/libABRTUtils.la
+ ../lib/libabrt_web.la \
+ ../lib/libabrt.la
abrt_action_rhtsupport_SOURCES = \
abrt_rh_support.h abrt_rh_support.c \
@@ -191,9 +190,8 @@ abrt_action_rhtsupport_LDFLAGS = -ltar
abrt_action_rhtsupport_LDADD = \
$(GLIB_LIBS) \
$(XMLRPC_LIBS) $(XMLRPC_CLIENT_LIBS) \
- ../lib/libABRT_web_utils.la \
- ../lib/libABRTdUtils.la \
- ../lib/libABRTUtils.la
+ ../lib/libabrt_web.la \
+ ../lib/libabrt.la
abrt_action_upload_SOURCES = \
abrt-action-upload.cpp
@@ -217,8 +215,7 @@ abrt_action_upload_LDFLAGS = -ltar
abrt_action_upload_LDADD = \
$(GLIB_LIBS) \
$(CURL_LIBS) \
- ../lib/libABRTdUtils.la \
- ../lib/libABRTUtils.la
+ ../lib/libabrt.la
abrt_action_kerneloops_SOURCES = \
abrt-action-kerneloops.cpp
@@ -238,9 +235,8 @@ abrt_action_kerneloops_CPPFLAGS = \
-Wall -Werror
# libABRTdUtils is used only because of LoadPluginSettings:
abrt_action_kerneloops_LDADD = \
- ../lib/libABRT_web_utils.la \
- ../lib/libABRTdUtils.la \
- ../lib/libABRTUtils.la
+ ../lib/libabrt_web.la \
+ ../lib/libabrt.la
abrt_action_mailx_SOURCES = \
abrt-action-mailx.cpp
@@ -259,8 +255,7 @@ abrt_action_mailx_CPPFLAGS = \
-D_GNU_SOURCE \
-Wall -Werror
abrt_action_mailx_LDADD = \
- ../lib/libABRTdUtils.la \
- ../lib/libABRTUtils.la
+ ../lib/libabrt.la
abrt_action_print_SOURCES = \
abrt-action-print.cpp
@@ -280,7 +275,6 @@ abrt_action_print_CPPFLAGS = \
-Wall -Werror
# libABRTdUtils is used only because of make_description_logger:
abrt_action_print_LDADD = \
- ../lib/libABRTdUtils.la \
- ../lib/libABRTUtils.la
+ ../lib/libabrt.la
DEFS = -DLOCALEDIR="$(localedir)" @DEFS@