Bug 49173 - Use XDG base directory instead of $HOME
Summary: Use XDG base directory instead of $HOME
Status: NEW
Alias: None
Product: xorg
Classification: Unclassified
Component: Lib/ICE (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-26 08:25 UTC by william.jon.mccann
Modified: 2016-07-01 18:46 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch proposal (2.78 KB, patch)
2016-05-13 18:22 UTC, Mario Sanchez Prada
no flags Details | Splinter Review
authutil: fix an out-of-bounds access (1.08 KB, patch)
2016-06-14 20:20 UTC, Allison Lortie (desrt)
no flags Details | Splinter Review
authutil: support $XDG_RUNTIME_DIR/ICEauthority (1.91 KB, patch)
2016-06-14 20:21 UTC, Allison Lortie (desrt)
no flags Details | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description william.jon.mccann 2012-04-26 08:25:25 UTC
Currently .ICEauthority is stored in the user's home directory. It would be nice to use the XDG Base Directory standard for the location instead. http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
Comment 1 faispasierch 2012-11-21 12:06:54 UTC
* ping
Comment 3 Eric Heintzmann 2012-12-29 09:39:20 UTC
What is planned about FreeDesktop.org XDG base directory specification for libice/x.org

According to XDG Basedir spec, ~/.ICEauthority should be moved to $XDG_CONFIG_HOME/subdir/ICEauthority

More details at :
http://ploum.net/post/207-modify-your-application-to-use-xdg-folders
https://live.gnome.org/GnomeGoals/XDGConfigFolders

Full specification can be found at: 
http://standards.freedesktop.org/basedir-spec/latest/

The Freedesktop.org XDG base directory specification that have good de facto adoption.
It has been adopted by
- GNOME ( https://live.gnome.org/GnomeGoals/XDGConfigFolders )
- GTK+ ( https://bugzilla.gnome.org/show_bug.cgi?id=646631 )
- KDE ( http://techbase.kde.org/KDE_System_Administration/XDG_Filesystem_Hierarchy#Freedesktop.org_and_Standard_Directories )
- QT ( http://harmattan-dev.nokia.com/docs/library/html/qt4/qsettings.html#setPath )
- XFCE ( http://docs.xfce.org/xfce/xfce4-session/advanced in Files and Environment Variables )
- LXDE
- Razor-qt
- VLC ( https://trac.videolan.org/vlc/ticket/1267 )
- GStreamer ( https://bugzilla.gnome.org/show_bug.cgi?id=518597 )
- Chrome ( http://code.google.com/p/chromium/issues/detail?id=16976 )
- many more upstream applications
- Ubuntu ( http://brainstorm.ubuntu.com/idea/6557/ & http://packages.ubuntu.com/fr/source/precise/libxdg-basedir )
- Debian ( http://packages.debian.org/squeeze/libxdg-basedir1 )
- Fedora
- Suse
- many more distributions

I think that libICE/X.org should use same locations than the vast majority of Desktop environment and applications.


There are real advantages of following this specification :
- a lot less cluttered $HOME
- Make backups a lot more safer and easier.
  Backuping your $XDG_DATA_HOME along with your files is enough 
  (or just excluding $XDG_CACHE_HOME)
- A lot easier to reset a default configuration if you want/need it (and 
  without any risk to loose informations). Even for the software itself 
  could choose to reset $XDG_CONFIG_HOME if needed.
- Avoid some strange bugs that happens because you had a old version of 
  some configuration file
- A lot more of flexibility and portability because no path are hardcoded.
Comment 4 Alan Coopersmith 2012-12-29 18:03:42 UTC
(In reply to comment #3)
> What is planned about FreeDesktop.org XDG base directory specification for
> libice/x.org

There are no plans.   No one has actively worked on or made plans for enhancing
libICE in years.  Change would have to come from people working on designs,
bringing them to the xorg-devel mailing list, and once agreed upon, submitting
patches to implement them.    Simply making long bug reports about why someone
else should do it results in no one ever doing it.
Comment 5 Mario Sanchez Prada 2016-05-13 18:22:03 UTC
Created attachment 123726 [details] [review]
Patch proposal

In case it's of interest for upstream, we recently came across this issue in Endless, since we realized that storing .ICEauthority under the user's home directory was particularly problematic when in ENOSPC situations, as the shell (via Mutter) would fail to notify the session manager that the shell has started due to not being able to write this file.

In this particular case, the net effect was that gnome-session, not seeing the shell's registered (even if it attempted to), would show an error dialog to the user after a 90 seconds timeout, forcing him/her to logout, even if there's no reason for it, as the shell is actually running and even present in the session bus.

To fix this issue, we decided to make libICE look for the .ICEauthority file under the XDG_RUNTIME_DIR directory instead, which works very nicely since that one is mounted in the tmpfs, and therefore unaware of the ENOSPC situation.

I realize XDG_RUNTIME_DIR is not the original proposal discussed here, but I'm attaching the patch anyway in case the project decides to merge it, or simply to spark any more discussion as needed. I particularly think it makes a lot of sense, but truth to be told I'm pretty ignorant on this domain, so who knows.

Please let me know what you think, thanks!
Comment 6 Allison Lortie (desrt) 2016-06-14 19:38:54 UTC
The patch here is almost perfect.  The only thing I would change about it is that the filename should not have the leading dot when it is stored in the XDG_RUNTIME_DIR.

If I update the patch, is there any chance of it being accepted?
Comment 7 Allison Lortie (desrt) 2016-06-14 20:20:49 UTC
Created attachment 124536 [details] [review]
authutil: fix an out-of-bounds access

There is a theoretical edge case where the $HOME environment variable
could be set to the empty string.  IceAuthFileName() unconditionally
checks index 1 of this string, which is out of bounds.
    
Fix that up by rejecting empty strings in the same way as we reject
NULL.
Comment 8 Allison Lortie (desrt) 2016-06-14 20:21:16 UTC
Created attachment 124537 [details] [review]
authutil: support $XDG_RUNTIME_DIR/ICEauthority

If we find that $XDG_RUNTIME_DIR is set (and $ICEAUTHORITY is not), then
the ICEauthority file is stored in the XDG_RUNTIME_DIR instead of the
home directory, and without a leading dot.
Comment 9 Mario Sanchez Prada 2016-06-14 23:01:52 UTC
JFTR I do also think those additions make sense. Thanks Allison for completing the patch.
Comment 10 Mario Sanchez Prada 2016-07-01 18:46:42 UTC
Ping?


bug/show.html.tmpl processed on Sep 27, 2016 at 19:04:29.
(provided by the Example extension).