Products › lamco-dbus-tools › Interfaces

GetConnectionCredentials: Who's behind a D-Bus connection

GetConnectionCredentials, GetConnectionUnixProcessID and GetConnectionUnixUser say who's behind each D-Bus connection, and lamco-dbus-tools records them.

D-Bus methods GetConnectionCredentials, GetConnectionUnixProcessID, GetConnectionUnixUser

GetConnectionCredentials, GetConnectionUnixProcessID and GetConnectionUnixUser are the methods of org.freedesktop.DBus that say who's behind a connection: Its user, its process, its groups and its security label. Services call them to decide whether a caller may do something, and polkit and the portals build on the answers. A debugger needs them to turn :1.113 into a program name. lamco-dbus-tools asks them for every connection on a bus, so a recording names processes, not only unique names.

What it is

All three take a bus name, unique or well-known, and answer about the process connected to the bus under it:

  • GetConnectionUnixUser returns the Unix user ID as a UINT32.
  • GetConnectionUnixProcessID returns the process ID as a UINT32.
  • GetConnectionCredentials returns a dictionary of whatever the bus can determine. The specification defines UnixUserID, UnixGroupIDs (complete or absent), ProcessID, LinuxSecurityLabel (the label SO_PEERSEC gives, such as an SELinux context) and ProcessFD, a file descriptor pinning the process. On Linux that's a pidfd from SO_PEERPIDFD. The specification calls it safer than the process ID, which can be reused.

Keys a bus can't determine are left out rather than guessed. The answers come from the socket, not from anything the client claims, so they're what a service should trust. A connection's process can have exited, or belong to another user whose /proc entries refuse a reader.

The difference between the two implementations that matters here is the descriptor. Each ProcessFD passed is a file descriptor charged to the asker. The repository's measurements found that on dbus-broker, many monitors starting at once and each asking for every connection's process descriptor fill the user's descriptor quota, and the bus then disconnects monitors, a long-running one among them. dbus-daemon answered them. So on dbus-broker the snapshot asks GetConnectionUnixProcessID and GetConnectionUnixUser instead, which carry no descriptor, and the record says which it used (credentials_from). In the repository's test of 40 recorders beside 30 connections, 22 were cut off on dbus-broker before that change, and none after.

These methods are ordinary driver calls, so a bus may refuse one. A bus behind a sandbox's proxy answers only for names the sandbox may see: xdg-dbus-proxy lets the GetConnection... questions through only for a name at see or above.

How lamco-dbus-tools reads it

dbussee names asks the bus for every connection's credentials (user, process, groups, security label), then reads the process's short name and control group in /proc. A process of another user may refuse some of these, and is recorded as not read. On dbus-broker it uses GetConnectionUnixProcessID and GetConnectionUnixUser, so no descriptor is passed. A recording's snapshot takes the same table, so dbussee pending and dbustell pending print :1.1 python3 (2652006) rather than a bare unique name. dbustell health reads the result, including connections the bus wouldn't describe.

dbussee names                                  # every connection: User, process, groups, label, cgroup
dbussee names --bus system --out names.json    # the same for the system bus, kept as a capture
dbussee pending --all                          # waiting calls, each caller named by its process
dbustell health names.json                     # what was examined, and NAME-001 for refused credentials

dbusdo has no command of its own for these methods. Any of them can be called with dbusdo call, as any method can, for example dbusdo call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetConnectionUnixUser s :1.42.

Where it has been run

The README's run record lists dbussee check, which takes the same names and credentials table, on the session and system buses of Debian 13 with Xfce (dbus-daemon 1.16.2), Fedora 45 with GNOME (dbus-broker 37), KDE neon with Plasma and Ubuntu 24.04 with Sway (both dbus-daemon 1.14.10), all on 2026-11-28. On Debian 13 that was 147 and 98 questions to the bus, and on Fedora 45 231 and 154, with nothing started. On KDE neon three minutes after boot it named Plasma's own processes on the bus an ssh login gets. The record doesn't single out the credentials methods from the rest of the check.

Findings

  • NAME-001: The bus would not say who is behind a connection.
  • AUD-007: A name owned by another unit than the files give.

Related