Bug#688932: g_get_user_*_dir () fails to conform to basedir-spec-0.8 (re. ${HOME})

Ivan Shmakov oneingray at gmail.com
Sat Sep 29 05:37:10 UTC 2012


>>>>> Bernhard R Link <brlink at debian.org> writes:
>>>>> * Simon McVittie <smcv at debian.org> [120926 18:50]:

	[Cc: 688932 at bugs.debian.org.]

 >> ... but I don't think this is the right way to make it happen.
 >> Please research previous discussion to check that you're not missing
 >> arguments that have happened in the past, then if you still think
 >> your proposal is the best option, take it upstream.

 > This was already taken upstream

	Could you please provide an URI of the prior discussion?  TIA.

 > and upstream's opinion was "if we do this as the unix guys expect
 > then users complain that changing $HOME changes the home directory.".

	The point is that the home directory is exactly “the directory
	pointed to by the HOME environment variable.”  At least on the
	Unix-like systems.

	It's just like the user's shell is the one pointed to by
	${SHELL}, and the user's executables' search path is the
	directories listed in ${PATH}.  Never an “ordinary” program is
	expected to use a system-wide configuration, or a hard-coded
	value, for these.

[…]

 > The documentation for g_get_home_dir [1] also documents what a proper
 > program can do, it's a simple:

 >  const char *homedir = g_getenv ("HOME");
 >    if (!homedir)
 >       homedir = g_get_home_dir ();

 > instead of using get_get_home_dir directly.

	Actually, as pointed out in [2], a conforming application should
	use g_get_user_cache_dir (), g_get_user_data_dir (), and
	g_get_user_config_dir () instead.

	Alas, the GLib implementation of these functions relies on
	g_get_home_dir (), and thus itself fails to conform to the
	specification [3], which explicitly requires that the HOME
	variable's value is used.  (FWIW, it doesn't even mention
	getpwuid () or passwd(5).)

[2] news:506480FE.4060907 at gnome.org
    http://permalink.gmane.org/gmane.comp.gnome.gtk+.devel.general/22728
[3] http://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html

 > (And tip of the day: If you are working with multiple home
 > directories regulariy and get tired of badly written programs
 > confusing the initial home directory with the current one, setting
 > the initial home directory to the empty string can help in many cases
 > (though you lose having a default one for programs not getting one
 > set)).

	The question is, where Bash will get its ~/.bash_profile from,
	then?

	A “proper” hack (for a certain definition thereof) would be to
	use an LD_PRELOAD module, redefining either g_get_home_dir (),
	or, perhaps, getpwuid () (to catch the cases getpwuid () ends up
	being used for no good reason at all.).

 > [1] For example
 > http://developer.gnome.org/glib/2.33/glib-Miscellaneous-Utility-Functions.html#g-get-home-dir

-- 
FSF associate member #7257



More information about the pkg-gnome-maintainers mailing list