Artix Linux Forum

Artix Linux => Announcements => Topic started by: Dudemanguy on 19 September 2021, 04:05:27

Title: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 19 September 2021, 04:05:27
Previously there was a brief attempt at packaging seatd as an alternative to elogind, but we found some issues and put it aside for awhile. Well time has passed and another look was given. This time around, with the help of an additional pam module, seatd support is looking much, much viable as a valid choice. Some more work needs to be done, but here's a brief tutorial on how to switch your system from using elogind to seatd.

Why use seatd?
elogind works great however it is quite complicated and large. By its nature, it is very tied to upstream systemd development (for better or worse). Additionally, it has a runtime dbus dependency. On the other hand, seatd's source code (https://git.sr.ht/~kennylevinsen/seatd/tree) is magnitudes smaller and much easier to understand. It has a logind API implementation in one single C file so it is still compatible with software that uses logind.

Init System Support Status
openrc: implemented
runit: implemented
s6: implemented
dinit: implemented

Note: it is highly recommended that you perform these commands in a separate TTY and not in a graphical environment. Playing around with the elogind daemon will likely kill your graphical session at some point. Make sure all important work is saved before proceeding.

pam_rundir
One important thing that elogind provides is automatic creation and handling of the XDG_RUNTIME_DIR environment variable and directories. seatd does not do this and many, many programs (wayland, pulseaudio, dbus, etc.) write runtime user data here so you mostly want this. Instead of using the elogind daemon, we can use a PAM module called pam_rundir that handles the directory creation and the XDG_RUNTIME_DIR environment variable. It is merely about 300 lines of C code (https://gitea.artixlinux.org/artix/pam_rundir) and only ever executes on system login/logout. All it does it create/delete the /run/user directories as appropriate and export the XDG_RUNTIME_DIR environment variable.
Code: [Select]
$ sudo pacman -S pam_rundir

seatd-${init}
Installing this likely removes elogind-${init} from your system so do not be surprised if your graphical session dies/restarts at this point. After you have seatd-${init} installed, you can add it to your service manager's defaults. e.g. for s6/s6-rc:
Code: [Select]
$ sudo pacman -S seatd-s6
$ sudo touch /etc/s6/adminsv/default/contents.d
$ sudo s6-db-reload

elogind removal
Strictly speaking, this part is optional. If you leave elogind on your system, it will still work fine. The dbus autostarting feature will make elogind always start by itself on login so it is a bit wasteful. You can opt to remove it totally.
Code: [Select]
$ sudo pacman -Rdd elogind
Of course, never lightly use -Rdd but in this case it is okay. seatd only needs libelogind to function. Programs that depend on elogind should function perfectly fine with seatd/libseat. Artix needs to update the package dependencies to be a bit more generic, but for now this is OK.

Add users to groups
One thing systemd (and by extension elogind) did was magically handle a lot of group stuff in the background. So your user did not need to be a part of the video group to start xorg for example. Without elogind, this no longer happens so you have to add your user to the correct groups if you want things to still work normally. See the Arch wiki page (https://wiki.archlinux.org/title/User#Pre-systemd_groups) for a list of some of these groups. You almost certainly want to add your user to audio and input at a minimum. seatd runs with the seat user so you will need to add yourself there for graphics.
Code: [Select]
$ sudo gpasswd -a $USER seat
$ sudo gpasswd -a $USER audio
$ sudo gpasswd -a $USER input
Add yourself and other users to more groups as needed. After that, you can just perform a reboot and you should be good to go. Enjoy using seatd!
Title: Re: [WIP] seatd support (elogind alternative)
Post by: phoenix_king_rus on 19 September 2021, 08:49:46
You will need to enable the [universe] repo in your pacman.conf settings if you have not done so.
Code: [Select]
[universe]
Server = https://universe.artixlinux.org/$arch
Server = https://mirror.pascalpuffke.de/artix-universe/$arch
Will this feature be only available in universe repo or it could be moved to official repos?
Title: Re: [WIP] seatd support (elogind alternative)
Post by: strajder on 19 September 2021, 10:52:30
Looking forward to seatd support in 66! :)

Edit: Just replaced elogind with seatd, rebooted and it works, thanks!
Title: Re: [WIP] seatd support (elogind alternative)
Post by: ndowens on 19 September 2021, 15:44:33
Looking forward to seatd support in 66! :)

