coastalwhite / lemurs

A customizable TUI display/login manager written in Rust 🐒
Apache License 2.0
652 stars 26 forks source link

Can't log to another user after logout #187

Open vigiraud opened 7 months ago

vigiraud commented 7 months ago

Hi, thanks for this project ! I just did a fresh installation of Arch with XFCE. I need to have two different users, let's say alice and bob. So I followed the instructions, and after booting my computer, Lemurs works perfectly fine and I can easily log into any user. Once I have logged out, I get back to Lemurs as expected. If I try to log to the same user, it will work fine once again. However, if I try to log to the other user, I get to a screen with nothing but this : IMG_20231202_200541 Which translates to :

Cannot contact configuration server. Cannot connect : permission denied.

I can't find my mouse, and the keyboard becomes unresponsive on this tty.

Here's what I have in my journalctl -xeu lemurs:

déc. 02 19:55:28 hostname systemd[1]: Started Lemurs.
░░ Subject: L'unité (unit) lemurs.service a terminé son démarrage
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ L'unité (unit) lemurs.service a terminé son démarrage, avec le résultat done.
déc. 02 19:55:38 hostname lemurs[561]: pam_loginuid(lemurs:session): Error writing /proc/self/loginuid: Operation not permitted
déc. 02 19:55:38 hostname lemurs[561]: pam_loginuid(lemurs:session): set_loginuid failed
déc. 02 19:55:38 hostname lemurs[561]: pam_unix(lemurs:session): session opened for user alice(uid=1001) by (uid=0)

The errors about pam_loginuid happen when I log in for the first time, where it seemingly work without problems.

I tried to disable lemurs, and to switch between users without any display manager, on the same tty, by launching XFCE just with the startxfce4 script. It works without issues.

Here is the /var/log/lemurs.log I obtain when I first succesfully log as alice, logout, and then fail to log as bob:

