arrfab / rpms / abrt

Forked from rpms/abrt 5 years ago
Clone

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

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