GParted should have a privileged DBUS backend
GParted should have a privileged backend
In modern Linux world the intended way to do operations that need privileged access rights is to have separate privileged DBUS services and invoke them over the wire with DBUS. This increases security because privileged actions are done in separate processes and also because DBUS is very security oriented.
There are two or more DBUS daemons running: one for a system bus and one for each session bus (i.e the specific desktop login) The application sends requests to the dbus daemon and it delivers the request to the service. When things are done DBUS gives back the results to the application. A DBUS service can provide
How do you use DBUS at an application level?
How do you write a DBUS service?
DBUS services are applications (usually in /usr/bin). Some examples are
- /usr/bin/devhelp --gapplication-service
They are accompanied by textual .service files in /usr/share/dbus-1/services/.
For example, org.jackaudio.service contains:
[D-BUS Service] Name=org.jackaudio.service Exec=/usr/bin/jackdbus auto
At startup a DBUS service registers interfaces with methods+arguments, signals+arguments, properties. For arguments and properties, DBUS understands the following data types:
- Integer (signed/unsigned, 16/32/64)
- Double (64 bit IEEE 754 floating point)
- String (UTF-8 encoded)
- Array (all elements of the array of the same type)
- Map (one type for key and one type for values)
These are the types that are sent over the wire. DBUS uses a binary protocol.
On top of that, the GDBus layer can transport every GVariant data type, which may be really great. I still have to do some research, but it may be that GIOmm wrappers can directly marshall many C++ types (integrals, floating point, bool, Glib::ustring and maybe containers like std::vector)
This is becoming important now that Wayland is taking place because Wayland forbids root graphical applications. Whilst there are workarounds for XWayland apps, you really cannot have XWayland-free graphical applications running as root
 Get on the D-BUS: https://www.linuxjournal.com/article/7744
 D-Bus API Design Guidelines: https://dbus.freedesktop.org/doc/dbus-api-design.html
 Offical DBUS Tutorial: https://dbus.freedesktop.org/doc/dbus-tutorial.html
 Aleksander Morgado (video): https://youtu.be/egj4UMPaylk
 Aleksander Morgado (presentation) https://aleksander.es/data/GNOMEASIA2014%20-%20Introduction%20to%20DBus.pdf
 Why Polkit: https://www.collabora.com/about-us/blog/2015/06/08/why-polkit-(or,-how-to-mount-a-disk-on-modern-linux)