Bug#688932: g_get_user_{cache, config, data}_dir () fail to meet XDG Base Directory Specification
Ivan Shmakov
oneingray at gmail.com
Fri Oct 26 09:51:42 UTC 2012
reopen 688932
retitle 688932 g_get_user_{cache,config,data}_dir () fail to meet XDG Base Directory Specification
severity 688932 minor
thanks
[Re-opening, as it's essentially the same issue, and it's /not/
resolved. I also hope to forward this one to the upstream
tracker, possibly with a patch, sometime next week.]
As per XDG Base Directory Specification 0.8 (quoted below), the
default values for XDG_CACHE_HOME, XDG_CONFIG_HOME, and
XDG_DATA_HOME, are both defined relative to the value of the
HOME environment variable. Contrary to that, the respective
g_get_user_{cache,config,data}_dir () functions return values
relative to the user's /initial/ home directory (as per
getpwuid ()->pw_dir) by default instead.
Consider, e. g. (the source is MIME'd):
$ LC_ALL=C make LDFLAGS=-lglib-2.0 ugpzy4dbahtheg6tnc1m39anxd
cc -lglib-2.0 ugpzy4dbahtheg6tnc1m39anxd.c -o ugpzy4dbahtheg6tnc1m39anxd
$ ./ugpzy4dbahtheg6tnc1m39anxd
XDG_CACHE_HOME => /home/private/users/jrh/.cache
XDG_CONFIG_HOME => /home/private/users/jrh/.config
XDG_DATA_HOME => /home/private/users/jrh/.local/share
$ HOME=$(mktemp -dt -- foo.XXXXXXXX) ./ugpzy4dbahtheg6tnc1m39anxd
XDG_CACHE_HOME => /home/private/users/jrh/.cache
XDG_CONFIG_HOME => /home/private/users/jrh/.config
XDG_DATA_HOME => /home/private/users/jrh/.local/share
$ (HOME=$(mktemp -dt -- foo.XXXXXXXX) \
&& XDG_CACHE_HOME=${HOME}/.cache \
XDG_CONFIG_HOME=${HOME}/.config \
XDG_DATA_HOME=${HOME}/.local/share \
./ugpzy4dbahtheg6tnc1m39anxd)
XDG_CACHE_HOME => /tmp/foo.nmGK6HNL/.cache
XDG_CONFIG_HOME => /tmp/foo.nmGK6HNL/.config
XDG_DATA_HOME => /tmp/foo.nmGK6HNL/.local/share
$
The end result is that the calling applications become
non-compliant to the specification.
Could this please be fixed?
TIA.
PS. As it seems, the easiest way to fix this issue is to change
g_get_home_dir () to prefer HOME over the value returned by
getpwuid () (either in the “sane” cases, or always), as was
suggested before. This would also fix the applications which
choose not to use g_get_user_*_dir (), and call the plain old
g_get_home_dir () instead.
--cut: http://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html --
$XDG_DATA_HOME defines the base directory relative to which user
specific data files should be stored. If $XDG_DATA_HOME is either
not set or empty, a default equal to $HOME/.local/share should be
used.
$XDG_CONFIG_HOME defines the base directory relative to which user
specific configuration files should be stored. If $XDG_CONFIG_HOME is
either not set or empty, a default equal to $HOME/.config should be
used.
…
$XDG_CACHE_HOME defines the base directory relative to which user
specific non-essential data files should be stored. If
$XDG_CACHE_HOME is either not set or empty, a default equal to
$HOME/.cache should be used.
--cut: http://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html --
--
FSF associate member #7257
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-csrc
Size: 504 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-gnome-maintainers/attachments/20121026/fd93fe79/attachment.c>
More information about the pkg-gnome-maintainers
mailing list