Skip to content

DBus message sender #535

Description

@nicomuns

Hello

My use case is the following, I have one systemd service acting as a DBus server, exposing a DBus method that will be called by several clients (also systemd services). I need to know which client called the method, so I used getObject().getCurrentlyProcessedMessage().getSender().
This gives me the unique identifier of the sender (:1.217 for example) but I don't know how to link it to my systemd services, I have no idea who :1.217 is. Is there any solution to this?

I'm using sdbus-cpp v1.17

DBus method:

void MyClass::myMethod(const std::string& arg0, const std::string& arg1, int32_t arg2) {
    const char* sender = getObject().getCurrentlyProcessedMessage().getSender();
    std::cout << "Sender of this method call: " << sender << std::endl;

    // ...
}

DBus server log example:
[21-04-2026 17:23:28.529] [myService] [info] [myFile.cpp:121] Sender of this method call: :1.217

Monitoring:

sudo busctl monitor Service
‣ Type=method_call  Endian=l  Flags=4  Version=1 Cookie=2  Timestamp="Tue 2026-04-21 15:23:28.529481 UTC"
  Sender=:1.217  Destination=Service  Path=ObjectPath  Interface=Interface  Member=Method
  UniqueName=:1.217
  MESSAGE "ssi" {
          STRING "";
          STRING "";
          INT32 0;
  };

Thank you

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions