g_get_home_dir(): honour $HOME

If the $HOME environment variable is set, prefer that to the entry in
/etc/passwd.

This brings us in line with almost every other utility and library on
UNIX-like systems while avoiding some of the more complicated
possibilities that have been suggested.

This incompatible change has been petitioned for quite some time by
many, and in particular from the Debian world, which carries a patch
that adds a new G_HOME environment variable with the same meaning as
this patch now assigns to HOME.

The primary motivation for the change was to increase the testability of
GLib-based programs from 'make check' types of frameworks: it is now
possible to set HOME to a temp directory to avoid the testsuite
modifying the user's real home directory.

The change also brings us increased compliance with the XDG Base
Directory Specification.  The specification specifically states that the
default values should be computed based on the HOME environment
variable, whereas we were basing them on the value from /etc/passwd.

The change was agreed to by all in attendence at the November 29 Gtk+
developer meeting.

https://bugzilla.gnome.org/show_bug.cgi?id=142568
This commit is contained in:
Ryan Lortie
2012-12-02 12:07:24 -05:00
parent 28f88cf111
commit 7523c04b54
2 changed files with 44 additions and 35 deletions

9
NEWS
View File

@@ -1,3 +1,12 @@
Overview of changes from GLib 2.35.2 to 2.35.3
==============================================
This release contains an incompatible change to the g_get_home_dir()
function. Previously, this function would effectively ignore the HOME
environment variable and always return the value from /etc/password. As
of this version, the HOME variable is used if it is set and the value
from /etc/passwd is only used as a fallback.
Overview of changes from GLib 2.35.1 to 2.35.2
==============================================