aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2012-12-13 00:49:06 +0000
committerBryn M. Reeves <bmr@redhat.com>2012-12-13 00:52:09 +0000
commit4d474bcd626df1ec35f3345cb4e3fefa4e63bd93 (patch)
treed85583e2b242e44a8a79ef70b452180574ffe833
parentbb525888d26d8671507b2e0e25ffd5cb82ec8ae6 (diff)
downloadsos-4d474bcd626df1ec35f3345cb4e3fefa4e63bd93.tar.gz
Fix exception when unreadable files are collected
Files in /proc/, /sys/ and other kernel file systems may have read permissions but not implement a read() syscall. Catch the exception that occurs when accessing these files. Fixes Issue #87
-rw-r--r--sos/utilities.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/sos/utilities.py b/sos/utilities.py
index a3859f1c..cf079ff5 100644
--- a/sos/utilities.py
+++ b/sos/utilities.py
@@ -263,9 +263,14 @@ class TarFileArchive(Archive):
tar_info.type = tarfile.DIRTYPE
fileobj = None
else:
- fp = open(src, 'rb')
- content = fp.read()
- fp.close()
+ try:
+ fp = open(src, 'rb')
+ content = fp.read()
+ fp.close()
+ except:
+ # files with read permissions that cannot be read may exist
+ # in /proc, /sys and other virtual file systems.
+ content = ""
tar_info.size = len(content)
fileobj = StringIO(content)