summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-10-21 17:43:38 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-10-21 17:45:02 +0200
commit4ef2c83a026bc4fcc933698e1fdc0632c8d41f28 (patch)
treea009d9d97ef5b189d7cf5a16e3038dfa2635fa76 /lib
parentff49f16f9cb9b6d75d16228fb40963eee9d562ec (diff)
downloadabrt-4ef2c83a026bc4fcc933698e1fdc0632c8d41f28.tar.gz
abrt-4ef2c83a026bc4fcc933698e1fdc0632c8d41f28.tar.xz
abrt-4ef2c83a026bc4fcc933698e1fdc0632c8d41f28.zip
dump_dir: make open fail if there is no "analyzer" file.
Also adjusts abrt-action-print to return better error message: '/tmp' is not a crash dump directory 1 Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/utils/dump_dir.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/utils/dump_dir.c b/lib/utils/dump_dir.c
index 555800c3..19a6c875 100644
--- a/lib/utils/dump_dir.c
+++ b/lib/utils/dump_dir.c
@@ -189,9 +189,8 @@ struct dump_dir *dd_opendir(const char *dir, int flags)
dd_lock(dd);
struct stat stat_buf;
- if (stat(dir, &stat_buf) != 0
- || !S_ISDIR(stat_buf.st_mode)
- ) {
+ if (stat(dir, &stat_buf) != 0 || !S_ISDIR(stat_buf.st_mode))
+ {
if (!(flags & DD_FAIL_QUIETLY))
error_msg("'%s' does not exist", dir);
dd_close(dd);
@@ -202,6 +201,24 @@ struct dump_dir *dd_opendir(const char *dir, int flags)
dd->dd_uid = stat_buf.st_uid;
dd->dd_gid = stat_buf.st_gid;
+ /* Without this check, e.g. abrt-action-print happily prints any current
+ * directory when run without arguments, because its option -d DIR
+ * defaults to "."! Let's require that at least some crash dump dir
+ * specific files exist before we declare open successful:
+ */
+ char *name = concat_path_file(dir, FILENAME_ANALYZER);
+ int bad = (lstat(name, &stat_buf) != 0 || !S_ISREG(stat_buf.st_mode));
+ free(name);
+ if (bad)
+ {
+ /*if (!(flags & DD_FAIL_QUIETLY))... - no, DD_FAIL_QUIETLY only means
+ * "it's ok if it doesn exist", not "ok if contents is bogus"!
+ */
+ error_msg("'%s' is not a crash dump directory", dir);
+ dd_close(dd);
+ return NULL;
+ }
+
return dd;
}