[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

best way to check for an active X session from a maintainer script?

This should be the last of the PAM-related threads on here for a while. :)

One of the new bits in the libpam0g package in unstable (soon to reach
testing) is that we need to restart PAM-using services because of a shlib
change.  There has been some fair criticism of the code used to manage this,
so as I've already put our poor translators through a couple of rounds I'd
like to make sure that the next change gets it right.

The problem is that some of the services that have to be restarted are
display managers, and restarting them will kill any active X sessions.  The
question is, where should the line be drawn between trying to automatically
restart these services, and warning the user that services could not be
safely restarted?

Javier Fernández-Sanguino Peña made me aware that there are tools in
an Essential: yes package that can query /var/run/utmp for users currently
logged in, including via a display manager, which seems nicer than trying to
detect $DISPLAY in the postinst's own environment.  So the current thought
is to use

   who | awk '{print $2}'|grep -q '^:[0-9]'

to detect whether there are users logged in via X before restarting the
display managers.

Does anyone know of a case where this would give the wrong result?  I'm not
sure what an xdmcp login would look like here, for instance, or if startx
creates a utmp entry that I should be concerned about registering as a false

Is there any reason that 'who' is fundamentally the wrong way to check for

Thoughts are welcome.

Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
vorlon@debian.org                                   http://www.debian.org/

Reply to: