Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 451150

Summary: app-admin/eselect: exits with no description when inherited lib is not readable
Product: Gentoo Hosted Projects Reporter: Michał Górny <mgorny>
Component: eselectAssignee: Gentoo eselect Team <eselect>
Status: RESOLVED FIXED    
Severity: normal Keywords: InVCS
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 475284    
Bug Blocks:    
Attachments: Patch for core.bash

Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-01-10 10:25:00 UTC
chmod o-r /usr/share/eselect/libs/something.bash

$ eselect foo
exiting
Comment 1 Ulrich Müller gentoo-dev 2013-01-12 06:38:29 UTC
Created attachment 335284 [details, diff]
Patch for core.bash

It correctly calls die(), but stderr is redirected during sourcing, so the output doesn't show.

Attached patch should fix it. I shall do some testing though, to see if it doesn't have unwanted side effects.
Comment 2 Ulrich Müller gentoo-dev 2013-01-12 06:40:32 UTC
(In reply to comment #1)
> It correctly calls die(), but stderr is redirected during sourcing, so the
> output doesn't show.

Sorry this is misleading. It should read: inherit() correctly calls die(), ...
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-01-12 11:26:36 UTC
Comment on attachment 335284 [details, diff]
Patch for core.bash

>diff --git a/libs/core.bash.in b/libs/core.bash.in
>index 4431a8f..960886b 100644
>--- a/libs/core.bash.in
>+++ b/libs/core.bash.in
>@@ -77,9 +77,9 @@ do_action() {
> 
> 	modfile=$( es_find_module "${action}" )
> 	(
>-		source "$ESELECT_DEFAULT_ACTIONS" 2>/dev/null \
>+		source "$ESELECT_DEFAULT_ACTIONS" \
> 			|| die "Couldn't source ${ESELECT_DEFAULT_ACTIONS}"
>-		source "${modfile}" 2>/dev/null \
>+		source "${modfile}" \
> 			|| die "Couldn't source ${modfile}"
> 		if [[ -z ${subaction} ]] ; then
> 			check_do "do_${DEFAULT_ACTION:-usage}" "$@"

Hmm, I don't think that this redirect should affect 'die'…

$ source /tmp/foo 2>/dev/null || { echo 11 >&2; }
11
Comment 4 Ulrich Müller gentoo-dev 2013-01-12 12:14:01 UTC
(In reply to comment #3)
> Hmm, I don't think that this redirect should affect 'die'…

Have to tested the patch?

The die in do_action wouldn't be affected, but it is never reached. The program dies in the inherit() function before, and there redirection is still active.
Comment 5 Ulrich Müller gentoo-dev 2013-01-12 12:14:22 UTC
(In reply to comment #4)
> Have to tested the patch?

s/to/you/
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-01-12 12:31:06 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > Hmm, I don't think that this redirect should affect 'die'…
> 
> Have to tested the patch?

Hmm, indeed it works.

> The die in do_action wouldn't be affected, but it is never reached. The
> program dies in the inherit() function before, and there redirection is
> still active.

Ah, I understand it now. Well, that looks a bit like addressing one issue through introduce another (maybe lesser one). I'd rather work on making die() work independently of 2>/dev/null.
Comment 8 Ulrich Müller gentoo-dev 2013-06-22 16:01:10 UTC
Fixed in eselect-1.3.5.
Comment 9 Ulrich Müller gentoo-dev 2013-07-06 06:28:02 UTC
(In reply to Ulrich Müller from comment #7)
> Fixed in git:
> <http://git.overlays.gentoo.org/gitweb/?p=proj/eselect.git;a=commit;
> h=12e3ecb19d311b888abc118d806fee635602e3ee>

This breaks bash on Mac OS X, see bug 475284. Reopening.
Comment 10 Ulrich Müller gentoo-dev 2013-07-06 14:22:42 UTC
Fixed in eselect 1.3.6. The stderr descriptor is now only saved for >=bash-4.1:
<http://git.overlays.gentoo.org/gitweb/?p=proj/eselect.git;a=commit;h=3a412426d924310abb59311dd3cc1133eb1c6849>

This means that the bug will still show up for users of bash 4.0 or lower. Please reopen if you think that this merits further attention.