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?

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

chitak166,

I’m a firm believer that the vast majority of things we needed for software were implemented by the 2000s.

Usually, people who don’t understand what they’re doing will overcomplicate things to cover-up their misunderstandings. I think choosing a technology before you have a use-case is one of these examples.

vsis,
@vsis@feddit.cl avatar

Those who don’t understand Unix are condemned to reinvent it, poorly. ~HS

kariboka,

Hichard Stallman?

Aux,

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

mcepl,

Yes, of course, the sockets are the answer to everything (and BTW, d-bus uses sockets as well, e.g. /run/dbus/system_bus_socket on my current system), but the problem is no standard for the communication over these sockets (or where is the socket located). For example, X11 developed one system of communicating over their socket, but it was used just by few X11 programs, and everybody else had their other system of communication. And even if an app found some socket, there was absolutely no standard how exactly should programs communicate over it. How to send more than just plain ASCII strings? Each program had to write their own serialization/deserialization code, their own format for marshalling binary data, etc. Now there is just one standard for those protocols, and even libraries with the standard (and well tested) code for it.

WarmApplePieShrek,

There’s still no standard on how to use dbus so I don’t get your point

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.

possiblylinux127,

Its so that your system can hold passengers

bus

norgur,
@norgur@discuss.tchncs.de avatar

Get into de bus?

MonkderZweite,

Btw, why do i need to start xfce;xfwm with dbus for automount in thunar to work, instead of just running dbus as a service on the side?

renzev,

By “start with dbus” do you mean with the dbus-launch utility? I think it’s needed because it sets some environment variables that thunar uses to actually find and connect to the bus. If you run just the daemon “on the side”, thunar won’t know how to connect to it. Kind of how you need $DISPLAY to be set correctly for X11 applications to work.

fiohnah,

My serious answer, not an argument: Use d-feet to inspect what’s available on the system and session buses. That’ll show the benefit of introspection and a common serialization mechanism.

About the security comments: Some access control mechanisms aren’t just allow/deny, and many need more than socket permissions. Those benefit from DBus policies, and PolicyKit integration helps for more complex needs. You can always DIY it, that’s Linux/FOSS life, but these are great tools to have in your toolbox. I’ll avoid credential passing via sockets whenever I can and have something else do it.

bizdelnick,

Multicast.

gens,

Because not using OOP is hard for gui devs.

corsicanguppy,

Lennart said so.

troyunrau,
@troyunrau@lemmy.ca avatar

No. DBUS has its roots in freedesktop.org and the KDE+Gnome projects. It’s basically a desktop agnostic reimplemented of KDE’s DCOP, which was itself a simplified CORBA (gnome was using ORBit at the time, if I recall correctly). DBUS was so useful that the domain spaces its been applied to soon rapidly outgrew the desktop space, and this is why it’s usually started earlier these days.

It also works on Windows.

nickwitha_k,

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.

xia,

Easy… decoupling. You hit the pause button on your keyboard, it does not need to “know” (in code or compile time or at runtime) what your music player is, and it can still pause it. Similarly, you can write a new media player, and not have to convince 1000 different projects to support or implement your custom api. en.m.wikipedia.org/wiki/Enterprise_service_bus

avidamoeba,
@avidamoeba@lemmy.ca avatar

Some heavy schooling happening in this thread. Glad to see it. Learning is a good thing. 🙌

teawrecks,

I’m learning a lot, so I’m not a fan of the people flaming and downvoting OP for having genuine confusion. I want us to incentivize more posts like this.

LemmyHead,

Same here. I’ve always wondered what dbus actually was and I’m glad OP asked

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux@lemmy.ml
  • DreamBathrooms
  • magazineikmin
  • ethstaker
  • GTA5RPClips
  • InstantRegret
  • rosin
  • love
  • Youngstown
  • slotface
  • khanakhh
  • kavyap
  • everett
  • thenastyranch
  • osvaldo12
  • provamag3
  • tester
  • cisconetworking
  • tacticalgear
  • ngwrru68w68
  • Durango
  • cubers
  • mdbf
  • normalnudes
  • anitta
  • modclub
  • Leos
  • megavids
  • JUstTest
  • All magazines