xdg-dbus-proxy icon indicating copy to clipboard operation
xdg-dbus-proxy copied to clipboard

Listening on a file socket

Open WhyNotHugo opened this issue 3 years ago • 3 comments

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?

WhyNotHugo avatar May 27 '22 16:05 WhyNotHugo

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

rusty-snake avatar May 27 '22 16:05 rusty-snake

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 avatar May 27 '22 17:05 WhyNotHugo

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:

  • If path exists, open that.
  • Otherwise, create the socket.

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

WhyNotHugo avatar May 27 '22 21:05 WhyNotHugo