flatpak / xdg-dbus-proxy

GNU Lesser General Public License v2.1
57 stars 21 forks source link

Listening on a file socket #44

Open WhyNotHugo opened 2 years ago

WhyNotHugo commented 2 years ago

I'm trying to use xdg-dbus-proxy with systemd socket based activation.

That is, systemd creates the socket early during startup, but will initialise the proxy only after receiving the first connection to it.

Currently it is possible to specify a file path via PATH:

xdg-dbus-proxy unix:path="$XDG_RUNTIME_DIR/bus" /path/to/where/the/proxy/listens

In order to do socket activation, the proxy would need to listen on a file descriptor:

xdg-dbus-proxy unix:path="$XDG_RUNTIME_DIR/bus" fd:3

Regrettably, passing simply fd:3 creates a file socket named fd:3. Would it be possible to also support listening of file descriptors for this kind of usage?

rusty-snake commented 2 years ago

Did you try /proc/self/fd/3 (as workaround)?

WhyNotHugo commented 2 years ago

Almost. xdp tries to CREATE the file, and that fails. Maybe this could be handled and try to open the provided path. That's good enough for me.

Error is:

May 27 19:03:27 victory env[453446]: Failed to start proxy for unix:path=/run/user/1000/bus: Error binding to address (GUnixSocketAddress): Address already in use

Note: This error is broken! When the downstream path exists, the error prints the path of the upstream path. I should report that in a separate issue, but noticed it before.

WhyNotHugo commented 2 years ago

Looking at flatpak_proxy_start in flatpak-proxy.c: it uses g_unix_socket_address_new, which seems to create a new socket... not sure if it's possible to adapt that to:

I'm not sure if this would be an acceptable solution either.