What is the point of dbus?

Does anybody know why dbus exists? I’ve been wracking my brain trying to come up with a usecase for dbus that isn’t already covered by Unix sockets.

You want to remotely control a daemon? Use sockets. You want the daemon to respond to the client? Sockets. Want to exchange information in json? plaintext? binary data? Sockets can do it. Want to restrict access to a socket? Go ahead, change the socket’s permissions. Want to prevent unauthorized programs from pretending to be someone they’re not? Change the permissions of the directory containing the socket. Want network transparency? That’s why we have abstract sockets.

Plenty of well-established software uses sockets. Music player daemon uses sockets. BSPWM uses sockets. Tmux uses sockets. Pipewire uses sockets. Dhcpcd uses sockets. Heck, dbus itself relies on sockets!

For developers, using sockets is easy. I once wrote a program that interfaced with BSPWM, and it was a breeze. Dbus, on the other hand, not so much. I tried writing a Python script that would contact Network Manager and check the WiFi signal strength. Right off the bat I’m using some obscure undocumented package for interfacing with dbus. What is an introspection? What is a proxy object? What is an interface? Why do I need 60 lines of (Python!) code for a seemingly trivial operation?

So why do some developers decide to use dbus when they could just use unix sockets and save a lot of hassle for themselves and others?

mvirts,

What’s the point of sockets?

loopgru,

WHY is Gamora?

troyunrau,
@troyunrau@lemmy.ca avatar

Look into history of object brokering in object oriented environments. I was around when KDE went from CORBA to DCOP to DBUS, but not involved in the decisions. Basically: object sharing between processes with security, type translation, and a few other things. In the Microsoft world, this was called “component object model” if my memory is correct.

DBUS is pretty nice for complex interactions.

azimir,

Based on the various other descriptions of the DBUS features, I kept thinking “this sounds like a message passing model with a bit of CORBA hiding in there”. It’s got a bit of SLP and AMQP/MQTT to it, just on a local machine instead of a distributed network. It’s solving a lot of problems with service discovery, message passing structure, and separating transmission layer details from service API design. Raw sockets/pipes can always be used to pass data (it’s how DBUS does it!), but there’s additional problems of where to send the data and how to ensure data formatting that sockets/pipes do not have the capability of solving by design since they’re simple and foundational to how interprocess communication works in the kernel.

ipsirc,
@ipsirc@lemmy.ml avatar

dbus can also start a program. For example when one notification was generated and no notification daemon is running, then dbus launch one to handle the request.

RedKrieg,
@RedKrieg@lemmy.redkrieg.com avatar

Doesn’t systemd have the ability to do this as well with unix sockets?

renzev,

I posted this in another comment, but to me it just sounds like this autostart mechanism in dbus is just a poor re-implementation of an init system

ninekeysdown,
@ninekeysdown@lemmy.world avatar

I just came across this - fedoramagazine.org/d-bus-overview/ - and I think it explains it pretty well.

ILikeBoobies,

Dbus is a better name

Aux,

What is the point of a steak when you can drink tea? Mmm…

smpl,
@smpl@discuss.tchncs.de avatar

I will conveniently avoid any dbus talk, because the why is not so interesting as the how and direct you to this path /var/run/wpa_supplicant. You would probably send SCAN_RESULTS on the socket, you could also initiate a SCAN first to include the strength of stations you’re not connected to. If you want deeper access to wireless, you use netlink to communicate with the kernel (see /usr/include/linux/nl80211.h) and poke some NL80211_STA_INFOs… or the other direction (everything is a file) you just parse /proc/net/wireless without any special permissions for the current signal strength.

Oh… and btw dbus has a simple binary protocol underneath all the XML/interface fluff and uses a UNIX socket.

NeoNachtwaechter,

Sometimes you want loose coupling.

bizdelnick,

Multicast.

gens,

Because not using OOP is hard for gui devs.

nickwitha_k, (edited )

Sockets are effectively point-to-point communication. Dbus is a bus. Your question is similar to “what is the point of I2, or an ATA bus when directly wiring ICs gets the job done”. Both have different strengths and weaknesses.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux@lemmy.ml
  • localhost
  • All magazines
  • Loading…
    Loading the web debug toolbar…
    Attempt #