commit:     c1c66b84d3e14b887b7b460111664e62238172fb
Author:     Alexander Miller <alex.miller <AT> gmx <DOT> de>
AuthorDate: Sun Jul 10 15:55:25 2022 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Jul 10 15:55:25 2022 +0000
URL:        https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=c1c66b84

equery check: Fix exception handling for Insufficient permissions

A quick look into the source reveals that there is actually code to handle the 
case,
but it expects the wrong exception type.
This patch fixes that and also avoids a crash for other errors.

Bug: https://bugs.gentoo.org/494134
Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

 pym/gentoolkit/equery/check.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/pym/gentoolkit/equery/check.py b/pym/gentoolkit/equery/check.py
index 7a7c3db..7e580b1 100644
--- a/pym/gentoolkit/equery/check.py
+++ b/pym/gentoolkit/equery/check.py
@@ -16,6 +16,7 @@ from functools import partial
 from getopt import gnu_getopt, GetoptError
 
 import portage.checksum as checksum
+from portage.exception import PermissionDenied
 
 import gentoolkit.pprinter as pp
 from gentoolkit import errors
@@ -138,10 +139,14 @@ class VerifyContents:
             md5sum = files[cfile][2]
             try:
                 cur_checksum = checksum.perform_md5(real_cfile, calc_prelink=1)
-            except IOError:
+            except PermissionDenied:
                 err = "Insufficient permissions to read %(cfile)s"
                 obj_errs.append(err % locals())
                 return obj_errs
+            except Exception as ex:
+                err = "Problem checking %(cfile)s: %(ex)s"
+                obj_errs.append(err % locals())
+                return obj_errs
             if cur_checksum != md5sum:
                 err = "%(cfile)s has incorrect MD5sum"
                 obj_errs.append(err % locals())

Reply via email to