refactor: proper session initialization#247
Conversation
| } | ||
| set_session_params(&mut process_env, post_login_env); | ||
| remove_xdg(&mut process_env); | ||
| set_seat_vars(&mut process_env, config.tty); |
There was a problem hiding this comment.
Previously, seat_vars were reset before calling try_auth, but this is not correct: pam-systemd wants to know XDG_VTNR, XDG_SEAT, source:
https://www.freedesktop.org/software/systemd/man/latest/pam_systemd.html
If not set, pam_systemd will initialize $XDG_SEAT and $XDG_VTNR based on the $DISPLAY variable (if the latter is set).
(it only works for xorg, and is an ugly fallback in any case)
| Ok(l) => l, | ||
| Err(_) => break, | ||
| }; | ||
| match line.as_str() { |
There was a problem hiding this comment.
Such command interface is required for proper pam support
While username/password approach is the only valid auth way for the https://docs.rs/pam/latest/pam/, I would like to switch to https://docs.rs/pam-client/latest/pam_client/ for the proper callback-based interface (see https://docs.rs/pam-client/latest/pam_client/trait.ConversationHandler.html), and using callbacks it would be possible to support things like fido/fingerprint auth
| post_login_env: &PostLoginEnvironment, | ||
| hooks: &Hooks<'_>, | ||
| config: &Config, | ||
| config_path: Option<&Path>, |
There was a problem hiding this comment.
I don't like passing both, but I haven't decided if I want to pass serialized config to the client through the stdio...
There was a problem hiding this comment.
I would be more comfortable doing that after I switch from line-based stdio communication
There was a problem hiding this comment.
Dropped that, config is now serialized/deserialized... And I hate it. I would like to create a separate struct for childprocess config, but it needs refactoring much more things than I want...
|
Changes after refactor: proper session initialization have little-to-no testing yet, I'm still figuring out the codebase and how should it work, trying to switch it to pam-client |
|
Oh, pam crate does support custom authenticators... |
|
I'll postpone pam refactor for now, the basics for parent-child communications are there, everything else can be implemented on top of that Wayland/shell sessions are working properly, but I don't have a machine with Xorg to test it |
|
Thank you for the patches. I will see if I can have a look somewhere this week. |
|
Tested this PR on Arch (CachyOS) , lemur reads sessions form /usr/share/wayland-sessions *Plasma on wayland: works Confirms this fixes #184 for cases that work. Without the patch lemurs sits inside session-c1.scope, so logind waits indefinitely om session close and subsequent logins (including SSH) hang for several minutes. With the patch lemurs stays out of the user session scope and relogin is immediate. Maybe the uswm path is a seperate issue. Happy to grab logs and open a followup issue if useful. Thanks for writing this. |
|
Update: tracked down the uswm issue. Fix here: CertainLach#1 |
Fixes: #166
Fixes: #228