ConsoleKit, SDDM, switch user

Abbreviated:


ReuseSession=true

I added the line to /usr/local/etc/sddm.conf.d/kde_settings.conf (you might find the file already present), however it's not effective. We're probably bitten by something like the bugs below (ignoring the systemd aspect).


– and following <https://github.com/sddm/sddm/pull/1273#issuecomment-665747662> (2020-07-29):



Testing can be a little ugly, in that it becomes impossible to use the GUI to log out. We can e.g. service sddm restart, but I don't like pulling the rug so abruptly.

… user switching is functional except for reuse. …

For me:
 
So far it looks like sddm or ck doesn't maintain more than one session. So switching to log in as new seems fine. Logging out leads to the lock screen problem. ck-list-sessions IIRC doesn't show more than one. No surprising if there is a crash if switching is looking for non-existent session. Read a post a week ago about setting X for multiple remote logins requiring extra setting up - but can't find what I read now : ( . Still reading session caching...
 
None of this makes sense to my head and makes me think ck is brain dead.

Code:
# ck-list-sessions
Session2:
    unix-user = '1001'
    realname = 'me'
    seat = 'Seat3'
    session-type = 'unspecified'
    session-class = 'user'
    session-state = 'online'
    active = FALSE
    x11-display = ':0'
    x11-display-device = ''
    display-device = '/dev/   ?   '
    remote-host-name = ''
    is-local = TRUE
    on-since = '2022-04-05T21:06:26.103021Z'
    login-session-id = ''
    XDG_RUNTIME_DIR = '/var/run/user/1001'

man entry confirms my suspicions:
Code:
example% ck-list-sessions

       This command would generate output like the following for each session:

       SessionSeat1Local:
               unix-user = '50'
               realname = 'GDM Reserved UID'
               seat = 'Seat1'
               session-type = 'LoginWindow'
               display-type = 'Local'
               open = 'TRUE'
               active = 'TRUE'
               x11-display = ':0'
               x11-display-device = '/dev/console'
               display-device = '/dev/console'
               remote-host-name = ''
               is-local = 'TRUE'
               on-since = '2009-08-11T06:46:42.941134Z'
               login-session-id = ''display-device = '/dev/console
               idle-since-hint = ''

(tried to Bold inside the code but doesn't stick.)

But pkg install consolekit2 did a little upgrade Upgrading consolekit2 from 1.2.4_1 to 1.2.4_2....
 
Maybe this bug which is reported as FIXED, except that the session I am using is reported as active = FALSE with unknown x11-display-device = ''
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221452

With 2 sessions now, one on vtty8 and one on vtty 10:
Code:
# ck-list-sessions
Session4:
    unix-user = '1002'
    realname = 'anybody'
    seat = 'Seat5'
    session-type = 'unspecified'
    session-class = 'user'
    session-state = 'online'
    active = FALSE
    x11-display = ':0'
    x11-display-device = ''
    display-device = '/dev/   ?   '
    remote-host-name = ''
    is-local = TRUE
    on-since = '2022-04-06T19:17:54.930612Z'
    login-session-id = ''
    XDG_RUNTIME_DIR = '/var/run/user/1002'
Session2:
    unix-user = '1001'
    realname = 'me'
    seat = 'Seat3'
    session-type = 'unspecified'
    session-class = 'user'
    session-state = 'online'
    active = FALSE
    x11-display = ':0'
    x11-display-device = ''
    display-device = '/dev/   ?   '
    remote-host-name = ''
    is-local = TRUE
    on-since = '2022-04-06T18:35:13.258090Z'
    login-session-id = ''
    XDG_RUNTIME_DIR = '/var/run/user/1001'

System log:
Code:
7 Apr 2022 05:17:49    hpz2freebsd    devd[97897]    check_clients:  dropping disconnected client
7 Apr 2022 05:17:56    hpz2freebsd    dbus-daemon[22255]    [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.109" (uid=1002 pid=54674 comm="") interface="org.freedesktop.ConsoleKit.Manager" member="CanSuspendThenHibernate" error name="(unset)" requested_reply="0" destination="org.freedesktop.ConsoleKit" (uid=0 pid=50007 comm="")
7 Apr 2022 05:17:56    hpz2freebsd    pulseaudio[60573]    [(null)] oss-util.c: '/dev/dsp0' doesn't support full duplex
7 Apr 2022 05:17:56    hpz2freebsd    pulseaudio[60573]    [(null)] oss-util.c: '/dev/dsp1' doesn't support full duplex
7 Apr 2022 05:17:56    hpz2freebsd    pulseaudio[60573]    [(null)] oss-util.c: '/dev/dsp2' doesn't support full duplex
7 Apr 2022 05:17:56    hpz2freebsd    pulseaudio[60573]    [(null)] oss-util.c: '/dev/dsp3' doesn't support full duplex
7 Apr 2022 05:17:56    hpz2freebsd    pulseaudio[60573]    [(null)] oss-util.c: '/dev/dsp5' doesn't support full duplex
7 Apr 2022 05:17:56    hpz2freebsd    pulseaudio[60573]    [(null)] oss-util.c: '/dev/dsp6' doesn't support full duplex
7 Apr 2022 05:17:56    hpz2freebsd    /hp-systray[61884]    hp-systray[61884]: error: option -s not recognized
7 Apr 2022 05:18:10    hpz2freebsd    devd[97897]    check_clients:  dropping disconnected client
7 Apr 2022 05:18:11    hpz2freebsd    kernel    pid 76521 (kcminit), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:18:11    hpz2freebsd    kernel    pid 76827 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:18:11    hpz2freebsd    kernel    pid 76877 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:18:11    hpz2freebsd    kernel    pid 77216 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:18:11    hpz2freebsd    kernel    pid 77453 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:20:10    hpz2freebsd    devd[97897]    check_clients:  dropping disconnected client
7 Apr 2022 05:20:32    hpz2freebsd    kernel    pid 79961 (kcminit), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:20:32    hpz2freebsd    kernel    pid 80084 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:20:32    hpz2freebsd    kernel    pid 80186 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:20:37    hpz2freebsd    devd[97897]    check_clients:  dropping disconnected client
7 Apr 2022 05:20:53    hpz2freebsd    syslogd    last message repeated 1 times
7 Apr 2022 05:20:54    hpz2freebsd    kernel    pid 82164 (kcminit), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:21:33    hpz2freebsd    kernel    pid 82276 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:21:33    hpz2freebsd    kernel    pid 82277 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:21:33    hpz2freebsd    kernel    pid 82503 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:21:33    hpz2freebsd    kernel    pid 82632 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:22:33    hpz2freebsd    kernel    pid 83866 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:22:33    hpz2freebsd    kernel    pid 83948 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:22:53    hpz2freebsd    kernel    pid 84140 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:22:53    hpz2freebsd    kernel    pid 84203 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:23:13    hpz2freebsd    kernel    pid 84588 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:23:13    hpz2freebsd    kernel    pid 84735 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:23:53    hpz2freebsd    kernel    pid 85397 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:23:53    hpz2freebsd    kernel    pid 85445 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
7 Apr 2022 05:24:13    hpz2freebsd    kernel    pid 85771 (baloo_file_extracto), jid 0, uid 1001: exited on signal 6 (core dumped)
 
For me:
All of those. Likely caused by the bugs in calling ck to create session. Note logout does work, but runs on default countdown time and refuses to respond to the logout button override.

Maybe this is caused by the code that manages no .xinitrc????

https://consolekit2.github.io/ConsoleKit2/

Session Lifecycle​

The session leader process is responsible for asking ConsoleKit2 to open a new session. In this respect, it is similar to the traditional POSIX user login accounting framework. In the typical case, the session leader is either an immediate descendant of a login manager or the login manager itself. The leader makes a connection to the D-Bus system bus and asks ConsoleKit2 to open a session. There are two methods available for opening a session: org.freedesktop.ConsoleKit.Manager.OpenSession() and org.freedesktop.ConsoleKit.Manager.OpenSessionWithParameters().

If the operation succeeds, a secret cookie will be returned to the session leader. The session leader should store this secret in the environment as XDG_SESSION_COOKIE so that it may be shared with its child processes.

At this point the session will be registered with ConsoleKit2 and a particular set of information about the session will be stored along with it.

ConsoleKit2 will decide, based on the information associated with the session, what Seat the session will be added to.

It will also be determined, based on the same set of information, whether the Session will control the hardware associated with the Seat. In other words, whether the Session will be active for the Seat it is attached to. The exact mechanism for this determination depends on the type of Seat and the capabilities of the host system.

The Session will remain open until the Session Leader disconnects from the D-Bus system bus or calls org.freedesktop.ConsoleKit.Manager.CloseSession(). The session will be removed from its Seat, and deregistered.
 
Something maybe screwy with sddm and console-kit.

https://www.freebsd.org/cgi/man.cgi?query=sddm&sektion=1&manpath=freebsd-release-ports
sddm runs the greeter as a system user named sddm whose home directory
needs to be set to /var/lib/sddm.

If pam and systemd are available, the greeter will go through logind,
which will give it access to drm devices.
sddm user exists.

Code:
# cat/etc/passwd
[...]
sddm:*:219:219:SDDM Display Manager user:/var/lib/sddm:/usr/sbin/nologin
[...]

processes run by sddm user do not.

Code:
# ps -auxw -U sddm
USER PID %CPU %MEM VSZ RSS TT  STAT STARTED TIME COMMAND
#

Is it OK if root runs sddm????
Code:
# ps -auxwd
[...]
root       79043    0.0  0.1     72672   17108 v0- I    07:34       0:00.02 |-- /usr/local/bin/sddm
root        3885    2.1  0.3  25338840  111728  -  S    07:37       3:38.36 | |-- /usr/local/bin/Xorg -nolisten tcp -auth /var/run/sddm/{8356a505-04c2-496f-98e3-1d5ef26bdef
root        6253    0.0  0.2     68384   51284  -  I    07:38       0:00.01 | `-- /usr/local/libexec/sddm-helper --socket /tmp/sddm-auth45f23e07-4eaf-49ed-b6c3-bc55691129e5
me          6430    0.0  0.0     16924    4892  -  I    07:38       0:00.00 |   `-- ck-launch-session startplasma-x11
me          7216    0.0  0.2     86492   61480  -  I    07:38       0:00.03 |     `-- startplasma-x11
[...]

Is console-kit-daemon meant to be running as a daemon or not???
Code:
root       80648    0.0  0.0     90436    9708  -  I    07:34       0:00.10 |-- /usr/local/sbin/console-kit-daemon --no-daemon

Seems that having ck to manage multiple user sessions is incompatible with users running ck sessions unless the ck daemon is in charge run by sddm.
 
ck-list-sessions looks better now.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=228116

scrubbed out ~.xsessions and ~.xinitrc and security.bsd.see_other*=0 in /etc/sysctl.conf

Code:
$ ck-list-sessions

Session2:

    unix-user = '1001'

    realname = 'me'

    seat = 'Seat1'

    session-type = 'unspecified'

    session-class = 'user'

    session-state = 'active'

    active = TRUE

    x11-display = ':0'

    x11-display-device = '/dev/ttyv8'

    display-device = '/dev/   ?   '

    remote-host-name = ''

    is-local = TRUE

    on-since = '2022-04-08T21:35:00.606683Z'

    login-session-id = ''

    XDG_RUNTIME_DIR = '/var/run/user/1001'

    VTNr = '9'

Seems mostly working, except for session reuse. But if I switch to the running virtual terminal. I can log in to running session (but not for the passwordless user - security requirement probably).
https://www.tenable.com/plugins/nessus/117443

Session locking/unlocking still partially broken.
 
Something is still broken between sddm and ck. I tried upgrading something and killed it like in the beginning when X would not start. Now 13.1-RC2 and lots of updates restored function.

ck-list-sessions still has a load of empty fields which probably are not helping.

sddm is running as root instead of sddm user as advertised in the man pages.

console-kit-daemon is not running as a daemon. Is it meant to be running as a daemon or not???
Code:
root       80648    0.0  0.0     90436    9708  -  I    07:34       0:00.10 |-- /usr/local/sbin/console-kit-daemon --no-daemon

Sometimes <switch users> will open every user in a new VT. Other times it will open them all in the same VT. Unclear how settings can cause this. Have been playing with kde_settings.conf in /usr/local/etc/sddm.conf.d. I presume these settings get passed to sddm as if they were sddm.conf. Seems slightly better with RememberLastUser=false. RememberLastSession is about SDDM remembering session type (kde|Gnome|etc) and not sddm|ck remembering last user session.
 
dbus daemon log says this - anyone got clues?

Code:
[system] Rejected send message, 2 matched rules; type="method_call", sender=":1.21" (uid=1001 pid=80580 comm="/usr/local/lib/libexec/org_kde_powerdevil ") interface="org.freedesktop.ConsoleKit.Manager" member="CanSuspendThenHibernate" error name="(unset)" requested_reply="0" destination="org.freedesktop.ConsoleKit" (uid=0 pid=56655 comm="/usr/local/sbin/console-kit-daemon --no-daemon ")


Similar bug goes back to FreeBSD 10 in 2016. Appears to me still unresolved.
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=206197
 
Have had a better look,
https://github.com/sddm/sddm/blob/develop/src/daemon/LogindDBusTypes.cpp
Code:
managerPath = QStringLiteral("/org/freedesktop/ConsoleKit/Manager");
looks like it should be:
Code:
managerPath = QStringLiteral("/org/freedesktop/ConsoleKit");
Changed it and seems a bit more stable maybe. Haven't managed the ck crash yet.
Still managing to be looking at an "active=FALSE" session! Only logging in to pre-ordained user after a logout seems to return to active session.
Code:
[/URL]
[URL='https://github.com/sddm/sddm']# ck-list-sessions
Session6:
    unix-user = '1001'
    realname = 'me'
    seat = 'Seat1'
    session-type = 'unspecified'
    session-class = 'user'
    session-state = 'online'
    active = FALSE
    x11-display = ':2'
    x11-display-device = '/dev/ttyva'
    display-device = '/dev/   ?   '
    remote-host-name = ''
    is-local = TRUE
    on-since = '2022-04-13T20:04:13.959578Z'
    login-session-id = ''
    XDG_RUNTIME_DIR = '/var/run/user/1001'
    VTNr = '11'
Session10:
    unix-user = '1001'
    realname = 'me'
    seat = 'Seat1'
    session-type = 'unspecified'
    session-class = 'user'
    session-state = 'online'
    active = FALSE
    x11-display = ':1'
    x11-display-device = '/dev/ttyva'
    display-device = '/dev/   ?   '
    remote-host-name = ''
    is-local = TRUE
    on-since = '2022-04-13T20:13:06.751603Z'
    login-session-id = ''
    XDG_RUNTIME_DIR = '/var/run/user/1001'
    VTNr = '11'
Session2:
    unix-user = '1001'
    realname = 'me'
    seat = 'Seat1'
    session-type = 'unspecified'
    session-class = 'user'
    session-state = 'online'
    active = FALSE
    x11-display = ':0'
    x11-display-device = '/dev/ttyv8'
    display-device = '/dev/   ?   '
    remote-host-name = ''
    is-local = TRUE
    on-since = '2022-04-13T20:01:19.104886Z'
    login-session-id = ''
    XDG_RUNTIME_DIR = '/var/run/user/1001'
    VTNr = '9'
 
Appears that sddm on FreeBSD is specifically buggy. Linux uses logind and FreeBSD uses ConsoleKit. Maybe the sddm ConsoleKit code is undertested. Need to know if Linux sddm is better. Might have to install a Linux distro if nobody else is looking....
 
Been poking round more in sddm code trying to make sense.

sddm ConfigReader code says it looks here:
//order of priority from least influence to most influence, is
// * m_sysConfigDir (system settings /usr/lib/sddm/sddm.conf.d/) in alphabetical order
// * m_configDir (user settings in /etc/sddm.conf.d/) in alphabetical order
// * m_path (classic fallback /etc/sddm.conf)

Curious that the description implies that higher priority config will overwrite lower priority, which is not how I understood it. Have to confirm the kde sddm.conf is read.

ck only runs as root, so running sddm as root contrary to the FreeBSD manual might be a security risk fudge from Linux -- that needs fixing. Unless ArchLinux/ConsoleKit2 will fix it.
 
https://wiki.archlinux.org/title/ConsoleKitIf ConsoleKit is not working (ck-list-sessions command showing active = FALSE), you should start your window manager using the bash_profile method: Xinit#Autostart X at login.

FreeBSD is not alone -- Manjaro reports same issue. Not sure if consolekit or logind since ArchLinux used to use consolekit..
https://forum.manjaro.org/t/bug-sddm-cant-reuse-session/59698/5

FreeBSD sddm says session reuse does not exist. There is a relogin which it says only works for autologin on session exit.
https://www.freebsd.org/cgi/man.cgi?query=sddm.conf(5)&sektion=&manpath=freebsd-release-ports

This poster describes in more detail how sddm/ck/pam might work or be broken 6 years ago. He needed a second login to get an active session.
https://unix.stackexchange.com/ques...orts-active-is-local-only-on-the-second-login
 
ck is messed. Suspect it was robust when built and messed later. Maybe worse since deprecated and forked.

Code:
# man ck-list-sessions
ck-list-sessions(1)              User Commands             ck-list-sessions(1)



NAME
       ck-list-sessions - Show ConsoleKit Session Information

SYNOPSIS
       ck-list-sessions [--all] [--format=format] [--help] [--version]

DESCRIPTION
       ck-list-sessions is a utility that displays information from the
       ConsoleKit database.  By default, only open sessions are shown.  The
       --all option can be used to display all existing sessions on the
       system.  ck-list-sessions returns information about each ConsoleKit
       session.  Users can specify which properties to display via the
       --format option.

       The following properties can be displayed for each session:

OPTIONS
       The following options are supported:

       -a, --all
                               Show all ConsoleKit sessions.  If this option
                               is not provided, only open sessions are shown.
[...]
# ck-list-sessions -a

** (ck-list-sessions:28724): WARNING **: 08:37:58.216: Unknown option -a
# ck-list-sessions --all

** (ck-list-sessions:28891): WARNING **: 08:38:13.191: Unknown option --all
# ck-list-sessions --version
ck-list-sessions 1.2.2
 
Further observations on sddm/ck.

Login single user ok.
Switch to second user - both sessions now active=FALSE.
Switch to another user (happened to be same) - now correct user active=TRUE.
Switch to another user (now got 4) all active=FALSE.
Can't switch any more - switch user button is inactive and only takes to lock screen.
 
Changing the console-kit-daemon service to debug is instructive. Presently, switching users is not functional but stable!

Code:
# cat /usr/local/share/dbus-1/system-services/org.freedesktop.ConsoleKit.service
[D-BUS Service]
Name=org.freedesktop.ConsoleKit
Exec=/usr/local/sbin/console-kit-daemon --debug
User=root

console-kit appears to be keeping track of sessions and users correctly.


DEBUG: CkManager: Found session '/org/freedesktop/ConsoleKit/Session6'

I think i am using the adjusted path. https://github.com/sddm/sddm/issues/1540

Behavior appears to be that "switch users" spawns a child user session.

ck-list-sessions reports incremented x11-display = ':3' for additional user switching, but does not allocate correct VTNr = '11' which remains the VTNr of the parent session even though I can hotkey to where it is supposed to be and see the session. Logging out of a child session returns back to parent without login. lock screen. Unlocking earlier sessions is disabled - authentication failure.

Somehow ck-list-sessions now returns nothing.

Some session cookie is missing.
Code:
2/5/22 7:12 AM    hpz2freebsd    console-kit-daemon[99187]    DEBUG: CkManager: Unable to lookup cookie for caller - failing
2/5/22 7:12 AM    hpz2freebsd    console-kit-daemon[99187]    DEBUG: manager: throwing error: Unable to find session for cookie

Something is spawning ck sessions.
Code:
2/5/22 7:12 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.280
2/5/22 7:12 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.281
2/5/22 7:12 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.282
2/5/22 7:12 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.283
2/5/22 7:12 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.284
2/5/22 7:12 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.285
2/5/22 7:12 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.286
2/5/22 7:12 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.287
2/5/22 7:12 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.288
2/5/22 7:12 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.289
[...]
2/5/22 7:30 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.298
2/5/22 7:30 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.299
2/5/22 7:30 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.300
[...]
2/5/22 7:44 AM    hpz2freebsd    console-kit-daemon[4523]    DEBUG: Removing sessions for service name: :1.303
 
So all it took to kill ck-list-sessions is logging out of a session - user had 3 sessions running and 4 users in total.

Smells like going over 12 VTs (8+4) may hit a code bug. Not sure why exactly we need 8 virtual consoles and X starts from 9. ck seems to like even numbered sessions like every X session should have its own virtual console.

Session 8 was logged out. Sessions 2,4,6 left.
Code:
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[10170]    DEBUG: CkManager: Found session '/org/freedesktop/ConsoleKit/Session6'
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[10170]    DEBUG: pid: 23667
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[10170]    DEBUG: uid = 565
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[10170]    DEBUG: pid = 11293
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[10170]    DEBUG: uid = 565
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[10170]    DEBUG: pid = 11293
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[10170]    DEBUG: CkManager: Unable to lookup cookie for caller - failing
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[10170]    DEBUG: manager: throwing error: Unable to find session for cookie
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[10170]    GLib-GObject-WARNING: instance of invalid non-instantiatable type '(null)'
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[10170]    GLib-GObject-CRITICAL: g_signal_handlers_disconnect_matched: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed aborting...
2/5/22 8:19 AM    hpz2freebsd    dbus-daemon[23756]    [system] Activating service name='org.freedesktop.ConsoleKit' requested by ':1.9' (uid=565 pid=11293 comm="/usr/local/lib/polkit-1/polkitd --no-debug ") (using servicehelper)
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Debugging enabled
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: initializing console-kit-daemon 1.2.2
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: bus_acquired org.freedesktop.ConsoleKit
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Creating thread for log writing
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: exported on /org/freedesktop/ConsoleKit/Manager
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Creating seat /org/freedesktop/ConsoleKit/Seat1 with 0 devices
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Active VT is: 12 (ttyvb)
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Creating thread for vt 1
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Creating thread for vt 2
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Creating thread for vt 3
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Creating thread for vt 4
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Creating thread for vt 5
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: VT_WAITACTIVE for vt 1
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Creating thread for vt 6
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: VT_WAITACTIVE for vt 2
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Creating thread for vt 7
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: VT_WAITACTIVE for vt 3
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Creating thread for vt 8
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: VT_WAITACTIVE for vt 4
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Creating thread for vt 9
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: VT_WAITACTIVE for vt 5
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Creating thread for vt 10
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: VT_WAITACTIVE for vt 7
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: VT_WAITACTIVE for vt 6
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: VT_WAITACTIVE for vt 9
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Creating thread for vt 11
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: VT_WAITACTIVE for vt 8
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: VT_WAITACTIVE for vt 10
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: register seat
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: exporting path /org/freedesktop/ConsoleKit/Seat1
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: VT_WAITACTIVE for vt 11
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: exported on /org/freedesktop/ConsoleKit/Seat1
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Added seat: /org/freedesktop/ConsoleKit/Seat1
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: ck_manager_dump: /var/run/ConsoleKit folder created
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: ck_manager_dump: /var/run/ConsoleKit/database~ created
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: ck_manager_dump: wrote database to /var/run/ConsoleKit/database~
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: ck_manager_dump: renamed /var/run/ConsoleKit/database~ to /var/run/ConsoleKit/database, operation successful
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Running programs in /usr/local/etc/ConsoleKit/run-seat.d for action seat_added
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Running programs in /usr/local/lib/ConsoleKit/run-seat.d for action seat_added
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Emitting seat-added: /org/freedesktop/ConsoleKit/Seat1
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: Writing log for event: 1651443572.269 type=SEAT_ADDED : seat-id='Seat1' seat-kind=0
2/5/22 8:19 AM    hpz2freebsd    dbus-daemon[23756]    [system] Successfully activated service 'org.freedesktop.ConsoleKit'
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: name_acquired
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: pid: 43815
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: uid = 565
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: pid = 11293
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: uid = 565
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: pid = 11293
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: CkManager: Unable to lookup cookie for caller - failing
2/5/22 8:19 AM    hpz2freebsd    console-kit-daemon[57489]    DEBUG: manager: throwing error: Unable to find session for cookie

Not sure what this is about DEBUG: ck_manager_dump: renamed /var/run/ConsoleKit/database~ to /var/run/ConsoleKit/database, operation successful

Code:
me@hpz2freebsd:~ $ cd /var/run/ConsoleKit/
me@hpz2freebsd:/var/run/ConsoleKit $ ls
database        inhibit
me@hpz2freebsd:/var/run/ConsoleKit $ cat database
[Seats]
seats=/org/freedesktop/ConsoleKit/Seat1

[Seat /org/freedesktop/ConsoleKit/Seat1]
kind=0
sessions=
devices=
me@hpz2freebsd:/var/run/ConsoleKit $

Old fedora description of what is required to fix fast user switching. https://fedoraproject.org/wiki/Desktop/FastUserSwitching
A bit sad that 14 years on, it's still not working here.

Also some comments from William McCann who did the original Sun code. https://bugzilla.gnome.org/show_bug.cgi?id=368704
 
Tried lightdm, which was somehow worse. After logging in 2 users, switching went straight to root console on VT1.

Back to sddm. Definitely using patched manager path port version after pkg uninstall sddm. ck is correctly switching active status when switching VTs. sddm user created temporary session3 when switching from session 2 to new user.

Debug log appears much quieter.

But under the hood it is worse!
Code:
root@hpz2freebsd:/home/ian # echo $XDG_SEAT_PATH
/org/freedesktop/DisplayManager/Seat0
root@hpz2freebsd:/home/ian # echo $XDG_SESSION_PATH
/org/freedesktop/DisplayManager/Session3

root@hpz2freebsd:/usr/ports/x11/sddm/work/sddm-0.19.0/src # grep -inRsH "Manager"
./daemon/PowerManager.cpp:118:const QString LOGIN1_OBJECT = QStringLiteral("org.freedesktop.login1.Manager");
./daemon/PowerManager.cpp:121:const QString CK2_PATH = QStringLiteral("/org/freedesktop/ConsoleKit/Manager");
./daemon/PowerManager.cpp:122:const QString CK2_OBJECT = QStringLiteral("org.freedesktop.ConsoleKit.Manager");

./daemon/DisplayManager.cpp:29:const QString DISPLAYMANAGER_SERVICE = QStringLiteral("org.freedesktop.DisplayManager");
./daemon/DisplayManager.cpp:30:const QString DISPLAYMANAGER_PATH = QStringLiteral("/org/freedesktop/DisplayManager");
./daemon/DisplayManager.cpp:31:const QString DISPLAYMANAGER_SEAT_PATH = QStringLiteral("/org/freedesktop/DisplayManager/Seat");
./daemon/DisplayManager.cpp:32:const QString DISPLAYMANAGER_SESSION_PATH = QStringLiteral("/org/freedesktop/DisplayManager/Session");
 
It appears the sddm managerPath variable is only used by logind and not CK at all. So improvements in sddm behavior must be due to other fixes in the latest port version.

d-feet works to look at what is on dbus.
Screenshot_20220508_061600.png
Screenshot_20220508_061700.png
Screenshot_20220508_061747.png
Screenshot_20220508_061809.png
Screenshot_20220508_061951.png

It appears sddm is not good. https://www.reddit.com/r/kde/comments/tzd3xb/should_kde_switch_to_gdm/

So I tried to use gdm which is apparently console kit aware at least prior to console kit 2. Others seem to be using GDM with KDE. And apparently GDM properly autostarts the Gnome keyring. (But i'm having trouble finding out how to make gdm work again.)

And having reread some old posts, probably not worth bothering.... https://forums.freebsd.org/threads/gnome-3-disappeared-in-freebsd-13-amd64-repo.82282/post-562270

So easier reading sddm code..... Console Kit 2 appears fully featured and I'm not sure what DisplayManager is meant to be doing if it is not using Console Kit methods - maybe that is the core problem.
 
This might be a problem if virtual terminal switching is in the "too hard" basket ???

/usr/ports/x11/sddm/work/sddm-0.19.0/src/common/VirtualTerminal_FreeBSD.cpp

Code:
#include <QDebug>

#include <QString>


#include "VirtualTerminal.h"



namespace SDDM {

    namespace VirtualTerminal {

        int setUpNewVt() {

            qDebug() << "New VT is unsupported on FreeBSD";

            return -1;

        }


        void jumpToVt(int vt, bool vt_auto) {

            qDebug() << "Jumping to VT" << vt << "is unsupported on FreeBSD";

        }

    }

}

root@hpz2freebsd:/usr/ports/x11/sddm/work/sddm-0.19.0/src # grep -inRsH "VirtualTerminal_FreeBSD"
./daemon/CMakeLists.txt:37:    list(APPEND DAEMON_SOURCES ${CMAKE_SOURCE_DIR}/src/common/VirtualTerminal_FreeBSD.cpp)
./helper/CMakeLists.txt:21:    list(APPEND HELPER_SOURCES ${CMAKE_SOURCE_DIR}/src/common/VirtualTerminal_FreeBSD.cpp)


ReuseSession is in the code to default to true.

/usr/ports/x11/sddm/work/sddm-0.19.0/src/common/Configuration.h
Code:
Section(Users,
            Entry(DefaultPath,         QString,     _S("/usr/local/bin:/usr/bin:/bin"),         _S("Default $PATH for logged in users"));
            Entry(MinimumUid,          int,         UID_MIN,                                    _S("Minimum user id for displayed users"));
            Entry(MaximumUid,          int,         UID_MAX,                                    _S("Maximum user id for displayed users"));
            Entry(HideUsers,           QStringList, QStringList(),                              _S("Comma-separated list of users that should not be listed"));
            Entry(HideShells,          QStringList, QStringList(),                              _S("Comma-separated list of shells.\n"
                                                                                                   "Users with these shells as their default won't be listed"));
            Entry(RememberLastUser,    bool,        true,                                       _S("Remember the last successfully logged in user"));
            Entry(RememberLastSession, bool,        true,                                       _S("Remember the session of the last successfully logged in user"));

            Entry(ReuseSession,        bool,        true,                                       _S("When logging in as the same user twice, restore the original session, rather than create a new one"));
        );

Relevant code - I can't see any ReuseSession code if there is no logind.

/usr/ports/x11/sddm/work/sddm-0.19.0/src/daemon/Display.cpp
Code:
  void Display::startAuth(const QString &user, const QString &password, const Session &session) {

        if (m_auth->isActive()) {
            qWarning() << "Existing authentication ongoing, aborting";
            return;
        }

        m_passPhrase = password;

        // sanity check
        if (!session.isValid()) {
            qCritical() << "Invalid session" << session.fileName();
            return;
        }
        if (session.xdgSessionType().isEmpty()) {
            qCritical() << "Failed to find XDG session type for session" << session.fileName();
            return;
        }
        if (session.exec().isEmpty()) {
            qCritical() << "Failed to find command for session" << session.fileName();
            return;
        }

        m_reuseSessionId = QString();

        if (Logind::isAvailable() && mainConfig.Users.ReuseSession.get()) {
            OrgFreedesktopLogin1ManagerInterface manager(Logind::serviceName(), Logind::managerPath(), QDBusConnection::systemBus());
            auto reply = manager.ListSessions();
            reply.waitForFinished();

            const auto info = reply.value();
            for(const SessionInfo &s : reply.value()) {
                if (s.userName == user) {
                    OrgFreedesktopLogin1SessionInterface session(Logind::serviceName(), s.sessionPath.path(), QDBusConnection::systemBus());
                    if (session.service() == QLatin1String("sddm") && session.state() == QLatin1String("online")) {
                        m_reuseSessionId = s.sessionId;
                        break;
                    }
                }
            }
        }
 
Back
Top