<div dir="ltr">Hi everyone,<div><br></div><div>I need to get the client/sender PID using my gDBus service for a SYSTEM message bus on Linux.</div><div><br></div><div>I create the message bus by calling g_bus_own_name with G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT, and then I see that the Acquire handlers are called with a GDBusConnection.</div><div><br></div><div>According to the documentation, it is possible to obtain a GCredentials from the connection by calling <a class="gmail-link" href="https://www.freedesktop.org/software/gstreamer-sdk/data/docs/latest/gio/GDBusConnection.html#g-dbus-connection-get-peer-credentials" title="g_dbus_connection_get_peer_credentials ()" style="color:rgb(114,159,207)">g_dbus_connection_get_peer_credentials</a>, (and from there I can get a unix ucred that has the pid), but I always get a NULL credentials.</div><div>The documentation for this function says: </div><div>"<span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">Gets the credentials of the authenticated peer. This will always return </span><a href="https://www.freedesktop.org/software/gstreamer-sdk/data/docs/latest/glib/glib/glib-Standard-Macros.html#NULL:CAPS" style="text-decoration-line:none;color:rgb(52,101,164);font-family:"Times New Roman";font-size:medium"><code class="gmail-literal">NULL</code></a><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"> unless </span><em class="gmail-parameter" style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"><code>connection</code></em><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"> acted as a server (e.g. </span><a class="gmail-link" href="https://www.freedesktop.org/software/gstreamer-sdk/data/docs/latest/gio/GDBusConnection.html#G-DBUS-CONNECTION-FLAGS-AUTHENTICATION-SERVER:CAPS" style="text-decoration-line:none;color:rgb(52,101,164);font-family:"Times New Roman";font-size:medium"><code class="gmail-literal">G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER</code></a><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"> was passed) when set up and the client passed credentials as part of the authentication process."</span><br></div><div><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"><br></span></div><div>How can I set the connection type, if I use the generated code dbus created?</div><div><br></div><div>I also tried getting the PID by calling programmatically the following command:</div><div><br></div><div><div style="border:1pt solid windowtext;padding:1pt 4pt;background:rgb(231,230,230)">

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:none;padding:0in;margin:0in 0in 8pt;line-height:107%;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;line-height:107%;font-family:Consolas;color:black">dbus-send --system --print-reply
--dest=org.freedesktop.DBus  /org/freedesktop/DBus
org.freedesktop.DBus.GetConnectionUnixProcessID ‘string:com.microsoft.mscrypt’</span><span style="font-size:10pt;line-height:107%;font-family:Consolas"></span></p>

</div></div><div><br></div><div>But I always receive the server's PID, and not the client's.</div><div><br></div><div>Any idea if/how it is possible to get the peer's PID connecting to a SYSTEM bus?</div><div><br></div><div>Thanks,</div><div>Amira.</div></div>