Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 494134 - app-portage/gentoolkit-0.3.0.8-r2: 'equery check sudo' crashes when running as non root and trying to check only root readable file
Summary: app-portage/gentoolkit-0.3.0.8-r2: 'equery check sudo' crashes when running a...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Tools (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage Tools Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-13 09:49 UTC by Nikoli
Modified: 2022-07-10 23:13 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
gentoolkit-0.3.0.9-equery-494134.patch (gentoolkit-0.3.0.9-equery-494134.patch,883 bytes, patch)
2014-12-16 12:58 UTC, Alexander Miller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikoli 2013-12-13 09:49:21 UTC
$ equery check sudo
Traceback (most recent call last):
  File "/usr/lib/python-exec/python2.7/equery", line 38, in <module>
    equery.main(sys.argv)
  File "/usr/lib64/python2.7/site-packages/gentoolkit/equery/__init__.py", line 357, in main
    loaded_module.main(module_args)
  File "/usr/lib64/python2.7/site-packages/gentoolkit/equery/check.py", line 288, in main
    check(matches)
  File "/usr/lib64/python2.7/site-packages/gentoolkit/equery/check.py", line 80, in __call__
    check_results = self._run_checks(pkg.parsed_contents())
  File "/usr/lib64/python2.7/site-packages/gentoolkit/equery/check.py", line 118, in _run_checks
    obj_errs = self._verify_obj(files, cfile, real_cfile, errs)
  File "/usr/lib64/python2.7/site-packages/gentoolkit/equery/check.py", line 148, in _verify_obj
    cur_checksum = checksum.perform_md5(real_cfile, calc_prelink=1)
  File "/usr/lib64/python2.7/site-packages/portage/checksum.py", line 188, in perform_md5
    return perform_checksum(x, "MD5", calc_prelink)[0]
  File "/usr/lib64/python2.7/site-packages/portage/checksum.py", line 390, in perform_checksum
    myhash, mysize = hashfunc_map[hashname](myfilename)
  File "/usr/lib64/python2.7/site-packages/portage/checksum.py", line 53, in __call__
    with _open_file(filename) as f:
  File "/usr/lib64/python2.7/site-packages/portage/checksum.py", line 30, in _open_file
    raise portage.exception.PermissionDenied(func_call)
portage.exception.PermissionDenied: open('/etc/sudoers')


I think it should not crash or exit with error when it can not read some file due to permissions, instead it should just skip it and show something like this:
* Checking app-admin/sudo-1.8.8 ...
!!! /etc/sudoers permission denied, you need to be root for checking this file
Comment 1 Alexander Miller 2014-12-16 12:58:28 UTC
Created attachment 391810 [details, diff]
gentoolkit-0.3.0.9-equery-494134.patch

A year later and I still hit the issue in gentoolkit-0.3.0.9-r2.

A quick look into the source reveals that there is actually code to handle the case, but it expects the wrong exception type. The attached patch fixes that and also avoids a crash for other errors.
Comment 2 Brian Dolbec (RETIRED) gentoo-dev 2022-07-10 15:53:22 UTC
Thank you, Patch applied, testing. will be in the next release.
Comment 3 Larry the Git Cow gentoo-dev 2022-07-10 16:23:14 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=c1c66b84d3e14b887b7b460111664e62238172fb

commit c1c66b84d3e14b887b7b460111664e62238172fb
Author:     Alexander Miller <alex.miller@gmx.de>
AuthorDate: 2022-07-10 15:55:25 +0000
Commit:     Brian Dolbec <dolsen@gentoo.org>
CommitDate: 2022-07-10 15:55:25 +0000

    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@gentoo.org>

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