b404a9
From f0f9bb1e9ab024da1ab4f9311164294404f536df Mon Sep 17 00:00:00 2001
b404a9
From: Jakub Filak <jfilak@redhat.com>
b404a9
Date: Mon, 27 Jan 2014 10:29:32 +0100
b404a9
Subject: [ABRT PATCH 17/27] harvest-vmcore: properly handle inaccessible dir
b404a9
 error
b404a9
b404a9
Related to rhbz#1032511
b404a9
b404a9
rmarko: added missing newlines to sys.stderr.write calls
b404a9
b404a9
Signed-off-by: Jakub Filak <jfilak@redhat.com>
b404a9
---
b404a9
 src/hooks/abrt_harvest_vmcore.py.in | 19 ++++++++++++++-----
b404a9
 1 file changed, 14 insertions(+), 5 deletions(-)
b404a9
b404a9
diff --git a/src/hooks/abrt_harvest_vmcore.py.in b/src/hooks/abrt_harvest_vmcore.py.in
b404a9
index ecfb32d..17e2be8 100644
b404a9
--- a/src/hooks/abrt_harvest_vmcore.py.in
b404a9
+++ b/src/hooks/abrt_harvest_vmcore.py.in
b404a9
@@ -231,10 +231,19 @@ def harvest_vmcore():
b404a9
         f_full = os.path.join(dump_dir, cfile)
b404a9
         if not os.path.isdir(f_full):
b404a9
             continue
b404a9
-        files = [ff for ff in os.listdir(f_full)
b404a9
-                 if os.path.isfile(os.path.join(f_full, ff))]
b404a9
-        if 'vmcore' not in files:
b404a9
+
b404a9
+        try:
b404a9
+            vmcoredirfilelist = os.listdir(f_full)
b404a9
+        except OSError as ex:
b404a9
+            sys.stderr.write("VMCore dir '%s' not accessible.\n" % f_full)
b404a9
             continue
b404a9
+        else:
b404a9
+             if all(("vmcore" != ff
b404a9
+                     for ff in vmcoredirfilelist
b404a9
+                        if os.path.isfile(os.path.join(f_full, ff)))):
b404a9
+                sys.stderr.write(
b404a9
+                    "VMCore dir '%s' doesn't contain 'vmcore' file.\n" % f_full)
b404a9
+                continue
b404a9
 
b404a9
         destdir = os.path.join(abrtdumpdir, ('vmcore-' + cfile))
b404a9
         destdirnew = destdir + '.new'
b404a9
@@ -250,7 +259,7 @@ def harvest_vmcore():
b404a9
         try:
b404a9
             shutil.copytree(f_full, destdirnew)
b404a9
         except (OSError, shutil.Error):
b404a9
-            sys.stderr.write("Unable to copy '%s' to '%s'. Skipping"
b404a9
+            sys.stderr.write("Unable to copy '%s' to '%s'. Skipping\n"
b404a9
                              % (f_full, destdirnew))
b404a9
 
b404a9
             # delete .new dir so we don't create mess
b404a9
@@ -261,7 +270,7 @@ def harvest_vmcore():
b404a9
             try:
b404a9
                 shutil.rmtree(f_full)
b404a9
             except OSError:
b404a9
-                sys.stderr.write("Unable to delete '%s'. Ignoring" % f_full)
b404a9
+                sys.stderr.write("Unable to delete '%s'. Ignoring\n" % f_full)
b404a9
 
b404a9
         # Let abrtd know what type of problem it is:
b404a9
         create_abrtd_info(destdirnew)
b404a9
-- 
b404a9
1.8.3.1
b404a9