Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 418475 - unreadable /etc/portage/ files shouldn't kill portageq/emerge/etc...
Summary: unreadable /etc/portage/ files shouldn't kill portageq/emerge/etc...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: All Linux
: Low enhancement (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 484436
  Show dependency tree
 
Reported: 2012-06-01 05:23 UTC by SpanKY
Modified: 2014-01-04 22:01 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description SpanKY gentoo-dev 2012-06-01 05:23:47 UTC
i could see issuing a warning to stderr, but these shouldn't traceback ... quite a good amount of information can still be provided if these things are unreadable.

# mkdir -p /etc/portage/package.keywords/
# chmod 0 /etc/portage/package.keywords/
$ portageq envvar CHOST
Traceback (most recent call last):
  File "/usr/bin/portageq", line 834, in <module>
    main()
  File "/usr/bin/portageq", line 815, in main
    retval = function(args)  
  File "/usr/bin/portageq", line 664, in envvar
    print(portage.settings[arg])
  File "/usr/lib64/portage/pym/portage/proxy/objectproxy.py", line 37, in __getitem__
    return object.__getattribute__(self, '_get_target')()[key]
  File "/usr/lib64/portage/pym/portage/__init__.py", line 588, in _get_target
    return _get_legacy_global(name)
  File "/usr/lib64/portage/pym/portage/_legacy_globals.py", line 34, in _get_legacy_global
    portage.db = portage.create_trees(**kwargs)
  File "/usr/lib64/portage/pym/portage/__init__.py", line 476, in create_trees
    config_incrementals=portage.const.INCREMENTALS)
  File "/usr/lib64/portage/pym/portage/proxy/objectproxy.py", line 31, in __call__
    return result(*args, **kwargs)
  File "/usr/lib64/portage/pym/portage/package/ebuild/config.py", line 531, in __init__
    local_config, global_accept_keywords=self.configdict["defaults"].get("ACCEPT_KEYWORDS", ""))
  File "/usr/lib64/portage/pym/portage/package/ebuild/_config/KeywordsManager.py", line 57, in __init__
    verify_eapi=False)
  File "/usr/lib64/portage/pym/portage/util/__init__.py", line 408, in grabdict_package
    pkgs=grabdict(myfilename, juststrings, empty=1, recursive=recursive)
  File "/usr/lib64/portage/pym/portage/util/__init__.py", line 356, in grabdict
    for x in grablines(myfilename, recursive):
  File "/usr/lib64/portage/pym/portage/util/__init__.py", line 470, in grablines
    dirlist = os.listdir(myfilename)
  File "/usr/lib64/portage/pym/portage/__init__.py", line 215, in __call__
    rval = self._func(*wrapped_args, **wrapped_kwargs)
OSError: [Errno 13] Permission denied: '/etc/portage/package.keywords'
$ emerge --info

Traceback (most recent call last):
  File "/usr/bin/emerge", line 43, in <module>
    retval = emerge_main()   
  File "/usr/lib64/portage/pym/_emerge/main.py", line 1517, in emerge_main
    settings, trees, mtimedb = load_emerge_config()
  File "/usr/lib64/portage/pym/_emerge/actions.py", line 2969, in load_emerge_config
    trees = portage.create_trees(trees=trees, **kwargs)
  File "/usr/lib64/portage/pym/portage/__init__.py", line 476, in create_trees
    config_incrementals=portage.const.INCREMENTALS)
  File "/usr/lib64/portage/pym/portage/proxy/objectproxy.py", line 31, in __call__
    return result(*args, **kwargs)
  File "/usr/lib64/portage/pym/portage/package/ebuild/config.py", line 531, in __init__
    local_config, global_accept_keywords=self.configdict["defaults"].get("ACCEPT_KEYWORDS", ""))
  File "/usr/lib64/portage/pym/portage/package/ebuild/_config/KeywordsManager.py", line 57, in __init__
    verify_eapi=False)
  File "/usr/lib64/portage/pym/portage/util/__init__.py", line 408, in grabdict_package
    pkgs=grabdict(myfilename, juststrings, empty=1, recursive=recursive)
  File "/usr/lib64/portage/pym/portage/util/__init__.py", line 356, in grabdict
    for x in grablines(myfilename, recursive):
  File "/usr/lib64/portage/pym/portage/util/__init__.py", line 470, in grablines
    dirlist = os.listdir(myfilename)
  File "/usr/lib64/portage/pym/portage/__init__.py", line 215, in __call__
    rval = self._func(*wrapped_args, **wrapped_kwargs)
