Support Init, PreSession and PostSession script hooks

Bug #602505 reported by Robert Ancell
36
This bug affects 12 people
Affects Status Importance Assigned to Milestone
Light Display Manager
Fix Released
High
Unassigned

Bug Description

Allow sysadmins to configure scripts to be run before and after sessions

Related branches

Changed in lightdm:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Robert Ancell (robert-ancell) wrote :
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Raising priority to high as several people have indicated to me this is important for adoption.

Changed in lightdm:
importance: Medium → High
Revision history for this message
Guido Berhoerster (gber) wrote :
Download full text (4.5 KiB)

As requested here is a summary of openSUSE's usage of scripting facilities offered by gdm and xdm.

Available scripting facilities in xdm and gdm
=============================================

xdm gdm
--------------------------------------------------------------------------------
Xsetup Init runs after starting X server, before the greeter
            PostLogin runs after authentication, before session setup
                            (including pam_open_session)
Xstartup PreSession runs after session has been initialized
Xsession Xsession wraps the session, runs as the user logging in
Xreset PostSession runs after session and X server have been terminated

xdm scripting use in openSUSE
=============================

Xsetup
------
* expected environment:
    DISPLAY the associated display name
    PATH the value of DisplayManager.DISPLAY.systemPath
    SHELL the value of DisplayManager.DISPLAY.systemShell
    XAUTHORITY may be set to an authority file
* configures external display in case of laptops with XRANDR 1.2 available
* starts xvkbd in case of tablet pcs
* sets root window background
* sets numlock status with numlockx
* reads in Xresources
* enables screensaver
* sets keymap using XKB or Xmodmap

Xstartup
--------
* expected environment:
    DISPLAY the associated display name
    HOME the initial working directory of the user
    LOGNAME the user name
    USER the user name
    PATH the value of DisplayManager.DISPLAY.systemPath
    SHELL the value of DisplayManager.DISPLAY.systemShell
    XAUTHORITY may be set to an authority file
    WINDOWPATH may be set to the "window path" leading to the X server
* kill xvkbd in case of tablet
* check for /etc/nologin, show error and exit if it exists
* enforces /etc/sysconfig/displaymanager $DISPLAYMANAGER_ROOT_LOGIN_REMOTE
* if DISPLAY is local execute /etc/X11/xdm/GiveDevices
* kill preload
* registers session in utmp by exec sessreg

Xsession
--------
* arguments: session name, language
* expected environment:
    DISPLAY the associated display name
    HOME the initial working directory of the user
    LOGNAME the user name
    USER the user name
    PATH the value of DisplayManager.DISPLAY.userPath
    SHELL the user's default shell (from getpwnam)
    XAUTHORITY may be set to a non-standard authority file
    KRB5CCNAME may be set to a Kerberos credentials cache name
    WINDOWPATH may be set to the "window path" leading to the X server
* if $SHELL not in /etc/shells disallow login
* redirect errors to user logfile
* handle login manager arguments (session, language)
    * session
        * if default/custom, do nothing
        * if failsafe, execute xterm
        * else set WINDOWMANAGER
    * language
        * if given, set LANG, otherwise fall back to /etc/profile.d/lang.sh
* if WINDOWMANAGER not set above, get system default from
  /etc/profile.d/profile.sh
* source /etc/X11/xinit/xinitrc.common
    * choose WINDOWMANAGER again if not specified yet
    * start xim server...

Read more...

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Guido, do these scripts require root access?

Revision history for this message
Robert Ancell (robert-ancell) wrote :

My current thinking on this feature:
- It's required, at least for migration from existing display managers.
- The shell scripts do too much, and a lot of this functionality should be in the display manager / x server. So my long term thinking is how can this be set up to "just work" by lightdm?
- Running shell scripts from lightdm is a bit ugly. I'm looking at if these can be done by wrapping the xsession and xserver calls in an optional shell script so the scripting is external to the daemon.
- The feature is important to get working now (I'd like to have this working for 0.3.x), so just providing GDM like behaviour is probably the fastest solution. This potentially causes a migration headache if I want to change the behaviour later.
- Eventually there will be a proper plugin system, and at that time I will probably move the scripting into a plugin so it can be optional. I would expect complex requirements to be implemented using a plugin.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Another note about plugins - I would like the plugins to be writable in multiple languages so they are easy to make (e.g. in Python).

Revision history for this message
Guido Berhoerster (gber) wrote :

All scripts except Xsession, which runs as the logged in user and essentially wraps the session, require root privileges.

At least in openSUSE these scripting facilities are used this way because it allows unified behavior on login and logout across all included login managers (XDM, KDM, GDM, LXDM).

Revision history for this message
Guido Berhoerster (gber) wrote :

Attached patch implements xdm/kdm/gdm-compatible script hooks.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

As requested in bug 832720 a reason for an Init script is to set the resolution in X.

Revision history for this message
edu jose (pepinmore) wrote :

Hi, just saw this bug and thought you may want to know we use these scripts (/etc/gdm/PostLogin/Default and /etc/gdm/PostSession/Default) in a clasroom full of Ubuntu-equiped laptops.

These laptops still run Ubuntu 10.04 lucid LTS, so they use GDM and Gnome 2.x, but we plan to install Ubuntu 11.10 (and thus Lightdm) on them. So it's good to know it supports these scripts.

We use /etc/gdm/PostLogin/Default for bringing a "fresh" home directory whenever a user logs in (so that any changes made to the desktop or files gets lost when login in).

And we use /etc/gdm/PostSession/Default for backing up the local data of the user at log out to another computer in the classroom.

Thank you for your interest in bringing support for these scripts in Lightdm!

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Guido, I commited your patch with some changes:
- Moved the script running from display.c to seat.c
- Renamed the scripts to display-setup, session-setup and session-cleanup
- Moved the location of the display-setup script to run every time a display server is run, not just when a greeter is run (e.g. a greeter is not run for autologins).

Please check if they still work as expected.

We probably want to consider more scripts, i.e.:
- greeter-setup (run before a greeter)
- display-cleanup (when a display is stopped/reset)

I'll mark this bug as fixed, please open new bugs for any new enhancements.

Changed in lightdm:
status: Triaged → Fix Committed
Revision history for this message
Robert Ancell (robert-ancell) wrote :

These changes will be in 0.9.5.

Revision history for this message
Guido Berhoerster (gber) wrote :

Robert,

> Guido, I commited your patch with some changes:
> - Moved the script running from display.c to seat.c
> - Renamed the scripts to display-setup, session-setup and session-cleanup
> - Moved the location of the display-setup script to run every time a display server is run, not just when a greeter is run (e.g. a greeter is not run for autologins).

"display-setup" was actually intended as what you called "greeter-setup" below (ie. the equivalent to Xsetup/Init) and is critical for us, could you rename it an move it back so it runs before the greeter session?

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Sure, I'll add greeter-setup as well as the others (or sponsor a patch).

Revision history for this message
Robert Ancell (robert-ancell) wrote :

OK, master now contains the greeter-setup-script option which is run after X is ready but before the greeter is. Returning an error from the script will stop the greeter from showing.

Changed in lightdm:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.