1 <?xml version="1.0" standalone="no" ?>
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"
8 <title>D-Bus Specification</title>
9 <releaseinfo>Version 0.16</releaseinfo>
10 <date>(not finalized)</date>
13 <firstname>Havoc</firstname>
14 <surname>Pennington</surname>
16 <orgname>Red Hat, Inc.</orgname>
18 <email>hp@pobox.com</email>
23 <firstname>Anders</firstname>
24 <surname>Carlsson</surname>
26 <orgname>CodeFactory AB</orgname>
28 <email>andersca@codefactory.se</email>
33 <firstname>Alexander</firstname>
34 <surname>Larsson</surname>
36 <orgname>Red Hat, Inc.</orgname>
38 <email>alexl@redhat.com</email>
43 <firstname>Sven</firstname>
44 <surname>Herzberg</surname>
46 <orgname>Imendio AB</orgname>
48 <email>sven@imendio.com</email>
55 <revnumber>current</revnumber>
56 <date><ulink url='http://cgit.freedesktop.org/dbus/dbus/log/doc/dbus-specification.xml'>commit log</ulink></date>
57 <authorinitials></authorinitials>
58 <revremark></revremark>
61 <revnumber>0.15</revnumber>
62 <date>3 November 2010</date>
63 <authorinitials></authorinitials>
64 <revremark></revremark>
67 <revnumber>0.14</revnumber>
68 <date>12 May 2010</date>
69 <authorinitials></authorinitials>
70 <revremark></revremark>
73 <revnumber>0.13</revnumber>
74 <date>23 Dezember 2009</date>
75 <authorinitials></authorinitials>
76 <revremark></revremark>
79 <revnumber>0.12</revnumber>
80 <date>7 November, 2006</date>
81 <authorinitials></authorinitials>
82 <revremark></revremark>
85 <revnumber>0.11</revnumber>
86 <date>6 February 2005</date>
87 <authorinitials></authorinitials>
88 <revremark></revremark>
91 <revnumber>0.10</revnumber>
92 <date>28 January 2005</date>
93 <authorinitials></authorinitials>
94 <revremark></revremark>
97 <revnumber>0.9</revnumber>
98 <date>7 Januar 2005</date>
99 <authorinitials></authorinitials>
100 <revremark></revremark>
103 <revnumber>0.8</revnumber>
104 <date>06 September 2003</date>
105 <authorinitials></authorinitials>
106 <revremark>First released document.</revremark>
111 <sect1 id="introduction">
112 <title>Introduction</title>
114 D-Bus is a system for low-latency, low-overhead, easy to use
115 interprocess communication (IPC). In more detail:
119 D-Bus is <emphasis>low-latency</emphasis> because it is designed
120 to avoid round trips and allow asynchronous operation, much like
126 D-Bus is <emphasis>low-overhead</emphasis> because it uses a
127 binary protocol, and does not have to convert to and from a text
128 format such as XML. Because D-Bus is intended for potentially
129 high-resolution same-machine IPC, not primarily for Internet IPC,
130 this is an interesting optimization.
135 D-Bus is <emphasis>easy to use</emphasis> because it works in terms
136 of <firstterm>messages</firstterm> rather than byte streams, and
137 automatically handles a lot of the hard IPC issues. Also, the D-Bus
138 library is designed to be wrapped in a way that lets developers use
139 their framework's existing object/type system, rather than learning
140 a new one specifically for IPC.
147 The base D-Bus protocol is a one-to-one (peer-to-peer or client-server)
148 protocol, specified in <xref linkend="message-protocol"/>. That is, it is
149 a system for one application to talk to a single other
150 application. However, the primary intended application of the protocol is the
151 D-Bus <firstterm>message bus</firstterm>, specified in <xref
152 linkend="message-bus"/>. The message bus is a special application that
153 accepts connections from multiple other applications, and forwards
158 Uses of D-Bus include notification of system changes (notification of when
159 a camera is plugged in to a computer, or a new version of some software
160 has been installed), or desktop interoperability, for example a file
161 monitoring service or a configuration service.
165 D-Bus is designed for two specific use cases:
169 A "system bus" for notifications from the system to user sessions,
170 and to allow the system to request input from user sessions.
175 A "session bus" used to implement desktop environments such as
180 D-Bus is not intended to be a generic IPC system for any possible
181 application, and intentionally omits many features found in other
182 IPC systems for this reason.
186 At the same time, the bus daemons offer a number of features not found in
187 other IPC systems, such as single-owner "bus names" (similar to X
188 selections), on-demand startup of services, and security policies.
189 In many ways, these features are the primary motivation for developing
190 D-Bus; other systems would have sufficed if IPC were the only goal.
194 D-Bus may turn out to be useful in unanticipated applications, but future
195 versions of this spec and the reference implementation probably will not
196 incorporate features that interfere with the core use cases.
200 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
201 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
202 document are to be interpreted as described in RFC 2119. However, the
203 document could use a serious audit to be sure it makes sense to do
204 so. Also, they are not capitalized.
207 <sect2 id="stability">
208 <title>Protocol and Specification Stability</title>
210 The D-Bus protocol is frozen (only compatible extensions are allowed) as
211 of November 8, 2006. However, this specification could still use a fair
212 bit of work to make interoperable reimplementation possible without
213 reference to the D-Bus reference implementation. Thus, this
214 specification is not marked 1.0. To mark it 1.0, we'd like to see
215 someone invest significant effort in clarifying the specification
216 language, and growing the specification to cover more aspects of the
217 reference implementation's behavior.
220 Until this work is complete, any attempt to reimplement D-Bus will
221 probably require looking at the reference implementation and/or asking
222 questions on the D-Bus mailing list about intended behavior.
223 Questions on the list are very welcome.
226 Nonetheless, this document should be a useful starting point and is
227 to our knowledge accurate, though incomplete.
233 <sect1 id="message-protocol">
234 <title>Message Protocol</title>
237 A <firstterm>message</firstterm> consists of a
238 <firstterm>header</firstterm> and a <firstterm>body</firstterm>. If you
239 think of a message as a package, the header is the address, and the body
240 contains the package contents. The message delivery system uses the header
241 information to figure out where to send the message and how to interpret
242 it; the recipient interprets the body of the message.
246 The body of the message is made up of zero or more
247 <firstterm>arguments</firstterm>, which are typed values, such as an
248 integer or a byte array.
252 Both header and body use the same type system and format for
253 serializing data. Each type of value has a wire format.
254 Converting a value from some other representation into the wire
255 format is called <firstterm>marshaling</firstterm> and converting
256 it back from the wire format is <firstterm>unmarshaling</firstterm>.
259 <sect2 id="message-protocol-signatures">
260 <title>Type Signatures</title>
263 The D-Bus protocol does not include type tags in the marshaled data; a
264 block of marshaled values must have a known <firstterm>type
265 signature</firstterm>. The type signature is made up of <firstterm>type
266 codes</firstterm>. A type code is an ASCII character representing the
267 type of a value. Because ASCII characters are used, the type signature
268 will always form a valid ASCII string. A simple string compare
269 determines whether two type signatures are equivalent.
273 As a simple example, the type code for 32-bit integer (<literal>INT32</literal>) is
274 the ASCII character 'i'. So the signature for a block of values
275 containing a single <literal>INT32</literal> would be:
279 A block of values containing two <literal>INT32</literal> would have this signature:
286 All <firstterm>basic</firstterm> types work like
287 <literal>INT32</literal> in this example. To marshal and unmarshal
288 basic types, you simply read one value from the data
289 block corresponding to each type code in the signature.
290 In addition to basic types, there are four <firstterm>container</firstterm>
291 types: <literal>STRUCT</literal>, <literal>ARRAY</literal>, <literal>VARIANT</literal>,
292 and <literal>DICT_ENTRY</literal>.
296 <literal>STRUCT</literal> has a type code, ASCII character 'r', but this type
297 code does not appear in signatures. Instead, ASCII characters
298 '(' and ')' are used to mark the beginning and end of the struct.
299 So for example, a struct containing two integers would have this
304 Structs can be nested, so for example a struct containing
305 an integer and another struct:
309 The value block storing that struct would contain three integers; the
310 type signature allows you to distinguish "(i(ii))" from "((ii)i)" or
315 The <literal>STRUCT</literal> type code 'r' is not currently used in the D-Bus protocol,
316 but is useful in code that implements the protocol. This type code
317 is specified to allow such code to interoperate in non-protocol contexts.
321 Empty structures are not allowed; there must be at least one
322 type code between the parentheses.
326 <literal>ARRAY</literal> has ASCII character 'a' as type code. The array type code must be
327 followed by a <firstterm>single complete type</firstterm>. The single
328 complete type following the array is the type of each array element. So
329 the simple example is:
333 which is an array of 32-bit integers. But an array can be of any type,
334 such as this array-of-struct-with-two-int32-fields:
338 Or this array of array of integer:
345 The phrase <firstterm>single complete type</firstterm> deserves some
346 definition. A single complete type is a basic type code, a variant type code,
347 an array with its element type, or a struct with its fields.
348 So the following signatures are not single complete types:
358 And the following signatures contain multiple complete types:
368 Note however that a single complete type may <emphasis>contain</emphasis>
369 multiple other single complete types.
373 <literal>VARIANT</literal> has ASCII character 'v' as its type code. A marshaled value of
374 type <literal>VARIANT</literal> will have the signature of a single complete type as part
375 of the <emphasis>value</emphasis>. This signature will be followed by a
376 marshaled value of that type.
380 A <literal>DICT_ENTRY</literal> works exactly like a struct, but rather
381 than parentheses it uses curly braces, and it has more restrictions.
382 The restrictions are: it occurs only as an array element type; it has
383 exactly two single complete types inside the curly braces; the first
384 single complete type (the "key") must be a basic type rather than a
385 container type. Implementations must not accept dict entries outside of
386 arrays, must not accept dict entries with zero, one, or more than two
387 fields, and must not accept dict entries with non-basic-typed keys. A
388 dict entry is always a key-value pair.
392 The first field in the <literal>DICT_ENTRY</literal> is always the key.
393 A message is considered corrupt if the same key occurs twice in the same
394 array of <literal>DICT_ENTRY</literal>. However, for performance reasons
395 implementations are not required to reject dicts with duplicate keys.
399 In most languages, an array of dict entry would be represented as a
400 map, hash table, or dict object.
404 The following table summarizes the D-Bus types.
409 <entry>Conventional Name</entry>
411 <entry>Description</entry>
416 <entry><literal>INVALID</literal></entry>
417 <entry>0 (ASCII NUL)</entry>
418 <entry>Not a valid type code, used to terminate signatures</entry>
420 <entry><literal>BYTE</literal></entry>
421 <entry>121 (ASCII 'y')</entry>
422 <entry>8-bit unsigned integer</entry>
424 <entry><literal>BOOLEAN</literal></entry>
425 <entry>98 (ASCII 'b')</entry>
426 <entry>Boolean value, 0 is <literal>FALSE</literal> and 1 is <literal>TRUE</literal>. Everything else is invalid.</entry>
428 <entry><literal>INT16</literal></entry>
429 <entry>110 (ASCII 'n')</entry>
430 <entry>16-bit signed integer</entry>
432 <entry><literal>UINT16</literal></entry>
433 <entry>113 (ASCII 'q')</entry>
434 <entry>16-bit unsigned integer</entry>
436 <entry><literal>INT32</literal></entry>
437 <entry>105 (ASCII 'i')</entry>
438 <entry>32-bit signed integer</entry>
440 <entry><literal>UINT32</literal></entry>
441 <entry>117 (ASCII 'u')</entry>
442 <entry>32-bit unsigned integer</entry>
444 <entry><literal>INT64</literal></entry>
445 <entry>120 (ASCII 'x')</entry>
446 <entry>64-bit signed integer</entry>
448 <entry><literal>UINT64</literal></entry>
449 <entry>116 (ASCII 't')</entry>
450 <entry>64-bit unsigned integer</entry>
452 <entry><literal>DOUBLE</literal></entry>
453 <entry>100 (ASCII 'd')</entry>
454 <entry>IEEE 754 double</entry>
456 <entry><literal>STRING</literal></entry>
457 <entry>115 (ASCII 's')</entry>
458 <entry>UTF-8 string (<emphasis>must</emphasis> be valid UTF-8). Must be nul terminated and contain no other nul bytes.</entry>
460 <entry><literal>OBJECT_PATH</literal></entry>
461 <entry>111 (ASCII 'o')</entry>
462 <entry>Name of an object instance</entry>
464 <entry><literal>SIGNATURE</literal></entry>
465 <entry>103 (ASCII 'g')</entry>
466 <entry>A type signature</entry>
468 <entry><literal>ARRAY</literal></entry>
469 <entry>97 (ASCII 'a')</entry>
472 <entry><literal>STRUCT</literal></entry>
473 <entry>114 (ASCII 'r'), 40 (ASCII '('), 41 (ASCII ')')</entry>
474 <entry>Struct</entry>
476 <entry><literal>VARIANT</literal></entry>
477 <entry>118 (ASCII 'v') </entry>
478 <entry>Variant type (the type of the value is part of the value itself)</entry>
480 <entry><literal>DICT_ENTRY</literal></entry>
481 <entry>101 (ASCII 'e'), 123 (ASCII '{'), 125 (ASCII '}') </entry>
482 <entry>Entry in a dict or map (array of key-value pairs)</entry>
484 <entry><literal>UNIX_FD</literal></entry>
485 <entry>104 (ASCII 'h')</entry>
486 <entry>Unix file descriptor</entry>
495 <sect2 id="message-protocol-marshaling">
496 <title>Marshaling (Wire Format)</title>
499 Given a type signature, a block of bytes can be converted into typed
500 values. This section describes the format of the block of bytes. Byte
501 order and alignment issues are handled uniformly for all D-Bus types.
505 A block of bytes has an associated byte order. The byte order
506 has to be discovered in some way; for D-Bus messages, the
507 byte order is part of the message header as described in
508 <xref linkend="message-protocol-messages"/>. For now, assume
509 that the byte order is known to be either little endian or big
514 Each value in a block of bytes is aligned "naturally," for example
515 4-byte values are aligned to a 4-byte boundary, and 8-byte values to an
516 8-byte boundary. To properly align a value, <firstterm>alignment
517 padding</firstterm> may be necessary. The alignment padding must always
518 be the minimum required padding to properly align the following value;
519 and it must always be made up of nul bytes. The alignment padding must
520 not be left uninitialized (it can't contain garbage), and more padding
521 than required must not be used.
525 Given all this, the types are marshaled on the wire as follows:
530 <entry>Conventional Name</entry>
531 <entry>Encoding</entry>
532 <entry>Alignment</entry>
537 <entry><literal>INVALID</literal></entry>
538 <entry>Not applicable; cannot be marshaled.</entry>
541 <entry><literal>BYTE</literal></entry>
542 <entry>A single 8-bit byte.</entry>
545 <entry><literal>BOOLEAN</literal></entry>
546 <entry>As for <literal>UINT32</literal>, but only 0 and 1 are valid values.</entry>
549 <entry><literal>INT16</literal></entry>
550 <entry>16-bit signed integer in the message's byte order.</entry>
553 <entry><literal>UINT16</literal></entry>
554 <entry>16-bit unsigned integer in the message's byte order.</entry>
557 <entry><literal>INT32</literal></entry>
558 <entry>32-bit signed integer in the message's byte order.</entry>
561 <entry><literal>UINT32</literal></entry>
562 <entry>32-bit unsigned integer in the message's byte order.</entry>
565 <entry><literal>INT64</literal></entry>
566 <entry>64-bit signed integer in the message's byte order.</entry>
569 <entry><literal>UINT64</literal></entry>
570 <entry>64-bit unsigned integer in the message's byte order.</entry>
573 <entry><literal>DOUBLE</literal></entry>
574 <entry>64-bit IEEE 754 double in the message's byte order.</entry>
577 <entry><literal>STRING</literal></entry>
578 <entry>A <literal>UINT32</literal> indicating the string's
579 length in bytes excluding its terminating nul, followed by
580 non-nul string data of the given length, followed by a terminating nul
587 <entry><literal>OBJECT_PATH</literal></entry>
588 <entry>Exactly the same as <literal>STRING</literal> except the
589 content must be a valid object path (see below).
595 <entry><literal>SIGNATURE</literal></entry>
596 <entry>The same as <literal>STRING</literal> except the length is a single
597 byte (thus signatures have a maximum length of 255)
598 and the content must be a valid signature (see below).
604 <entry><literal>ARRAY</literal></entry>
606 A <literal>UINT32</literal> giving the length of the array data in bytes, followed by
607 alignment padding to the alignment boundary of the array element type,
608 followed by each array element. The array length is from the
609 end of the alignment padding to the end of the last element,
610 i.e. it does not include the padding after the length,
611 or any padding after the last element.
612 Arrays have a maximum length defined to be 2 to the 26th power or
613 67108864. Implementations must not send or accept arrays exceeding this
620 <entry><literal>STRUCT</literal></entry>
622 A struct must start on an 8-byte boundary regardless of the
623 type of the struct fields. The struct value consists of each
624 field marshaled in sequence starting from that 8-byte
631 <entry><literal>VARIANT</literal></entry>
633 A variant type has a marshaled
634 <literal>SIGNATURE</literal> followed by a marshaled
635 value with the type given in the signature. Unlike
636 a message signature, the variant signature can
637 contain only a single complete type. So "i", "ai"
638 or "(ii)" is OK, but "ii" is not. Use of variants may not
639 cause a total message depth to be larger than 64, including
640 other container types such as structures.
643 1 (alignment of the signature)
646 <entry><literal>DICT_ENTRY</literal></entry>
654 <entry><literal>UNIX_FD</literal></entry>
655 <entry>32-bit unsigned integer in the message's byte
656 order. The actual file descriptors need to be
657 transferred out-of-band via some platform specific
658 mechanism. On the wire, values of this type store the index to the
659 file descriptor in the array of file descriptors that
660 accompany the message.</entry>
668 <sect3 id="message-protocol-marshaling-object-path">
669 <title>Valid Object Paths</title>
672 An object path is a name used to refer to an object instance.
673 Conceptually, each participant in a D-Bus message exchange may have
674 any number of object instances (think of C++ or Java objects) and each
675 such instance will have a path. Like a filesystem, the object
676 instances in an application form a hierarchical tree.
680 The following rules define a valid object path. Implementations must
681 not send or accept messages with invalid object paths.
685 The path may be of any length.
690 The path must begin with an ASCII '/' (integer 47) character,
691 and must consist of elements separated by slash characters.
696 Each element must only contain the ASCII characters
702 No element may be the empty string.
707 Multiple '/' characters cannot occur in sequence.
712 A trailing '/' character is not allowed unless the
713 path is the root path (a single '/' character).
722 <sect3 id="message-protocol-marshaling-signature">
723 <title>Valid Signatures</title>
725 An implementation must not send or accept invalid signatures.
726 Valid signatures will conform to the following rules:
730 The signature ends with a nul byte.
735 The signature is a list of single complete types.
736 Arrays must have element types, and structs must
737 have both open and close parentheses.
742 Only type codes and open and close parentheses are
743 allowed in the signature. The <literal>STRUCT</literal> type code
744 is not allowed in signatures, because parentheses
750 The maximum depth of container type nesting is 32 array type
751 codes and 32 open parentheses. This implies that the maximum
752 total depth of recursion is 64, for an "array of array of array
753 of ... struct of struct of struct of ..." where there are 32
759 The maximum length of a signature is 255.
764 Signatures must be nul-terminated.
773 <sect2 id="message-protocol-messages">
774 <title>Message Format</title>
777 A message consists of a header and a body. The header is a block of
778 values with a fixed signature and meaning. The body is a separate block
779 of values, with a signature specified in the header.
783 The length of the header must be a multiple of 8, allowing the body to
784 begin on an 8-byte boundary when storing the entire message in a single
785 buffer. If the header does not naturally end on an 8-byte boundary
786 up to 7 bytes of nul-initialized alignment padding must be added.
790 The message body need not end on an 8-byte boundary.
794 The maximum length of a message, including header, header alignment padding,
795 and body is 2 to the 27th power or 134217728. Implementations must not
796 send or accept messages exceeding this size.
800 The signature of the header is:
804 Written out more readably, this is:
806 BYTE, BYTE, BYTE, BYTE, UINT32, UINT32, ARRAY of STRUCT of (BYTE,VARIANT)
811 These values have the following meanings:
817 <entry>Description</entry>
822 <entry>1st <literal>BYTE</literal></entry>
823 <entry>Endianness flag; ASCII 'l' for little-endian
824 or ASCII 'B' for big-endian. Both header and body are
825 in this endianness.</entry>
828 <entry>2nd <literal>BYTE</literal></entry>
829 <entry><firstterm>Message type</firstterm>. Unknown types must be ignored.
830 Currently-defined types are described below.
834 <entry>3rd <literal>BYTE</literal></entry>
835 <entry>Bitwise OR of flags. Unknown flags
836 must be ignored. Currently-defined flags are described below.
840 <entry>4th <literal>BYTE</literal></entry>
841 <entry>Major protocol version of the sending application. If
842 the major protocol version of the receiving application does not
843 match, the applications will not be able to communicate and the
844 D-Bus connection must be disconnected. The major protocol
845 version for this version of the specification is 1.
849 <entry>1st <literal>UINT32</literal></entry>
850 <entry>Length in bytes of the message body, starting
851 from the end of the header. The header ends after
852 its alignment padding to an 8-boundary.
856 <entry>2nd <literal>UINT32</literal></entry>
857 <entry>The serial of this message, used as a cookie
858 by the sender to identify the reply corresponding
859 to this request. This must not be zero.
863 <entry><literal>ARRAY</literal> of <literal>STRUCT</literal> of (<literal>BYTE</literal>,<literal>VARIANT</literal>)</entry>
864 <entry>An array of zero or more <firstterm>header
865 fields</firstterm> where the byte is the field code, and the
866 variant is the field value. The message type determines
867 which fields are required.
875 <firstterm>Message types</firstterm> that can appear in the second byte
881 <entry>Conventional name</entry>
882 <entry>Decimal value</entry>
883 <entry>Description</entry>
888 <entry><literal>INVALID</literal></entry>
890 <entry>This is an invalid type.</entry>
893 <entry><literal>METHOD_CALL</literal></entry>
895 <entry>Method call.</entry>
898 <entry><literal>METHOD_RETURN</literal></entry>
900 <entry>Method reply with returned data.</entry>
903 <entry><literal>ERROR</literal></entry>
905 <entry>Error reply. If the first argument exists and is a
906 string, it is an error message.</entry>
909 <entry><literal>SIGNAL</literal></entry>
911 <entry>Signal emission.</entry>
918 Flags that can appear in the third byte of the header:
923 <entry>Conventional name</entry>
924 <entry>Hex value</entry>
925 <entry>Description</entry>
930 <entry><literal>NO_REPLY_EXPECTED</literal></entry>
932 <entry>This message does not expect method return replies or
933 error replies; the reply can be omitted as an
934 optimization. However, it is compliant with this specification
935 to return the reply despite this flag and the only harm
936 from doing so is extra network traffic.
940 <entry><literal>NO_AUTO_START</literal></entry>
942 <entry>The bus must not launch an owner
943 for the destination name in response to this message.
951 <sect3 id="message-protocol-header-fields">
952 <title>Header Fields</title>
955 The array at the end of the header contains <firstterm>header
956 fields</firstterm>, where each field is a 1-byte field code followed
957 by a field value. A header must contain the required header fields for
958 its message type, and zero or more of any optional header
959 fields. Future versions of this protocol specification may add new
960 fields. Implementations must ignore fields they do not
961 understand. Implementations must not invent their own header fields;
962 only changes to this specification may introduce new header fields.
966 Again, if an implementation sees a header field code that it does not
967 expect, it must ignore that field, as it will be part of a new
968 (but compatible) version of this specification. This also applies
969 to known header fields appearing in unexpected messages, for
970 example: if a signal has a reply serial it must be ignored
971 even though it has no meaning as of this version of the spec.
975 However, implementations must not send or accept known header fields
976 with the wrong type stored in the field value. So for example a
977 message with an <literal>INTERFACE</literal> field of type
978 <literal>UINT32</literal> would be considered corrupt.
982 Here are the currently-defined header fields:
987 <entry>Conventional Name</entry>
988 <entry>Decimal Code</entry>
990 <entry>Required In</entry>
991 <entry>Description</entry>
996 <entry><literal>INVALID</literal></entry>
999 <entry>not allowed</entry>
1000 <entry>Not a valid field name (error if it appears in a message)</entry>
1003 <entry><literal>PATH</literal></entry>
1005 <entry><literal>OBJECT_PATH</literal></entry>
1006 <entry><literal>METHOD_CALL</literal>, <literal>SIGNAL</literal></entry>
1007 <entry>The object to send a call to,
1008 or the object a signal is emitted from.
1010 <literal>/org/freedesktop/DBus/Local</literal> is reserved;
1011 implementations should not send messages with this path,
1012 and the reference implementation of the bus daemon will
1013 disconnect any application that attempts to do so.
1017 <entry><literal>INTERFACE</literal></entry>
1019 <entry><literal>STRING</literal></entry>
1020 <entry><literal>SIGNAL</literal></entry>
1022 The interface to invoke a method call on, or
1023 that a signal is emitted from. Optional for
1024 method calls, required for signals.
1025 The special interface
1026 <literal>org.freedesktop.DBus.Local</literal> is reserved;
1027 implementations should not send messages with this
1028 interface, and the reference implementation of the bus
1029 daemon will disconnect any application that attempts to
1034 <entry><literal>MEMBER</literal></entry>
1036 <entry><literal>STRING</literal></entry>
1037 <entry><literal>METHOD_CALL</literal>, <literal>SIGNAL</literal></entry>
1038 <entry>The member, either the method name or signal name.</entry>
1041 <entry><literal>ERROR_NAME</literal></entry>
1043 <entry><literal>STRING</literal></entry>
1044 <entry><literal>ERROR</literal></entry>
1045 <entry>The name of the error that occurred, for errors</entry>
1048 <entry><literal>REPLY_SERIAL</literal></entry>
1050 <entry><literal>UINT32</literal></entry>
1051 <entry><literal>ERROR</literal>, <literal>METHOD_RETURN</literal></entry>
1052 <entry>The serial number of the message this message is a reply
1053 to. (The serial number is the second <literal>UINT32</literal> in the header.)</entry>
1056 <entry><literal>DESTINATION</literal></entry>
1058 <entry><literal>STRING</literal></entry>
1059 <entry>optional</entry>
1060 <entry>The name of the connection this message is intended for.
1061 Only used in combination with the message bus, see
1062 <xref linkend="message-bus"/>.</entry>
1065 <entry><literal>SENDER</literal></entry>
1067 <entry><literal>STRING</literal></entry>
1068 <entry>optional</entry>
1069 <entry>Unique name of the sending connection.
1070 The message bus fills in this field so it is reliable; the field is
1071 only meaningful in combination with the message bus.</entry>
1074 <entry><literal>SIGNATURE</literal></entry>
1076 <entry><literal>SIGNATURE</literal></entry>
1077 <entry>optional</entry>
1078 <entry>The signature of the message body.
1079 If omitted, it is assumed to be the
1080 empty signature "" (i.e. the body must be 0-length).</entry>
1083 <entry><literal>UNIX_FDS</literal></entry>
1085 <entry><literal>UINT32</literal></entry>
1086 <entry>optional</entry>
1087 <entry>The number of Unix file descriptors that
1088 accompany the message. If omitted, it is assumed
1089 that no Unix file descriptors accompany the
1090 message. The actual file descriptors need to be
1091 transferred via platform specific mechanism
1092 out-of-band. They must be sent at the same time as
1093 part of the message itself. They may not be sent
1094 before the first byte of the message itself is
1095 transferred or after the last byte of the message
1105 <sect2 id="message-protocol-names">
1106 <title>Valid Names</title>
1108 The various names in D-Bus messages have some restrictions.
1111 There is a <firstterm>maximum name length</firstterm>
1112 of 255 which applies to bus names, interfaces, and members.
1114 <sect3 id="message-protocol-names-interface">
1115 <title>Interface names</title>
1117 Interfaces have names with type <literal>STRING</literal>, meaning that
1118 they must be valid UTF-8. However, there are also some
1119 additional restrictions that apply to interface names
1122 <listitem><para>Interface names are composed of 1 or more elements separated by
1123 a period ('.') character. All elements must contain at least
1127 <listitem><para>Each element must only contain the ASCII characters
1128 "[A-Z][a-z][0-9]_" and must not begin with a digit.
1132 <listitem><para>Interface names must contain at least one '.' (period)
1133 character (and thus at least two elements).
1136 <listitem><para>Interface names must not begin with a '.' (period) character.</para></listitem>
1137 <listitem><para>Interface names must not exceed the maximum name length.</para></listitem>
1141 <sect3 id="message-protocol-names-bus">
1142 <title>Bus names</title>
1144 Connections have one or more bus names associated with them.
1145 A connection has exactly one bus name that is a unique connection
1146 name. The unique connection name remains with the connection for
1147 its entire lifetime.
1148 A bus name is of type <literal>STRING</literal>,
1149 meaning that it must be valid UTF-8. However, there are also
1150 some additional restrictions that apply to bus names
1153 <listitem><para>Bus names that start with a colon (':')
1154 character are unique connection names.
1157 <listitem><para>Bus names are composed of 1 or more elements separated by
1158 a period ('.') character. All elements must contain at least
1162 <listitem><para>Each element must only contain the ASCII characters
1163 "[A-Z][a-z][0-9]_-". Only elements that are part of a unique
1164 connection name may begin with a digit, elements in
1165 other bus names must not begin with a digit.
1169 <listitem><para>Bus names must contain at least one '.' (period)
1170 character (and thus at least two elements).
1173 <listitem><para>Bus names must not begin with a '.' (period) character.</para></listitem>
1174 <listitem><para>Bus names must not exceed the maximum name length.</para></listitem>
1178 Note that the hyphen ('-') character is allowed in bus names but
1179 not in interface names.
1182 <sect3 id="message-protocol-names-member">
1183 <title>Member names</title>
1185 Member (i.e. method or signal) names:
1187 <listitem><para>Must only contain the ASCII characters
1188 "[A-Z][a-z][0-9]_" and may not begin with a
1189 digit.</para></listitem>
1190 <listitem><para>Must not contain the '.' (period) character.</para></listitem>
1191 <listitem><para>Must not exceed the maximum name length.</para></listitem>
1192 <listitem><para>Must be at least 1 byte in length.</para></listitem>
1196 <sect3 id="message-protocol-names-error">
1197 <title>Error names</title>
1199 Error names have the same restrictions as interface names.
1204 <sect2 id="message-protocol-types">
1205 <title>Message Types</title>
1207 Each of the message types (<literal>METHOD_CALL</literal>, <literal>METHOD_RETURN</literal>, <literal>ERROR</literal>, and
1208 <literal>SIGNAL</literal>) has its own expected usage conventions and header fields.
1209 This section describes these conventions.
1211 <sect3 id="message-protocol-types-method">
1212 <title>Method Calls</title>
1214 Some messages invoke an operation on a remote object. These are
1215 called method call messages and have the type tag <literal>METHOD_CALL</literal>. Such
1216 messages map naturally to methods on objects in a typical program.
1219 A method call message is required to have a <literal>MEMBER</literal> header field
1220 indicating the name of the method. Optionally, the message has an
1221 <literal>INTERFACE</literal> field giving the interface the method is a part of. In the
1222 absence of an <literal>INTERFACE</literal> field, if two interfaces on the same object have
1223 a method with the same name, it is undefined which of the two methods
1224 will be invoked. Implementations may also choose to return an error in
1225 this ambiguous case. However, if a method name is unique
1226 implementations must not require an interface field.
1229 Method call messages also include a <literal>PATH</literal> field
1230 indicating the object to invoke the method on. If the call is passing
1231 through a message bus, the message will also have a
1232 <literal>DESTINATION</literal> field giving the name of the connection
1233 to receive the message.
1236 When an application handles a method call message, it is required to
1237 return a reply. The reply is identified by a <literal>REPLY_SERIAL</literal> header field
1238 indicating the serial number of the <literal>METHOD_CALL</literal> being replied to. The
1239 reply can have one of two types; either <literal>METHOD_RETURN</literal> or <literal>ERROR</literal>.
1242 If the reply has type <literal>METHOD_RETURN</literal>, the arguments to the reply message
1243 are the return value(s) or "out parameters" of the method call.
1244 If the reply has type <literal>ERROR</literal>, then an "exception" has been thrown,
1245 and the call fails; no return value will be provided. It makes
1246 no sense to send multiple replies to the same method call.
1249 Even if a method call has no return values, a <literal>METHOD_RETURN</literal>
1250 reply is required, so the caller will know the method
1251 was successfully processed.
1254 The <literal>METHOD_RETURN</literal> or <literal>ERROR</literal> reply message must have the <literal>REPLY_SERIAL</literal>
1258 If a <literal>METHOD_CALL</literal> message has the flag <literal>NO_REPLY_EXPECTED</literal>,
1259 then as an optimization the application receiving the method
1260 call may choose to omit the reply message (regardless of
1261 whether the reply would have been <literal>METHOD_RETURN</literal> or <literal>ERROR</literal>).
1262 However, it is also acceptable to ignore the <literal>NO_REPLY_EXPECTED</literal>
1263 flag and reply anyway.
1266 Unless a message has the flag <literal>NO_AUTO_START</literal>, if the
1267 destination name does not exist then a program to own the destination
1268 name will be started before the message is delivered. The message
1269 will be held until the new program is successfully started or has
1270 failed to start; in case of failure, an error will be returned. This
1271 flag is only relevant in the context of a message bus, it is ignored
1272 during one-to-one communication with no intermediate bus.
1274 <sect4 id="message-protocol-types-method-apis">
1275 <title>Mapping method calls to native APIs</title>
1277 APIs for D-Bus may map method calls to a method call in a specific
1278 programming language, such as C++, or may map a method call written
1279 in an IDL to a D-Bus message.
1282 In APIs of this nature, arguments to a method are often termed "in"
1283 (which implies sent in the <literal>METHOD_CALL</literal>), or "out" (which implies
1284 returned in the <literal>METHOD_RETURN</literal>). Some APIs such as CORBA also have
1285 "inout" arguments, which are both sent and received, i.e. the caller
1286 passes in a value which is modified. Mapped to D-Bus, an "inout"
1287 argument is equivalent to an "in" argument, followed by an "out"
1288 argument. You can't pass things "by reference" over the wire, so
1289 "inout" is purely an illusion of the in-process API.
1292 Given a method with zero or one return values, followed by zero or more
1293 arguments, where each argument may be "in", "out", or "inout", the
1294 caller constructs a message by appending each "in" or "inout" argument,
1295 in order. "out" arguments are not represented in the caller's message.
1298 The recipient constructs a reply by appending first the return value
1299 if any, then each "out" or "inout" argument, in order.
1300 "in" arguments are not represented in the reply message.
1303 Error replies are normally mapped to exceptions in languages that have
1307 In converting from native APIs to D-Bus, it is perhaps nice to
1308 map D-Bus naming conventions ("FooBar") to native conventions
1309 such as "fooBar" or "foo_bar" automatically. This is OK
1310 as long as you can say that the native API is one that
1311 was specifically written for D-Bus. It makes the most sense
1312 when writing object implementations that will be exported
1313 over the bus. Object proxies used to invoke remote D-Bus
1314 objects probably need the ability to call any D-Bus method,
1315 and thus a magic name mapping like this could be a problem.
1318 This specification doesn't require anything of native API bindings;
1319 the preceding is only a suggested convention for consistency
1325 <sect3 id="message-protocol-types-signal">
1326 <title>Signal Emission</title>
1328 Unlike method calls, signal emissions have no replies.
1329 A signal emission is simply a single message of type <literal>SIGNAL</literal>.
1330 It must have three header fields: <literal>PATH</literal> giving the object
1331 the signal was emitted from, plus <literal>INTERFACE</literal> and <literal>MEMBER</literal> giving
1332 the fully-qualified name of the signal. The <literal>INTERFACE</literal> header is required
1333 for signals, though it is optional for method calls.
1337 <sect3 id="message-protocol-types-errors">
1338 <title>Errors</title>
1340 Messages of type <literal>ERROR</literal> are most commonly replies
1341 to a <literal>METHOD_CALL</literal>, but may be returned in reply
1342 to any kind of message. The message bus for example
1343 will return an <literal>ERROR</literal> in reply to a signal emission if
1344 the bus does not have enough memory to send the signal.
1347 An <literal>ERROR</literal> may have any arguments, but if the first
1348 argument is a <literal>STRING</literal>, it must be an error message.
1349 The error message may be logged or shown to the user
1354 <sect3 id="message-protocol-types-notation">
1355 <title>Notation in this document</title>
1357 This document uses a simple pseudo-IDL to describe particular method
1358 calls and signals. Here is an example of a method call:
1360 org.freedesktop.DBus.StartServiceByName (in STRING name, in UINT32 flags,
1361 out UINT32 resultcode)
1363 This means <literal>INTERFACE</literal> = org.freedesktop.DBus, <literal>MEMBER</literal> = StartServiceByName,
1364 <literal>METHOD_CALL</literal> arguments are <literal>STRING</literal> and <literal>UINT32</literal>, <literal>METHOD_RETURN</literal> argument
1365 is <literal>UINT32</literal>. Remember that the <literal>MEMBER</literal> field can't contain any '.' (period)
1366 characters so it's known that the last part of the name in
1367 the "IDL" is the member name.
1370 In C++ that might end up looking like this:
1372 unsigned int org::freedesktop::DBus::StartServiceByName (const char *name,
1373 unsigned int flags);
1375 or equally valid, the return value could be done as an argument:
1377 void org::freedesktop::DBus::StartServiceByName (const char *name,
1379 unsigned int *resultcode);
1381 It's really up to the API designer how they want to make
1382 this look. You could design an API where the namespace wasn't used
1383 in C++, using STL or Qt, using varargs, or whatever you wanted.
1386 Signals are written as follows:
1388 org.freedesktop.DBus.NameLost (STRING name)
1390 Signals don't specify "in" vs. "out" because only
1391 a single direction is possible.
1394 It isn't especially encouraged to use this lame pseudo-IDL in actual
1395 API implementations; you might use the native notation for the
1396 language you're using, or you might use COM or CORBA IDL, for example.
1401 <sect2 id="message-protocol-handling-invalid">
1402 <title>Invalid Protocol and Spec Extensions</title>
1405 For security reasons, the D-Bus protocol should be strictly parsed and
1406 validated, with the exception of defined extension points. Any invalid
1407 protocol or spec violations should result in immediately dropping the
1408 connection without notice to the other end. Exceptions should be
1409 carefully considered, e.g. an exception may be warranted for a
1410 well-understood idiosyncrasy of a widely-deployed implementation. In
1411 cases where the other end of a connection is 100% trusted and known to
1412 be friendly, skipping validation for performance reasons could also make
1413 sense in certain cases.
1417 Generally speaking violations of the "must" requirements in this spec
1418 should be considered possible attempts to exploit security, and violations
1419 of the "should" suggestions should be considered legitimate (though perhaps
1420 they should generate an error in some cases).
1424 The following extension points are built in to D-Bus on purpose and must
1425 not be treated as invalid protocol. The extension points are intended
1426 for use by future versions of this spec, they are not intended for third
1427 parties. At the moment, the only way a third party could extend D-Bus
1428 without breaking interoperability would be to introduce a way to negotiate new
1429 feature support as part of the auth protocol, using EXTENSION_-prefixed
1430 commands. There is not yet a standard way to negotiate features.
1434 In the authentication protocol (see <xref linkend="auth-protocol"/>) unknown
1435 commands result in an ERROR rather than a disconnect. This enables
1436 future extensions to the protocol. Commands starting with EXTENSION_ are
1437 reserved for third parties.
1442 The authentication protocol supports pluggable auth mechanisms.
1447 The address format (see <xref linkend="addresses"/>) supports new
1453 Messages with an unknown type (something other than
1454 <literal>METHOD_CALL</literal>, <literal>METHOD_RETURN</literal>,
1455 <literal>ERROR</literal>, <literal>SIGNAL</literal>) are ignored.
1456 Unknown-type messages must still be well-formed in the same way
1457 as the known messages, however. They still have the normal
1463 Header fields with an unknown or unexpected field code must be ignored,
1464 though again they must still be well-formed.
1469 New standard interfaces (with new methods and signals) can of course be added.
1479 <sect1 id="auth-protocol">
1480 <title>Authentication Protocol</title>
1482 Before the flow of messages begins, two applications must
1483 authenticate. A simple plain-text protocol is used for
1484 authentication; this protocol is a SASL profile, and maps fairly
1485 directly from the SASL specification. The message encoding is
1486 NOT used here, only plain text messages.
1489 In examples, "C:" and "S:" indicate lines sent by the client and
1490 server respectively.
1492 <sect2 id="auth-protocol-overview">
1493 <title>Protocol Overview</title>
1495 The protocol is a line-based protocol, where each line ends with
1496 \r\n. Each line begins with an all-caps ASCII command name containing
1497 only the character range [A-Z_], a space, then any arguments for the
1498 command, then the \r\n ending the line. The protocol is
1499 case-sensitive. All bytes must be in the ASCII character set.
1501 Commands from the client to the server are as follows:
1504 <listitem><para>AUTH [mechanism] [initial-response]</para></listitem>
1505 <listitem><para>CANCEL</para></listitem>
1506 <listitem><para>BEGIN</para></listitem>
1507 <listitem><para>DATA <data in hex encoding></para></listitem>
1508 <listitem><para>ERROR [human-readable error explanation]</para></listitem>
1509 <listitem><para>NEGOTIATE_UNIX_FD</para></listitem>
1512 From server to client are as follows:
1515 <listitem><para>REJECTED <space-separated list of mechanism names></para></listitem>
1516 <listitem><para>OK <GUID in hex></para></listitem>
1517 <listitem><para>DATA <data in hex encoding></para></listitem>
1518 <listitem><para>ERROR</para></listitem>
1519 <listitem><para>AGREE_UNIX_FD</para></listitem>
1523 Unofficial extensions to the command set must begin with the letters
1524 "EXTENSION_", to avoid conflicts with future official commands.
1525 For example, "EXTENSION_COM_MYDOMAIN_DO_STUFF".
1528 <sect2 id="auth-nul-byte">
1529 <title>Special credentials-passing nul byte</title>
1531 Immediately after connecting to the server, the client must send a
1532 single nul byte. This byte may be accompanied by credentials
1533 information on some operating systems that use sendmsg() with
1534 SCM_CREDS or SCM_CREDENTIALS to pass credentials over UNIX domain
1535 sockets. However, the nul byte must be sent even on other kinds of
1536 socket, and even on operating systems that do not require a byte to be
1537 sent in order to transmit credentials. The text protocol described in
1538 this document begins after the single nul byte. If the first byte
1539 received from the client is not a nul byte, the server may disconnect
1543 A nul byte in any context other than the initial byte is an error;
1544 the protocol is ASCII-only.
1547 The credentials sent along with the nul byte may be used with the
1548 SASL mechanism EXTERNAL.
1551 <sect2 id="auth-command-auth">
1552 <title>AUTH command</title>
1554 If an AUTH command has no arguments, it is a request to list
1555 available mechanisms. The server must respond with a REJECTED
1556 command listing the mechanisms it understands, or with an error.
1559 If an AUTH command specifies a mechanism, and the server supports
1560 said mechanism, the server should begin exchanging SASL
1561 challenge-response data with the client using DATA commands.
1564 If the server does not support the mechanism given in the AUTH
1565 command, it must send either a REJECTED command listing the mechanisms
1566 it does support, or an error.
1569 If the [initial-response] argument is provided, it is intended for use
1570 with mechanisms that have no initial challenge (or an empty initial
1571 challenge), as if it were the argument to an initial DATA command. If
1572 the selected mechanism has an initial challenge and [initial-response]
1573 was provided, the server should reject authentication by sending
1577 If authentication succeeds after exchanging DATA commands,
1578 an OK command must be sent to the client.
1581 The first octet received by the server after the \r\n of the BEGIN
1582 command from the client must be the first octet of the
1583 authenticated/encrypted stream of D-Bus messages.
1586 If BEGIN is received by the server, the first octet received
1587 by the client after the \r\n of the OK command must be the
1588 first octet of the authenticated/encrypted stream of D-Bus
1592 <sect2 id="auth-command-cancel">
1593 <title>CANCEL Command</title>
1595 At any time up to sending the BEGIN command, the client may send a
1596 CANCEL command. On receiving the CANCEL command, the server must
1597 send a REJECTED command and abort the current authentication
1601 <sect2 id="auth-command-data">
1602 <title>DATA Command</title>
1604 The DATA command may come from either client or server, and simply
1605 contains a hex-encoded block of data to be interpreted
1606 according to the SASL mechanism in use.
1609 Some SASL mechanisms support sending an "empty string";
1610 FIXME we need some way to do this.
1613 <sect2 id="auth-command-begin">
1614 <title>BEGIN Command</title>
1616 The BEGIN command acknowledges that the client has received an
1617 OK command from the server, and that the stream of messages
1621 The first octet received by the server after the \r\n of the BEGIN
1622 command from the client must be the first octet of the
1623 authenticated/encrypted stream of D-Bus messages.
1626 <sect2 id="auth-command-rejected">
1627 <title>REJECTED Command</title>
1629 The REJECTED command indicates that the current authentication
1630 exchange has failed, and further exchange of DATA is inappropriate.
1631 The client would normally try another mechanism, or try providing
1632 different responses to challenges.
1634 Optionally, the REJECTED command has a space-separated list of
1635 available auth mechanisms as arguments. If a server ever provides
1636 a list of supported mechanisms, it must provide the same list
1637 each time it sends a REJECTED message. Clients are free to
1638 ignore all lists received after the first.
1641 <sect2 id="auth-command-ok">
1642 <title>OK Command</title>
1644 The OK command indicates that the client has been
1645 authenticated. The client may now proceed with negotiating
1646 Unix file descriptor passing. To do that it shall send
1647 NEGOTIATE_UNIX_FD to the server.
1650 Otherwise, the client must respond to the OK command by
1651 sending a BEGIN command, followed by its stream of messages,
1652 or by disconnecting. The server must not accept additional
1653 commands using this protocol after the BEGIN command has been
1654 received. Further communication will be a stream of D-Bus
1655 messages (optionally encrypted, as negotiated) rather than
1659 If a client sends BEGIN the first octet received by the client
1660 after the \r\n of the OK command must be the first octet of
1661 the authenticated/encrypted stream of D-Bus messages.
1664 The OK command has one argument, which is the GUID of the server.
1665 See <xref linkend="addresses"/> for more on server GUIDs.
1668 <sect2 id="auth-command-error">
1669 <title>ERROR Command</title>
1671 The ERROR command indicates that either server or client did not
1672 know a command, does not accept the given command in the current
1673 context, or did not understand the arguments to the command. This
1674 allows the protocol to be extended; a client or server can send a
1675 command present or permitted only in new protocol versions, and if
1676 an ERROR is received instead of an appropriate response, fall back
1677 to using some other technique.
1680 If an ERROR is sent, the server or client that sent the
1681 error must continue as if the command causing the ERROR had never been
1682 received. However, the the server or client receiving the error
1683 should try something other than whatever caused the error;
1684 if only canceling/rejecting the authentication.
1687 If the D-Bus protocol changes incompatibly at some future time,
1688 applications implementing the new protocol would probably be able to
1689 check for support of the new protocol by sending a new command and
1690 receiving an ERROR from applications that don't understand it. Thus the
1691 ERROR feature of the auth protocol is an escape hatch that lets us
1692 negotiate extensions or changes to the D-Bus protocol in the future.
1695 <sect2 id="auth-command-negotiate-unix-fd">
1696 <title>NEGOTIATE_UNIX_FD Command</title>
1698 The NEGOTIATE_UNIX_FD command indicates that the client
1699 supports Unix file descriptor passing. This command may only
1700 be sent after the connection is authenticated, i.e. after OK
1701 was received by the client. This command may only be sent on
1702 transports that support Unix file descriptor passing.
1705 On receiving NEGOTIATE_UNIX_FD the server must respond with
1706 either AGREE_UNIX_FD or ERROR. It shall respond the former if
1707 the transport chosen supports Unix file descriptor passing and
1708 the server supports this feature. It shall respond the latter
1709 if the transport does not support Unix file descriptor
1710 passing, the server does not support this feature, or the
1711 server decides not to enable file descriptor passing due to
1712 security or other reasons.
1715 <sect2 id="auth-command-agree-unix-fd">
1716 <title>AGREE_UNIX_FD Command</title>
1718 The AGREE_UNIX_FD command indicates that the server supports
1719 Unix file descriptor passing. This command may only be sent
1720 after the connection is authenticated, and the client sent
1721 NEGOTIATE_UNIX_FD to enable Unix file descriptor passing. This
1722 command may only be sent on transports that support Unix file
1726 On receiving AGREE_UNIX_FD the client must respond with BEGIN,
1727 followed by its stream of messages, or by disconnecting. The
1728 server must not accept additional commands using this protocol
1729 after the BEGIN command has been received. Further
1730 communication will be a stream of D-Bus messages (optionally
1731 encrypted, as negotiated) rather than this protocol.
1734 <sect2 id="auth-command-future">
1735 <title>Future Extensions</title>
1737 Future extensions to the authentication and negotiation
1738 protocol are possible. For that new commands may be
1739 introduced. If a client or server receives an unknown command
1740 it shall respond with ERROR and not consider this fatal. New
1741 commands may be introduced both before, and after
1742 authentication, i.e. both before and after the OK command.
1745 <sect2 id="auth-examples">
1746 <title>Authentication examples</title>
1750 <title>Example of successful magic cookie authentication</title>
1752 (MAGIC_COOKIE is a made up mechanism)
1754 C: AUTH MAGIC_COOKIE 3138363935333137393635383634
1760 <title>Example of finding out mechanisms then picking one</title>
1763 S: REJECTED KERBEROS_V4 SKEY
1764 C: AUTH SKEY 7ab83f32ee
1765 S: DATA 8799cabb2ea93e
1766 C: DATA 8ac876e8f68ee9809bfa876e6f9876g8fa8e76e98f
1772 <title>Example of client sends unknown command then falls back to regular auth</title>
1776 C: AUTH MAGIC_COOKIE 3736343435313230333039
1782 <title>Example of server doesn't support initial auth mechanism</title>
1784 C: AUTH MAGIC_COOKIE 3736343435313230333039
1785 S: REJECTED KERBEROS_V4 SKEY
1786 C: AUTH SKEY 7ab83f32ee
1787 S: DATA 8799cabb2ea93e
1788 C: DATA 8ac876e8f68ee9809bfa876e6f9876g8fa8e76e98f
1794 <title>Example of wrong password or the like followed by successful retry</title>
1796 C: AUTH MAGIC_COOKIE 3736343435313230333039
1797 S: REJECTED KERBEROS_V4 SKEY
1798 C: AUTH SKEY 7ab83f32ee
1799 S: DATA 8799cabb2ea93e
1800 C: DATA 8ac876e8f68ee9809bfa876e6f9876g8fa8e76e98f
1802 C: AUTH SKEY 7ab83f32ee
1803 S: DATA 8799cabb2ea93e
1804 C: DATA 8ac876e8f68ee9809bfa876e6f9876g8fa8e76e98f
1810 <title>Example of skey cancelled and restarted</title>
1812 C: AUTH MAGIC_COOKIE 3736343435313230333039
1813 S: REJECTED KERBEROS_V4 SKEY
1814 C: AUTH SKEY 7ab83f32ee
1815 S: DATA 8799cabb2ea93e
1818 C: AUTH SKEY 7ab83f32ee
1819 S: DATA 8799cabb2ea93e
1820 C: DATA 8ac876e8f68ee9809bfa876e6f9876g8fa8e76e98f
1826 <title>Example of successful magic cookie authentication with successful negotiation of Unix FD passing</title>
1828 (MAGIC_COOKIE is a made up mechanism)
1830 C: AUTH MAGIC_COOKIE 3138363935333137393635383634
1832 C: NEGOTIATE_UNIX_FD
1838 <title>Example of successful magic cookie authentication with unsuccessful negotiation of Unix FD passing</title>
1840 (MAGIC_COOKIE is a made up mechanism)
1842 C: AUTH MAGIC_COOKIE 3138363935333137393635383634
1844 C: NEGOTIATE_UNIX_FD
1851 <sect2 id="auth-states">
1852 <title>Authentication state diagrams</title>
1855 This section documents the auth protocol in terms of
1856 a state machine for the client and the server. This is
1857 probably the most robust way to implement the protocol.
1860 <sect3 id="auth-states-client">
1861 <title>Client states</title>
1864 To more precisely describe the interaction between the
1865 protocol state machine and the authentication mechanisms the
1866 following notation is used: MECH(CHALL) means that the
1867 server challenge CHALL was fed to the mechanism MECH, which
1873 CONTINUE(RESP) means continue the auth conversation
1874 and send RESP as the response to the server;
1880 OK(RESP) means that after sending RESP to the server
1881 the client side of the auth conversation is finished
1882 and the server should return "OK";
1888 ERROR means that CHALL was invalid and could not be
1894 Both RESP and CHALL may be empty.
1898 The Client starts by getting an initial response from the
1899 default mechanism and sends AUTH MECH RESP, or AUTH MECH if
1900 the mechanism did not provide an initial response. If the
1901 mechanism returns CONTINUE, the client starts in state
1902 <emphasis>WaitingForData</emphasis>, if the mechanism
1903 returns OK the client starts in state
1904 <emphasis>WaitingForOK</emphasis>.
1908 The client should keep track of available mechanisms and
1909 which it mechanisms it has already attempted. This list is
1910 used to decide which AUTH command to send. When the list is
1911 exhausted, the client should give up and close the
1916 <title><emphasis>WaitingForData</emphasis></title>
1924 MECH(CHALL) returns CONTINUE(RESP) → send
1926 <emphasis>WaitingForData</emphasis>
1930 MECH(CHALL) returns OK(RESP) → send DATA
1931 RESP, goto <emphasis>WaitingForOK</emphasis>
1935 MECH(CHALL) returns ERROR → send ERROR
1936 [msg], goto <emphasis>WaitingForData</emphasis>
1944 Receive REJECTED [mechs] →
1945 send AUTH [next mech], goto
1946 WaitingForData or <emphasis>WaitingForOK</emphasis>
1951 Receive ERROR → send
1953 <emphasis>WaitingForReject</emphasis>
1958 Receive OK → send
1959 BEGIN, terminate auth
1960 conversation, authenticated
1965 Receive anything else → send
1967 <emphasis>WaitingForData</emphasis>
1975 <title><emphasis>WaitingForOK</emphasis></title>
1980 Receive OK → send BEGIN, terminate auth
1981 conversation, <emphasis>authenticated</emphasis>
1986 Receive REJECT [mechs] → send AUTH [next mech],
1987 goto <emphasis>WaitingForData</emphasis> or
1988 <emphasis>WaitingForOK</emphasis>
1994 Receive DATA → send CANCEL, goto
1995 <emphasis>WaitingForReject</emphasis>
2001 Receive ERROR → send CANCEL, goto
2002 <emphasis>WaitingForReject</emphasis>
2008 Receive anything else → send ERROR, goto
2009 <emphasis>WaitingForOK</emphasis>
2017 <title><emphasis>WaitingForReject</emphasis></title>
2022 Receive REJECT [mechs] → send AUTH [next mech],
2023 goto <emphasis>WaitingForData</emphasis> or
2024 <emphasis>WaitingForOK</emphasis>
2030 Receive anything else → terminate auth
2031 conversation, disconnect
2040 <sect3 id="auth-states-server">
2041 <title>Server states</title>
2044 For the server MECH(RESP) means that the client response
2045 RESP was fed to the the mechanism MECH, which returns one of
2050 CONTINUE(CHALL) means continue the auth conversation and
2051 send CHALL as the challenge to the client;
2057 OK means that the client has been successfully
2064 REJECT means that the client failed to authenticate or
2065 there was an error in RESP.
2070 The server starts out in state
2071 <emphasis>WaitingForAuth</emphasis>. If the client is
2072 rejected too many times the server must disconnect the
2077 <title><emphasis>WaitingForAuth</emphasis></title>
2083 Receive AUTH → send REJECTED [mechs], goto
2084 <emphasis>WaitingForAuth</emphasis>
2090 Receive AUTH MECH RESP
2094 MECH not valid mechanism → send REJECTED
2096 <emphasis>WaitingForAuth</emphasis>
2100 MECH(RESP) returns CONTINUE(CHALL) → send
2102 <emphasis>WaitingForData</emphasis>
2106 MECH(RESP) returns OK → send OK, goto
2107 <emphasis>WaitingForBegin</emphasis>
2111 MECH(RESP) returns REJECT → send REJECTED
2113 <emphasis>WaitingForAuth</emphasis>
2121 Receive BEGIN → terminate
2122 auth conversation, disconnect
2128 Receive ERROR → send REJECTED [mechs], goto
2129 <emphasis>WaitingForAuth</emphasis>
2135 Receive anything else → send
2137 <emphasis>WaitingForAuth</emphasis>
2146 <title><emphasis>WaitingForData</emphasis></title>
2154 MECH(RESP) returns CONTINUE(CHALL) → send
2156 <emphasis>WaitingForData</emphasis>
2160 MECH(RESP) returns OK → send OK, goto
2161 <emphasis>WaitingForBegin</emphasis>
2165 MECH(RESP) returns REJECT → send REJECTED
2167 <emphasis>WaitingForAuth</emphasis>
2175 Receive BEGIN → terminate auth conversation,
2182 Receive CANCEL → send REJECTED [mechs], goto
2183 <emphasis>WaitingForAuth</emphasis>
2189 Receive ERROR → send REJECTED [mechs], goto
2190 <emphasis>WaitingForAuth</emphasis>
2196 Receive anything else → send ERROR, goto
2197 <emphasis>WaitingForData</emphasis>
2205 <title><emphasis>WaitingForBegin</emphasis></title>
2210 Receive BEGIN → terminate auth conversation,
2211 client authenticated
2217 Receive CANCEL → send REJECTED [mechs], goto
2218 <emphasis>WaitingForAuth</emphasis>
2224 Receive ERROR → send REJECTED [mechs], goto
2225 <emphasis>WaitingForAuth</emphasis>
2231 Receive anything else → send ERROR, goto
2232 <emphasis>WaitingForBegin</emphasis>
2242 <sect2 id="auth-mechanisms">
2243 <title>Authentication mechanisms</title>
2245 This section describes some new authentication mechanisms.
2246 D-Bus also allows any standard SASL mechanism of course.
2248 <sect3 id="auth-mechanisms-sha">
2249 <title>DBUS_COOKIE_SHA1</title>
2251 The DBUS_COOKIE_SHA1 mechanism is designed to establish that a client
2252 has the ability to read a private file owned by the user being
2253 authenticated. If the client can prove that it has access to a secret
2254 cookie stored in this file, then the client is authenticated.
2255 Thus the security of DBUS_COOKIE_SHA1 depends on a secure home
2259 Throughout this description, "hex encoding" must output the digits
2260 from a to f in lower-case; the digits A to F must not be used
2261 in the DBUS_COOKIE_SHA1 mechanism.
2264 Authentication proceeds as follows:
2268 The client sends the username it would like to authenticate
2274 The server sends the name of its "cookie context" (see below); a
2275 space character; the integer ID of the secret cookie the client
2276 must demonstrate knowledge of; a space character; then a
2277 randomly-generated challenge string, all of this hex-encoded into
2283 The client locates the cookie and generates its own
2284 randomly-generated challenge string. The client then concatenates
2285 the server's decoded challenge, a ":" character, its own challenge,
2286 another ":" character, and the cookie. It computes the SHA-1 hash
2287 of this composite string as a hex digest. It concatenates the
2288 client's challenge string, a space character, and the SHA-1 hex
2289 digest, hex-encodes the result and sends it back to the server.
2294 The server generates the same concatenated string used by the
2295 client and computes its SHA-1 hash. It compares the hash with
2296 the hash received from the client; if the two hashes match, the
2297 client is authenticated.
2303 Each server has a "cookie context," which is a name that identifies a
2304 set of cookies that apply to that server. A sample context might be
2305 "org_freedesktop_session_bus". Context names must be valid ASCII,
2306 nonzero length, and may not contain the characters slash ("/"),
2307 backslash ("\"), space (" "), newline ("\n"), carriage return ("\r"),
2308 tab ("\t"), or period ("."). There is a default context,
2309 "org_freedesktop_general" that's used by servers that do not specify
2313 Cookies are stored in a user's home directory, in the directory
2314 <filename>~/.dbus-keyrings/</filename>. This directory must
2315 not be readable or writable by other users. If it is,
2316 clients and servers must ignore it. The directory
2317 contains cookie files named after the cookie context.
2320 A cookie file contains one cookie per line. Each line
2321 has three space-separated fields:
2325 The cookie ID number, which must be a non-negative integer and
2326 may not be used twice in the same file.
2331 The cookie's creation time, in UNIX seconds-since-the-epoch
2337 The cookie itself, a hex-encoded random block of bytes. The cookie
2338 may be of any length, though obviously security increases
2339 as the length increases.
2345 Only server processes modify the cookie file.
2346 They must do so with this procedure:
2350 Create a lockfile name by appending ".lock" to the name of the
2351 cookie file. The server should attempt to create this file
2352 using <literal>O_CREAT | O_EXCL</literal>. If file creation
2353 fails, the lock fails. Servers should retry for a reasonable
2354 period of time, then they may choose to delete an existing lock
2355 to keep users from having to manually delete a stale
2356 lock. <footnote><para>Lockfiles are used instead of real file
2357 locking <literal>fcntl()</literal> because real locking
2358 implementations are still flaky on network
2359 filesystems.</para></footnote>
2364 Once the lockfile has been created, the server loads the cookie
2365 file. It should then delete any cookies that are old (the
2366 timeout can be fairly short), or more than a reasonable
2367 time in the future (so that cookies never accidentally
2368 become permanent, if the clock was set far into the future
2369 at some point). If no recent keys remain, the
2370 server may generate a new key.
2375 The pruned and possibly added-to cookie file
2376 must be resaved atomically (using a temporary
2377 file which is rename()'d).
2382 The lock must be dropped by deleting the lockfile.
2388 Clients need not lock the file in order to load it,
2389 because servers are required to save the file atomically.
2394 <sect1 id="addresses">
2395 <title>Server Addresses</title>
2397 Server addresses consist of a transport name followed by a colon, and
2398 then an optional, comma-separated list of keys and values in the form key=value.
2399 Each value is escaped.
2403 <programlisting>unix:path=/tmp/dbus-test</programlisting>
2404 Which is the address to a unix socket with the path /tmp/dbus-test.
2407 Value escaping is similar to URI escaping but simpler.
2411 The set of optionally-escaped bytes is:
2412 <literal>[0-9A-Za-z_-/.\]</literal>. To escape, each
2413 <emphasis>byte</emphasis> (note, not character) which is not in the
2414 set of optionally-escaped bytes must be replaced with an ASCII
2415 percent (<literal>%</literal>) and the value of the byte in hex.
2416 The hex value must always be two digits, even if the first digit is
2417 zero. The optionally-escaped bytes may be escaped if desired.
2422 To unescape, append each byte in the value; if a byte is an ASCII
2423 percent (<literal>%</literal>) character then append the following
2424 hex value instead. It is an error if a <literal>%</literal> byte
2425 does not have two hex digits following. It is an error if a
2426 non-optionally-escaped byte is seen unescaped.
2430 The set of optionally-escaped bytes is intended to preserve address
2431 readability and convenience.
2435 A server may specify a key-value pair with the key <literal>guid</literal>
2436 and the value a hex-encoded 16-byte sequence. <xref linkend="uuids"/>
2437 describes the format of the <literal>guid</literal> field. If present,
2438 this UUID may be used to distinguish one server address from another. A
2439 server should use a different UUID for each address it listens on. For
2440 example, if a message bus daemon offers both UNIX domain socket and TCP
2441 connections, but treats clients the same regardless of how they connect,
2442 those two connections are equivalent post-connection but should have
2443 distinct UUIDs to distinguish the kinds of connection.
2447 The intent of the address UUID feature is to allow a client to avoid
2448 opening multiple identical connections to the same server, by allowing the
2449 client to check whether an address corresponds to an already-existing
2450 connection. Comparing two addresses is insufficient, because addresses
2451 can be recycled by distinct servers, and equivalent addresses may look
2452 different if simply compared as strings (for example, the host in a TCP
2453 address can be given as an IP address or as a hostname).
2457 Note that the address key is <literal>guid</literal> even though the
2458 rest of the API and documentation says "UUID," for historical reasons.
2462 [FIXME clarify if attempting to connect to each is a requirement
2463 or just a suggestion]
2464 When connecting to a server, multiple server addresses can be
2465 separated by a semi-colon. The library will then try to connect
2466 to the first address and if that fails, it'll try to connect to
2467 the next one specified, and so forth. For example
2468 <programlisting>unix:path=/tmp/dbus-test;unix:path=/tmp/dbus-test2</programlisting>
2473 <sect1 id="transports">
2474 <title>Transports</title>
2476 [FIXME we need to specify in detail each transport and its possible arguments]
2478 Current transports include: unix domain sockets (including
2479 abstract namespace on linux), launchd, TCP/IP, and a debug/testing transport
2480 using in-process pipes. Future possible transports include one that
2481 tunnels over X11 protocol.
2484 <sect2 id="transports-unix-domain-sockets">
2485 <title>Unix Domain Sockets</title>
2487 Unix domain sockets can be either paths in the file system or on Linux
2488 kernels, they can be abstract which are similar to paths but
2489 do not show up in the file system.
2493 When a socket is opened by the D-Bus library it truncates the path
2494 name right before the first trailing Nul byte. This is true for both
2495 normal paths and abstract paths. Note that this is a departure from
2496 previous versions of D-Bus that would create sockets with a fixed
2497 length path name. Names which were shorter than the fixed length
2498 would be padded by Nul bytes.
2501 Unix domain sockets are not available on windows.
2503 <sect3 id="transports-unix-domain-sockets-addresses">
2504 <title>Server Address Format</title>
2506 Unix domain socket addresses are identified by the "unix:" prefix
2507 and support the following key/value pairs:
2514 <entry>Values</entry>
2515 <entry>Description</entry>
2521 <entry>(path)</entry>
2522 <entry>path of the unix domain socket. If set, the "tmpdir" and "abstract" key must not be set.</entry>
2525 <entry>tmpdir</entry>
2526 <entry>(path)</entry>
2527 <entry>temporary directory in which a socket file with a random file name starting with 'dbus-' will be created by the server. This key can only be used in server addresses, not in client addresses. If set, the "path" and "abstract" key must not be set.</entry>
2530 <entry>abstract</entry>
2531 <entry>(string)</entry>
2532 <entry>unique string (path) in the abstract namespace. If set, the "path" or "tempdir" key must not be set.</entry>
2539 <sect2 id="transports-launchd">
2540 <title>launchd</title>
2542 launchd is a open-source server management system that replaces init, inetd
2543 and cron on Apple Mac OS X versions 10.4 and above. It provides a common session
2544 bus address for each user and deprecates the X11-enabled D-Bus launcher on OSX.
2548 launchd allocates a socket and provides it with the unix path through the
2549 DBUS_LAUNCHD_SESSION_BUS_SOCKET variable in launchd's environment. Every process
2550 spawned by launchd (or dbus-daemon, if it was started by launchd) can access
2551 it through its environment.
2552 Other processes can query for the launchd socket by executing:
2553 $ launchctl getenv DBUS_LAUNCHD_SESSION_BUS_SOCKET
2554 This is normally done by the D-Bus client library so doesn't have to be done
2558 launchd is not available on Microsoft Windows.
2560 <sect3 id="transports-launchd-addresses">
2561 <title>Server Address Format</title>
2563 launchd addresses are identified by the "launchd:" prefix
2564 and support the following key/value pairs:
2571 <entry>Values</entry>
2572 <entry>Description</entry>
2578 <entry>(environment variable)</entry>
2579 <entry>path of the unix domain socket for the launchd created dbus-daemon.</entry>
2586 <sect2 id="transports-tcp-sockets">
2587 <title>TCP Sockets</title>
2589 The tcp transport provides TCP/IP based connections between clients
2590 located on the same or different hosts.
2593 Using tcp transport without any additional secure authentification mechanismus
2594 over a network is unsecure.
2597 Windows notes: Because of the tcp stack on windows does not provide sending
2598 credentials over a tcp connection, the EXTERNAL authentification
2599 mechanismus does not work.
2601 <sect3 id="transports-tcp-sockets-addresses">
2602 <title>Server Address Format</title>
2604 TCP/IP socket addresses are identified by the "tcp:" prefix
2605 and support the following key/value pairs:
2612 <entry>Values</entry>
2613 <entry>Description</entry>
2619 <entry>(string)</entry>
2620 <entry>dns name or ip address</entry>
2624 <entry>(number)</entry>
2625 <entry>The tcp port the server will open. A zero value let the server
2626 choose a free port provided from the underlaying operating system.
2627 libdbus is able to retrieve the real used port from the server.
2631 <entry>family</entry>
2632 <entry>(string)</entry>
2633 <entry>If set, provide the type of socket family either "ipv4" or "ipv6". If unset, the family is unspecified.</entry>
2640 <sect2 id="transports-nonce-tcp-sockets">
2641 <title>Nonce-secured TCP Sockets</title>
2643 The nonce-tcp transport provides a secured TCP transport, using a
2644 simple authentication mechanism to ensure that only clients with read
2645 access to a certain location in the filesystem can connect to the server.
2646 The server writes a secret, the nonce, to a file and an incoming client
2647 connection is only accepted if the client sends the nonce right after
2648 the connect. The nonce mechanism requires no setup and is orthogonal to
2649 the higher-level authentication mechanisms described in the
2650 Authentication section.
2654 On start, the server generates a random 16 byte nonce and writes it
2655 to a file in the user's temporary directory. The nonce file location
2656 is published as part of the server's D-Bus address using the
2657 "noncefile" key-value pair.
2659 After an accept, the server reads 16 bytes from the socket. If the
2660 read bytes do not match the nonce stored in the nonce file, the
2661 server MUST immediately drop the connection.
2662 If the nonce match the received byte sequence, the client is accepted
2663 and the transport behaves like an unsecured tcp transport.
2666 After a successful connect to the server socket, the client MUST read
2667 the nonce from the file published by the server via the noncefile=
2668 key-value pair and send it over the socket. After that, the
2669 transport behaves like an unsecured tcp transport.
2671 <sect3 id="transports-nonce-tcp-sockets-addresses">
2672 <title>Server Address Format</title>
2674 Nonce TCP/IP socket addresses uses the "nonce-tcp:" prefix
2675 and support the following key/value pairs:
2682 <entry>Values</entry>
2683 <entry>Description</entry>
2689 <entry>(string)</entry>
2690 <entry>dns name or ip address</entry>
2694 <entry>(number)</entry>
2695 <entry>The tcp port the server will open. A zero value let the server
2696 choose a free port provided from the underlaying operating system.
2697 libdbus is able to retrieve the real used port from the server.
2701 <entry>family</entry>
2702 <entry>(string)</entry>
2703 <entry>If set, provide the type of socket family either "ipv4" or "ipv6". If unset, the family is unspecified.</entry>
2706 <entry>noncefile</entry>
2707 <entry>(path)</entry>
2708 <entry>file location containing the secret</entry>
2716 <sect1 id="meta-transports">
2717 <title>Meta Transports</title>
2719 Meta transports are a kind of transport with special enhancements or
2720 behavior. Currently available meta transports include: autolaunch
2723 <sect2 id="meta-transports-autolaunch">
2724 <title>Autolaunch</title>
2725 <para>The autolaunch transport provides a way for dbus clients to autodetect
2726 a running dbus session bus and to autolaunch a session bus if not present.
2728 <sect3 id="meta-transports-autolaunch-addresses">
2729 <title>Server Address Format</title>
2731 Autolaunch addresses uses the "autolaunch:" prefix and support the
2732 following key/value pairs:
2739 <entry>Values</entry>
2740 <entry>Description</entry>
2745 <entry>scope</entry>
2746 <entry>(string)</entry>
2747 <entry>scope of autolaunch (Windows only)
2751 "*install-path" - limit session bus to dbus installation path.
2752 The dbus installation path is determined from the location of
2753 the shared dbus library. If the library is located in a 'bin'
2754 subdirectory the installation root is the directory above,
2755 otherwise the directory where the library lives is taken as
2758 <install-root>/bin/[lib]dbus-1.dll
2759 <install-root>/[lib]dbus-1.dll
2765 "*user" - limit session bus to the recent user.
2770 other values - specify dedicated session bus like "release",
2782 <sect3 id="meta-transports-autolaunch-windows-implementation">
2783 <title>Windows implementation</title>
2785 On start, the server opens a platform specific transport, creates a mutex
2786 and a shared memory section containing the related session bus address.
2787 This mutex will be inspected by the dbus client library to detect a
2788 running dbus session bus. The access to the mutex and the shared memory
2789 section are protected by global locks.
2792 In the recent implementation the autolaunch transport uses a tcp transport
2793 on localhost with a port choosen from the operating system. This detail may
2794 change in the future.
2797 Disclaimer: The recent implementation is in an early state and may not
2798 work in all cirumstances and/or may have security issues. Because of this
2799 the implementation is not documentated yet.
2804 <sect1 id="naming-conventions">
2805 <title>Naming Conventions</title>
2808 D-Bus namespaces are all lowercase and correspond to reversed domain
2809 names, as with Java. e.g. "org.freedesktop"
2812 Interface, signal, method, and property names are "WindowsStyleCaps", note
2813 that the first letter is capitalized, unlike Java.
2816 Object paths are normally all lowercase with underscores used rather than
2822 <title>UUIDs</title>
2824 A working D-Bus implementation uses universally-unique IDs in two places.
2825 First, each server address has a UUID identifying the address,
2826 as described in <xref linkend="addresses"/>. Second, each operating
2827 system kernel instance running a D-Bus client or server has a UUID
2828 identifying that kernel, retrieved by invoking the method
2829 org.freedesktop.DBus.Peer.GetMachineId() (see <xref
2830 linkend="standard-interfaces-peer"/>).
2833 The term "UUID" in this document is intended literally, i.e. an
2834 identifier that is universally unique. It is not intended to refer to
2835 RFC4122, and in fact the D-Bus UUID is not compatible with that RFC.
2838 The UUID must contain 128 bits of data and be hex-encoded. The
2839 hex-encoded string may not contain hyphens or other non-hex-digit
2840 characters, and it must be exactly 32 characters long. To generate a
2841 UUID, the current reference implementation concatenates 96 bits of random
2842 data followed by the 32-bit time in seconds since the UNIX epoch (in big
2846 It would also be acceptable and probably better to simply generate 128
2847 bits of random data, as long as the random number generator is of high
2848 quality. The timestamp could conceivably help if the random bits are not
2849 very random. With a quality random number generator, collisions are
2850 extremely unlikely even with only 96 bits, so it's somewhat academic.
2853 Implementations should, however, stick to random data for the first 96 bits
2858 <sect1 id="standard-interfaces">
2859 <title>Standard Interfaces</title>
2861 See <xref linkend="message-protocol-types-notation"/> for details on
2862 the notation used in this section. There are some standard interfaces
2863 that may be useful across various D-Bus applications.
2865 <sect2 id="standard-interfaces-peer">
2866 <title><literal>org.freedesktop.DBus.Peer</literal></title>
2868 The <literal>org.freedesktop.DBus.Peer</literal> interface
2871 org.freedesktop.DBus.Peer.Ping ()
2872 org.freedesktop.DBus.Peer.GetMachineId (out STRING machine_uuid)
2876 On receipt of the <literal>METHOD_CALL</literal> message
2877 <literal>org.freedesktop.DBus.Peer.Ping</literal>, an application should do
2878 nothing other than reply with a <literal>METHOD_RETURN</literal> as
2879 usual. It does not matter which object path a ping is sent to. The
2880 reference implementation handles this method automatically.
2883 On receipt of the <literal>METHOD_CALL</literal> message
2884 <literal>org.freedesktop.DBus.Peer.GetMachineId</literal>, an application should
2885 reply with a <literal>METHOD_RETURN</literal> containing a hex-encoded
2886 UUID representing the identity of the machine the process is running on.
2887 This UUID must be the same for all processes on a single system at least
2888 until that system next reboots. It should be the same across reboots
2889 if possible, but this is not always possible to implement and is not
2891 It does not matter which object path a GetMachineId is sent to. The
2892 reference implementation handles this method automatically.
2895 The UUID is intended to be per-instance-of-the-operating-system, so may represent
2896 a virtual machine running on a hypervisor, rather than a physical machine.
2897 Basically if two processes see the same UUID, they should also see the same
2898 shared memory, UNIX domain sockets, process IDs, and other features that require
2899 a running OS kernel in common between the processes.
2902 The UUID is often used where other programs might use a hostname. Hostnames
2903 can change without rebooting, however, or just be "localhost" - so the UUID
2907 <xref linkend="uuids"/> explains the format of the UUID.
2911 <sect2 id="standard-interfaces-introspectable">
2912 <title><literal>org.freedesktop.DBus.Introspectable</literal></title>
2914 This interface has one method:
2916 org.freedesktop.DBus.Introspectable.Introspect (out STRING xml_data)
2920 Objects instances may implement
2921 <literal>Introspect</literal> which returns an XML description of
2922 the object, including its interfaces (with signals and methods), objects
2923 below it in the object path tree, and its properties.
2926 <xref linkend="introspection-format"/> describes the format of this XML string.
2929 <sect2 id="standard-interfaces-properties">
2930 <title><literal>org.freedesktop.DBus.Properties</literal></title>
2932 Many native APIs will have a concept of object <firstterm>properties</firstterm>
2933 or <firstterm>attributes</firstterm>. These can be exposed via the
2934 <literal>org.freedesktop.DBus.Properties</literal> interface.
2938 org.freedesktop.DBus.Properties.Get (in STRING interface_name,
2939 in STRING property_name,
2941 org.freedesktop.DBus.Properties.Set (in STRING interface_name,
2942 in STRING property_name,
2944 org.freedesktop.DBus.Properties.GetAll (in STRING interface_name,
2945 out DICT<STRING,VARIANT> props);
2949 The available properties and whether they are writable can be determined
2950 by calling <literal>org.freedesktop.DBus.Introspectable.Introspect</literal>,
2951 see <xref linkend="standard-interfaces-introspectable"/>.
2954 An empty string may be provided for the interface name; in this case,
2955 if there are multiple properties on an object with the same name,
2956 the results are undefined (picking one by according to an arbitrary
2957 deterministic rule, or returning an error, are the reasonable
2961 If one or more properties change on an object, the
2962 <literal>org.freedesktop.DBus.Properties.PropertiesChanged</literal>
2963 signal may be emitted (this signal was added in 0.14):
2967 org.freedesktop.DBus.Properties.PropertiesChanged (STRING interface_name,
2968 DICT<STRING,VARIANT> changed_properties,
2969 ARRAY<STRING> invalidated_properties);
2973 where <literal>changed_properties</literal> is a dictionary
2974 containing the changed properties with the new values and
2975 <literal>invalidated_properties</literal> is an array of
2976 properties that changed but the value is not conveyed.
2979 Whether the <literal>PropertiesChanged</literal> signal is
2980 supported can be determined by calling
2981 <literal>org.freedesktop.DBus.Introspectable.Introspect</literal>. Note
2982 that the signal may be supported for an object but it may
2983 differ how whether and how it is used on a per-property basis
2984 (for e.g. performance or security reasons). Each property (or
2985 the parent interface) must be annotated with the
2986 <literal>org.freedesktop.DBus.Property.EmitsChangedSignal</literal>
2987 annotation to convey this (usually the default value
2988 <literal>true</literal> is sufficient meaning that the
2989 annotation does not need to be used). See <xref
2990 linkend="introspection-format"/> for details on this
2996 <sect1 id="introspection-format">
2997 <title>Introspection Data Format</title>
2999 As described in <xref linkend="standard-interfaces-introspectable"/>,
3000 objects may be introspected at runtime, returning an XML string
3001 that describes the object. The same XML format may be used in
3002 other contexts as well, for example as an "IDL" for generating
3003 static language bindings.
3006 Here is an example of introspection data:
3008 <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
3009 "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
3010 <node name="/org/freedesktop/sample_object">
3011 <interface name="org.freedesktop.SampleInterface">
3012 <method name="Frobate">
3013 <arg name="foo" type="i" direction="in"/>
3014 <arg name="bar" type="s" direction="out"/>
3015 <arg name="baz" type="a{us}" direction="out"/>
3016 <annotation name="org.freedesktop.DBus.Deprecated" value="true"/>
3018 <method name="Bazify">
3019 <arg name="bar" type="(iiu)" direction="in"/>
3020 <arg name="bar" type="v" direction="out"/>
3022 <method name="Mogrify">
3023 <arg name="bar" type="(iiav)" direction="in"/>
3025 <signal name="Changed">
3026 <arg name="new_value" type="b"/>
3028 <property name="Bar" type="y" access="readwrite"/>
3030 <node name="child_of_sample_object"/>
3031 <node name="another_child_of_sample_object"/>
3036 A more formal DTD and spec needs writing, but here are some quick notes.
3040 Only the root <node> element can omit the node name, as it's
3041 known to be the object that was introspected. If the root
3042 <node> does have a name attribute, it must be an absolute
3043 object path. If child <node> have object paths, they must be
3049 If a child <node> has any sub-elements, then they
3050 must represent a complete introspection of the child.
3051 If a child <node> is empty, then it may or may
3052 not have sub-elements; the child must be introspected
3053 in order to find out. The intent is that if an object
3054 knows that its children are "fast" to introspect
3055 it can go ahead and return their information, but
3056 otherwise it can omit it.
3061 The direction element on <arg> may be omitted,
3062 in which case it defaults to "in" for method calls
3063 and "out" for signals. Signals only allow "out"
3064 so while direction may be specified, it's pointless.
3069 The possible directions are "in" and "out",
3070 unlike CORBA there is no "inout"
3075 The possible property access flags are
3076 "readwrite", "read", and "write"
3081 Multiple interfaces can of course be listed for
3087 The "name" attribute on arguments is optional.
3093 Method, interface, property, and signal elements may have
3094 "annotations", which are generic key/value pairs of metadata.
3095 They are similar conceptually to Java's annotations and C# attributes.
3096 Well-known annotations:
3103 <entry>Values (separated by ,)</entry>
3104 <entry>Description</entry>
3109 <entry>org.freedesktop.DBus.Deprecated</entry>
3110 <entry>true,false</entry>
3111 <entry>Whether or not the entity is deprecated; defaults to false</entry>
3114 <entry>org.freedesktop.DBus.GLib.CSymbol</entry>
3115 <entry>(string)</entry>
3116 <entry>The C symbol; may be used for methods and interfaces</entry>
3119 <entry>org.freedesktop.DBus.Method.NoReply</entry>
3120 <entry>true,false</entry>
3121 <entry>If set, don't expect a reply to the method call; defaults to false.</entry>
3124 <entry>org.freedesktop.DBus.Property.EmitsChangedSignal</entry>
3125 <entry>true,invalidates,false</entry>
3128 If set to <literal>false</literal>, the
3129 <literal>org.freedesktop.DBus.Properties.PropertiesChanged</literal>
3131 linkend="standard-interfaces-properties"/> is not
3132 guaranteed to be emitted if the property changes.
3135 If set to <literal>invalidates</literal> the signal
3136 is emitted but the value is not included in the
3140 If set to <literal>true</literal> the signal is
3141 emitted with the value included.
3144 The value for the annotation defaults to
3145 <literal>true</literal> if the enclosing interface
3146 element does not specify the annotation. Otherwise it
3147 defaults to the value specified in the enclosing
3156 <sect1 id="message-bus">
3157 <title>Message Bus Specification</title>
3158 <sect2 id="message-bus-overview">
3159 <title>Message Bus Overview</title>
3161 The message bus accepts connections from one or more applications.
3162 Once connected, applications can exchange messages with other
3163 applications that are also connected to the bus.
3166 In order to route messages among connections, the message bus keeps a
3167 mapping from names to connections. Each connection has one
3168 unique-for-the-lifetime-of-the-bus name automatically assigned.
3169 Applications may request additional names for a connection. Additional
3170 names are usually "well-known names" such as
3171 "org.freedesktop.TextEditor". When a name is bound to a connection,
3172 that connection is said to <firstterm>own</firstterm> the name.
3175 The bus itself owns a special name, <literal>org.freedesktop.DBus</literal>.
3176 This name routes messages to the bus, allowing applications to make
3177 administrative requests. For example, applications can ask the bus
3178 to assign a name to a connection.
3181 Each name may have <firstterm>queued owners</firstterm>. When an
3182 application requests a name for a connection and the name is already in
3183 use, the bus will optionally add the connection to a queue waiting for
3184 the name. If the current owner of the name disconnects or releases
3185 the name, the next connection in the queue will become the new owner.
3189 This feature causes the right thing to happen if you start two text
3190 editors for example; the first one may request "org.freedesktop.TextEditor",
3191 and the second will be queued as a possible owner of that name. When
3192 the first exits, the second will take over.
3196 Messages may have a <literal>DESTINATION</literal> field (see <xref
3197 linkend="message-protocol-header-fields"/>). If the
3198 <literal>DESTINATION</literal> field is present, it specifies a message
3199 recipient by name. Method calls and replies normally specify this field.
3200 The message bus must send messages (of any type) with the
3201 <literal>DESTINATION</literal> field set to the specified recipient,
3202 regardless of whether the recipient has set up a match rule matching
3207 Signals normally do not specify a destination; they are sent to all
3208 applications with <firstterm>message matching rules</firstterm> that
3213 When the message bus receives a method call, if the
3214 <literal>DESTINATION</literal> field is absent, the call is taken to be
3215 a standard one-to-one message and interpreted by the message bus
3216 itself. For example, sending an
3217 <literal>org.freedesktop.DBus.Peer.Ping</literal> message with no
3218 <literal>DESTINATION</literal> will cause the message bus itself to
3219 reply to the ping immediately; the message bus will not make this
3220 message visible to other applications.
3224 Continuing the <literal>org.freedesktop.DBus.Peer.Ping</literal> example, if
3225 the ping message were sent with a <literal>DESTINATION</literal> name of
3226 <literal>com.yoyodyne.Screensaver</literal>, then the ping would be
3227 forwarded, and the Yoyodyne Corporation screensaver application would be
3228 expected to reply to the ping.
3232 <sect2 id="message-bus-names">
3233 <title>Message Bus Names</title>
3235 Each connection has at least one name, assigned at connection time and
3236 returned in response to the
3237 <literal>org.freedesktop.DBus.Hello</literal> method call. This
3238 automatically-assigned name is called the connection's <firstterm>unique
3239 name</firstterm>. Unique names are never reused for two different
3240 connections to the same bus.
3243 Ownership of a unique name is a prerequisite for interaction with
3244 the message bus. It logically follows that the unique name is always
3245 the first name that an application comes to own, and the last
3246 one that it loses ownership of.
3249 Unique connection names must begin with the character ':' (ASCII colon
3250 character); bus names that are not unique names must not begin
3251 with this character. (The bus must reject any attempt by an application
3252 to manually request a name beginning with ':'.) This restriction
3253 categorically prevents "spoofing"; messages sent to a unique name
3254 will always go to the expected connection.
3257 When a connection is closed, all the names that it owns are deleted (or
3258 transferred to the next connection in the queue if any).
3261 A connection can request additional names to be associated with it using
3262 the <literal>org.freedesktop.DBus.RequestName</literal> message. <xref
3263 linkend="message-protocol-names-bus"/> describes the format of a valid
3264 name. These names can be released again using the
3265 <literal>org.freedesktop.DBus.ReleaseName</literal> message.
3268 <sect3 id="bus-messages-request-name">
3269 <title><literal>org.freedesktop.DBus.RequestName</literal></title>
3273 UINT32 RequestName (in STRING name, in UINT32 flags)
3280 <entry>Argument</entry>
3282 <entry>Description</entry>
3288 <entry>STRING</entry>
3289 <entry>Name to request</entry>
3293 <entry>UINT32</entry>
3294 <entry>Flags</entry>
3304 <entry>Argument</entry>
3306 <entry>Description</entry>
3312 <entry>UINT32</entry>
3313 <entry>Return value</entry>
3320 This method call should be sent to
3321 <literal>org.freedesktop.DBus</literal> and asks the message bus to
3322 assign the given name to the method caller. Each name maintains a
3323 queue of possible owners, where the head of the queue is the primary
3324 or current owner of the name. Each potential owner in the queue
3325 maintains the DBUS_NAME_FLAG_ALLOW_REPLACEMENT and
3326 DBUS_NAME_FLAG_DO_NOT_QUEUE settings from its latest RequestName
3327 call. When RequestName is invoked the following occurs:
3331 If the method caller is currently the primary owner of the name,
3332 the DBUS_NAME_FLAG_ALLOW_REPLACEMENT and DBUS_NAME_FLAG_DO_NOT_QUEUE
3333 values are updated with the values from the new RequestName call,
3334 and nothing further happens.
3340 If the current primary owner (head of the queue) has
3341 DBUS_NAME_FLAG_ALLOW_REPLACEMENT set, and the RequestName
3342 invocation has the DBUS_NAME_FLAG_REPLACE_EXISTING flag, then
3343 the caller of RequestName replaces the current primary owner at
3344 the head of the queue and the current primary owner moves to the
3345 second position in the queue. If the caller of RequestName was
3346 in the queue previously its flags are updated with the values from
3347 the new RequestName in addition to moving it to the head of the queue.
3353 If replacement is not possible, and the method caller is
3354 currently in the queue but not the primary owner, its flags are
3355 updated with the values from the new RequestName call.
3361 If replacement is not possible, and the method caller is
3362 currently not in the queue, the method caller is appended to the
3369 If any connection in the queue has DBUS_NAME_FLAG_DO_NOT_QUEUE
3370 set and is not the primary owner, it is removed from the
3371 queue. This can apply to the previous primary owner (if it
3372 was replaced) or the method caller (if it updated the
3373 DBUS_NAME_FLAG_DO_NOT_QUEUE flag while still stuck in the
3374 queue, or if it was just added to the queue with that flag set).
3380 Note that DBUS_NAME_FLAG_REPLACE_EXISTING results in "jumping the
3381 queue," even if another application already in the queue had specified
3382 DBUS_NAME_FLAG_REPLACE_EXISTING. This comes up if a primary owner
3383 that does not allow replacement goes away, and the next primary owner
3384 does allow replacement. In this case, queued items that specified
3385 DBUS_NAME_FLAG_REPLACE_EXISTING <emphasis>do not</emphasis>
3386 automatically replace the new primary owner. In other words,
3387 DBUS_NAME_FLAG_REPLACE_EXISTING is not saved, it is only used at the
3388 time RequestName is called. This is deliberate to avoid an infinite loop
3389 anytime two applications are both DBUS_NAME_FLAG_ALLOW_REPLACEMENT
3390 and DBUS_NAME_FLAG_REPLACE_EXISTING.
3393 The flags argument contains any of the following values logically ORed
3400 <entry>Conventional Name</entry>
3401 <entry>Value</entry>
3402 <entry>Description</entry>
3407 <entry>DBUS_NAME_FLAG_ALLOW_REPLACEMENT</entry>
3411 If an application A specifies this flag and succeeds in
3412 becoming the owner of the name, and another application B
3413 later calls RequestName with the
3414 DBUS_NAME_FLAG_REPLACE_EXISTING flag, then application A
3415 will lose ownership and receive a
3416 <literal>org.freedesktop.DBus.NameLost</literal> signal, and
3417 application B will become the new owner. If DBUS_NAME_FLAG_ALLOW_REPLACEMENT
3418 is not specified by application A, or DBUS_NAME_FLAG_REPLACE_EXISTING
3419 is not specified by application B, then application B will not replace
3420 application A as the owner.
3425 <entry>DBUS_NAME_FLAG_REPLACE_EXISTING</entry>
3429 Try to replace the current owner if there is one. If this
3430 flag is not set the application will only become the owner of
3431 the name if there is no current owner. If this flag is set,
3432 the application will replace the current owner if
3433 the current owner specified DBUS_NAME_FLAG_ALLOW_REPLACEMENT.
3438 <entry>DBUS_NAME_FLAG_DO_NOT_QUEUE</entry>
3442 Without this flag, if an application requests a name that is
3443 already owned, the application will be placed in a queue to
3444 own the name when the current owner gives it up. If this
3445 flag is given, the application will not be placed in the
3446 queue, the request for the name will simply fail. This flag
3447 also affects behavior when an application is replaced as
3448 name owner; by default the application moves back into the
3449 waiting queue, unless this flag was provided when the application
3450 became the name owner.
3458 The return code can be one of the following values:
3464 <entry>Conventional Name</entry>
3465 <entry>Value</entry>
3466 <entry>Description</entry>
3471 <entry>DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER</entry>
3472 <entry>1</entry> <entry>The caller is now the primary owner of
3473 the name, replacing any previous owner. Either the name had no
3474 owner before, or the caller specified
3475 DBUS_NAME_FLAG_REPLACE_EXISTING and the current owner specified
3476 DBUS_NAME_FLAG_ALLOW_REPLACEMENT.</entry>
3479 <entry>DBUS_REQUEST_NAME_REPLY_IN_QUEUE</entry>
3482 <entry>The name already had an owner,
3483 DBUS_NAME_FLAG_DO_NOT_QUEUE was not specified, and either
3484 the current owner did not specify
3485 DBUS_NAME_FLAG_ALLOW_REPLACEMENT or the requesting
3486 application did not specify DBUS_NAME_FLAG_REPLACE_EXISTING.
3490 <entry>DBUS_REQUEST_NAME_REPLY_EXISTS</entry> <entry>3</entry>
3491 <entry>The name already has an owner,
3492 DBUS_NAME_FLAG_DO_NOT_QUEUE was specified, and either
3493 DBUS_NAME_FLAG_ALLOW_REPLACEMENT was not specified by the
3494 current owner, or DBUS_NAME_FLAG_REPLACE_EXISTING was not
3495 specified by the requesting application.</entry>
3498 <entry>DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER</entry>
3500 <entry>The application trying to request ownership of a name is already the owner of it.</entry>
3508 <sect3 id="bus-messages-release-name">
3509 <title><literal>org.freedesktop.DBus.ReleaseName</literal></title>
3513 UINT32 ReleaseName (in STRING name)
3520 <entry>Argument</entry>
3522 <entry>Description</entry>
3528 <entry>STRING</entry>
3529 <entry>Name to release</entry>
3539 <entry>Argument</entry>
3541 <entry>Description</entry>
3547 <entry>UINT32</entry>
3548 <entry>Return value</entry>
3555 This method call should be sent to
3556 <literal>org.freedesktop.DBus</literal> and asks the message bus to
3557 release the method caller's claim to the given name. If the caller is
3558 the primary owner, a new primary owner will be selected from the
3559 queue if any other owners are waiting. If the caller is waiting in
3560 the queue for the name, the caller will removed from the queue and
3561 will not be made an owner of the name if it later becomes available.
3562 If there are no other owners in the queue for the name, it will be
3563 removed from the bus entirely.
3565 The return code can be one of the following values:
3571 <entry>Conventional Name</entry>
3572 <entry>Value</entry>
3573 <entry>Description</entry>
3578 <entry>DBUS_RELEASE_NAME_REPLY_RELEASED</entry>
3579 <entry>1</entry> <entry>The caller has released his claim on
3580 the given name. Either the caller was the primary owner of
3581 the name, and the name is now unused or taken by somebody
3582 waiting in the queue for the name, or the caller was waiting
3583 in the queue for the name and has now been removed from the
3587 <entry>DBUS_RELEASE_NAME_REPLY_NON_EXISTENT</entry>
3589 <entry>The given name does not exist on this bus.</entry>
3592 <entry>DBUS_RELEASE_NAME_REPLY_NOT_OWNER</entry>
3594 <entry>The caller was not the primary owner of this name,
3595 and was also not waiting in the queue to own this name.</entry>
3603 <sect3 id="bus-messages-list-queued-owners">
3604 <title><literal>org.freedesktop.DBus.ListQueuedOwners</literal></title>
3608 ARRAY of STRING ListQueuedOwners (in STRING name)
3615 <entry>Argument</entry>
3617 <entry>Description</entry>
3623 <entry>STRING</entry>
3624 <entry>The well-known bus name to query, such as
3625 <literal>com.example.cappuccino</literal></entry>
3635 <entry>Argument</entry>
3637 <entry>Description</entry>
3643 <entry>ARRAY of STRING</entry>
3644 <entry>The unique bus names of connections currently queued
3645 for the name</entry>
3652 This method call should be sent to
3653 <literal>org.freedesktop.DBus</literal> and lists the connections
3654 currently queued for a bus name (see
3655 <xref linkend="term-queued-owner"/>).
3660 <sect2 id="message-bus-routing">
3661 <title>Message Bus Message Routing</title>
3665 <sect3 id="message-bus-routing-match-rules">
3666 <title>Match Rules</title>
3668 An important part of the message bus routing protocol is match
3669 rules. Match rules describe what messages can be sent to a client
3670 based on the contents of the message. When a message is routed
3671 through the bus it is compared to clients' match rules. If any
3672 of the rules match, the message is dispatched to the client.
3673 If none of the rules match the message never leaves the bus. This
3674 is an effective way to control traffic over the bus and to make sure
3675 only relevant message need to be processed by the client.
3678 Match rules are added using the AddMatch bus method
3679 (see <xref linkend="bus-messages-add-match"/>). Rules are
3680 specified as a string of comma separated key/value pairs.
3681 Excluding a key from the rule indicates a wildcard match.
3682 For instance excluding the the member from a match rule but
3683 adding a sender would let all messages from that sender through.
3684 An example of a complete rule would be
3685 "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='Foo',path='/bar/foo',destination=':452345.34',arg2='bar'"
3688 The following table describes the keys that can be used to create
3690 The following table summarizes the D-Bus types.
3696 <entry>Possible Values</entry>
3697 <entry>Description</entry>
3702 <entry><literal>type</literal></entry>
3703 <entry>'signal', 'method_call', 'method_return', 'error'</entry>
3704 <entry>Match on the message type. An example of a type match is type='signal'</entry>
3707 <entry><literal>sender</literal></entry>
3708 <entry>A bus or unique name (see <xref linkend="term-bus-name"/>
3709 and <xref linkend="term-unique-name"/> respectively)
3711 <entry>Match messages sent by a particular sender. An example of a sender match
3712 is sender='org.freedesktop.Hal'</entry>
3715 <entry><literal>interface</literal></entry>
3716 <entry>An interface name (see <xref linkend="message-protocol-names-interface"/>)</entry>
3717 <entry>Match messages sent over or to a particular interface. An example of an
3718 interface match is interface='org.freedesktop.Hal.Manager'.
3719 If a message omits the interface header, it must not match any rule
3720 that specifies this key.</entry>
3723 <entry><literal>member</literal></entry>
3724 <entry>Any valid method or signal name</entry>
3725 <entry>Matches messages which have the give method or signal name. An example of
3726 a member match is member='NameOwnerChanged'</entry>
3729 <entry><literal>path</literal></entry>
3730 <entry>An object path (see <xref linkend="message-protocol-marshaling-object-path"/>)</entry>
3731 <entry>Matches messages which are sent from or to the given object. An example of a
3732 path match is path='/org/freedesktop/Hal/Manager'</entry>
3735 <entry><literal>path_namespace</literal></entry>
3736 <entry>An object path</entry>
3739 Matches messages which are sent from or to an
3740 object for which the object path is either the
3741 given value, or that value followed by one or
3742 more path components.
3747 <literal>path_namespace='/com/example/foo'</literal>
3748 would match signals sent by
3749 <literal>/com/example/foo</literal>
3751 <literal>/com/example/foo/bar</literal>,
3753 <literal>/com/example/foobar</literal>.
3757 Using both <literal>path</literal> and
3758 <literal>path_namespace</literal> in the same match
3759 rule is not allowed.
3764 This match key was added in version 0.16 of the
3765 D-Bus specification and implemented by the bus
3766 daemon in dbus 1.5.0 and later.
3772 <entry><literal>destination</literal></entry>
3773 <entry>A unique name (see <xref linkend="term-unique-name"/>)</entry>
3774 <entry>Matches messages which are being sent to the given unique name. An
3775 example of a destination match is destination=':1.0'</entry>
3778 <entry><literal>arg[0, 1, 2, 3, ...]</literal></entry>
3779 <entry>Any string</entry>
3780 <entry>Arg matches are special and are used for further restricting the
3781 match based on the arguments in the body of a message. Only arguments of type
3782 STRING can be matched in this way. An example of an argument match
3783 would be arg3='Foo'. Only argument indexes from 0 to 63 should be
3787 <entry><literal>arg[0, 1, 2, 3, ...]path</literal></entry>
3788 <entry>Any string</entry>
3790 <para>Argument path matches provide a specialised form of wildcard matching for
3791 path-like namespaces. They can match arguments whose type is either STRING or
3792 OBJECT_PATH. As with normal argument matches,
3793 if the argument is exactly equal to the string given in the match
3794 rule then the rule is satisfied. Additionally, there is also a
3795 match when either the string given in the match rule or the
3796 appropriate message argument ends with '/' and is a prefix of the
3797 other. An example argument path match is arg0path='/aa/bb/'. This
3798 would match messages with first arguments of '/', '/aa/',
3799 '/aa/bb/', '/aa/bb/cc/' and '/aa/bb/cc'. It would not match
3800 messages with first arguments of '/aa/b', '/aa' or even '/aa/bb'.</para>
3802 <para>This is intended for monitoring “directories” in file system-like
3803 hierarchies, as used in the <citetitle>dconf</citetitle> configuration
3804 system. An application interested in all nodes in a particular hierarchy would
3805 monitor <literal>arg0path='/ca/example/foo/'</literal>. Then the service could
3806 emit a signal with zeroth argument <literal>"/ca/example/foo/bar"</literal> to
3807 represent a modification to the “bar” property, or a signal with zeroth
3808 argument <literal>"/ca/example/"</literal> to represent atomic modification of
3809 many properties within that directory, and the interested application would be
3810 notified in both cases.</para>
3813 This match key was added in version 0.12 of the
3814 D-Bus specification, implemented for STRING
3815 arguments by the bus daemon in dbus 1.2.0 and later,
3816 and implemented for OBJECT_PATH arguments in dbus 1.5.0
3823 <entry><literal>arg0namespace</literal></entry>
3824 <entry>Like a bus name, except that the string is not
3825 required to contain a '.' (period)</entry>
3827 <para>Match messages whose first argument is of type STRING, and is a bus name
3828 or interface name within the specified namespace. This is primarily intended
3829 for watching name owner changes for a group of related bus names, rather than
3830 for a single name or all name changes.</para>
3832 <para>Because every valid interface name is also a valid
3833 bus name, this can also be used for messages whose
3834 first argument is an interface name.</para>
3836 <para>For example, the match rule
3837 <literal>member='NameOwnerChanged',arg0namespace='com.example.backend'</literal>
3838 matches name owner changes for bus names such as
3839 <literal>com.example.backend.foo</literal>,
3840 <literal>com.example.backend.foo.bar</literal>, and
3841 <literal>com.example.backend</literal> itself.</para>
3843 <para>See also <xref linkend='bus-messages-name-owner-changed'/>.</para>
3846 This match key was added in version 0.16 of the
3847 D-Bus specification and implemented by the bus
3848 daemon in dbus 1.5.0 and later.
3859 <sect2 id="message-bus-starting-services">
3860 <title>Message Bus Starting Services</title>
3862 The message bus can start applications on behalf of other applications.
3863 In CORBA terms, this would be called <firstterm>activation</firstterm>.
3864 An application that can be started in this way is called a
3865 <firstterm>service</firstterm>.
3868 With D-Bus, starting a service is normally done by name. That is,
3869 applications ask the message bus to start some program that will own a
3870 well-known name, such as <literal>org.freedesktop.TextEditor</literal>.
3871 This implies a contract documented along with the name
3872 <literal>org.freedesktop.TextEditor</literal> for which objects
3873 the owner of that name will provide, and what interfaces those
3877 To find an executable corresponding to a particular name, the bus daemon
3878 looks for <firstterm>service description files</firstterm>. Service
3879 description files define a mapping from names to executables. Different
3880 kinds of message bus will look for these files in different places, see
3881 <xref linkend="message-bus-types"/>.
3884 Service description files have the ".service" file
3885 extension. The message bus will only load service description files
3886 ending with .service; all other files will be ignored. The file format
3887 is similar to that of <ulink
3888 url="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html">desktop
3889 entries</ulink>. All service description files must be in UTF-8
3890 encoding. To ensure that there will be no name collisions, service files
3891 must be namespaced using the same mechanism as messages and service
3896 [FIXME the file format should be much better specified than "similar to
3897 .desktop entries" esp. since desktop entries are already
3898 badly-specified. ;-)]
3899 These sections from the specification apply to service files as well:
3902 <listitem><para>General syntax</para></listitem>
3903 <listitem><para>Comment format</para></listitem>
3907 <title>Example service description file</title>
3909 # Sample service description file
3911 Names=org.freedesktop.ConfigurationDatabase;org.gnome.GConf;
3912 Exec=/usr/libexec/gconfd-2
3917 When an application asks to start a service by name, the bus daemon tries to
3918 find a service that will own that name. It then tries to spawn the
3919 executable associated with it. If this fails, it will report an
3920 error. [FIXME what happens if two .service files offer the same service;
3921 what kind of error is reported, should we have a way for the client to
3925 The executable launched will have the environment variable
3926 <literal>DBUS_STARTER_ADDRESS</literal> set to the address of the
3927 message bus so it can connect and request the appropriate names.
3930 The executable being launched may want to know whether the message bus
3931 starting it is one of the well-known message buses (see <xref
3932 linkend="message-bus-types"/>). To facilitate this, the bus must also set
3933 the <literal>DBUS_STARTER_BUS_TYPE</literal> environment variable if it is one
3934 of the well-known buses. The currently-defined values for this variable
3935 are <literal>system</literal> for the systemwide message bus,
3936 and <literal>session</literal> for the per-login-session message
3937 bus. The new executable must still connect to the address given
3938 in <literal>DBUS_STARTER_ADDRESS</literal>, but may assume that the
3939 resulting connection is to the well-known bus.
3942 [FIXME there should be a timeout somewhere, either specified
3943 in the .service file, by the client, or just a global value
3944 and if the client being activated fails to connect within that
3945 timeout, an error should be sent back.]
3948 <sect3 id="message-bus-starting-services-scope">
3949 <title>Message Bus Service Scope</title>
3951 The "scope" of a service is its "per-", such as per-session,
3952 per-machine, per-home-directory, or per-display. The reference
3953 implementation doesn't yet support starting services in a different
3954 scope from the message bus itself. So e.g. if you start a service
3955 on the session bus its scope is per-session.
3958 We could add an optional scope to a bus name. For example, for
3959 per-(display,session pair), we could have a unique ID for each display
3960 generated automatically at login and set on screen 0 by executing a
3961 special "set display ID" binary. The ID would be stored in a
3962 <literal>_DBUS_DISPLAY_ID</literal> property and would be a string of
3963 random bytes. This ID would then be used to scope names.
3964 Starting/locating a service could be done by ID-name pair rather than
3968 Contrast this with a per-display scope. To achieve that, we would
3969 want a single bus spanning all sessions using a given display.
3970 So we might set a <literal>_DBUS_DISPLAY_BUS_ADDRESS</literal>
3971 property on screen 0 of the display, pointing to this bus.
3976 <sect2 id="message-bus-types">
3977 <title>Well-known Message Bus Instances</title>
3979 Two standard message bus instances are defined here, along with how
3980 to locate them and where their service files live.
3982 <sect3 id="message-bus-types-login">
3983 <title>Login session message bus</title>
3985 Each time a user logs in, a <firstterm>login session message
3986 bus</firstterm> may be started. All applications in the user's login
3987 session may interact with one another using this message bus.
3990 The address of the login session message bus is given
3991 in the <literal>DBUS_SESSION_BUS_ADDRESS</literal> environment
3992 variable. If that variable is not set, applications may
3993 also try to read the address from the X Window System root
3994 window property <literal>_DBUS_SESSION_BUS_ADDRESS</literal>.
3995 The root window property must have type <literal>STRING</literal>.
3996 The environment variable should have precedence over the
3997 root window property.
3999 <para>The address of the login session message bus is given in the
4000 <literal>DBUS_SESSION_BUS_ADDRESS</literal> environment variable. If
4001 DBUS_SESSION_BUS_ADDRESS is not set, or if it's set to the string
4002 "autolaunch:", the system should use platform-specific methods of
4003 locating a running D-Bus session server, or starting one if a running
4004 instance cannot be found. Note that this mechanism is not recommended
4005 for attempting to determine if a daemon is running. It is inherently
4006 racy to attempt to make this determination, since the bus daemon may
4007 be started just before or just after the determination is made.
4008 Therefore, it is recommended that applications do not try to make this
4009 determination for their functionality purposes, and instead they
4010 should attempt to start the server.</para>
4012 <sect4 id="message-bus-types-login-x-windows">
4013 <title>X Windowing System</title>
4015 For the X Windowing System, the application must locate the
4016 window owner of the selection represented by the atom formed by
4020 <para>the literal string "_DBUS_SESSION_BUS_SELECTION_"</para>
4024 <para>the current user's username</para>
4028 <para>the literal character '_' (underscore)</para>
4032 <para>the machine's ID</para>
4038 The following properties are defined for the window that owns
4040 <informaltable frame="all">
4049 <para>meaning</para>
4055 <para>_DBUS_SESSION_BUS_ADDRESS</para>
4059 <para>the actual address of the server socket</para>
4065 <para>_DBUS_SESSION_BUS_PID</para>
4069 <para>the PID of the server process</para>
4078 At least the _DBUS_SESSION_BUS_ADDRESS property MUST be
4079 present in this window.
4083 If the X selection cannot be located or if reading the
4084 properties from the window fails, the implementation MUST conclude
4085 that there is no D-Bus server running and proceed to start a new
4086 server. (See below on concurrency issues)
4090 Failure to connect to the D-Bus server address thus obtained
4091 MUST be treated as a fatal connection error and should be reported
4096 As an alternative, an implementation MAY find the information
4097 in the following file located in the current user's home directory,
4098 in subdirectory .dbus/session-bus/:
4101 <para>the machine's ID</para>
4105 <para>the literal character '-' (dash)</para>
4109 <para>the X display without the screen number, with the
4110 following prefixes removed, if present: ":", "localhost:"
4111 ."localhost.localdomain:". That is, a display of
4112 "localhost:10.0" produces just the number "10"</para>
4118 The contents of this file NAME=value assignment pairs and
4119 lines starting with # are comments (no comments are allowed
4120 otherwise). The following variable names are defined:
4127 <para>Variable</para>
4131 <para>meaning</para>
4137 <para>DBUS_SESSION_BUS_ADDRESS</para>
4141 <para>the actual address of the server socket</para>
4147 <para>DBUS_SESSION_BUS_PID</para>
4151 <para>the PID of the server process</para>
4157 <para>DBUS_SESSION_BUS_WINDOWID</para>
4161 <para>the window ID</para>
4170 At least the DBUS_SESSION_BUS_ADDRESS variable MUST be present
4175 Failure to open this file MUST be interpreted as absence of a
4176 running server. Therefore, the implementation MUST proceed to
4177 attempting to launch a new bus server if the file cannot be
4182 However, success in opening this file MUST NOT lead to the
4183 conclusion that the server is running. Thus, a failure to connect to
4184 the bus address obtained by the alternative method MUST NOT be
4185 considered a fatal error. If the connection cannot be established,
4186 the implementation MUST proceed to check the X selection settings or
4187 to start the server on its own.
4191 If the implementation concludes that the D-Bus server is not
4192 running it MUST attempt to start a new server and it MUST also
4193 ensure that the daemon started as an effect of the "autolaunch"
4194 mechanism provides the lookup mechanisms described above, so
4195 subsequent calls can locate the newly started server. The
4196 implementation MUST also ensure that if two or more concurrent
4197 initiations happen, only one server remains running and all other
4198 initiations are able to obtain the address of this server and
4199 connect to it. In other words, the implementation MUST ensure that
4200 the X selection is not present when it attempts to set it, without
4201 allowing another process to set the selection between the
4202 verification and the setting (e.g., by using XGrabServer /
4209 [FIXME specify location of .service files, probably using
4210 DESKTOP_DIRS etc. from basedir specification, though login session
4211 bus is not really desktop-specific]
4215 <sect3 id="message-bus-types-system">
4216 <title>System message bus</title>
4218 A computer may have a <firstterm>system message bus</firstterm>,
4219 accessible to all applications on the system. This message bus may be
4220 used to broadcast system events, such as adding new hardware devices,
4221 changes in the printer queue, and so forth.
4224 The address of the system message bus is given
4225 in the <literal>DBUS_SYSTEM_BUS_ADDRESS</literal> environment
4226 variable. If that variable is not set, applications should try
4227 to connect to the well-known address
4228 <literal>unix:path=/var/run/dbus/system_bus_socket</literal>.
4231 The D-Bus reference implementation actually honors the
4232 <literal>$(localstatedir)</literal> configure option
4233 for this address, on both client and server side.
4238 [FIXME specify location of system bus .service files]
4243 <sect2 id="message-bus-messages">
4244 <title>Message Bus Messages</title>
4246 The special message bus name <literal>org.freedesktop.DBus</literal>
4247 responds to a number of additional messages.
4250 <sect3 id="bus-messages-hello">
4251 <title><literal>org.freedesktop.DBus.Hello</literal></title>
4262 <entry>Argument</entry>
4264 <entry>Description</entry>
4270 <entry>STRING</entry>
4271 <entry>Unique name assigned to the connection</entry>
4278 Before an application is able to send messages to other applications
4279 it must send the <literal>org.freedesktop.DBus.Hello</literal> message
4280 to the message bus to obtain a unique name. If an application without
4281 a unique name tries to send a message to another application, or a
4282 message to the message bus itself that isn't the
4283 <literal>org.freedesktop.DBus.Hello</literal> message, it will be
4284 disconnected from the bus.
4287 There is no corresponding "disconnect" request; if a client wishes to
4288 disconnect from the bus, it simply closes the socket (or other
4289 communication channel).
4292 <sect3 id="bus-messages-list-names">
4293 <title><literal>org.freedesktop.DBus.ListNames</literal></title>
4297 ARRAY of STRING ListNames ()
4304 <entry>Argument</entry>
4306 <entry>Description</entry>
4312 <entry>ARRAY of STRING</entry>
4313 <entry>Array of strings where each string is a bus name</entry>
4320 Returns a list of all currently-owned names on the bus.
4323 <sect3 id="bus-messages-list-activatable-names">
4324 <title><literal>org.freedesktop.DBus.ListActivatableNames</literal></title>
4328 ARRAY of STRING ListActivatableNames ()
4335 <entry>Argument</entry>
4337 <entry>Description</entry>
4343 <entry>ARRAY of STRING</entry>
4344 <entry>Array of strings where each string is a bus name</entry>
4351 Returns a list of all names that can be activated on the bus.
4354 <sect3 id="bus-messages-name-exists">
4355 <title><literal>org.freedesktop.DBus.NameHasOwner</literal></title>
4359 BOOLEAN NameHasOwner (in STRING name)
4366 <entry>Argument</entry>
4368 <entry>Description</entry>
4374 <entry>STRING</entry>
4375 <entry>Name to check</entry>
4385 <entry>Argument</entry>
4387 <entry>Description</entry>
4393 <entry>BOOLEAN</entry>
4394 <entry>Return value, true if the name exists</entry>
4401 Checks if the specified name exists (currently has an owner).
4405 <sect3 id="bus-messages-name-owner-changed">
4406 <title><literal>org.freedesktop.DBus.NameOwnerChanged</literal></title>
4410 NameOwnerChanged (STRING name, STRING old_owner, STRING new_owner)
4417 <entry>Argument</entry>
4419 <entry>Description</entry>
4425 <entry>STRING</entry>
4426 <entry>Name with a new owner</entry>
4430 <entry>STRING</entry>
4431 <entry>Old owner or empty string if none</entry>
4435 <entry>STRING</entry>
4436 <entry>New owner or empty string if none</entry>
4443 This signal indicates that the owner of a name has changed.
4444 It's also the signal to use to detect the appearance of
4445 new names on the bus.
4448 <sect3 id="bus-messages-name-lost">
4449 <title><literal>org.freedesktop.DBus.NameLost</literal></title>
4453 NameLost (STRING name)
4460 <entry>Argument</entry>
4462 <entry>Description</entry>
4468 <entry>STRING</entry>
4469 <entry>Name which was lost</entry>
4476 This signal is sent to a specific application when it loses
4477 ownership of a name.
4481 <sect3 id="bus-messages-name-acquired">
4482 <title><literal>org.freedesktop.DBus.NameAcquired</literal></title>
4486 NameAcquired (STRING name)
4493 <entry>Argument</entry>
4495 <entry>Description</entry>
4501 <entry>STRING</entry>
4502 <entry>Name which was acquired</entry>
4509 This signal is sent to a specific application when it gains
4510 ownership of a name.
4514 <sect3 id="bus-messages-start-service-by-name">
4515 <title><literal>org.freedesktop.DBus.StartServiceByName</literal></title>
4519 UINT32 StartServiceByName (in STRING name, in UINT32 flags)
4526 <entry>Argument</entry>
4528 <entry>Description</entry>
4534 <entry>STRING</entry>
4535 <entry>Name of the service to start</entry>
4539 <entry>UINT32</entry>
4540 <entry>Flags (currently not used)</entry>
4550 <entry>Argument</entry>
4552 <entry>Description</entry>
4558 <entry>UINT32</entry>
4559 <entry>Return value</entry>
4564 Tries to launch the executable associated with a name. For more information, see <xref linkend="message-bus-starting-services"/>.
4568 The return value can be one of the following values:
4573 <entry>Identifier</entry>
4574 <entry>Value</entry>
4575 <entry>Description</entry>
4580 <entry>DBUS_START_REPLY_SUCCESS</entry>
4582 <entry>The service was successfully started.</entry>
4585 <entry>DBUS_START_REPLY_ALREADY_RUNNING</entry>
4587 <entry>A connection already owns the given name.</entry>
4596 <sect3 id="bus-messages-update-activation-environment">
4597 <title><literal>org.freedesktop.DBus.UpdateActivationEnvironment</literal></title>
4601 UpdateActivationEnvironment (in ARRAY of DICT<STRING,STRING> environment)
4608 <entry>Argument</entry>
4610 <entry>Description</entry>
4616 <entry>ARRAY of DICT<STRING,STRING></entry>
4617 <entry>Environment to add or update</entry>
4622 Normally, session bus activated services inherit the environment of the bus daemon. This method adds to or modifies that environment when activating services.
4625 Some bus instances, such as the standard system bus, may disable access to this method for some or all callers.
4628 Note, both the environment variable names and values must be valid UTF-8. There's no way to update the activation environment with data that is invalid UTF-8.
4633 <sect3 id="bus-messages-get-name-owner">
4634 <title><literal>org.freedesktop.DBus.GetNameOwner</literal></title>
4638 STRING GetNameOwner (in STRING name)
4645 <entry>Argument</entry>
4647 <entry>Description</entry>
4653 <entry>STRING</entry>
4654 <entry>Name to get the owner of</entry>
4664 <entry>Argument</entry>
4666 <entry>Description</entry>
4672 <entry>STRING</entry>
4673 <entry>Return value, a unique connection name</entry>
4678 Returns the unique connection name of the primary owner of the name
4679 given. If the requested name doesn't have an owner, returns a
4680 <literal>org.freedesktop.DBus.Error.NameHasNoOwner</literal> error.
4684 <sect3 id="bus-messages-get-connection-unix-user">
4685 <title><literal>org.freedesktop.DBus.GetConnectionUnixUser</literal></title>
4689 UINT32 GetConnectionUnixUser (in STRING bus_name)
4696 <entry>Argument</entry>
4698 <entry>Description</entry>
4704 <entry>STRING</entry>
4705 <entry>Unique or well-known bus name of the connection to
4706 query, such as <literal>:12.34</literal> or
4707 <literal>com.example.tea</literal></entry>
4717 <entry>Argument</entry>
4719 <entry>Description</entry>
4725 <entry>UINT32</entry>
4726 <entry>Unix user ID</entry>
4731 Returns the Unix user ID of the process connected to the server. If
4732 unable to determine it (for instance, because the process is not on the
4733 same machine as the bus daemon), an error is returned.
4737 <sect3 id="bus-messages-get-connection-unix-process-id">
4738 <title><literal>org.freedesktop.DBus.GetConnectionUnixProcessID</literal></title>
4742 UINT32 GetConnectionUnixProcessID (in STRING bus_name)
4749 <entry>Argument</entry>
4751 <entry>Description</entry>
4757 <entry>STRING</entry>
4758 <entry>Unique or well-known bus name of the connection to
4759 query, such as <literal>:12.34</literal> or
4760 <literal>com.example.tea</literal></entry>
4770 <entry>Argument</entry>
4772 <entry>Description</entry>
4778 <entry>UINT32</entry>
4779 <entry>Unix process id</entry>
4784 Returns the Unix process ID of the process connected to the server. If
4785 unable to determine it (for instance, because the process is not on the
4786 same machine as the bus daemon), an error is returned.
4790 <sect3 id="bus-messages-add-match">
4791 <title><literal>org.freedesktop.DBus.AddMatch</literal></title>
4795 AddMatch (in STRING rule)
4802 <entry>Argument</entry>
4804 <entry>Description</entry>
4810 <entry>STRING</entry>
4811 <entry>Match rule to add to the connection</entry>
4816 Adds a match rule to match messages going through the message bus (see <xref linkend='message-bus-routing-match-rules'/>).
4817 If the bus does not have enough resources the <literal>org.freedesktop.DBus.Error.OOM</literal>
4821 <sect3 id="bus-messages-remove-match">
4822 <title><literal>org.freedesktop.DBus.RemoveMatch</literal></title>
4826 RemoveMatch (in STRING rule)
4833 <entry>Argument</entry>
4835 <entry>Description</entry>
4841 <entry>STRING</entry>
4842 <entry>Match rule to remove from the connection</entry>
4847 Removes the first rule that matches (see <xref linkend='message-bus-routing-match-rules'/>).
4848 If the rule is not found the <literal>org.freedesktop.DBus.Error.MatchRuleNotFound</literal>
4853 <sect3 id="bus-messages-get-id">
4854 <title><literal>org.freedesktop.DBus.GetId</literal></title>
4858 GetId (out STRING id)
4865 <entry>Argument</entry>
4867 <entry>Description</entry>
4873 <entry>STRING</entry>
4874 <entry>Unique ID identifying the bus daemon</entry>
4879 Gets the unique ID of the bus. The unique ID here is shared among all addresses the
4880 bus daemon is listening on (TCP, UNIX domain socket, etc.) and its format is described in
4881 <xref linkend="uuids"/>. Each address the bus is listening on also has its own unique
4882 ID, as described in <xref linkend="addresses"/>. The per-bus and per-address IDs are not related.
4883 There is also a per-machine ID, described in <xref linkend="standard-interfaces-peer"/> and returned
4884 by org.freedesktop.DBus.Peer.GetMachineId().
4885 For a desktop session bus, the bus ID can be used as a way to uniquely identify a user's session.
4893 <appendix id="implementation-notes">
4894 <title>Implementation notes</title>
4895 <sect1 id="implementation-notes-subsection">
4903 <glossary><title>Glossary</title>
4905 This glossary defines some of the terms used in this specification.
4908 <glossentry id="term-bus-name"><glossterm>Bus Name</glossterm>
4911 The message bus maintains an association between names and
4912 connections. (Normally, there's one connection per application.) A
4913 bus name is simply an identifier used to locate connections. For
4914 example, the hypothetical <literal>com.yoyodyne.Screensaver</literal>
4915 name might be used to send a message to a screensaver from Yoyodyne
4916 Corporation. An application is said to <firstterm>own</firstterm> a
4917 name if the message bus has associated the application's connection
4918 with the name. Names may also have <firstterm>queued
4919 owners</firstterm> (see <xref linkend="term-queued-owner"/>).
4920 The bus assigns a unique name to each connection,
4921 see <xref linkend="term-unique-name"/>. Other names
4922 can be thought of as "well-known names" and are
4923 used to find applications that offer specific functionality.
4928 <glossentry id="term-message"><glossterm>Message</glossterm>
4931 A message is the atomic unit of communication via the D-Bus
4932 protocol. It consists of a <firstterm>header</firstterm> and a
4933 <firstterm>body</firstterm>; the body is made up of
4934 <firstterm>arguments</firstterm>.
4939 <glossentry id="term-message-bus"><glossterm>Message Bus</glossterm>
4942 The message bus is a special application that forwards
4943 or routes messages between a group of applications
4944 connected to the message bus. It also manages
4945 <firstterm>names</firstterm> used for routing
4951 <glossentry id="term-name"><glossterm>Name</glossterm>
4954 See <xref linkend="term-bus-name"/>. "Name" may
4955 also be used to refer to some of the other names
4956 in D-Bus, such as interface names.
4961 <glossentry id="namespace"><glossterm>Namespace</glossterm>
4964 Used to prevent collisions when defining new interfaces or bus
4965 names. The convention used is the same one Java uses for defining
4966 classes: a reversed domain name.
4971 <glossentry id="term-object"><glossterm>Object</glossterm>
4974 Each application contains <firstterm>objects</firstterm>, which have
4975 <firstterm>interfaces</firstterm> and
4976 <firstterm>methods</firstterm>. Objects are referred to by a name,
4977 called a <firstterm>path</firstterm>.
4982 <glossentry id="one-to-one"><glossterm>One-to-One</glossterm>
4985 An application talking directly to another application, without going
4986 through a message bus. One-to-one connections may be "peer to peer" or
4987 "client to server." The D-Bus protocol has no concept of client
4988 vs. server after a connection has authenticated; the flow of messages
4989 is symmetrical (full duplex).
4994 <glossentry id="term-path"><glossterm>Path</glossterm>
4997 Object references (object names) in D-Bus are organized into a
4998 filesystem-style hierarchy, so each object is named by a path. As in
4999 LDAP, there's no difference between "files" and "directories"; a path
5000 can refer to an object, while still having child objects below it.
5005 <glossentry id="term-queued-owner"><glossterm>Queued Name Owner</glossterm>
5008 Each bus name has a primary owner; messages sent to the name go to the
5009 primary owner. However, certain names also maintain a queue of
5010 secondary owners "waiting in the wings." If the primary owner releases
5011 the name, then the first secondary owner in the queue automatically
5012 becomes the new owner of the name.
5017 <glossentry id="term-service"><glossterm>Service</glossterm>
5020 A service is an executable that can be launched by the bus daemon.
5021 Services normally guarantee some particular features, for example they
5022 may guarantee that they will request a specific name such as
5023 "org.freedesktop.Screensaver", have a singleton object
5024 "/org/freedesktop/Application", and that object will implement the
5025 interface "org.freedesktop.ScreensaverControl".
5030 <glossentry id="term-service-description-files"><glossterm>Service Description Files</glossterm>
5033 ".service files" tell the bus about service applications that can be
5034 launched (see <xref linkend="term-service"/>). Most importantly they
5035 provide a mapping from bus names to services that will request those
5036 names when they start up.
5041 <glossentry id="term-unique-name"><glossterm>Unique Connection Name</glossterm>
5044 The special name automatically assigned to each connection by the
5045 message bus. This name will never change owner, and will be unique
5046 (never reused during the lifetime of the message bus).
5047 It will begin with a ':' character.