After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 646950 - XDG dirs cannot be relative paths
XDG dirs cannot be relative paths
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-04-06 19:49 UTC by ulrik sverdrup
Modified: 2018-05-24 13:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
backtrace of XDG_CACHE_HOME=tmp totem (5.25 KB, text/plain)
2011-04-06 19:49 UTC, ulrik sverdrup
  Details
relative XDG dir warning and set to default (2.49 KB, patch)
2011-09-03 13:08 UTC, Kushal Das
none Details | Review
relative XDG dir warning and set to default (2.51 KB, patch)
2011-09-03 19:05 UTC, Kushal Das
needs-work Details | Review

Description ulrik sverdrup 2011-04-06 19:49:26 UTC
Created attachment 185352 [details]
backtrace of  XDG_CACHE_HOME=tmp totem

I was using  XDG_CACHE_HOME=tmp  (and the other related variables set identically) and totem unexpectedly crashed when starting to play a file.

I'm using totem 2.30.2 (from debian). I have looked at current git and I think the crash reason is on this line:  http://git.gnome.org/browse/totem/tree/src/totem-uri.c#n432   where g_filename_to_uri is called on the relative path fake_filename that is constructed just above the relevant line. I haven't actually tried to modify this spot.

Totem survives relative paths in the other variables (XDG_DATA_HOME, XDG_CONFIG_HOME) just fine.

Backtrace is attached.
Comment 1 Bastien Nocera 2011-04-07 00:57:38 UTC
We won't crash anymore, in gnome-3-0 and master, we'll just warn gently. I would expect glib to return an absolute path for g_get_user_cache_dir().

The XDG Base spec doesn't mention whether relative paths are alright:
http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

commit e72ced40b1d90fa9481b8c0ab7dde10f4a961803
Author: Bastien Nocera <hadess@hadess.net>
Date:   Thu Apr 7 01:07:44 2011 +0100

    main: Stop crash when XDG_CACHE_HOME is relative
    
    Don't crash but error when a relative path is given.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=646950
Comment 2 Lennart Poettering 2011-04-07 01:53:49 UTC
We should update the spec to make this clear and glib should ignore env vars set to relative paths and spit out a warning.
Comment 3 ulrik sverdrup 2011-04-07 02:30:48 UTC
Bastien, I don't think your patch actually fixes this crash. Of course, this is only my suspicion from reading it so take the claim with a grain of salt. The change I see in master adds an assertion that only guards against a NULL uri but it's the played video file uri it is checking, unrelated to the cache home variable.

The spec not allowing relative directories sounds reasonable, it breaks anyway as soon programs change directory.
Comment 4 ulrik sverdrup 2011-04-07 02:31:37 UTC
Take it with a grain of salt :-) because I'm wrong.
Comment 5 Bastien Nocera 2011-04-08 14:10:52 UTC
glib should warn, and set to defaults any of the XDG dirs that are relative, instead of absolute paths.
Comment 6 Kushal Das 2011-09-03 13:08:14 UTC
Created attachment 195567 [details] [review]
relative XDG dir warning and set to default

GLib will warn and set to defaults any of the follwing XDG dirs that are relative, instead of absolute paths.

XDG_CACHE_HOME, XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_RUNTIME_DIR
Comment 7 Lennart Poettering 2011-09-03 18:48:04 UTC
Make sure to use g_path_is_absolute() to get cross platform support right.
Comment 8 Kushal Das 2011-09-03 19:05:39 UTC
Created attachment 195599 [details] [review]
relative XDG dir warning and set to default

New patch with formatting fixed and using g_path_is_absolute.
Comment 9 Dan Winship 2011-09-03 19:34:32 UTC
(In reply to comment #7)
> Make sure to use g_path_is_absolute() to get cross platform support right.

for *XDG* directories?
Comment 10 Philip Withnall 2018-02-16 13:17:38 UTC
Review of attachment 195599 [details] [review]:

This needs some unit tests.

::: glib/gutils.c
@@ +2258,3 @@
+            data_dir = NULL;
+            g_warning ("XDG_DATA_HOME is set to relative path, setting it to default");
+        }

Please factor this block out into a utility function.

@@ +2448,3 @@
     {
       runtime_dir = g_strdup (getenv ("XDG_RUNTIME_DIR"));
+

Spurious whitespace change.
Comment 11 GNOME Infrastructure Team 2018-05-24 13:01:58 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/403.