Edit: Just replaced elogind with seatd, rebooted and it works, thanks!
There is a seatd-suite66 in universe. I am currently trying to get a sort of logind selection/option for the scripts, instead of a hard dep on one or the other.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 19 September 2021, 16:00:06
Will this feature be only available in universe repo or it could be moved to official repos?
Universe is just a stopgap for now until we finish updating our packaging to support any logind backend. elogind is a bit of a hard depend at the moment.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: strajder on 19 September 2021, 16:23:18
There is a seatd-suite66 in universe. I am currently trying to get a sort of logind selection/option for the scripts, instead of a hard dep on one or the other.
Hmm, curiously it works with elogind removed (didn't remove elogind-suite66 and libelogind though, as they report the removal would break dependencies) and seatd and seatd-suite66 installed.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: ndowens on 19 September 2021, 16:26:42
Hmm, curiously it works with elogind removed (didn't remove elogind-suite66 and libelogind though, as they report the removal would break dependencies) and seatd and seatd-suite66 installed.
Yep :) though I want to figure out a way to make 66 accept variable in *depends field or may have to do something similar to how Dudemanguy did it in s6.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: calvinh on 19 September 2021, 16:58:58
I am running 66 as well. Will consider switching to seatd in the future.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: katinka on 19 September 2021, 20:34:14

Init System Support Status

openrc: not implemented
runit: not implemented
s6: implemented and working
suite66: work in progress

Is it planned for openrc and runit too?
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 19 September 2021, 21:04:10
Of course. It's just that myself and @ndowens are the main ones working on this and we use s6 and suite66 respectively. :P
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 19 September 2021, 21:53:14
I have just finished a major rewrite of pam_rundir and you can see the source here (https://gitea.artixlinux.org/artix/pam_rundir). The functionality should be the same. I removed the complicated counting logic the original implementation had and instead used utmp for tracking user logins. Additional other small improvements are in there like switching to snsprintf() and so on. The universe package has been updated to this new release (v1.1.0). Please try it and let me know if you encounter any problems.

Sidenote: the package now has an install file that adds the pam_rundir.so line to pam on install and removes it on uninstall so you don't have to do it manually anymore. Ideally this just gets added to the default pambase file in the future.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: katinka on 19 September 2021, 23:41:57
No problem @Dudemanguy‍. I don´t panic. Good things come to those who can wait :)
Actually I wanted to have tried s6 & Co for a long time, but little time and the complexity have prevented me so far.

Btw... great job
Title: Re: [WIP] seatd support (elogind alternative)
Post by: jrballesteros05 on 20 September 2021, 18:15:39
Hello, I followed this tutorial but I got a message like this link:

https://www.reddit.com/r/voidlinux/comments/knqwq8/how_to_get_sway_to_work/

I don't know if I have to set an environment variable or something like that. I followed step by step carefully.

At the moment I switched back to elogind.

Best regards.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: capezotte on 20 September 2021, 18:49:45
Have you enabled pam_rundir.so as the article says?

If it's not working, you can do it "manually" like the Qt apps do:

Code: [Select]
export XDG_RUNTIME_DIR="/tmp/runtime-$(id -un)"
mkdir -p "$XDG_RUNTIME_DIR" && chmod 700 "$XDG_RUNTIME_DIR" &&
sway

While I'll stay with elogind on Artix until package dependencies are sorted out, I'll try building and running pam_rundir.so on other Linux distros (where I'm already using seatd).
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 20 September 2021, 19:31:40
Hello, I followed this tutorial but I got a message like this link:

https://www.reddit.com/r/voidlinux/comments/knqwq8/how_to_get_sway_to_work/

I don't know if I have to set an environment variable or something like that. I followed step by step carefully.

At the moment I switched back to elogind.

Best regards.
pam_rundir should automatically set the environment variable. Are you saying it did not?
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 20 September 2021, 20:46:56
Small update, I discovered a subtle bug in pam_rundir. You had to play around with a few users to hit it. This should now be fixed. I also ported it over to utmpx.h instead of utmp.h (the latter is deprecated). This is updated in universe as version 1.2.0.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: jrballesteros05 on 21 September 2021, 12:22:17
Hello, I tried those steps again but in my case I couldn't make it work.

I attach the image from my TTY, I don't know if I am missing something, I also tried what @capezotte  replied but in my case I haven't had success.


Title: Re: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 21 September 2021, 16:22:36
Sad to say, I'm at a loss there. That error does not appear to be any issue with the XDG_RUNTIME_DIR and so I think that part is working correctly. That sway error occurs when it is unable to find any logind or seatd session at all. So even though the seatd daemon is running for you and your user appears to be in the correct group, for some reason it cannot find it. When you logged in was there a /run/user/1000 directory (or something similar)?

seatd update
Upstream has fixed the VT crash that occurred with wlroots. The fixes have been backported to seatd-0.6.2-1.3. If you had the patched version of libinput I previously provided, you can get rid of it by simply reinstalling it from the Artix repos.
Code: [Select]
# pacman -S libinput

You will need to restart your seatd service. Obviously, this will kill your graphical session so be prepared.
Code: [Select]
# s6-svc -r /run/s6-rc/servicedirs/seatd-srv

Now you can start Sway (or any other wlroots compositor) again and you should be able to seamlessly switch VTs.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: jrballesteros05 on 21 September 2021, 17:41:22
Sad to say, I'm at a loss there. That error does not appear to be any issue with the XDG_RUNTIME_DIR and so I think that part is working correctly. That sway error occurs when it is unable to find any logind or seatd session at all. So even though the seatd daemon is running for you and your user appears to be in the correct group, for some reason it cannot find it. When you logged in was there a /run/user/1000 directory (or something similar)?

seatd update
Upstream has fixed the VT crash that occurred with wlroots. The fixes have been backported to seatd-0.6.2-1.3. If you had the patched version of libinput I previously provided, you can get rid of it by simply reinstalling it from the Artix repos.
Code: [Select]
# pacman -S libinput

You will need to restart your seatd service. Obviously, this will kill your graphical session so be prepared.
Code: [Select]
# s6-svc -r /run/s6-rc/servicedirs/seatd-srv

Now you can start Sway (or any other wlroots compositor) again and you should be able to seamlessly switch VTs.

Hi again, I did those steps again and I still have no success with sway. The /run/user/1000 exists but it was completely empty,  when i install elogind again, it contains some stuffs.

Something I got curious was when I restarted the seatd service and my graphical session was killed, I don't know if that's suppose to be normal.

When I install elogind back everything goes to normal but I guess this is not the purpose of this post :P

What I also look a bit strange sway should look for seatd backend instead of liblogind, right?
Title: Re: [WIP] seatd support (elogind alternative)
Post by: jrballesteros05 on 21 September 2021, 17:58:16
I realised I am a retard and I forgot that I have the env "LIBSEAT_BACKEND=logind" variable in /etc/profile.d/wayland.sh


Code: [Select]
cat /etc/profile.d/wayland.sh
#!/bin/bash
export MOZ_ENABLE_WAYLAND=1
export XDG_CURRENT_DESKTOP=sway
export XDG_SESSION_TYPE=wayland
export QT_QPA_PLATFORM=wayland
#export QT_SCALE_FACTOR=1.25
#export LIBSEAT_BACKEND=logind

I just commented and everything is working fine.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 21 September 2021, 19:03:14
Hah, glad you figured it out! And yeah don't kill/restart elogind or seatd unless you like having your graphics killed.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 22 September 2021, 22:06:12
Small update. pam_rundir, seatd-s6, and seatd-suite66 have been all been moved out of Universe and into gremlins and galaxy-gremlins. Additionally, the pambase package has been updated and placed into gremlins. If you had previously installed the Universe packages, the new pambase package will generate a .pacnew file. Overwriting the old file with the .pacnew is recommended.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: jrballesteros05 on 23 September 2021, 10:05:40
If you use NetworkManager you should keep in mind this to make it work with seatd backend.

https://wiki.archlinux.org/title/NetworkManager#Set_up_PolicyKit_permissions

Title: Re: [WIP] seatd support (elogind alternative)
Post by: zachir on 24 September 2021, 18:40:07
I use Runit, and I'd like to help with getting this working, although I have some questions first, as I use an elogind script to lock the screen before sleeping, and the dbus functionality to tell xss-lock to lock the screen when I run `loginctl lock-session', would either of those be impacted? And if so, is there already a workaround?

If  both of those are workable, then I already have the 0.6.2-1.3 version of seatd installed (which seems to be the latest version that can coexist with elogind), and I could try to help write a seatd-runit script to test.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 24 September 2021, 19:08:36
The loginctl binary does not exist with seatd, so you could not call it directly. However, the compiled version of seatd that is in the repos does support the logind API. So calling the equivalent API request via another method (like say dbus for example) should still work.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: tiosgz on 24 September 2021, 20:12:21
Quote
seatd and elogind are in conflict

Is there any particular reason for this change? I’m not going to switch to elogind-less seatd at the moment, but seatd is required by wlroots.

Edit: in case someone is reading this & wondering what happened, see this thread (https://forum.artixlinux.org/index.php/topic,3080.html)
Title: Re: [WIP] seatd support (elogind alternative)
Post by: zachir on 25 September 2021, 01:33:34
The loginctl binary does not exist with seatd, so you could not call it directly. However, the compiled version of seatd that is in the repos does support the logind API. So calling the equivalent API request via another method (like say dbus for example) should still work.

It shouldn't be too hard to work around the 'loginctl' binary issue if it keeps the dbus side, so that should be good enough. Any tips for starting off writing the script, based on how it works on s6?

Edit: I have a temporary init script, where should I send it after I test it? I don't have a PKGBUILD made for it yet, just the /etc/runit/sv/seatd/run script.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: capezotte on 12 October 2021, 21:19:24
A suggestion: the seatd-as-elogind-replacement package could contain a rewritten version of the /usr/lib/udev/rules.d/73-seat-late.rules file (included with elogind), which would chmod 666 device files tagged with uaccess (or run another command that does something with the ACLs like elogind itself does).

It'd obviate the need for users to add themselves to groups.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: picokan on 21 October 2021, 22:51:11
Of course, never lightly use -Rdd but in this case it is okay. seatd only needs libelogind to function.
I know libelogind comes from libsystemd, but what aspect of it does seatd need to work?
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 21 October 2021, 23:11:50
A suggestion: the seatd-as-elogind-replacement package could contain a rewritten version of the /usr/lib/udev/rules.d/73-seat-late.rules file (included with elogind), which would chmod 666 device files tagged with uaccess (or run another command that does something with the ACLs like elogind itself does).

It'd obviate the need for users to add themselves to groups.
Late here, but is there a non-systemd/elogind program that can do this? I'm not too aware of this kind of thing.

I know libelogind comes from libsystemd, but what aspect of it does seatd need to work?
The seatd in the repos is compiled with elogind support so it's linked to libelogind. It's used to implement the loginctl API.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: picokan on 23 October 2021, 17:48:51
I tried to run the seatd-runit package in the gitea unsuccessfully. After looking around I still don't know why, but lightdm refused to keep me logged in.

It looked as though it just started X and then immediately killed it. I could only get to the desktop using startx and ~/.xinitrc. I'm not even sure the problem is with seatd-runit but I checked the permissions of .Xauthority, that seatd was running and that I was in at least the seatd, input and audio groups.

Unsuccessfully might be a bit harsh, I guess. I could still run the setup without a display manager, but I'd rather not.

EDIT
I tried changing the script to run exec /usr/bin/seatd -u seatd -g seatd instead of /usr/bin/seatd -g video. I noticed no difference.
I also noticed that anything that requires the DE to elevate privileges (shutdown, mount from filemanager) doesn't work, it will simply tell you that you don't have the right privileges.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 24 October 2021, 16:09:07
Oh yeah, someone needs to update the script and add seatd-runit to the repos. We have it for all the other init systems.

DEs should be able to start with seatd. I actually don't know if the other elevated privileges stuff would work, but if it's part of the loginctl API I think it should. For instance, I can mount usb devices without polkit asking me for a password at least. I don't know the details of what GUI buttons do in desktop environments though so it's possible that might not work.

Edit: Oh I just remembered. The runit DE init scripts all do a dbus check to see if elogind is running. So yeah it wouldn't work without some changes.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: capezotte on 24 October 2021, 16:20:23
Late here, but is there a non-systemd/elogind program that can do this? I'm not too aware of this kind of thing.

I'm not aware of any pre-made programs (or PAM modules?) for fully simulating the {systemd-,e}logind per-logged-in-user ACL functionality, either.

Personally, I think MODE=666, chmod 666 are good enough solutions, and they mostly avoid the problem of reintroducing the possibility of rootless keyloggers that comes with adding yourself to group input. The reasoning for "chmod 666 bad" I've seen on a logind dev's blogpost (https://enotty.pipebreaker.pl/2012/05/23/linux-automatic-user-acl-management/) seems kind of contrived, to be honest).

Another possibility is doing a throwback to 2008 and calling setfacl with a e.g. plugdev group (or all regular-user UIDs on the system).
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 24 October 2021, 16:46:19
Yeah chmod 666 is probably a better solution as a stopgap for now. I'll do some testing with that when I get some time. Maybe later I can actually look into uaccess and see how this all works.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: picokan on 31 October 2021, 21:47:57
I saw that the seatd-runit package got moved to testing recently, so I tried it again in the hope that it would work, but I got the same problems as last time. These runit DE init scripts you talk about, what are they? sv check dbus is on some scripts, and deleting those either did nothing or brought me to a black screen without even the possibility of accessing a tty.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: picokan on 12 November 2021, 00:51:29
Welp, I'm throwing in the towel. Even on a fresh install I couldn't get seatd to work with runit. If anyone got it to run I'd like to know what they did and their setup.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: picokan on 12 November 2021, 10:39:04
Of course after I say that I find what the source of the problem was. I accidentally found this when I forgot to remove pam_rundir and reinstalled elogind and elogind itself also started to have this problem. Once I remove pam_rundir, the infinite login loop problem goes away, but now I don't have XDG_RUNTIME_DIR so things like sound don't work.

At least now it was narrowed down to something.

Edit: Also found out that the inability for my DE to elevate privileges apparently comes from it using polkit to do these things, and the lack of support from polkit for anything that isn't (e)logind. Also, pam_rundir does set the environment variable and create the proper folders when I login through the tty and use startx, it just gives me the infinite login loop on the display manager (lightdm, might try another one).
Title: Re: [WIP] seatd support (elogind alternative)
Post by: xarthna on 06 December 2021, 00:02:34
I've successfully made the switch to seatd from elogind based off @Dudemanguy 's post. I wanted to note a couple of things I had to do to get the same level of functionality that comes bundled with elogind.

First I had to troubleshoot why X wasn't starting. I autostart X on login with xinit based off the information provided in the Arch wiki (https://wiki.archlinux.org/title/Xinit#Autostart_X_at_login). The environment variable $XDG_VTNR set by elogind  was not present so I had to remove that from my .bash_profile.

Second, after removing elogind from the system via pacman -Rdd elogind, I had to ignore this package in /etc/pacman.conf with IgnorePkg = elogind due to the fact that xorg-server upgrade pulled it back in and it took over acpi events from acpid (third point).

Third, I had to install acpid and register handlers for my laptop to get the lid close functionality that was being provided by elogind. In /etc/acpi/handler.sh:

Code: [Select]
    button/lid)
        case "$3" in
            close)
                monitor_count=$(DISPLAY=:0 xrandr | grep -c -e '\sconnected')
                if [ "$monitor_count" -eq 1 ]; then
                  DISPLAY=:0 /bin/xset s activate
                  /bin/sleep 1
                  /bin/echo mem > /sys/power/state
                else
                  DISPLAY=:0 /bin/xset dpms force off
                fi
                ;;

Fourth, I had another frequently open program KeePassXC that responded to dbus events that were not being triggered anymore. To gain this functionality back on screen lock activation I call a script:

Code: [Select]
#!/usr/bin/env bash

/usr/bin/dbus-send --session --print-reply --dest=org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.MainWindow.lockAllDatabases


Lastly, running rootless X I did not have to add myself to the seatd group, though I did have to add myself to the video group.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: replabrobin on 12 December 2021, 15:13:01
I tried installing seatd-runit and it worked out fine. I had to make a small change to get my slim-runit to use seatd, but after that it worked fine.

However, after reboot I saw messages during shutdown about elogind still running. It was started by something at boot.

I could not find any runit startup, but then I tried removing it. I see this

Code: [Select]
# pacman -R elogind
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: removing elogind breaks dependency 'elogind' required by libappindicator-gtk3
:: removing elogind breaks dependency 'elogind' required by networkmanager
:: removing elogind breaks dependency 'elogind' required by polkit
:: removing elogind breaks dependency 'elogind' required by xorg-server

I suppose that means I either have some wrong package installed or I cannot remove elogind fully. I am running this on my rpi4 with armtix and the xorg-server looks like this

Code: [Select]
# packer -Qi xorg-server
Name            : xorg-server
Version         : 21.1.1-3.1
Description     : Xorg X server
Architecture    : aarch64
URL             : https://xorg.freedesktop.org
Licenses        : custom
Groups          : xorg
Provides        : X-ABI-VIDEODRV_VERSION=25.2  X-ABI-XINPUT_VERSION=24.4  X-ABI-EXTENSION_VERSION=10.0  x-server
Depends On      : libepoxy  libxfont2  pixman  xorg-server-common  libunwind  dbus  libgl  xf86-input-libinput  nettle  elogind
                  libpciaccess  libdrm  libxshmfence  libxcvt
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : nvidia-utils<=331.20  glamor-egl  xf86-video-modesetting
Replaces        : glamor-egl  xf86-video-modesetting
Installed Size  : 3.54 MiB
Packager        : Unknown Packager
Build Date      : Tue 23 Nov 2021 02:44:45 GMT
Install Date    : Sat 27 Nov 2021 12:17:56 GMT
Install Reason  : Explicitly installed
Install Script  : Yes
Validated By    : SHA-256 Sum


I suppose it might be feasible to provide something in both seatd and elogind provides that would create a solution.

For now I switch back to elogind.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: replabrobin on 14 December 2021, 20:10:56
OK I see that the actual dependency is libelogind so I guess the pacman -Rdd elogind is OK.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Dudemanguy on 14 December 2021, 21:32:35
Yeah it's probably OK to -Rdd elogind but expect some things to break.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: replabrobin on 14 December 2021, 23:13:38
OK I tried seatd with elogind removed and noticed that Networkmanager works, but I cannot use the disconnect and some other controls in openbox with the network-manager-applet. The disconnect fails with an authorisation message.

It may be I need to set up some policy with a polkit file and or add myself to some group.

Edit: I was already in the wheel & network groups and so I followed the instructions here https://wiki.archlinux.org/title/NetworkManager#Set_up_PolicyKit_permissions and set up a polkit file as in that article. After that I was able to force remove elogind and the network-manager-applet behaved properly.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: picokan on 31 December 2021, 14:28:31
Also found out that the inability for my DE to elevate privileges apparently comes from it using polkit to do these things, and the lack of support from polkit for anything that isn't (e)logind.
Today I was playing around with consolekit2 and found out that it has support for polkit. So, weirdly enough, after all this I'm neither using seatd nor elogind, just plain consolekit2 and absolutely nothing broke (note: I'm using xinitrc instead of a DM, so that might not work). I've heard that consolekit2 and seatd go well together to provide as an alternative to elogind, but right now I'm not seeing any reason to add seatd into the mix. It'd be nice to have consolekit2 and a consolekit configured polkit in the repositories. As of now, I'm using AUR packages that I have to configure to build correctly and to use the latest versions.

Now, I think libelogind isn't going anywhere soon unless I change to wayland.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: RIA77 on 13 January 2022, 22:31:15
Hello!
 Fresh install of OpenRC Lxqt and seatd.
 Added user to seatd group, added to audio, video etc.
 Can't login as normal user. Added user to input group.
 I can login as root, but not as normal user. Thank you..
Title: Re: [WIP] seatd support (elogind alternative)
Post by: RIA77 on 14 January 2022, 13:26:32
Changed Lightdm to Sddm, now it works.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: ancaro on 15 January 2022, 21:07:34
I installed seatd on 2 machines and sadly had to revert back.
I had the same NetworkManager issue as replabrobin #41, couldn't connect or disconnect even thought I was on the required groups the BTW wiki (Archwiki) to the rescue https://wiki.archlinux.org/title/NetworkManager#Set_up_PolicyKit_permissions (https://wiki.archlinux.org/title/NetworkManager#Set_up_PolicyKit_permissions)
Code: [Select]
doas bash -c " echo -e 'polkit.addRule(function(action, subject) {
  if (action.id.indexOf("org.freedesktop.NetworkManager.") == 0 && subject.isInGroup("network")) {
    return polkit.Result.YES;
  }
});' >> /etc/polkit-1/rules.d/50-org.freedesktop.NetworkManager.rules"
instantly fixed it.
What stopped working was Plasma on Wayland although Enlightenment seemed to work fine and Firefox wasn't able anymore to read u2f keys like the Google Titan.
I reverted back on bare metal but I'm setting up a vm to keep testing it. Things like opendoas seatd or toybox have a special place on my heart because they don't load 30 or 40 years of legacy on to my cpu!
Title: Re: [WIP] seatd support (elogind alternative)
Post by: RIA77 on 22 January 2022, 14:05:08
Hello!
 I have been using S6- XFCE. Just removed Elogind, but I can't restart or shutdown anymore.
 I can login into XFCE, but restart and shutdown has been greyed out.
 Added user to groups -wheel, audio, video, storage, input, disk.
 Thank you.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: phoenix_king_rus on 22 January 2022, 15:08:34
Hello!
 I have been using S6- XFCE. Just removed Elogind, but I can't restart or shutdown anymore.
 I can login into XFCE, but restart and shutdown has been greyed out.
 Added user to groups -wheel, audio, video, storage, input, disk.
 Thank you.
Most likely GUI methods for restart/shutdown internally rely on (e)logind commands like loginctl poweroff
Title: Re: [WIP] seatd support (elogind alternative)
Post by: strajder on 22 January 2022, 15:15:21
Most likely GUI methods for restart/shutdown internally rely on (e)logind commands like loginctl poweroff
This can be easily fixed by creating a script /usr/bin/loginctl (or /usr/bin/systemctl) with logic to parse loginctl's arguments and call /usr/bin/shutdown or init-specific programs to handle shutdown/reboot directly.

Update: A quick 66 demonstration:
Code: [Select]
#!/bin/sh

show_usage()
{
cat <<EOT
Usage: ${0##*/} [halt|reboot|poweroff]
EOT
}

case $1 in
halt) 66-hpr -h;;
reboot) 66-hpr -r;;
poweroff) 66-hpr -p;;
*) show_usage
esac
Title: Re: [WIP] seatd support (elogind alternative)
Post by: picokan on 22 January 2022, 15:45:07
Hello!
 I have been using S6- XFCE. Just removed Elogind, but I can't restart or shutdown anymore.
 I can login into XFCE, but restart and shutdown has been greyed out.
 Added user to groups -wheel, audio, video, storage, input, disk.
 Thank you.
This should be because polkit doesn't support seatd/seatd doesn't support polkit, I made a post about it in this thread. Aside from the shutdown/reboot buttons being greyed out, anything that needs elevated privileges (mounting/unmounting from file manager if you're not in the storage group, gparted, timeshift, etc) won't work unless you do it in a terminal.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: xarthna on 27 January 2022, 23:06:35
Also to note is that other packages like xorg-server will pull in elogind again. I had to add that to IgnorePkg in /etc/pacman.conf. And a full system upgrade is done by:

Code: [Select]
pacman -Syudd

after checking that is the only dependency check not allowing a normal upgrade to go forward. Ignoring packages is not supported by Artix developers, so do so at your own risk. However, without doing so will allow elogind to be installed again.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: xarthna on 27 January 2022, 23:25:32
Hello!
 I have been using S6- XFCE. Just removed Elogind, but I can't restart or shutdown anymore.
 I can login into XFCE, but restart and shutdown has been greyed out.
 Added user to groups -wheel, audio, video, storage, input, disk.
 Thank you.

I'm not sure if you have configuration options to configure the commands that respond to gui interactions (or if this would affect the gui UX at all), but in the terminal I had to write a super server to handle reboot/shutdown without using doas since the execline scripts wrap a binary owned by root /bin/reboot. If you did the same and configure the buttons with event handlers for your commands, it might be something that allows the interaction?

Code: [Select]
# /etc/s6/adminsv/hpr-srv/run
#!/usr/bin/env -S execlineb -P

s6-ipcserver /run/hpr
s6-ipcserver-access -i data/rules
s6-sudod s6-linux-init-hpr

Then under the service dir: data/rules/uid/1000/allow to allow uid 1000 to send privleged commands to the root binary for hpr operations provided by s6-linux-init-hpr binary.

An accompanying bash script to speak to the super server throught the socket:

e.g. $HOME/.local/bin/reboot
Code: [Select]
#!/usr/bin/env bash

s6-sudo /run/hpr -r

Now  you might be able to configure your gui to use the script. I don't know how any of those gui mechanisms work, but thought I might throw out an idea based on my experience of what I had to do to after switching to seatd for feature parity with what elogind was providing.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: picokan on 09 April 2022, 20:23:26
For those that use pipewire, wireplumber does not work with seatd. You have to either use elogind (instead of seatd) or pipewire-media-session (instead of wireplumber).
Title: Re: [WIP] seatd support (elogind alternative)
Post by: fabseman on 10 April 2022, 11:37:34
For those that use pipewire, wireplumber does not work with seatd. You have to either use elogind (instead of seatd) or pipewire-media-session (instead of wireplumber).

That’s only because Artix compiles Wireplumber without “-Delogind=disabled” as an argument:

https://gitea.artixlinux.org/packagesW/wireplumber/src/branch/master/x86_64/extra/PKGBUILD

And compiling wireplumber with said argument does in fact make it useable with seatd, though it apparently affects Bluetooth-usage:

https://gitlab.freedesktop.org/pipewire/wireplumber/-/issues/208

But I haven’t tested that, since I don’t use Bluetooth - and even then it seems a minor inconvenience, since I suspect that most would start pipewire on their own :)
Title: Re: [WIP] seatd support (elogind alternative)
Post by: pluto on 24 July 2022, 05:25:17
Wow!

Thank you guys for this work! Im glad im found this.

elogind was the last pain wich had to be to removed  :)

Everything works so far perfectly (openrc).

The only thing, i cant shutdown/reboot over GUI (KDE) anymore. sudo shutdown or sudo reboot works.

Sadly, i dont quite understand this and how to implement this for openrc: https://forum.artixlinux.org/index.php/topic,3050.msg23032.html#msg23032

Edit:

Edit: and i found out that i cant install ungoogled-chromium so simple anymore, because it has a depency on systemd (i think elogind delivered this depency before?). Is there a easy way to fake it?

I installed it now with pacman -Sdd ungoogled-chromium. But i think there could now be missing some missing depencys because with that command i skipped the check. So far it started normaly anyway.


found out that this fix this: https://artixlinux.org/news.php#artix-archlinux-support_moves_to_%5Buniverse%5D

Edit2: After 10 hours more fiddeling... so far everything works. except like mentioned the shutdown/reboot over gui, and programms cant ask for root password (kate for example to save something under /etc/X11/ for example). Or grub-customizer.

Already found out, that this is possible a problem with polkit, because following error i get:


Code: [Select]
[user@polis ~]$ /usr/lib/polkit-kde-authentication-agent-1
New PolkitAgentListener  0x560214096800
Adding new listener  PolkitQt1::Agent::Listener(0x5602140c0fd0) for  0x560214096800
Listener online
"Cannot register authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject"
Authentication agent result: false
Couldn't register listener!
[user@polis ~]$

Code: [Select]
[user@polis ~]$ grub-customizer 
localuser:root being added to access control list
==== AUTHENTICATING FOR net.launchpad.danielrichter2007.pkexec.grub-customizer ====
Authentication is required to run Grub Customizer
Authenticating as: user
Password:
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie
==== AUTHENTICATION FAILED ====
Error executing command as another user: Not authorized

This incident has been reported.
localuser:root being removed from access control list
[user@polis ~]$

The Text translated from the Picture:

The document cannot be saved because writing to /test is not possible.
Please check if you have write permissions for the file and if there is enough space. The original file may be deleted or damaged. Do not exit the program until the file has been written successfully.



Edit: This just fixed somehow self, after i installed today virt-manager, qemu etc and tutanota (and for tutanota gnome-keyring) and a update with pacman -Syu.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: cat herders of linux on 24 July 2022, 20:17:32
seatd works on dinit?

I was greeted with a login prompt from tty after doing these steps from the op.  But I had did it in a terminal in mate from gui and it didn't crash mate.

Lightdm I started manually but won't let me login...

I can login as root though.   Strange.  Root but not user.

Is there a group for open console or xorg my user might need? 

 Xf86OpenConsole can not open virtual console 7 permission denied

The ~/.local/share/xorg/Xorg.0.log seems to repeat the same error but offers no new insights.  pastebin nonetheless  https://pastebin.com/Yaqpvf3M

I installed xfce4 from tty after rebooting to bypass lightdm and see what startxfce4 would throw at me

Can only login as root to reach a gui.  Please advise.

should i thus install xf86-input-evdev?

some of this looks relevant possibly...  https://unix.stackexchange.com/questions/497204/cannot-open-virtual-console-7-permission-denied-when-trying-to-start-x-on-gent

Quote
i7-7700:[root]:~/Desktop# dinitctl enable seatd
dinitctl: service already enabled.
i7-7700:[root]:~/Desktop# dinitctl start seatd
Service 'seatd' failed to start.
i7-7700:[root]:~/Desktop#


Everyone likely gone to bed in Europe by now...


Switching back to elogind I am not greeted with a command prompt but lightdm no longer allows autologin

removing pam_rundir restored autologin under elogind so i conclude pam_rundir is the problem i was having with xf86OpenConsole permissions issue?  And also the issue with why i couldn't login except through root to the gui.

back on elogind for now.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: cat herders of linux on 24 July 2022, 22:28:56
tried it one more time

Quote
sudo dinitctl enable seatd
Service 'seatd' has been enabled.
Service 'seatd' failed to start.
clealry this is the failing step.  i had added my user to seat and created seatd and added it to that also but that was of no avail and since you say seat is all that's required i deleted the seatd group after all.  either way it's no dice.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: pluto on 29 July 2022, 21:06:41
I have now found a way to shutdown/reboot convenient.

Atleast on KDE. On KDE i had everytime this Addon: https://www.pling.com/p/1288430 (dont know why https://store.kde.org redirects to pling if you search for something).

This worked for me, because i dont use KDEs Applauncher (im using instead rofi) and had mentioned addon added to my topbar.

Now i found this addon: https://www.pling.com/p/1297839

This allows to run a custom script or command.

So i installed zenity, and wrote following Script:

Code: [Select]
#!/bin/sh

var=$(zenity --width=300 --height=220 --list --radiolist --text="" --title="System" --column "Auswahl" --column "Aktion" False Herrunterfahren TRUE Neustart)

if [ -n "${var}" ];then
  case $var in
  Herrunterfahren)
    sudo poweroff
    ;;
  Neustart)
    sudo reboot
    ;;
  esac
fi

Added poweroff and reboot to sudoers file.

And edited my Button to run this script.

Now it looks like attached.



Title: Re: [WIP] seatd support (elogind alternative)
Post by: xarthna on 03 August 2022, 03:33:29
Also to note is that other packages like xorg-server will pull in elogind again. I had to add that to IgnorePkg in /etc/pacman.conf. And a full system upgrade is done by:

Code: [Select]
pacman -Syudd

after checking that is the only dependency check not allowing a normal upgrade to go forward. Ignoring packages is not supported by Artix developers, so do so at your own risk. However, without doing so will allow elogind to be installed again.

If you hold back elogind and were using pipewire-media-session, recent updates may have switched you to wireplumber. e.g pipewire-pulse for bluetooth audio. To switch to using wireplumber, first write a service to start it as a user service when logging in, then configure wireplumber to not use logind.

Code: [Select]
mkdir -p ~/.config/wireplumber/bluetooth.lua.d
cp /usr/share/wireplumber/bluetooth.lua.d/50-bluez-config.lua ~/.config/wireplumber/bluetooth.lua.d/

# set default true to false within lua file
["with-logind"] = false

This will allow you to start wireplumber without a logind on your system.

Ref: https://gitlab.freedesktop.org/pipewire/wireplumber/-/issues/208
Title: Re: [WIP] seatd support (elogind alternative)
Post by: jrballesteros05 on 05 August 2022, 10:43:17
If you hold back elogind and were using pipewire-media-session, recent updates may have switched you to wireplumber. e.g pipewire-pulse for bluetooth audio. To switch to using wireplumber, first write a service to start it as a user service when logging in, then configure wireplumber to not use logind.

Code: [Select]
mkdir -p ~/.config/wireplumber/bluetooth.lua.d
cp /usr/share/wireplumber/bluetooth.lua.d/50-bluez-config.lua ~/.config/wireplumber/bluetooth.lua.d/

# set default true to false within lua file
["with-logind"] = false

This will allow you to start wireplumber without a logind on your system.

Ref: https://gitlab.freedesktop.org/pipewire/wireplumber/-/issues/208

Thanks a lot! With this I could finally try seatd with bluetooth. It works :D.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: pluto on 06 August 2022, 22:35:37
If you hold back elogind and were using pipewire-media-session, recent updates may have switched you to wireplumber. e.g pipewire-pulse for bluetooth audio. To switch to using wireplumber, first write a service to start it as a user service when logging in, then configure wireplumber to not use logind.

Code: [Select]
mkdir -p ~/.config/wireplumber/bluetooth.lua.d
cp /usr/share/wireplumber/bluetooth.lua.d/50-bluez-config.lua ~/.config/wireplumber/bluetooth.lua.d/

# set default true to false within lua file
["with-logind"] = false

This will allow you to start wireplumber without a logind on your system.

Ref: https://gitlab.freedesktop.org/pipewire/wireplumber/-/issues/208

Interesting. Tried pipewire and wireplumber out now. After that i dont have sound at all. pavucontrol and kde says there is no audio available.

Pipewire and Wireplumber arent started after system start either. I can start them manually in the terminal. but no sound too.


Forgot to start pipewire-pulse.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Hitman on 28 February 2024, 11:11:28
I have switched to seatd on dinit, it works fine, i did not need any workaround for wireplumber, and there is no lingering logind process anywhere which is nice.


However i encountered 2 small nagging issues that are worth asking here:

-polkit doesn't work, probably for obvious reasons but is there any new hack to make it work?
-Turnstile does not start properly. /run/turnstiled is created but empty and no --services-dir arguments get passed to it's process. What can i look for if anything is missing in the env? It should work as the pair should complement each other, if i'm not wrong @konimex
My pam.d/system-login has pam_turnstile.so and pam_rundir.so after it.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: 90 on 28 February 2024, 13:44:53
-Turnstile does not start properly. /run/turnstiled is created but empty and no --services-dir arguments get passed to it's process. What can i look for if anything is missing in the env? It should work as the pair should complement each other,
My pam.d/system-login has pam_turnstile.so and pam_rundir.so after it.
I believe you shouldn't need pam_rundir here at all since Turnstile already has its own way to manage $XDG_RUNTIME_DIR enabled via /etc/turnstile/turnstiled.conf.

Also, unfortunately I found that I wasn't able to continue using purely seatd due to the fact that libpulse and spice-vdagent depend on (e)logind. Is there anything I could do regarding that?
Title: Re: [WIP] seatd support (elogind alternative)
Post by: artoo on 28 February 2024, 14:48:38
Is there anything I could do regarding that?

No, it would take a fully functional elogind replacement, ie turnstile + seatd.
Seatd alone can't replace elogind.


Just read the readme
https://github.com/chimera-linux/turnstile
Title: Re: [WIP] seatd support (elogind alternative)
Post by: 90 on 28 February 2024, 21:34:29
Is there anything I could do regarding that?

No, it would take a fully functional elogind replacement, ie turnstile + seatd.
Seatd alone can't replace elogind.


Just read the readme
https://github.com/chimera-linux/turnstile
Well, by "purely seatd" I should have been more precise and said that I was in fact running it with Turnstile. Even so, the aforementioned packages depend specifically on elogind, so I wouldn't know how to rebuild those using Turnstile + seatd.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Hitman on 29 February 2024, 01:16:47
I believe you shouldn't need pam_rundir here at all since Turnstile already has its own way to manage $XDG_RUNTIME_DIR enabled via /etc/turnstile/turnstiled.conf.

I've been trying to make greetd work without success, but after putting sddm back, lo and behold the user dinit process appeared and was working. Of course it's gone again after a reboot.
sddm seems to export everything by it's own, so the desktop session works without pam_rundir and even without turnstile. In a tty however i need pam_rundir for XDG_RUNTIME_DIR to be exported.
*also to note, the user doesn't get added to the seat group automatically, it maybe can hinder something but nothing so far changed after adding it.

LE: Okay nevermind, i got greetd to work, then i edited /etc/turnstile/turnstiled.conf and now it does work without pam_rundir, and the user dinit services are starting!
So pam_rundir (and also sddm in some cases) conflicts with turnstile.
tl:dr it worked exactly as you said and guess i'm on Wayland now :D

LE2: It still works with sddm and a X11 session, but it messes with the environment a bit.

LE3:
*another note: in dinit the (system) dbus service gets disabled, i didn't notice this at first since the user service by turnstile does most things, only gvfs and system_bus_socket didn't work in my case.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Hitman on 01 March 2024, 17:43:31
Heh, i just realized, how in God's name is the system dbus service starting an instance of elogind-daemon?

I figured it out: delete this file: /usr/share/dbus-1/system-services/org.freedesktop.login1.service
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Hitman on 07 March 2024, 01:56:57
*One more note: for getting the power button to register on non supported DE's, under the default acpi script /etc/acpi/handler.sh, add the poweroff command at this argument:
Code: [Select]
...
            PBTN|PWRF)
                logger 'PowerButton pressed'
                poweroff
...
Title: Re: [WIP] seatd support (elogind alternative)
Post by: kiblaster on 02 June 2024, 09:39:22
I tried to use seatd instead of elogind but:

Code: [Select]
pacman -R elogind
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: removing elogind breaks dependency 'elogind' required by elogind-dinit
:: removing elogind breaks dependency 'elogind' required by gnome-desktop-common
:: removing elogind breaks dependency 'elogind' required by libpulse
:: removing elogind breaks dependency 'elogind' required by networkmanager
:: removing elogind breaks dependency 'elogind' required by polkit
:: removing elogind breaks dependency 'elogind' required by rtkit

No DE I use bspwm.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Hitman on 02 June 2024, 15:20:18
In the first post it says you need to use -Rdd.
You can even leave it alone since realistically the only thing that can start it is the system instance of dbus.
Title: Re: [WIP] seatd support (elogind alternative)
Post by: kixik on 25 February 2025, 03:08:21
What would be required for seatd alone (no elogind neither turnstile) to let docker + vagrant work?

Everything seems to be working fine except for docker.  Upon doing vagrant up I get:

Code: [Select]
Stderr: docker: Error response from daemon: failed to create endpoint <...>_1740448731 on network bridge: failed to add the host (veth8af48a7) <=> sandbox (veth907cd9c) pair interfaces: operation not supported.

It seems I would need some priviliege to create a bridge?  No idea...  BTW my user is already included in the docker group, and I just tried adding it unsuccessfully to the network group.  With elogind this was working or course.  I read one needs to add their user into the groups as opposed to what happens with logind, but I have no clue.  Is this possible at all?  If not with seatd alone, perhaps with tunstile?  Or is this some sort of logind only thing?
Title: Re: [WIP] seatd support (elogind alternative)
Post by: Hitman on 02 March 2025, 16:40:04
@kixik Might be an ambigous answer and excuse me in advance but there are embedded distros like OpenWrt who can do Docker and use no login stuff at all, a review of how their packages are built might provide a clue, if you have the time of course.
If it works with Turnstile you can turn off the user service backend without much hassle.