Blame SOURCES/0017-harvest-vmcore-properly-handle-inaccessible-dir-erro.patch

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