OSError: [Errno 13] Permission denied: '/etc/portage/package.keywords'
Comment 1 Zac Medico gentoo-dev 2012-06-01 05:52:57 UTC
(In reply to comment #0)
> i could see issuing a warning to stderr, but these shouldn't traceback ...

How about if we just show an "Access Denied" message?

> quite a good amount of information can still be provided if these things are
> unreadable.

But whatever information they can get is probably none of their business if they don't have access to all portage config files. We could try to construct a partial config instance, but then it could potentially return erroneous results for some queries.
Comment 2 SpanKY gentoo-dev 2012-06-01 16:14:54 UTC
(In reply to comment #1)

it might be accurate information, it might not.  for most package.* paths, it won't matter at all to `portageq envvar` or most (if not all) of `emerge --info`.  i think that's up to the user to determine.

if we issued a warning to stderr that said:
warning: access denied while accessing: <path>
warning: information displayed might not be accurate
Comment 3 Zac Medico gentoo-dev 2012-06-01 22:13:10 UTC
By parsing package.keywords on demand, we don't even have to show an error message until it's accessed:

http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b03ed0de134456870c0361dd573e18830c45fa49
Comment 5 SpanKY gentoo-dev 2012-06-01 23:59:12 UTC
ah, that's a good solution too :)
Comment 6 Zac Medico gentoo-dev 2012-06-02 00:44:09 UTC
Some of these config files support */* wildcard settings that are translated to global environment settings, making it trickier to load them on demand:

   package.license -> ACCEPT_LICENSE
   package.properties -> ACCEPT_PROPERTIES
   package.env -> any variable
   package.accept_keywords -> ACCEPT_KEYWORDS

This one's currently not implemented:

  package.accept_keywords -> ACCEPT_KEYWORDS
Comment 7 SpanKY gentoo-dev 2012-06-02 01:46:34 UTC
(In reply to comment #6)

i'd like to think that the variables affected there are in the minority of requested ones.  so if the loading code simply warned on those, that'd be fine.

package.env would only matter if someone was specifically querying the info for that right ?  so generally `portageq ...` and `emerge --info` don't care about package.env.
Comment 8 Zac Medico gentoo-dev 2012-06-02 01:53:40 UTC
I think we can just drop the */* wildcard to global var translation, in order to make everything lazy. It makes sense to do so, regardless of the permission thing.
Comment 9 Sebastian Luther (few) 2012-06-02 05:51:38 UTC
(In reply to comment #8)
> I think we can just drop the */* wildcard to global var translation, in
> order to make everything lazy. It makes sense to do so, regardless of the
> permission thing.

Please don't do that. Specifying global settings like this is a much better approach than using global variables from make.conf + config files. Using config files only is much cleaner. If you want to drop something, drop the variables. 
I migrated all my systems long ago to not use variables in make.conf and I'd prefer that this doesn't break.

What exactly is the problem with requiring /etc/portage to be readable? Either you're allowed to access portage's config in which case you may use emerge --info. Or someone didn't want you to access portage's config files. Portage should not try to circumvent this.
Comment 10 Alexander Berntsen (RETIRED) gentoo-dev 2013-10-02 09:47:43 UTC
Can we close this bug as resolved now? The issue described in the original post is no longer present.
Comment 11 Arfrever Frehtes Taifersar Arahesis 2013-10-02 10:45:07 UTC
All potential files should be checked (also in /var/cache/edb and /var/lib/portage).

/etc/portage/modules:
http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commitdiff;h=5924b7afae7c731abc24a0e16fcd103e680e3e5b
Comment 12 SpanKY gentoo-dev 2013-10-04 05:40:20 UTC
if i find another case, i'll file a new bug