Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ly immediately displays "logged out" after entering valid credentials to log into sway #445

Closed
AnyTimeTraveler opened this issue Sep 19, 2022 · 13 comments

Comments

@AnyTimeTraveler
Copy link
Contributor

Problem

Ly immediately displays "logged out" after entering valid credentials to log into sway.

OS: Up to date ArchLinux as of this post
Ly Version: 0.5.3.r82.g5db09ce-1 from AUR

Steps to reproduce

  1. Boot
  2. ly appears on tty2 with sway and my username prefilled from previous logins
  3. Enter Password into ly and hit enter
  4. Message at the top changes to "logged out"

Service Status

Examining the ly.service in systemd shows the following:

% sudo systemctl status ly.service
● ly.service - TUI display manager
     Loaded: loaded (/usr/lib/systemd/system/ly.service; enabled; preset: disabled)
     Active: active (running) since Mon 2022-09-19 22:56:42 CEST; 16min ago
   Main PID: 605 (ly)
      Tasks: 1 (limit: 38408)
     Memory: 10.6M
        CPU: 51ms
     CGroup: /system.slice/ly.service
             └─605 /usr/bin/ly

Sep 19 22:56:42 desktop systemd[1]: Started TUI display manager.
Sep 19 22:56:53 desktop ly[605]: pam_systemd_home(ly:auth): systemd-homed is not available: Unit dbus-org.freedesktop.home1.service not found.
Sep 19 22:56:53 desktop ly[605]: pam_unix(ly:session): session opened for user simon(uid=1000) by (uid=0)
Sep 19 22:56:53 desktop ly[605]: pam_systemd(ly:session): Failed to create session: Connection reset by peer
Sep 19 22:56:53 desktop ly[605]: pam_env(ly:session): deprecated reading of user environment enabled
Sep 19 22:56:53 desktop ly[605]: pam_unix(ly:session): session closed for user simon

Current Workaround

  1. Boot
  2. ALT + CTRL + F3
  3. login to tty
  4. type "sway" and hit enter
  5. Sway starts as it used to with ly

Conclusion

I suspect that the line "pam_systemd(ly:session): Failed to create session: Connection reset by peer" has something to do with it,
but either my google-fu isn't strong enough or this issue is new, because I can't find anything useful.

I would appreciate suggestions on what to try very much!

@the-technat
Copy link

I encountered the same issue some days ago, althouth slighlty different.

Sway logged out immediately when I wanted to login to sway. Launching the shell worked.

So I then started sway from the command line and got the error that XDG_RUNTIME_DIR is not set. After digging around a bit I realized that my systemd user session hasn't been started and thus xdg-desktop-portal.service wasn't run (I assume that's the service that sets XDG_RUNTIME_DIR by default).

So could it be that ly ignores systemd/user session? As @AnyTimeTraveler mentioned he could launch sway from the command line which is certainly possible if the shell files set XDG_RUNTIME_DIR or start systemd/user. @AnyTimeTraveler is this the case for you?

@AnyTimeTraveler
Copy link
Contributor Author

Yes @the-technat , I also now found out that, when you login into a shell with ly and then type "sway", it shows an error about the lack of the XDG_RUNTIME_DIR and exits.
When opening a TTY and typing "sway --debug" it also spits out a message: XDG_RUNTIME_DIR is missing, ignoring

For some reason, sway is fine with the lack of the env var when launched in a TTY, but it's a dealbreaker when launched from a ly shell session.

I will try to find time to look into the sway codebase to find out what difference leads to these different codepaths and error messages.

Ly does seem to set the runtime dir itself, here so something must be going wrong.

@AnyTimeTraveler
Copy link
Contributor Author

Update: It suddenly works again

I don't know what changed.
I tried it today, after updating yesterday, and somehow the XDG_RUNTIME_DIR is set properly when I chose to log into sway.

The result of the command grep -i upgraded /var/log/pacman.log for the time range since I submitted the issue can be found here

The full pacman.log since the submission time can be found here in case it helps in any way

@AnyTimeTraveler
Copy link
Contributor Author

AnyTimeTraveler commented Sep 27, 2022

Okay, now I am really confused.
It stopped working.
I have not changed my behaviour, as far as I know and I have paid attention to not update my machine.
It worked exactly once before I booted today and found it showing the "logged out" message again.

Is there some systemd magic that could cause this?
I have no clue what is happening here.

@paul-ri
Copy link

paul-ri commented Sep 28, 2022

I've had to revert to an older commit of ly because of likely the same problem. Starting sway with --debug printed out that XDG_RUNTIME_DIR wasn't setup. There are other issues in the repo that could be related: #443

@AnyTimeTraveler
Copy link
Contributor Author

I have found the issue and created a pull request for the fix/workaround #446
The environment variables are being reset again, after being set.

@t0fik
Copy link

t0fik commented Sep 30, 2022

I found that setting wayland_specifier option to true I am able to login to Wayland session (Sway and Gnome are affected).
XDG_RUNTIME_DIR variable is set.
This workaround helps only on first login.

With X session (Xfce) variable is set with first session and all session management buttons are active. After logout new login is run without XDG_RUNTIME_DIR and buttons for Reboot and Shutdown are disabled.

I've also noticed, that ly after first logout stays attached to user session.

Other missing XDG_ variables from sessions 2+:

  • XDG_SEAT
  • XDG_SESSION_DESKTOP
  • XDG_SESSION_TYPE
  • XDG_SESSION_CLASS
  • XDG_VTNR
  • XDG_SESSION_ID

Another thing are mentioned by @AnyTimeTraveler problems with session creation.
First login starts systemd session (listed by loginctl)
Another login do not create another one.
When using Lightdm each login to Xfce is causing session creation. Old ones are hanging in closing state, I assume, that is Xfce specific problem, other DE's closes sessions.

Test VM:
OS: Fedora 36
Graphics: virtio w/OpenGL
RAM: 2GiB
CPU: 2
installed DE: Gnome 42, XFCE 4.16, sway 1.7
ly version: master HEAD

Test package for Fedora is available here: https://copr.fedorainfracloud.org/coprs/tofik/ly/

@savanne-kham
Copy link

savanne-kham commented Oct 3, 2022

Hello,

Since some updates, I have the same issue on Arch Linux where I have installed ly-git 0.5.3.r82.g5db09ce-1 from AUR.

I can only login shell and it is written XDG_RUNTIME_DIR is not set as others says.

I found 2 workaround described below :

1) Set XDG_RUNTIME_DIR manually and use seatd

Set XDG_RUNTIME_DIR manually in .bashrc as described in Gentoo Wiki :

#!/bin/bash
if test -z "${XDG_RUNTIME_DIR}"; then
    export XDG_RUNTIME_DIR=/tmp/${UID}-runtime-dir
    if ! test -d "${XDG_RUNTIME_DIR}"; then
        mkdir "${XDG_RUNTIME_DIR}"
        chmod 0700 "${XDG_RUNTIME_DIR}"
    fi
fi

Then I still couldn't login to sway from Ly prompt neither from shell by typing $ sway; there are still some errors related to seat something.

So I installed seatd, added my user to seat group and enable/start seatd.service as recommended in Arch Wiki.

That make it works and I can login directly to sway from ly prompt.

2) Use previous version i.e.: ly 0.5.3-0

Though I don't like the solution (1) above I have found that ly 0.5.3-0 (the version without animations) from AUR works properly without all these trickery.

Hopping that we will find a good solution,
Savanne

@AnyTimeTraveler
Copy link
Contributor Author

@t0fik and @savanne-kham would you be so kind and test my pull request?
It should set the environment variables correctly.
It works on my machine, but I need more people to test it.
The pull request: #446
My repository to clone from: https://github.com/AnyTimeTraveler/ly
I'm available via Telegram if you need help with compiling.

@t0fik
Copy link

t0fik commented Oct 5, 2022

@AnyTimeTraveler after applying your PR variables was set. Still new session wasn't started.

@AnyTimeTraveler
Copy link
Contributor Author

I just installed it on a new machine.
Indeed, sway didn't get a seat.
I checked the ArchWiki and found that it needs polkit if you use systemd-logind to assign seats.
After I installed polkit I had a working session.

Can you check if it is installed and could you post the error message you get?

@t0fik
Copy link

t0fik commented Oct 5, 2022

@AnyTimeTraveler polkit is installed by default in Fedora Xfce spin. I am able to login, even without your patch and session is created properly. Problem starts after you logout and try to login again.

Steps to reproduce:

  1. Start machine
  2. With ly use login to graphical interface (here everything works fine) (X11 DE's out of the box, Wayland DE's after setting wayland_specifier to true in config file)
  3. Logout
  4. Login again

With second and subsequent logins:

  • Wayland sessions do not start
  • X11 sessions starts but they are in state like login to the TTY and use startx
  • XDG_ variables are not set (without your patch)

What I noticed:

  • ly is attached to session created by first login (this might be a root cause of the issue)
  • ly tries to reuse old session (State=closing) to login user instead of creating new one, after login session state do not change
  • ly do not create own session. Lightdm and GDM creates session with class greeter

Other tests I did:

  • replacing pam service with one from Lightdm
  • replacing start scripts with bare minimum, basicaly with: exec /bin/sh -c "exec -l $SHELL -c \"$1\""
  • force terminating remaining user session caused termination of ly process (owned by root)

None of those changes resolved the issue

@AnyTimeTraveler
Copy link
Contributor Author

I see.
That is a seperate issue, I think.
At least my reasoning is that, if everything works the first time, ly doesn't reset everything properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants