emersion / basu

The sd-bus library, extracted from systemd
59 stars 8 forks source link

Add support for FreeBSD #15

Closed emersion closed 3 years ago

emersion commented 4 years ago

Closes: https://github.com/emersion/basu/issues/6

kennylevinsen commented 3 years ago
kennylevinsen commented 3 years ago

managed to accumulate enough hacks for compile to pass: https://builds.sr.ht/~emersion/job/364759

cederom commented 3 years ago

I am very very interested to make it working on FreeBSD as replacement for elogind or alternative implementation of logind in order to make Enlightenment + EFL + Wayland work. I did already make it compile but some logind like implementations are mandatory for E+W to run :-)

cederom commented 3 years ago

Anyways maybe it is better to push open standard https://git.sr.ht/~kennylevinsen/seatd instead fighting with linuxisms ? :-)

kennylevinsen commented 3 years ago

I did already make it compile but some logind like implementations are mandatory for E+W to run :-)

Anyways maybe it is better to push open standard https://git.sr.ht/~kennylevinsen/seatd instead fighting with linuxisms ? :-)

As you already found, seatd is the minimal logind-like solution, while basu covers the sd-bus dbus client usage that was commonly piggy-backed off elogind.

seatd does require your compositor/display server to have libseat support though - wlroots has official support, covering all wlroots compositors. There is also Weston fork that I have yet to make an MR out of, but similar work is likely needed for the enlightenment compositor.

(And yes, it would be better to not fight linuxisms and just write a new, clean dbus library like we did with seatd, but I'm not volunteering at the current time. :) )

kennylevinsen commented 3 years ago

I believe the problem lies in this area of dbus-daemon: https://github.com/freedesktop/dbus/blob/669e3c0acabd58ac0c86146fe77022a54558966c/dbus/dbus-sysdeps-unix.c#L2190

Specifically, on platforms where SO_PEERCRED is available, the dbus server will try to use that. FreeBSD does not. Instead, it's trying to read credentials off the socket in the form of an SCM_CREDS message.

... basu never sends such a message, because sd-bus never supported this use-case. We'll have to add this ourselves.

Inspiration available here: https://github.com/freedesktop/dbus/blob/669e3c0acabd58ac0c86146fe77022a54558966c/dbus/dbus-sysdeps-unix.c#L1852, where needs to be changed: https://github.com/emersion/basu/blob/d8dc86662de875ba2a4b2454898db84f0f1ea8a3/src/libsystemd/sd-bus/bus-socket.c#L598.

basu currently sends "\0AUTH EXTERNAL " as a single message with no credentials, but the correct form is to send \0 as a single message with SCM_CREDS/SCM_CREDENTIALS attached, then followed by "AUTH EXTERNAL ".

kennylevinsen commented 3 years ago

Superseded by https://github.com/emersion/basu/pull/32.