[2023-12-02T21:55:46Z INFO  lemurs] Main lemurs logger is running
[2023-12-02T21:55:46Z INFO  lemurs] Switching to tty 2
[2023-12-02T21:55:46Z INFO  lemurs] UI booted up
[2023-12-02T21:55:46Z WARN  lemurs::post_login] Failed to read from the wayland folder '/etc/lemurs/wayland'
[2023-12-02T21:55:46Z INFO  lemurs::info_caching] Attempting to get a cached information from '/var/cache/lemurs'
[2023-12-02T21:55:46Z INFO  lemurs::info_caching] Read cache file and found environment 'XFCE' and username 'alice'
[2023-12-02T21:55:46Z INFO  lemurs::ui] Loading username 'alice' from cache
[2023-12-02T21:55:46Z INFO  lemurs::ui] Loading environment 'XFCE' from cache
[2023-12-02T21:56:22Z INFO  lemurs] Starting new session for 'alice' in environment 'X { xinitrc_path: "/etc/lemurs/wms/XFCE" }'
[2023-12-02T21:56:22Z INFO  lemurs::post_login::env_variables] Setting Display
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'DISPLAY' to ':1'
[2023-12-02T21:56:22Z INFO  lemurs::post_login::env_variables] Setting XDG Session Parameters
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'XDG_SESSION_CLASS' to 'user'
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'XDG_SESSION_TYPE' to 'x11'
[2023-12-02T21:56:22Z INFO  lemurs::post_login::env_variables] Clearing XDG preemptively to set later
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Preemptively removed environment variable 'XDG_SESSION_CLASS'
[2023-12-02T21:56:22Z INFO  lemurs::auth] Login attempt for 'alice'
[2023-12-02T21:56:22Z INFO  lemurs::auth::pam] Started opening session
[2023-12-02T21:56:22Z INFO  lemurs::auth::pam] Gotten Authenticator
[2023-12-02T21:56:22Z INFO  lemurs::auth::pam] Got handler
[2023-12-02T21:56:22Z INFO  lemurs::auth::pam] Validated account
[2023-12-02T21:56:22Z INFO  lemurs::auth::pam] Opened session
[2023-12-02T21:56:22Z INFO  lemurs::ui] Setting cached information
[2023-12-02T21:56:22Z INFO  lemurs::info_caching] Attempting to set cache
[2023-12-02T21:56:22Z INFO  lemurs::info_caching] Successfully set username in cache file
[2023-12-02T21:56:22Z INFO  lemurs::post_login::env_variables] Setting XDG Seat Variables
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Skipped setting environment variable 'XDG_SEAT'. It was already set to 'seat0'
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Skipped setting environment variable 'XDG_VTNR'. It was already set to '2'
[2023-12-02T21:56:22Z INFO  lemurs::post_login::env_variables] Setting XDG Session Variables
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Skipped setting environment variable 'XDG_RUNTIME_DIR'. It was already set to '/run/user/1000'
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Skipped setting environment variable 'XDG_SESSION_ID'. It was already set to 'c1'
[2023-12-02T21:56:22Z INFO  lemurs::post_login::env_variables] Setting Basic Environment Variables
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Successfully changed working directory to /home/alice!
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'HOME' to '/home/alice'
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'SHELL' to '/usr/bin/bash'
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'USER' to 'alice'
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'LOGNAME' to 'alice'
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'PATH' to '/usr/local/sbin:/usr/local/bin:/usr/bin'
[2023-12-02T21:56:22Z INFO  lemurs::post_login::env_variables] Setting XDG Common Paths
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'XDG_CONFIG_HOME' to '/home/alice/.config'
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'XDG_CACHE_HOME' to '/home/alice/.cache'
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'XDG_DATA_HOME' to '/home/alice/.local/share'
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'XDG_STATE_HOME' to '/home/alice/.local/state'
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'XDG_DATA_DIRS' to '/usr/local/share:/usr/share'
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'XDG_CONFIG_DIRS' to '/etc/xdg'
[2023-12-02T21:56:22Z INFO  lemurs::post_login] Starting X11 session
[2023-12-02T21:56:22Z INFO  lemurs::post_login::x] Start setup of X server
[2023-12-02T21:56:22Z INFO  lemurs::post_login::x] Filling `.Xauthority` file at `/home/alice/.config/.Xauthority`
[2023-12-02T21:56:22Z INFO  lemurs::env_container] Set environment variable 'XAUTHORITY' to '/home/alice/.config/.Xauthority'
[2023-12-02T21:56:23Z INFO  lemurs::post_login::x] It took X server 1201ms to start
[2023-12-02T21:56:23Z INFO  lemurs::post_login::x] X server is running
[2023-12-02T21:56:23Z INFO  lemurs::auth::utmpx] Adding UTMPX record
[2023-12-02T21:56:23Z INFO  lemurs::auth::utmpx] Added UTMPX record
[2023-12-02T21:56:23Z INFO  lemurs::env_container] Removing session environment variables
[2023-12-02T21:56:23Z INFO  lemurs::env_container] Reverting to environment before session
[2023-12-02T21:56:23Z INFO  lemurs::env_container] Reverting to environment before session
[2023-12-02T21:56:23Z INFO  lemurs] Waiting for environment to terminate
[2023-12-02T21:56:23Z INFO  lemurs::post_login] Waiting for client to exit
[2023-12-02T21:58:40Z INFO  lemurs::post_login::wait_with_log] Joining with logging thread.
[2023-12-02T21:58:40Z INFO  lemurs::post_login] Client exited with exit code `exit status: 0`
[2023-12-02T21:58:40Z INFO  lemurs::post_login] Telling X server to shut down
[2023-12-02T21:58:40Z INFO  lemurs::post_login] Waiting for X server
[2023-12-02T21:58:40Z INFO  lemurs::post_login::wait_with_log] Joining with logging thread.
[2023-12-02T21:58:40Z INFO  lemurs] Environment terminated. Returning to Lemurs...
[2023-12-02T21:58:40Z INFO  lemurs::auth::utmpx] Removing UTMPX record
[2023-12-02T21:58:47Z INFO  lemurs] Starting new session for 'bob' in environment 'X { xinitrc_path: "/etc/lemurs/wms/XFCE" }'
[2023-12-02T21:58:47Z INFO  lemurs::post_login::env_variables] Setting Display
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'DISPLAY' to ':1'
[2023-12-02T21:58:47Z INFO  lemurs::post_login::env_variables] Setting XDG Session Parameters
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'XDG_SESSION_CLASS' to 'user'
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'XDG_SESSION_TYPE' to 'x11'
[2023-12-02T21:58:47Z INFO  lemurs::post_login::env_variables] Clearing XDG preemptively to set later
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Preemptively removed environment variable 'XDG_SESSION_CLASS'
[2023-12-02T21:58:47Z INFO  lemurs::auth] Login attempt for 'bob'
[2023-12-02T21:58:47Z INFO  lemurs::auth::pam] Started opening session
[2023-12-02T21:58:47Z INFO  lemurs::auth::pam] Gotten Authenticator
[2023-12-02T21:58:47Z INFO  lemurs::auth::pam] Got handler
[2023-12-02T21:58:47Z INFO  lemurs::auth::pam] Validated account
[2023-12-02T21:58:47Z INFO  lemurs::auth::pam] Opened session
[2023-12-02T21:58:47Z INFO  lemurs::ui] Setting cached information
[2023-12-02T21:58:47Z INFO  lemurs::info_caching] Attempting to set cache
[2023-12-02T21:58:47Z INFO  lemurs::info_caching] Successfully set username in cache file
[2023-12-02T21:58:47Z INFO  lemurs::post_login::env_variables] Setting XDG Seat Variables
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'XDG_SEAT' to 'seat0'
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'XDG_VTNR' to '2'
[2023-12-02T21:58:47Z INFO  lemurs::post_login::env_variables] Setting XDG Session Variables
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'XDG_RUNTIME_DIR' to '/run/user/1001'
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'XDG_SESSION_ID' to '1'
[2023-12-02T21:58:47Z INFO  lemurs::post_login::env_variables] Setting Basic Environment Variables
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Successfully changed working directory to /home/bob!
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'HOME' to '/home/bob'
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'SHELL' to '/usr/bin/bash'
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'USER' to 'bob'
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'LOGNAME' to 'bob'
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'PATH' to '/usr/local/sbin:/usr/local/bin:/usr/bin'
[2023-12-02T21:58:47Z INFO  lemurs::post_login::env_variables] Setting XDG Common Paths
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'XDG_CONFIG_HOME' to '/home/bob/.config'
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'XDG_CACHE_HOME' to '/home/bob/.cache'
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'XDG_DATA_HOME' to '/home/bob/.local/share'
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'XDG_STATE_HOME' to '/home/bob/.local/state'
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'XDG_DATA_DIRS' to '/usr/local/share:/usr/share'
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'XDG_CONFIG_DIRS' to '/etc/xdg'
[2023-12-02T21:58:47Z INFO  lemurs::post_login] Starting X11 session
[2023-12-02T21:58:47Z INFO  lemurs::post_login::x] Start setup of X server
[2023-12-02T21:58:47Z INFO  lemurs::post_login::x] Filling `.Xauthority` file at `/home/bob/.config/.Xauthority`
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Set environment variable 'XAUTHORITY' to '/home/bob/.config/.Xauthority'
[2023-12-02T21:58:47Z INFO  lemurs::post_login::x] It took X server 0ms to start
[2023-12-02T21:58:47Z INFO  lemurs::post_login::x] X server is running
[2023-12-02T21:58:47Z INFO  lemurs::auth::utmpx] Adding UTMPX record
[2023-12-02T21:58:47Z INFO  lemurs::auth::utmpx] Added UTMPX record
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Removing session environment variables
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Reverting to environment before session
[2023-12-02T21:58:47Z INFO  lemurs::env_container] Reverting to environment before session
[2023-12-02T21:58:47Z INFO  lemurs] Waiting for environment to terminate
[2023-12-02T21:58:47Z INFO  lemurs::post_login] Waiting for client to exit

lemurs.client.log and lemurs.xorg.log are empty. Something strange that I noticed is that when I boot my computer, successfully log in a alice for example, then logout to go back to lemurs, if I go to another tty and type loginctl, this is what I get:

SESSION  UID USER        SEAT  TTY  STATE   IDLE SINCE
      2    0 root        seat0 tty3 active  no   
     c1 1001 alice       seat0 tty2 closing no   

2 sessions listed.

Where we can see that the session which is supposed to be closed, is stuck in the closing state... I don't know what to do, I'm not even sure where the problem comes from. Was a multi-users setup tested on lemurs ? Thanks.

coastalwhite commented 7 months ago

Thank you for the report.

This seems like a new problem, I appreciate all the investigative work. I am guessing somehow the work we are doing on loginctl is correct. I am not 100% sure what that problem is.

dvzrv commented 1 month ago

I am met with the same issue (currently testing with sway, but it happens with other sessions too).

When trying to start sway for the 2nd time I get:

Started Tiling Wayland compositor and replacement for the i3 window manager.
00:00:00.002 [ERROR] [wlr] [libseat] [libseat/backend/logind.c:642] Could not check if session was active: No such device or address
00:00:00.002 [ERROR] [wlr] [libseat] [libseat/libseat.c:79] No backend was able to open a seat
00:00:00.002 [ERROR] [wlr] [backend/session/session.c:83] Unable to create seat: Function not implemented
00:00:00.002 [ERROR] [wlr] [backend/session/session.c:248] Failed to load session backend
00:00:00.002 [ERROR] [wlr] [backend/backend.c:79] Failed to start a session
00:00:00.002 [ERROR] [wlr] [backend/backend.c:359] Failed to start a DRM session
00:00:00.002 [ERROR] [sway/server.c:137] Unable to create backend
sway.service: Main process exited, code=exited, status=1/FAILURE
sway.service: Failed with result 'exit-code'.

