Ubuntu

If 'startx' is run from within a text console, ConsoleKit session is not marked 'active'

Reported by Paul Donohue on 2009-11-15
54
This bug affects 10 people
Affects Status Importance Assigned to Milestone
consolekit (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: consolekit

Using consolekit 0.3.1-0ubuntu2 in Karmic.

If I login to a text console, a ConsoleKit session is created for that terminal. If I then run 'startx' (if I'm not running GDM, or 'startx :1' if I am running GDM), I do not have my normal permissions, because my session is not marked 'active', because my session has not been populated with the appropriate X device information. Running 'ck-list-sessions' from within X shows:
Session1:
        unix-user = '1000'
        realname = 'Paul Donohue'
        seat = 'Seat1'
        session-type = ''
        active = FALSE
        x11-display = ''
        x11-display-device = ''
        display-device = '/dev/tty2'
        remote-host-name = ''
        is-local = TRUE
        on-since = '2009-11-14T22:10:24.941984Z'
        login-session-id = '4294967295'
        idle-since-hint = '2009-11-14T22:10:55.016849Z'

I expect to have the same permissions whether I login via GDM, or login via a text console, then run 'startx'.

I believe the simplest solution is to replace the current /etc/X11/Xsession.d/90consolekit with something like the following:

CK_GET_X11_DISPLAY_DEVICE=/usr/lib/ConsoleKit/ck-get-x11-display-device
CK_LIST_SESSIONS=/usr/bin/ck-list-sessions
CK_LAUNCH_SESSION=/usr/bin/ck-launch-session

if [ -x "$CK_GET_X11_DISPLAY_DEVICE" -a -x "$CK_LIST_SESSIONS" -a -x "$CK_LAUNCH_SESSION" ] ; then
    if [ "$($CK_LIST_SESSIONS | grep "$($CK_GET_X11_DISPLAY_DEVICE)")" == "" ] ; then
        STARTUP="$CK_LAUNCH_SESSION $STARTUP"
    fi
fi

This script checks for an existing CK session that is populated with an appropriate x11-display-device, and if one is not present, it creates a new session. This will prevent a duplicate CK session from being created when logging in via GDM (which already creates an appropriately populated CK session), but allows an additional CK session to be created when 'startx' is run from a text console (with a CK session that is not appropriately populated).

Using this script, I get my expected permissions, and 'ck-list-sessions' shows:
Session1:
        unix-user = '1000'
        realname = 'Paul Donohue'
        seat = 'Seat1'
        session-type = ''
        active = FALSE
        x11-display = ''
        x11-display-device = ''
        display-device = '/dev/tty2'
        remote-host-name = ''
        is-local = TRUE
        on-since = '2009-11-14T22:10:24.941984Z'
        login-session-id = '4294967295'
        idle-since-hint = '2009-11-14T22:10:55.016849Z'
Session2:
        unix-user = '1000'
        realname = 'Paul Donohue'
        seat = 'Seat1'
        session-type = ''
        active = TRUE
        x11-display = ':1'
        x11-display-device = '/dev/tty8'
        display-device = '/dev/tty2'
        remote-host-name = ''
        is-local = TRUE
        on-since = '2009-11-14T22:10:32.525471Z'
        login-session-id = '4294967295'

Another (less trivial) solution would be to patch ck-launch-session to allow updating the existing session with the appropriate X display information, then always run ck-launch-session from 90consolekit to perform this update. (See Bug #319396)

Oops, the script shown in the original bug report and patch had a typo (== instead of =), this one is corrected.

George Politis (gpolitis) wrote :

Patch works for me and fixes:

1. No audio when running startx http://ubuntuforums.org/showthread.php?t=1320661
2. Unable to mount USB, Not Authorized http://ubuntuforums.org/showthread.php?p=9146247

This appears to have been fixed in Lucid, which provides an updated 90consolekit script similar to the one above, but using a dbus call instead of ck-list-sessions to determine whether a session has already been started.

Using the new Lucid script, I get two Sessions after running X from the command line, as expected:
Session10:
        unix-user = '1000'
        realname = 'Paul Donohue'
        seat = 'Seat1'
        session-type = ''
        active = TRUE
        x11-display = ':0'
        x11-display-device = '/dev/tty8'
        display-device = '/dev/tty1'
        remote-host-name = ''
        is-local = TRUE
        on-since = '2010-04-29T23:17:02.170005Z'
        login-session-id = '4294967295'
Session3:
        unix-user = '1000'
        realname = 'Paul Donohue'
        seat = 'Seat1'
        session-type = ''
        active = FALSE
        x11-display = ''
        x11-display-device = ''
        display-device = '/dev/tty1'
        remote-host-name = ''
        is-local = TRUE
        on-since = '2010-04-29T23:08:24.154070Z'
        login-session-id = '4294967295'
        idle-since-hint = '2010-04-29T23:17:30.017725Z'

Out of curiosity, I tried manually running the dbus commands used in the new script, but I get an error:
/etc/X11/Xsession.d# dbus-send --system --dest=org.freedesktop.ConsoleKit --type=method_call --print-reply --reply-timeout=2000 /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.GetCurrentSession
Error org.freedesktop.ConsoleKit.Manager.GeneralError: Unable to lookup session information for process '5533'

I'm not sure if I should be concerned about this or not...

Changed in consolekit (Ubuntu):
status: New → Confirmed
Psy[H[] (vovik-wfa) wrote :

For me it worked fine in maverick, but became broken in natty

found solution here: http://forum.ubuntu.ru/index.php?topic=151466.0
added "session optional pam_loginuid.so" line before "session optional pam_ck_connector.so nox11" in "/etc/pam.d/common-session"
it fixed the problem.

Psy[H[] (vovik-wfa) wrote :

...but editing /etc/pam.d/common-session by hand causes problems on upgrade.

Psy[H[] (vovik-wfa) wrote :

bug is still actual in current oneiric

This seems to work fine for me under natty (I did an upgrade from maverick, not a fresh install).

$ ck-list-sessions
Session1:
        unix-user = '1000'
        realname = 'Paul Donohue'
        seat = 'Seat1'
        session-type = ''
        active = FALSE
        x11-display = ''
        x11-display-device = ''
        display-device = '/dev/tty1'
        remote-host-name = ''
        is-local = TRUE
        on-since = '2011-09-08T13:41:34.171550Z'
        login-session-id = '4294967295'
        idle-since-hint = '2011-09-08T13:42:04.326562Z'
Session2:
        unix-user = '1000'
        realname = 'Paul Donohue'
        seat = 'Seat1'
        session-type = ''
        active = TRUE
        x11-display = ':0'
        x11-display-device = '/dev/tty7'
        display-device = '/dev/tty1'
        remote-host-name = ''
        is-local = TRUE
        on-since = '2011-09-08T13:41:45.813003Z'
        login-session-id = '4294967295'
$

My /etc/pam.d/common-session does not contain pam_loginuid:
/etc/pam.d$ grep -v '^#' common-session

session [default=1] pam_permit.so
session requisite pam_deny.so
session required pam_permit.so
session required pam_unix.so
session optional pam_ck_connector.so nox11
/etc/pam.d$

What does ck-list-sessions show for you after logging in on the terminal (before running startx), and after running startx?

Psy[H[] (vovik-wfa) wrote :

OK, done some testing in oneiric..

Attaching outputs...

Adding "session optional pam_loginuid.so" to common-session in oneiric fixes the issue with startx and does not break login through lightdm. I haven't tested gdm though.

Psy[H[] (vovik-wfa) wrote :

More elegant and proper workaround:

echo 'Name: ConsoleKit Session Management
Default: yes
Priority: 0
Session-Interactive-Only: yes
Session-Type: Additional
Session-Final:
 optional pam_ck_connector.so nox11
' | sudo tee /usr/share/pam-configs/startx-fix
sudo dpkg-reconfigure libpam-runtime

Psy[H[] (vovik-wfa) wrote :

...damn. Copied contents of wrong file here.

here is the correct sequence:

echo 'Name: ConsoleKit startx fix
Default: yes
Priority: 0
Session-Interactive-Only: yes
Session-Type: Additional
Session-Final:
 optional pam_loginuid.so
' | sudo tee /usr/share/pam-configs/startx-fix
sudo dpkg-reconfigure libpam-runtime

Psy[H[] (vovik-wfa) wrote :

For some reason on every pam-related update one of pam-configs gets disabled: either consolekit or custom startx-fix.
One of them also gets disabled by default on every 'dpkg-reconfigure libpam-runtime'.

Psy[H[] (vovik-wfa) wrote :

LOL! That was the empty line in the end of startx-fix config. Upgrades go smooth without it.

Now the super-correct workaround sequence:

echo 'Name: ConsoleKit startx fix
Default: yes
Priority: 0
Session-Interactive-Only: yes
Session-Type: Additional
Session-Final:
 optional pam_loginuid.so' | sudo tee /usr/share/pam-configs/startx-fix
sudo dpkg-reconfigure libpam-runtime

Peter Schneider (pitpompej) wrote :

that last fix works great for me on precise. thank you

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers