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

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