This issue can only be solved by restarting lemurs.

My assumption is lemurs is either blocking the logind access for sway or is otherwise making it impossible for sway to check the user's active session.

dvzrv commented 1 month ago

Looking deeper into this I think I found the culprit: Lemur never fully closes the seat for the user after the user attempts to end the session and the seat remains in state "closing".

$ loginctl show-session c2
Id=c2
User=1000
Name=user
Timestamp=Tue 2024-05-28 08:48:23 CEST
TimestampMonotonic=632170501
VTNr=2
Seat=seat0
TTY=tty2
Remote=no
Service=lemurs
Scope=session-c2.scope
Leader=3017
Audit=4294967295
Type=wayland
Class=user
Active=no
State=closing
IdleHint=no
IdleSinceHint=0
IdleSinceHintMonotonic=0
LockedHint=no

When looking at the user's status it becomes clear that lemurs lowered itself into the session scope, but never exited (the below omits non-useful data) and is the only process keeping that seat alive:

$ loginctl user-status 1000
user (1000)
   Since: Tue 2024-05-28 08:38:15 CEST; 38min ago
   State: active
Sessions: *4 c2
  Linger: no
    Unit: user-1000.slice
          ├─session-4.scope
          │ ├─3063 "login -- user"
          │ ├─5394 -zsh
          │ └─6038 loginctl user-status 1000
          ├─session-c2.scope
          │ └─3017 /usr/bin/lemurs
[..]
dvzrv commented 1 month ago

Looking at the above, my assumption would be, that lemurs needs to exit at that point in time to free the seat, or lower a process into that seat (for handling) which may exit.

When choosing the first route I guess lemurs.service would have to be able to automatically restart.

As is, lemurs blocks a login after an initial login and logout, because the lemurs presented to the user at that point runs in the scope of the session that the previous user exited.