SL7 SwitchDesk Notes

The standard lightdm login manager on SL7 has a number of shortcomings. In particular:

  • It caches the selected desktop on the local machine using the AccountsService daemon
  • It caches the last selected desktop for any user in the filesystem (at /var/lib/lightdm/.cache/lightdm-gtk-greeter/state)
  • If a user has not previously selected a desktop and thus has nothing stored in the AccountsService daemon then it uses the most recently selected for any user.
  • It attempts to write the most recent desktop choice to ~/.dmrc for the user but never reads it.
  • Writes to the ~/.dmrc file fail when a network filesystem is used for home directories as lightdm tries to change user by just calling setuid

The biggest problem this causes is that a user cannot make their desktop choice once and then expect it to be their default on all DICE SL7 machines. This might not be a problem for a member of staff who only uses their allocated DICE desktop machine. For those using lab machines this is a real pain, if a user is not careful they end up with a seemingly random desktop choice each time they login.

This problem has been solved in Informatics by introducing a "DICE" desktop environment which will run the desired desktop for the user.

To achieve this the following changes have been made, the tweaks are all in the dice/options/lightdm.h LCFG header.

Hardwired the lightdm "last" session

The file /var/lib/lightdm/.cache/lightdm-gtk-greeter/state now has mode 0444 and always contains:

[greeter]
last-user=
last-session=dice

to further prevent modification the directory /var/lib/lightdm/.cache has a mode of 0500 and /var/lib/lightdm/.cache/lightdm-gtk-greeter has a mode of 0555

These are all done using the LCFG file component.

Also the lightdm default for the "user session" is set to dice in /etc/lightdm/lightdm.conf by setting the lightdm.defaultsession LCFG resource.

Patched accountsservice daemon

The accountsservice daemon has been patched to never store (or use) its internal user->x_session cache; this permits one-off choices to be made by the greeter, but the choice is never cached in memory or written to file (it also blocks some gobject notifications to the same effect). This means that in the absence of an active choice made immediately before login, lightdm will always fall back to using the desktop choice stored in the last-session cache file (which we enforce to be DICE; see above).

The patch is available as part of the latest accountsservice-0.6.35-7.inf.<patch> SRPM.

switchdesk application

A local switchdesk application has been introduced, for consistency it has the same name as a similar application that was available as standard in SL6. It is in the dice-desktop package which is in the dice subversion repository.

This is written in Python and has a simple graphical interface which uses Tk. This application has a switchdesk.desktop file so it should appear somewhere in the menus for most desktop environments, it is quite hard to predict where though since different desktops gather similar applications in different places. It can also be called directly from the command line either with the desktop as an argument or in an interactive manner. See computing.help for full details.

The list of available desktops is found by examining the .desktop files in the /usr/share/xsessions/ directory. When a user makes a selection it is stored in a .dmrc file for the current platform, for example on SL7 the file will be ~/.dmrc.el7. The platform name comes from the content of the /etc/LCFG-RELEASE file. This makes it possible to choose different desktops on different platforms which is often necessary, for instance the mate desktop is not available on SL6.

See switchdesk(1) manual page for more details.

xinit-dice

When the DICE desktop is started by lightdm at login time the /usr/libexec/xinit-dice script is run (this is specified in the /usr/share/xsessions/dice.desktop file). This is an enhanced version of the standard /usr/libexec/xinit-compat script, which is provided in SL7 to handle ~/.xsession files, along with some ideas borrowed from the /etc/X11/xinit/Xsession script.

The xinit-dice script first checks if a user has a ~/.xsession file, if so it will be run with stderr redirected to stdout to make it easier to log errors. If there is no ~/.xsession file then it calls the /usr/sbin/dice-desktop-cmd script (part of the dice-desktop package) which checks for .dmrc files in a user's home directory. It first checks for a platform-specific file (e.g. ~/.dmrc.el7) and then falls back to ~/.dmrc. If neither exists or the file refers to a desktop which is not supported on the current platform then finally the default desktop will be launched by calling the /etc/X11/xinit/Xclients script (this is Gnome3 on SL7).

See xinit-dice(1) and dice-desktop-cmd(1) manual pages for more details.

Future Ideas

Instead of patching the accountsservice package it would be much better to create a small daemon which intercepts the requests from lightdm and returns an appropriate response.

-- StephenQuinney - 18 Nov 2015

Topic revision: r2 - 18 Nov 2015 - 11:54:12 - GrahamDutton
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
This Wiki uses Cookies