summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2011-04-06 11:03:12 +0200
committerJiri Moskovcak <jmoskovc@redhat.com>2011-04-06 11:03:12 +0200
commite46ab2a95aabe30fc043531fddbda16118e2888d (patch)
tree084b940e0e8159a176e421de340b969a4c1d8c2e /src
parent04cc4f8c63a635bcdbce4d887e7c6b3483e6f141 (diff)
parent2cc15eb689fa8690f652ea6db34cb2d40d0cc2cc (diff)
downloadabrt-e46ab2a95aabe30fc043531fddbda16118e2888d.tar.gz
abrt-e46ab2a95aabe30fc043531fddbda16118e2888d.tar.xz
abrt-e46ab2a95aabe30fc043531fddbda16118e2888d.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src')
-rw-r--r--src/cli/report.cpp27
-rw-r--r--src/daemon/Settings.cpp10
-rw-r--r--src/daemon/abrt.conf2
-rw-r--r--src/include/abrtlib.h2
-rw-r--r--src/lib/copy_file_recursive.c10
-rw-r--r--src/lib/strbuf.c23
-rw-r--r--src/plugins/abrt-dump-oops.c38
7 files changed, 68 insertions, 44 deletions
diff --git a/src/cli/report.cpp b/src/cli/report.cpp
index 172cb8f8..e2873a28 100644
--- a/src/cli/report.cpp
+++ b/src/cli/report.cpp
@@ -23,29 +23,6 @@
#define FIELD_SEP "%----"
/*
- * Trims whitespace characters both from left and right side of a string.
- * Modifies the string in-place. Returns the trimmed string.
- */
-static char *trim(char *str)
-{
- if (!str)
- return NULL;
-
- // Remove leading spaces.
- overlapping_strcpy(str, skip_whitespace(str));
-
- // Remove trailing spaces.
- int i = strlen(str);
- while (--i >= 0)
- {
- if (!isspace(str[i]))
- break;
- }
- str[++i] = '\0';
- return str;
-}
-
-/*
* Escapes the field content string to avoid confusion with file comments.
* Returned field must be free()d by caller.
*/
@@ -226,11 +203,11 @@ static int read_crash_report_field(const char *text, crash_data_t *report,
char newvalue[length + 1];
strncpy(newvalue, textfield, length);
newvalue[length] = '\0';
- trim(newvalue);
+ strtrim(newvalue);
char oldvalue[strlen(value->content) + 1];
strcpy(oldvalue, value->content);
- trim(oldvalue);
+ strtrim(oldvalue);
// Return if no change in the contents detected.
if (strcmp(newvalue, oldvalue) == 0)
diff --git a/src/daemon/Settings.cpp b/src/daemon/Settings.cpp
index e25b7959..b3d1ade5 100644
--- a/src/daemon/Settings.cpp
+++ b/src/daemon/Settings.cpp
@@ -64,11 +64,14 @@ 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] == ',')
{
- l = g_list_append(l, xstrdup(item->buf));
+ trim_item = strtrim(item->buf);
+ l = g_list_append(l, xstrdup(trim_item));
strbuf_clear(item);
}
else
@@ -76,7 +79,10 @@ static GList *parse_list(const char* list)
}
if (item->len > 0)
- l = g_list_append(l, xstrdup(item->buf));
+ {
+ trim_item = strtrim(item->buf);
+ l = g_list_append(l, xstrdup(trim_item));
+ }
strbuf_free(item);
return l;
diff --git a/src/daemon/abrt.conf b/src/daemon/abrt.conf
index 460bf061..3611b29b 100644
--- a/src/daemon/abrt.conf
+++ b/src/daemon/abrt.conf
@@ -33,4 +33,4 @@ MaxCrashReportsSize = 1000
# So far we support only one line here
#
[ LogScanners ]
-abrt-dump-oops = abrt-dump-oops -drwx /var/log/messages
+abrt-dump-oops = abrt-dump-oops -d /var/spool/abrt -rwx /var/log/messages
diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h
index d9364673..70dc300c 100644
--- a/src/include/abrtlib.h
+++ b/src/include/abrtlib.h
@@ -94,6 +94,8 @@ extern "C" {
int prefixcmp(const char *str, const char *prefix);
#define suffixcmp abrt_suffixcmp
int suffixcmp(const char *str, const char *suffix);
+#define strtrim abrt_strtrim
+char *strtrim(char *str);
#define concat_path_file abrt_concat_path_file
char *concat_path_file(const char *path, const char *filename);
#define append_to_malloced_string abrt_append_to_malloced_string
diff --git a/src/lib/copy_file_recursive.c b/src/lib/copy_file_recursive.c
index c3f021c7..48108a1d 100644
--- a/src/lib/copy_file_recursive.c
+++ b/src/lib/copy_file_recursive.c
@@ -126,6 +126,16 @@ int copy_file_recursive(const char *source, const char *dest)
if (close(dst_fd) < 0) {
perror_msg("Error writing to '%s'", dest);
retval = -1;
+ } else {
+ /* (Try to) copy atime and mtime */
+ struct timeval atime_mtime[2];
+ atime_mtime[0].tv_sec = source_stat.st_atime;
+ // note: if "st_atim.tv_nsec" doesn't compile, try "st_atimensec":
+ atime_mtime[0].tv_usec = source_stat.st_atim.tv_nsec / 1000;
+ atime_mtime[1].tv_sec = source_stat.st_mtime;
+ atime_mtime[1].tv_usec = source_stat.st_mtim.tv_nsec / 1000;
+ // note: can use utimensat when it is more widely supported:
+ utimes(dest, atime_mtime);
}
goto ret;
}
diff --git a/src/lib/strbuf.c b/src/lib/strbuf.c
index f56815a0..572f11cc 100644
--- a/src/lib/strbuf.c
+++ b/src/lib/strbuf.c
@@ -37,6 +37,29 @@ int suffixcmp(const char *str, const char *suffix)
return strcmp(str + len_minus_suflen, suffix);
}
+/*
+ * Trims whitespace characters both from left and right side of a string.
+ * Modifies the string in-place. Returns the trimmed string.
+ */
+char *strtrim(char *str)
+{
+ if (!str)
+ return NULL;
+
+ // Remove leading spaces.
+ overlapping_strcpy(str, skip_whitespace(str));
+
+ // Remove trailing spaces.
+ int i = strlen(str);
+ while (--i >= 0)
+ {
+ if (!isspace(str[i]))
+ break;
+ }
+ str[++i] = '\0';
+ return str;
+}
+
struct strbuf *strbuf_new(void)
{
struct strbuf *buf = xzalloc(sizeof(*buf));
diff --git a/src/plugins/abrt-dump-oops.c b/src/plugins/abrt-dump-oops.c
index eb95c990..f716c3db 100644
--- a/src/plugins/abrt-dump-oops.c
+++ b/src/plugins/abrt-dump-oops.c
@@ -26,6 +26,7 @@
#define PROGNAME "abrt-dump-oops"
static bool world_readable_dump = false;
+static const char *debug_dumps_dir = ".";
static void queue_oops(GList **vec, const char *data, const char *version)
{
@@ -508,7 +509,7 @@ static unsigned save_oops_to_dump_dir(GList *oops_list, unsigned oops_cnt)
/* and readable only for the owner otherwise */
if (!world_readable_dump)
{
- mode = 0644;
+ mode = 0640;
my_euid = geteuid();
}
@@ -516,14 +517,19 @@ static unsigned save_oops_to_dump_dir(GList *oops_list, unsigned oops_cnt)
unsigned errors = 0;
while (idx != 0 && --countdown != 0)
{
- char path[sizeof(DEBUG_DUMPS_DIR"/oops-YYYY-MM-DD-hh:mm:ss-%lu-%lu") + 2 * sizeof(long)*3];
- sprintf(path, DEBUG_DUMPS_DIR"/oops-%s-%lu-%lu", iso_date, (long)my_pid, (long)idx);
-
char *first_line = (char*)g_list_nth_data(oops_list, --idx);
char *second_line = (char*)strchr(first_line, '\n'); /* never NULL */
*second_line++ = '\0';
- struct dump_dir *dd = dd_create(path, /*uid:*/ my_euid, mode);
+ struct dump_dir *dd;
+ {
+ char base[sizeof("oops-YYYY-MM-DD-hh:mm:ss-%lu-%lu") + 2 * sizeof(long)*3];
+ sprintf(base, "oops-%s-%lu-%lu", iso_date, (long)my_pid, (long)idx);
+ char *path = concat_path_file(debug_dumps_dir, base);
+ dd = dd_create(path, /*uid:*/ my_euid, mode);
+ free(path);
+ }
+
if (dd)
{
dd_create_basic_files(dd, /*uid:*/ my_euid);
@@ -560,7 +566,7 @@ int main(int argc, char **argv)
/* Can't keep these strings/structs static: _() doesn't support that */
const char *program_usage_string = _(
- PROGNAME" [-vsrdow] FILE\n"
+ PROGNAME" [-vsrowx] [-d DIR] FILE\n"
"\n"
"Extract oops from syslog/dmesg file"
);
@@ -568,23 +574,23 @@ int main(int argc, char **argv)
OPT_v = 1 << 0,
OPT_s = 1 << 1,
OPT_r = 1 << 2,
- OPT_d = 1 << 3,
- OPT_o = 1 << 4,
- OPT_w = 1 << 5,
+ OPT_o = 1 << 3,
+ OPT_w = 1 << 4,
+ OPT_d = 1 << 5,
OPT_x = 1 << 6,
};
/* Keep enum above and order of options below in sync! */
struct options program_options[] = {
OPT__VERBOSE(&g_verbose),
- OPT_BOOL('s', NULL, NULL, _("Log to syslog")),
- OPT_BOOL('r', NULL, NULL, _("Parse kernel's message buffer before parsing FILE")),
- OPT_BOOL('d', NULL, NULL, _("Create ABRT dump for every oops found")),
- OPT_BOOL('o', NULL, NULL, _("Print found oopses on standard output")),
- OPT_BOOL('w', NULL, NULL, _("Do not exit, watch the file for new oopses")),
- /* oopses doesn't contain any sensitive info, and even
+ OPT_BOOL( 's', NULL, NULL, _("Log to syslog")),
+ OPT_BOOL( 'r', NULL, NULL, _("Parse kernel's message buffer before parsing FILE")),
+ OPT_BOOL( 'o', NULL, NULL, _("Print found oopses on standard output")),
+ OPT_BOOL( 'w', NULL, NULL, _("Do not exit, watch the file for new oopses")),
+ /* oopses don't contain any sensitive info, and even
* the old koops app was showing the oopses to all users
*/
- OPT_BOOL('x', NULL, NULL, _("Make the dump directory world readable")),
+ OPT_STRING('d', NULL, &debug_dumps_dir, "DIR", _("Create ABRT dump in DIR for every oops found")),
+ OPT_BOOL( 'x', NULL, NULL, _("Make the dump directory world readable")),
OPT_END()
};
unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);