summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-03-04 16:02:34 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2011-03-04 16:02:34 +0100
commit961037dfc5d16bc5f256620c87a6bb76e11c3036 (patch)
tree2b310c9c9ba3da66078e9a43b120bcf514a5a32d
parentb781a2f4f7f799a7e1e097819b3535220a8754f3 (diff)
downloadabrt-961037dfc5d16bc5f256620c87a6bb76e11c3036.tar.gz
abrt-961037dfc5d16bc5f256620c87a6bb76e11c3036.tar.xz
abrt-961037dfc5d16bc5f256620c87a6bb76e11c3036.zip
add saving of username; fix one liners loading
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r--src/daemon/abrt_event.conf1
-rw-r--r--src/lib/crash_data.c22
2 files changed, 18 insertions, 5 deletions
diff --git a/src/daemon/abrt_event.conf b/src/daemon/abrt_event.conf
index 23765718..45d8e9a4 100644
--- a/src/daemon/abrt_event.conf
+++ b/src/daemon/abrt_event.conf
@@ -44,6 +44,7 @@ include events.d/*.conf
# abrt-action-analyze-c needs package name, save package data first
EVENT=post-create abrt-action-save-package-data
+EVENT=post-create getent passwd "`cat uid`" | cut -d: -f1 >username
EVENT=post-create analyzer=Python abrt-action-analyze-python
EVENT=post-create analyzer=Kerneloops abrt-action-analyze-oops
# If you want all users (not just root) to be able to see oopses:
diff --git a/src/lib/crash_data.c b/src/lib/crash_data.c
index 8c948436..ce546a54 100644
--- a/src/lib/crash_data.c
+++ b/src/lib/crash_data.c
@@ -133,13 +133,16 @@ static char* is_text_file(const char *name, ssize_t *sz)
lseek(fd, 0, SEEK_SET);
char *buf = (char*)xmalloc(*sz);
- ssize_t r = *sz = full_read(fd, buf, *sz);
+ ssize_t r = full_read(fd, buf, *sz);
close(fd);
if (r < 0)
{
free(buf);
return NULL; /* it's not text (because we can't read it) */
}
+ if (r < *sz)
+ buf[r] = '\0';
+ *sz = r;
/* Some files in our dump directories are known to always be textual */
const char *base = strrchr(name, '/');
@@ -211,11 +214,20 @@ void load_crash_data_from_dump_dir(crash_data_t *crash_data, struct dump_dir *dd
}
char *content;
- if (sz < 4*1024) /* is_text_file did read entire file */
- content = xstrndup(text, sz); //TODO: can avoid this copying if is_text_file() adds NUL
- else /* no, need to read it all */
+ if (sz < 4*1024) /* did is_text_file read entire file? */
+ {
+ content = text;
+ /* Strip '\n' from one-line elements: */
+ char *nl = strchr(content, '\n');
+ if (nl && nl[1] == '\0')
+ *nl = '\0';
+ }
+ else
+ {
+ /* no, need to read it all */
+ free(text);
content = dd_load_text(dd, short_name);
- free(text);
+ }
add_to_crash_data_ext(crash_data,
short_name,