Bug 70592

Summary: dbus-send doesn't print unix file descriptor types
Product: dbus Reporter: Robert Ancell <robert.ancell>
Component: coreAssignee: Havoc Pennington <hp>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: chengwei.yang.cn
Version: unspecifiedKeywords: patch
Hardware: All   
OS: All   
Whiteboard: review?
i915 platform: i915 features:
Attachments: Support printing unix file descriptors in dbus-send/dbus-monitor
Support printing unix file descriptors in dbus-send/dbus-monitor

Description Robert Ancell 2013-10-18 00:50:28 UTC
Created attachment 87806 [details] [review]
Support printing unix file descriptors in dbus-send/dbus-monitor

dbus-send doesn't print unix file descriptor types, i.e.:

$ dbus-send --system --dest=org.freedesktop.login1 --print-reply /org/freedesktop/login1 org.freedesktop.login1.Manager.Inhibit string:'handle-power-key' string:'bob' string:'Blah blah' string:'block'
method return sender=:1.2 -> dest=:1.116 reply_serial=2
    (dbus-monitor too dumb to decipher arg type 'h')

type 'h' is a Unix file descriptor.
Comment 1 Simon McVittie 2013-10-18 08:28:31 UTC
Comment on attachment 87806 [details] [review]
Support printing unix file descriptors in dbus-send/dbus-monitor

Review of attachment 87806 [details] [review]:
-----------------------------------------------------------------

::: tools/dbus-print-message.c
@@ +349,5 @@
> +
> +	case DBUS_TYPE_UNIX_FD:
> +	  {
> +	    dbus_uint32_t val;
> +	    dbus_message_iter_get_basic (iter, &val);

I think the libdbus ABI is that it's an int, not a dbus_uint32_t, on platforms where that makes a difference (but please check the source code, I could be wrong).

(I know it's a uint32 in the wire protocol, but the uint32 doesn't numerically equal the fd anyway.)
Comment 2 Robert Ancell 2013-10-20 21:47:36 UTC
Created attachment 87900 [details] [review]
Support printing unix file descriptors in dbus-send/dbus-monitor

Thanks for catching that! Looking in dbus/dbus-message.c it does indeed special case unix file descriptors and actually do the conversion from the u32 index into a file descriptor (int).
Comment 3 Chengwei Yang 2013-11-18 06:08:28 UTC
Comment on attachment 87900 [details] [review]
Support printing unix file descriptors in dbus-send/dbus-monitor

Review of attachment 87900 [details] [review]:
-----------------------------------------------------------------

looks good.
Comment 4 Chengwei Yang 2013-12-04 01:16:01 UTC
patch applied, so mark it as fixed.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.