DBUS_TYPE_LINUX_CRED ?

Lennart Poettering mzqohf at 0pointer.de
Mon Dec 16 06:06:53 PST 2013


On Mon, 16.12.13 11:23, Simon McVittie (simon.mcvittie at collabora.co.uk) wrote:

> 
> On 13/12/13 18:17, Lennart Poettering wrote:
> > On Fri, 13.12.13 11:39, Serge Hallyn (serge.hallyn at ubuntu.com) wrote:
> > 
> >> Hi,
> >>
> >> dbus-protocol.h defines DBUS_TYPE_UNIX_FD as an iter type which can
> >> be appended to a message.  Would it be acceptable to add something
> >> along the lines of DBUS_TYPE_LINUX_CRED ?  Better yet, is there already
> >> a way of sending a struct ucred as SCM_CREDENTIAL by appending it to
> >> a dbus message?
> > 
> > You can also query the identity of a bus peer with the bus driver calls
> > GetConnectionUnixUser and GetConnectionUnixProcessID.
> 
> ... and in the 1.7 development branch, there's
> GetConnectionCredentials(), which returns everything we know about the
> connection in one convenient a{sv}. (Hopefully the kdbus prototypes
> implement that too?)

In systemd's bus driver for kdbus we do not currently implement that,
since we just wanted compatibility with released versions, and for the
complex stuff there is an ioctl based iface that we wrap anyway, and is
a lot more pwoerful.

Note however that in kdbus retrieving credentials of a peer or a sender
is always done via masks. When you query the creds of a peer you specify
with a bit mask which credentials you actually want. Similar, when you
connect to a bus you tell it which sender credentials you want and those
you will then find attached to every message you receive.

I am pretty sure for the bus driver call GetConnectionCredentials() you
probably want to have a bit mask too, since there might be quite a few
creds eventually and you shouldn't make it it mandatory to always get
all of them...

This is the list of creds you can ask for in these masks:

http://cgit.freedesktop.org/systemd/systemd/tree/src/systemd/sd-bus.h#n50

Also note that in a kdbus world these credentials are far more important
than before. For example, if you add an object to your bus connection
you can already specifiy capabilities for each method that the client
needs to have to connect. For example, when you ask systemd for a reboot
you actually need CAP_SYS_BOOT, and so on.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the dbus mailing list