Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 172472 - app-admin/eselect-1.0.9: load_config() wrongly returns values from the environment
Summary: app-admin/eselect-1.0.9: load_config() wrongly returns values from the enviro...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: eselect (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Gentoo eselect Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 179880 181166
  Show dependency tree
 
Reported: 2007-03-27 21:27 UTC by Ulrich Müller
Modified: 2007-06-17 10:06 UTC (History)
1 user (show)

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


Attachments
Patch for eselect-1.0.9 (eselect.patch,263 bytes, patch)
2007-06-07 00:00 UTC, Ulrich Müller
Details | Diff
Patch for eselect-1.0.9 (eselect.patch,261 bytes, patch)
2007-06-07 00:12 UTC, Ulrich Müller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Müller gentoo-dev 2007-03-27 21:27:05 UTC
"eselect env update" behaves differently from "env-update". Path elements are accumulated in profile.env and are not deleted, even if they are removed from the files in env.d. The following session illustrates the problem:

# echo INFOPATH=foo >/etc/env.d/99test
# env-update; . /etc/profile
>>> Regenerating /etc/ld.so.cache...
# echo $INFOPATH
/usr/share/info:[...]:foo
[O.K.]

# echo INFOPATH=bar >/etc/env.d/99test
# env-update; . /etc/profile
>>> Regenerating /etc/ld.so.cache...
# echo $INFOPATH
/usr/share/info:[...]:bar
[O.K.]

# rm /etc/env.d/99test
# env-update; . /etc/profile
>>> Regenerating /etc/ld.so.cache...
# echo $INFOPATH
/usr/share/info:[...]
[O.K.]

# echo INFOPATH=foo >/etc/env.d/99test
# eselect env update; . /etc/profile
Regenerating /etc/ld.so.cache...
# echo $INFOPATH
/usr/share/info:[...]:foo
[O.K.]

# echo INFOPATH=bar >/etc/env.d/99test
# eselect env update; . /etc/profile
Regenerating /etc/ld.so.cache...
# echo $INFOPATH
/usr/share/info:[...]:foo:bar
[This should contain "bar" only.]

# rm /etc/env.d/99test
# eselect env update; . /etc/profile
Regenerating /etc/ld.so.cache...
# echo $INFOPATH
/usr/share/info:[...]:foo:bar
[Should contain neither "foo" nor "bar".]

# env-update; . /etc/profile
>>> Regenerating /etc/ld.so.cache...
# echo $INFOPATH
/usr/share/info:[...]
[O.K.]
Comment 1 Ulrich Müller gentoo-dev 2007-03-29 08:14:41 UTC
Still the same in 1.0.9.
Comment 2 George Shapovalov (RETIRED) gentoo-dev 2007-05-19 12:11:48 UTC
I observe the same. 
I tried to use "do_action env update &> /dev/null" in gnat.eselect module, but that pulls in active enc settings (like active PATH, ADA_INCLUDE_PATH, etc) which essentially breaks functionality of gnat.eselect module. This can be worked around by using env-update directly inside the gnat.eselect, however this is flagged "incorrect" in the eselect documentation (in developer-guide.html), plus it only makes sense to use eselect's own modules where possible.

I could provide a gnat specific extra test case, but the one above is way more simple and represents the issue well enough (short version: add "do_action env update &> /dev/null" to the end of do_set and do_update functions of gnat.eselect module and try switching from e.g. x86_64-pc-linux-gnu-gnat-gcc-4.2 to x86_64-pc-linux-gnu-gnat-gcc-4.1 (gnat-gcc-4.1.2 and gnat-gcc-4.2.0 would need to be installed) and then do ". /etc/profile" in some shell without running env-update first and then check PATH and ADA_INCLUDE_PATH vars. They should not contain old (but that were active at the moment of running eselect gnat set or env update) values (4.1 when activating 4.2 or vice verse).

I also upped the severity one notch, as eselect is an important package and env is a central its module and this is indeed a major issue for any package trying to utilize this functionality.

George
Comment 3 Ulrich Müller gentoo-dev 2007-06-06 23:57:55 UTC
Looks like the problem is in lib/config.bash, function load_config(). The ${key} variable misses a local declaration; so if it is not set in the config file, then its value will happily be taken from the environment.

Attached patch should fix the problem.
Comment 4 Ulrich Müller gentoo-dev 2007-06-07 00:00:21 UTC
Created attachment 121363 [details, diff]
Patch for eselect-1.0.9
Comment 5 Ulrich Müller gentoo-dev 2007-06-07 00:12:48 UTC
Created attachment 121365 [details, diff]
Patch for eselect-1.0.9

Quotation marks are not neccessary here.
Comment 6 Ulrich Müller gentoo-dev 2007-06-08 06:56:52 UTC
george: Can you confirm if the patch fixes the problem for you?
Comment 7 George Shapovalov (RETIRED) gentoo-dev 2007-06-14 12:09:54 UTC
Sorry for the delay, got carried out by other stuff.
Yes, this fixes it. Thanks! Now we only need this fix to be picked up :).

George
Comment 8 Ulrich Müller gentoo-dev 2007-06-16 20:49:49 UTC
Changed summary since the problem is not in env.eselect, but in config.bash.
Comment 9 Danny van Dyk (RETIRED) gentoo-dev 2007-06-17 10:06:58 UTC
Fixed as of 1.0.10