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"
9 <title>D-BUS Specification</title>
10 <releaseinfo>Version 0.8</releaseinfo>
11 <date>06 September 2003</date>
14 <firstname>Havoc</firstname>
15 <surname>Pennington</surname>
17 <orgname>Red Hat, Inc.</orgname>
19 <email>hp@pobox.com</email>
24 <firstname>Anders</firstname>
25 <surname>Carlsson</surname>
27 <orgname>CodeFactory AB</orgname>
29 <email>andersca@codefactory.se</email>
34 <firstname>Alexander</firstname>
35 <surname>Larsson</surname>
37 <orgname>Red Hat, Inc.</orgname>
39 <email>alexl@redhat.com</email>
46 <sect1 id="introduction">
47 <title>Introduction</title>
49 D-BUS is a system for low-latency, low-overhead, easy to use
50 interprocess communication (IPC). In more detail:
54 D-BUS is <emphasis>low-latency</emphasis> because it is designed
55 to avoid round trips and allow asynchronous operation, much like
61 D-BUS is <emphasis>low-overhead</emphasis> because it uses a
62 binary protocol, and does not have to convert to and from a text
63 format such as XML. Because D-BUS is intended for potentially
64 high-resolution same-machine IPC, not primarily for Internet IPC,
65 this is an interesting optimization.
70 D-BUS is <emphasis>easy to use</emphasis> because it works in terms
71 of <firstterm>messages</firstterm> rather than byte streams, and
72 automatically handles a lot of the hard IPC issues. Also, the D-BUS
73 library is designed to be wrapped in a way that lets developers use
74 their framework's existing object/type system, rather than learning
75 a new one specifically for IPC.
81 The base D-BUS protocol is a peer-to-peer protocol, specified in <xref
82 linkend="message-protocol"/>. That is, it is a system for one application
83 to talk to a single other application. However, the primary intended
84 application of D-BUS is the D-BUS <firstterm>message bus</firstterm>,
85 specified in <xref linkend="message-bus"/>. The message bus is a special
86 application that accepts connections from multiple other applications, and
87 forwards messages among them.
90 Uses of D-BUS include notification of system changes (notification of when
91 a camera is plugged in to a computer, or a new version of some software
92 has been installed), or desktop interoperablity, for example a file
93 monitoring service or a configuration service.
97 <sect1 id="message-protocol">
98 <title>Message Protocol</title>
100 A <firstterm>message</firstterm> consists of a
101 <firstterm>header</firstterm> and a <firstterm>body</firstterm>. If you
102 think of a message as a package, the header is the address, and the body
103 contains the package contents. The message delivery system uses the header
104 information to figure out where to send the message and how to interpret
105 it; the recipient inteprets the body of the message.
109 The body of the message is made up of zero or more
110 <firstterm>arguments</firstterm>, which are typed
111 values, such as an integer or a byte array.
114 <sect2 id="message-protocol-header-encoding">
115 <title>Header Encoding</title>
117 Following the mandatory fields, there are zero or more named fields (see
118 <xref linkend="message-protocol-header-fields"/>), and then nul bytes
119 padding the header such that its total length in bytes is a multiple of
123 The header MUST begin with the following mandatory fields in the following
130 <entry>Description</entry>
135 <entry>1 byte</entry>
136 <entry>Endianness flag; ASCII 'l' for little-endian
137 or ASCII 'B' for big-endian.</entry>
140 <entry>1 byte</entry>
141 <entry>Type of message. Unknown types MUST be ignored.
142 Currently-defined types are described below.
146 <entry>1 byte</entry>
147 <entry>Bitwise OR of flags. Unknown flags
148 MUST be ignored. Currently-defined flags are described below.
152 <entry>1 byte</entry>
153 <entry>Major protocol version of the sending application. If
154 the major protocol version of the receiving application does not
155 match, the applications will not be able to communicate and the
156 D-BUS connection MUST be disconnected. The major protocol
157 version for this version of the specification is 0.
161 <entry>4 bytes</entry>
162 <entry>An unsigned 32-bit integer in the
163 message's byte order, indicating the total length in bytes of
164 the header including named fields and any alignment padding.
165 MUST be a multiple of 8.
169 <entry>4 bytes</entry>
170 <entry>An unsigned 32-bit integer in the
171 message's byte order, indicating the total length in bytes of
176 <entry>4 bytes</entry>
177 <entry>The message's serial number, an unsigned 32-bit integer in
178 the message's byte order. The serial number is a cookie used to
179 identify message replies; thus all outstanding unreplied-to messages
180 from the same connection MUST have a different serial number.
181 Zero is not a valid serial number, but all other numbers are
190 Types that can appear in the second byte of the header:
195 <entry>Conventional name</entry>
196 <entry>Decimal value</entry>
197 <entry>Description</entry>
202 <entry>INVALID</entry>
204 <entry>This is an invalid type, if seen in a message
205 the connection should be dropped immediately.</entry>
208 <entry>METHOD_CALL</entry>
210 <entry>Method call.</entry>
213 <entry>METHOD_RETURN</entry>
215 <entry>Method reply with returned data.</entry>
220 <entry>Error reply. If the first argument exists and is a
221 string, it is an error message.</entry>
224 <entry>SIGNAL</entry>
226 <entry>Signal emission.</entry>
233 Flags that can appear in the third byte of the header:
238 <entry>Conventional name</entry>
239 <entry>Hex value</entry>
240 <entry>Description</entry>
245 <entry>NO_REPLY_EXPECTED</entry>
247 <entry>This message does not expect method return replies or
248 error replies; the reply can be omitted as an
249 optimization. However, it is compliant with this specification
250 to return the reply despite this flag.</entry>
253 <entry>AUTO_ACTIVATION</entry>
255 <entry>This message automatically activates the
256 addressed service before the message is delivered.</entry>
264 <sect2 id="message-protocol-header-fields">
265 <title>Header Fields</title>
267 In addition to the required header information mentioned
268 in <xref linkend="message-protocol-header-encoding"/>,
269 the header must contain the required named header
270 fields and zero or more of the optional named
271 header fields. Future versions of this protocol
272 specification may add new fields. Implementations must
273 ignore fields they do not understand. Implementations
274 must not invent their own header fields; only changes to
275 this specification may introduce new header fields.
279 Header field names MUST consist of a single byte, possible values
280 of which are defined below. Following the name, the field MUST have
281 a type code represented as a single unsigned byte, and then a
282 properly-aligned value of that type. See <xref
283 linkend="message-protocol-arguments"/> for a description of how each
284 type is encoded. If an implementation sees a header field name that
285 it does not understand, it MUST ignore that field.
289 Here are the currently-defined named header fields:
294 <entry>Conventional Name</entry>
295 <entry>Decimal Value</entry>
297 <entry>Required</entry>
298 <entry>Description</entry>
303 <entry>INVALID</entry>
305 <entry>INVALID</entry>
307 <entry>Not a valid field name (error if it appears in a message)</entry>
312 <entry>OBJECT_PATH</entry>
314 <entry>The object to send the message to; objects are identified by
315 a path, "/foo/bar"</entry>
318 <entry>INTERFACE</entry>
320 <entry>STRING</entry>
322 <entry>The interface to invoke a method call on, or
323 that a signal is emitted from. e.g. "org.freedesktop.Introspectable"</entry>
326 <entry>MEMBER</entry>
328 <entry>STRING</entry>
330 <entry>The member, either the method name or signal name.
331 e.g. "Frobate"</entry>
334 <entry>ERROR_NAME</entry>
336 <entry>STRING</entry>
338 <entry>The name of the error that occurred, for errors</entry>
341 <entry>REPLY_SERIAL</entry>
343 <entry>UINT32</entry>
345 <entry>The serial number of the message this message is a reply
346 to. (The serial number is one of the mandatory header fields,
347 see <xref linkend="message-protocol-header-encoding"/>.)</entry>
350 <entry>DESTINATION</entry>
352 <entry>STRING</entry>
354 <entry>The name of the service this message should be routed to.
355 Only used in combination with the message bus, see
356 <xref linkend="message-bus"/>.</entry>
359 <entry>SENDER</entry>
361 <entry>STRING</entry>
363 <entry>Sender service. The name of the base service that sent
364 this message. The message bus fills in this field; the field is
365 only meaningful in combination with the message bus.</entry>
373 <sect2 id="message-protocol-header-padding">
374 <title>Header Alignment Padding</title>
376 To allow implementations to keep the header and the body in a single
377 buffer while keeping data types aligned, the total length of the header
378 must be a multiple of 8 bytes. To achieve this, the header MUST be padded
379 with nul bytes to align its total length on an 8-byte boundary.
380 The minimum number of padding bytes MUST be used. Because zero is an
381 invalid field name, implementations can distinguish padding (which must be
382 zero initialized) from additional named fields.
386 <sect2 id="message-protocol-arguments">
387 <title>Message Arguments</title>
389 The message body is made up of arguments. Each argument is a type code,
390 represented by a single unsigned byte, followed by the aligned value of
391 the argument in a type-dependent format. Alignment padding between the
392 typecode and the value is initialized to zero.
399 <entry>Type name</entry>
401 <entry>Description</entry>
406 <entry>INVALID</entry>
407 <entry>0 (ASCII NUL)</entry>
408 <entry>Not a valid type code (error if it appears in a message)</entry>
411 <entry>118 (ASCII 'v') </entry>
412 <entry>Marks a "void"/"unset"/"nonexistent"/"null" argument</entry>
415 <entry>121 (ASCII 'y')</entry>
416 <entry>8-bit unsigned integer</entry>
418 <entry>BOOLEAN</entry>
419 <entry>98 (ASCII 'b')</entry>
420 <entry>Boolean value, 0 is FALSE and 1 is TRUE. Everything else is invalid.</entry>
423 <entry>105 (ASCII 'i')</entry>
424 <entry>32-bit signed integer</entry>
426 <entry>UINT32</entry>
427 <entry>117 (ASCII 'u')</entry>
428 <entry>32-bit unsigned integer</entry>
431 <entry>120 (ASCII 'x')</entry>
432 <entry>64-bit signed integer</entry>
434 <entry>UINT64</entry>
435 <entry>116 (ASCII 't')</entry>
436 <entry>64-bit unsigned integer</entry>
438 <entry>DOUBLE</entry>
439 <entry>100 (ASCII 'd')</entry>
440 <entry>IEEE 754 double</entry>
442 <entry>STRING</entry>
443 <entry>115 (ASCII 's')</entry>
444 <entry>UTF-8 string (<emphasis>must</emphasis> be valid UTF-8). Must be zero terminated. </entry>
446 <entry>CUSTOM</entry>
447 <entry>99 (ASCII 'c')</entry>
448 <entry>A named byte array, used for custom types</entry>
451 <entry>97 (ASCII 'a')</entry>
455 <entry>109 (ASCII 'm')</entry>
456 <entry>A dictionary of key/value pairs</entry>
458 <entry>OBJECT_PATH</entry>
459 <entry>111 (ASCII 'o')</entry>
460 <entry>Name of an object</entry>
467 The types are encoded as follows:
472 <entry>Type name</entry>
473 <entry>Encoding</entry>
478 <entry>INVALID</entry>
479 <entry>Not applicable; cannot be encoded.</entry>
482 <entry>No data is encoded; the type code is followed immediately
483 by the type code of the next argument.</entry>
486 <entry>A byte.</entry>
488 <entry>BOOLEAN</entry>
489 <entry>A byte, with valid values 0 and 1.</entry>
492 <entry>32-bit signed integer in the message's byte order, aligned to 4-byte boundary.</entry>
494 <entry>UINT32</entry>
495 <entry>32-bit unsigned integer in the message's byte order, aligned to 4-byte boundary.</entry>
498 <entry>64-bit signed integer in the message's byte order, aligned to 8-byte boundary.</entry>
500 <entry>UINT64</entry>
501 <entry>64-bit unsigned integer in the message's byte order, aligned to 8-byte boundary.</entry>
503 <entry>DOUBLE</entry>
504 <entry>64-bit IEEE 754 double in the message's byte order, aligned to 8-byte boundary.</entry>
506 <entry>STRING</entry>
507 <entry>UINT32 aligned to 4-byte boundary indicating the string's
508 length in bytes excluding its terminating nul, followed by
509 string data of the given length, followed by a terminating nul
513 <entry>CUSTOM</entry>
514 <entry>A string (encoded as the STRING type above) giving the
515 name of the type followed by an UINT32 aligned to 4-byte boundary
516 indicating the data length in bytes, followed by the data.
517 The string has some restrictions on its content, see
518 <xref linkend="message-protocol-names"/>.
522 <entry>A sequence of bytes giving the element type of the array, terminated
523 by a type different from ARRAY (just one byte for one-dimensional arrays, but
524 larger for multi-dimensional arrays), followed by an UINT32 (aligned to 4 bytes)
525 giving the length of the array data in bytes. This is followed by each array entry
526 encoded the way it would normally be encoded, except arrays, which are encoded
527 without the type information, since that is already declared above. Arrays containing
532 <entry>UINT32 giving the length of the dictionary data in bytes.
533 This is followed by a number of keyname/value pairs, where the
534 keyname is encoded as a STRING above, and the value is encoded
535 as a byte with typecode and how that type normally would be encoded
539 <entry>OBJECT_PATH</entry>
540 <entry>Encoded as if it were a STRING.
549 <sect2 id="message-protocol-names">
550 <title>Valid names</title>
552 The various names in D-BUS messages have some restrictions.
554 <sect3 id="message-protocol-names-interface">
555 <title>Interface names</title>
557 Interfaces have names with type STRING, meaning that
558 they must be valid UTF-8. However, there are also some
559 additional restrictions that apply to interface names
562 <listitem><para>They are composed of 1 or more elements separated by
563 a period ('.') character. All elements must contain at least
567 <listitem><para>Each element must only contain the ASCII characters
568 "[A-Z][a-z][0-9]_" and must not begin with a digit.
572 <listitem><para>They must contain at least one '.' (period)
573 character (and thus at least two elements).
576 <listitem><para>They must not begin with a '.' (period) character.</para></listitem>
577 <listitem><para>They must not exceed 256 bytes in length.</para></listitem>
578 <listitem><para>They must be at least 1 byte in length.</para></listitem>
582 <sect3 id="message-protocol-names-service">
583 <title>Service names</title>
585 Service names have the same restrictions as interface names, with a
586 special exception for base services. A base service name's first
587 element must start with a colon (':') character. After the colon, any
588 characters in the range "[A-Z][a-z][0-9]_" may appear. Elements after
589 the first must follow the usual rules, except that they may start with
590 a digit. Service names not starting with a colon have none of these
591 exceptions and follow the same rules as interface names.
594 <sect3 id="message-protocol-names-method">
595 <title>Method names</title>
599 <listitem><para>Must only contain the ASCII characters
600 "[A-Z][a-z][0-9]_" and may not begin with a
601 digit.</para></listitem>
602 <listitem><para>Must not contain the '.' (period) character</para></listitem>
603 <listitem><para>Must not exceed 256 bytes in length</para></listitem>
604 <listitem><para>Must be at least 1 byte in length</para></listitem>
608 <sect3 id="message-protocol-names-path">
609 <title>Path names</title>
611 A path (type OBJECT_PATH) must begin with an ASCII '/' (slash)
612 character. Paths may not end with a slash character unless the path is
613 the one-byte string "/". Two slash characters may not appear adjacent
614 to one another (the empty string is not a valid "subdirectory"). Paths
615 may not exceed 256 bytes in length.
618 <sect3 id="message-protocol-names-error">
619 <title>Error names</title>
621 Error names have the same restrictions as interface names.
624 <sect3 id="message-protocol-names-custom">
625 <title>Custom types</title>
627 Custom type names for values of type CUSTOM follow the same
628 restrictions as interface names.
633 <sect2 id="message-protocol-types">
634 <title>Message types</title>
636 Each of the message types (METHOD_CALL, METHOD_RETURN, ERROR, and
637 SIGNAL) has its own expected usage conventions and header fields.
639 <sect3 id="message-protocol-types-method">
640 <title>Method Calls, Returns, and Errors</title>
642 Some messages invoke an operation on a remote object. These are
643 called method call messages and have the type tag METHOD_CALL. Such
644 messages map naturally to methods on objects in a typical program.
647 A method call message is expected to have a MEMBER header field
648 indicating the name of the method. Optionally, the message has an
649 INTERFACE field giving the interface the method is a part of. In the
650 absence of an INTERFACE field, if two interfaces on the same object have
651 a method with the same name, it is undefined which of the two methods
652 will be invoked. Implementations may also choose to return an error in
653 this ambiguous case. However, if a method name is unique
654 implementations should not require an interface field.
657 Method call messages also include a PATH field indicating the
658 object to invoke the method on. If the call is passing through
659 a message bus, the message will also have a SERVICE field giving
660 the service to receive the message.
663 When an application handles a method call message, it is expected to
664 return a reply. The reply is identified by a REPLY_SERIAL header field
665 indicating the serial number of the METHOD_CALL being replied to. The
666 reply can have one of two types; either METHOD_RETURN or ERROR.
669 If the reply has type METHOD_RETURN, the arguments to the reply message
670 are the return value(s) or "out parameters" of the method call.
671 If the reply has type ERROR, then an "exception" has been thrown,
672 and the call fails; no return value will be provided. It makes
673 no sense to send multiple replies to the same method call.
676 Even if a method call has no return values, a METHOD_RETURN
677 reply is expected, so the caller will know the method
678 was successfully processed.
681 The METHOD_RETURN or ERROR reply message MUST have the REPLY_SERIAL
682 header field. If this field is missing, it should be treated as
686 If a METHOD_CALL message has the flag NO_REPLY_EXPECTED,
687 then as an optimization the application receiving the method
688 call may choose to omit the reply message (regardless of
689 whether the reply would have been METHOD_RETURN or ERROR).
690 However, it is also acceptable to ignore the NO_REPLY_EXPECTED
691 flag and reply anyway.
694 If a message has the flag AUTO_ACTIVATION, then the addressed
695 service will be activated before the message is delivered, if
696 not already active. The message will be held until the service
697 is successfully activated or has failed to activate; in case
698 of failure, an activation error will be returned.
700 <sect4 id="message-protocol-types-method-apis">
701 <title>Mapping method calls to native APIs</title>
703 APIs for D-BUS may map method calls to a method call in a specific
704 programming language, such as C++, or may map a method call written
705 in an IDL to a D-BUS message.
708 In APIs of this nature, arguments to a method are often termed "in"
709 (which implies sent in the METHOD_CALL), or "out" (which implies
710 returned in the METHOD_RETURN). Some APIs such as CORBA also have
711 "inout" arguments, which are both sent and received, i.e. the caller
712 passes in a value which is modified. Mapped to D-BUS, an "inout"
713 argument is equivalent to an "in" argument, followed by an "out"
714 argument. You can't pass things "by reference" over the wire, so
715 "inout" is purely an illusion of the in-process API.
718 Given a method with zero or one return values, followed by zero or more
719 arguments, where each argument may be "in", "out", or "inout", the
720 caller constructs a message by appending each "in" or "inout" argument,
721 in order. "out" arguments are not represented in the caller's message.
724 The recipient constructs a reply by appending first the return value
725 if any, then each "out" or "inout" argument, in order.
726 "in" arguments are not represented in the reply message.
732 <sect3 id="message-protocol-types-signal">
733 <title>Signal Emission</title>
735 Unlike method calls, signal emissions have no replies.
736 A signal emission is simply a single message of type SIGNAL.
737 It must have three header fields: PATH giving the object
738 the signal was emitted from, plus INTERFACE and MEMBER giving
739 the fully-qualified name of the signal.
743 <sect3 id="message-protocol-types-notation">
744 <title>Notation in this document</title>
746 This document uses a simple pseudo-IDL to describe particular method
747 calls and signals. Here is an example of a method call:
749 org.freedesktop.DBus.ActivateService (in STRING service_name, in UINT32 flags,
750 out UINT32 resultcode)
752 This means INTERFACE = org.freedesktop.DBus, MEMBER = ActivateService,
753 METHOD_CALL arguments are STRING and UINT32, METHOD_RETURN argument
754 is UINT32. Remember that the MEMBER field can't contain any '.' (period)
755 characters so it's known that the last part of the name in
756 the "IDL" is the member name.
759 In C++ that might end up looking like this:
761 unsigned int org::freedesktop::DBus::ActivateService (const char *service_name,
764 or equally valid, the return value could be done as an argument:
766 void org::freedesktop::DBus::ActivateService (const char *service_name,
768 unsigned int *resultcode);
770 It's really up to the API designer how they want to make
771 this look. You could design an API where the namespace wasn't used
772 in C++, using STL or Qt, using varargs, or whatever you wanted.
775 Signals are written as follows:
777 org.freedesktop.DBus.ServiceLost (STRING service_name)
779 Signals don't specify "in" vs. "out" because only
780 a single direction is possible.
783 In this ad hoc notation, the special type name ANY means any type
784 other than NIL, and the special type name ANY_OR_NIL means any valid
788 It isn't especially encouraged to use this lame pseudo-IDL in actual
789 API implementations; you might use the native notation for the
790 language you're using, or you might use COM or CORBA IDL, for example.
797 <sect1 id="auth-protocol">
798 <title>Authentication Protocol</title>
800 Before the flow of messages begins, two applications must
801 authenticate. A simple plain-text protocol is used for
802 authentication; this protocol is a SASL profile, and maps fairly
803 directly from the SASL specification. The message encoding is
804 NOT used here, only plain text messages.
807 In examples, "C:" and "S:" indicate lines sent by the client and
810 <sect2 id="auth-protocol-overview">
811 <title>Protocol Overview</title>
813 The protocol is a line-based protocol, where each line ends with
814 \r\n. Each line begins with an all-caps ASCII command name containing
815 only the character range [A-Z], a space, then any arguments for the
816 command, then the \r\n ending the line. The protocol is
817 case-sensitive. All bytes must be in the ASCII character set.
819 Commands from the client to the server are as follows:
822 <listitem><para>AUTH [mechanism] [initial-response]</para></listitem>
823 <listitem><para>CANCEL</para></listitem>
824 <listitem><para>BEGIN</para></listitem>
825 <listitem><para>DATA <data in base 64 encoding></para></listitem>
826 <listitem><para>ERROR [human-readable error explanation]</para></listitem>
829 From server to client are as follows:
832 <listitem><para>REJECTED <space-separated list of mechanism names></para></listitem>
833 <listitem><para>OK</para></listitem>
834 <listitem><para>DATA <data in base 64 encoding></para></listitem>
835 <listitem><para>ERROR</para></listitem>
839 <sect2 id="auth-nul-byte">
840 <title>Special credentials-passing nul byte</title>
842 Immediately after connecting to the server, the client must send a
843 single nul byte. This byte may be accompanied by credentials
844 information on some operating systems that use sendmsg() with
845 SCM_CREDS or SCM_CREDENTIALS to pass credentials over UNIX domain
846 sockets. However, the nul byte MUST be sent even on other kinds of
847 socket, and even on operating systems that do not require a byte to be
848 sent in order to transmit credentials. The text protocol described in
849 this document begins after the single nul byte. If the first byte
850 received from the client is not a nul byte, the server may disconnect
854 A nul byte in any context other than the initial byte is an error;
855 the protocol is ASCII-only.
858 The credentials sent along with the nul byte may be used with the
859 SASL mechanism EXTERNAL.
862 <sect2 id="auth-command-auth">
863 <title>AUTH command</title>
865 If an AUTH command has no arguments, it is a request to list
866 available mechanisms. The server SHOULD respond with a REJECTED
867 command listing the mechanisms it understands.
870 If an AUTH command specifies a mechanism, and the server supports
871 said mechanism, the server SHOULD begin exchanging SASL
872 challenge-response data with the client using DATA commands.
875 If the server does not support the mechanism given in the AUTH
876 command, it SHOULD send a REJECTED command listing the mechanisms
880 If the [initial-response] argument is provided, it is intended for
881 use with mechanisms that have no initial challenge (or an empty
882 initial challenge), as if it were the argument to an initial DATA
883 command. If the selected mechanism has an initial challenge, the
884 server should reject authentication by sending REJECTED.
887 If authentication succeeds after exchanging DATA commands,
888 an OK command should be sent to the client.
891 The first octet received by the client after the \r\n of the OK
892 command MUST be the first octet of the authenticated/encrypted
893 stream of D-BUS messages.
896 The first octet received by the server after the \r\n of the BEGIN
897 command from the client MUST be the first octet of the
898 authenticated/encrypted stream of D-BUS messages.
901 <sect2 id="auth-command-cancel">
902 <title>CANCEL Command</title>
904 At any time up to sending the BEGIN command, the client may send a
905 CANCEL command. On receiving the CANCEL command, the server MUST
906 send a REJECTED command and abort the current authentication
910 <sect2 id="auth-command-data">
911 <title>DATA Command</title>
913 The DATA command may come from either client or server, and simply
914 contains a base64-encoded block of data to be interpreted
915 according to the SASL mechanism in use.
918 Some SASL mechanisms support sending an "empty string";
919 FIXME we need some way to do this.
922 <sect2 id="auth-command-begin">
923 <title>BEGIN Command</title>
925 The BEGIN command acknowledges that the client has received an
926 OK command from the server, and that the stream of messages
930 The first octet received by the server after the \r\n of the BEGIN
931 command from the client MUST be the first octet of the
932 authenticated/encrypted stream of D-BUS messages.
935 <sect2 id="auth-command-rejected">
936 <title>REJECTED Command</title>
938 The REJECTED command indicates that the current authentication
939 exchange has failed, and further exchange of DATA is inappropriate.
940 The client would normally try another mechanism, or try providing
941 different responses to challenges.
943 Optionally, the REJECTED command has a space-separated list of
944 available auth mechanisms as arguments. If a server ever provides
945 a list of supported mechanisms, it MUST provide the same list
946 each time it sends a REJECTED message. Clients are free to
947 ignore all lists received after the first.
950 <sect2 id="auth-command-ok">
951 <title>OK Command</title>
953 The OK command indicates that the client has been authenticated,
954 and that further communication will be a stream of D-BUS messages
955 (optionally encrypted, as negotiated) rather than this protocol.
958 The first octet received by the client after the \r\n of the OK
959 command MUST be the first octet of the authenticated/encrypted
960 stream of D-BUS messages.
963 The client MUST respond to the OK command by sending a BEGIN
964 command, followed by its stream of messages, or by disconnecting.
965 The server MUST NOT accept additional commands using this protocol
966 after the OK command has been sent.
969 <sect2 id="auth-command-error">
970 <title>ERROR Command</title>
972 The ERROR command indicates that either server or client did not
973 know a command, does not accept the given command in the current
974 context, or did not understand the arguments to the command. This
975 allows the protocol to be extended; a client or server can send a
976 command present or permitted only in new protocol versions, and if
977 an ERROR is received instead of an appropriate response, fall back
978 to using some other technique.
981 If an ERROR is sent, the server or client that sent the
982 error MUST continue as if the command causing the ERROR had never been
983 received. However, the the server or client receiving the error
984 should try something other than whatever caused the error;
985 if only canceling/rejecting the authentication.
988 <sect2 id="auth-examples">
989 <title>Authentication examples</title>
993 <title>Example of successful magic cookie authentication</title>
995 (MAGIC_COOKIE is a made up mechanism)
997 C: AUTH MAGIC_COOKIE BsAY3g4gBNo=
1003 <title>Example of finding out mechanisms then picking one</title>
1006 S: REJECTED KERBEROS_V4 SKEY
1007 C: AUTH SKEY bW9yZ2Fu
1008 S: DATA OTUgUWE1ODMwOA==
1009 C: DATA Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA==
1015 <title>Example of client sends unknown command then falls back to regular auth</title>
1019 C: AUTH MAGIC_COOKIE BsAY3g4gBNo=
1025 <title>Example of server doesn't support initial auth mechanism</title>
1027 C: AUTH MAGIC_COOKIE BsAY3g4gBNo=
1028 S: REJECTED KERBEROS_V4 SKEY
1029 C: AUTH SKEY bW9yZ2Fu
1030 S: DATA OTUgUWE1ODMwOA==
1031 C: DATA Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA==
1037 <title>Example of wrong password or the like followed by successful retry</title>
1039 C: AUTH MAGIC_COOKIE BsAY3g4gBNo=
1040 S: REJECTED KERBEROS_V4 SKEY
1041 C: AUTH SKEY bW9yZ2Fu
1042 S: DATA OTUgUWE1ODMwOA==
1043 C: DATA Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA==
1045 C: AUTH SKEY bW9yZ2Fu
1046 S: DATA OTUgUWE1ODMwOA==
1047 C: DATA Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA==
1053 <title>Example of skey cancelled and restarted</title>
1055 C: AUTH MAGIC_COOKIE BsAY3g4gBNo=
1056 S: REJECTED KERBEROS_V4 SKEY
1057 C: AUTH SKEY bW9yZ2Fu
1058 S: DATA OTUgUWE1ODMwOA==
1061 C: AUTH SKEY bW9yZ2Fu
1062 S: DATA OTUgUWE1ODMwOA==
1063 C: DATA Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA==
1070 <sect2 id="auth-states">
1071 <title>Authentication state diagrams</title>
1074 This section documents the auth protocol in terms of
1075 a state machine for the client and the server. This is
1076 probably the most robust way to implement the protocol.
1079 <sect3 id="auth-states-client">
1080 <title>Client states</title>
1083 <title><emphasis>Start</emphasis></title>
1086 <listitem><para>send AUTH with initial data -> <emphasis>WaitingForData</emphasis></para></listitem>
1087 <listitem><para>send AUTH with no initial data -> <emphasis>WaitingForData</emphasis> or <emphasis>NeedSendData</emphasis> (depends on mechanism)</para></listitem>
1089 The <emphasis>Start</emphasis> state is stateful (it has a list of
1090 available mechanisms and those it has already attempted). This list
1091 is used to decide which AUTH command to send. When the list is
1092 exhausted, the client should give up and close the connection.
1097 <title><emphasis>WaitingForData</emphasis></title>
1101 <listitem><para>receive OK -> <emphasis>NeedSendBegin</emphasis></para></listitem>
1102 <listitem><para>receive REJECTED -> <emphasis>Start</emphasis></para></listitem>
1103 <listitem><para>receive ERROR -> <emphasis>Start</emphasis></para></listitem>
1104 <listitem><para>receive DATA -> <emphasis>NeedSendData</emphasis></para></listitem>
1105 <listitem><para>receive anything else -> <emphasis>NeedSendError</emphasis></para></listitem>
1107 When going back to <emphasis>Start</emphasis>, the mechanism in
1108 progress should be marked as failed and not retried (at least not
1109 with the same parameters). When receiving REJECTED with a list of
1110 mechanisms, the list should be recorded and used to select
1116 <title><emphasis>NeedSendData</emphasis></title>
1119 <listitem><para>send DATA -> <emphasis>WaitingForData</emphasis></para></listitem>
1120 <listitem><para>send CANCEL -> <emphasis>Start</emphasis></para></listitem>
1126 <title><emphasis>NeedSendError</emphasis></title>
1130 <listitem><para>send ERROR -> return to previous state</para></listitem>
1136 <title><emphasis>NeedSendBegin</emphasis></title>
1140 <listitem><para>send BEGIN -> Authorized</para></listitem>
1146 <title><emphasis>Authorized</emphasis></title>
1148 This is the end state, flow of messages begins.
1154 <sect3 id="auth-states-server">
1155 <title>Server states</title>
1158 <title><emphasis>WaitingForAuth</emphasis></title>
1161 <listitem><para>receive AUTH with initial response -> <emphasis>NeedSendData</emphasis></para></listitem>
1162 <listitem><para>receive AUTH without initial response -> <emphasis>NeedSendData</emphasis> or <emphasis>WaitingForData</emphasis> depending on mechanism</para></listitem>
1168 <title><emphasis>NeedSendData</emphasis></title>
1171 <listitem><para>send DATA -> <emphasis>WaitingForData</emphasis></para></listitem>
1172 <listitem><para>send ERROR -> <emphasis>WaitingForData</emphasis></para></listitem>
1173 <listitem><para>send REJECTED -> <emphasis>WaitingForAuth</emphasis></para></listitem>
1174 <listitem><para>send OK -> <emphasis>WaitingForBegin</emphasis></para></listitem>
1180 <title><emphasis>WaitingForData</emphasis></title>
1183 <listitem><para>receive DATA -> <emphasis>NeedSendData</emphasis></para></listitem>
1184 <listitem><para>receive CANCEL -> <emphasis>NeedSendRejected</emphasis></para></listitem>
1185 <listitem><para>receive ERROR -> <emphasis>NeedSendRejected</emphasis></para></listitem>
1186 <listitem><para>receive anything else -> <emphasis>NeedSendError</emphasis></para></listitem>
1192 <title><emphasis>NeedSendError</emphasis></title>
1196 <listitem><para>send ERROR -> return to previous state</para></listitem>
1202 <title><emphasis>NeedSendRejected</emphasis></title>
1206 <listitem><para>send REJECTED -> <emphasis>WaitingForAuth</emphasis></para></listitem>
1212 <title><emphasis>WaitingForBegin</emphasis></title>
1216 <listitem><para>receive BEGIN -> <emphasis>Authorized</emphasis></para></listitem>
1217 <listitem><para>receive anything else -> <emphasis>NeedSendError</emphasis></para></listitem>
1223 <title><emphasis>Authorized</emphasis></title>
1225 This is the end state, flow of messages begins.
1232 <sect2 id="auth-mechanisms">
1233 <title>Authentication mechanisms</title>
1235 This section describes some new authentication mechanisms.
1236 D-BUS also allows any standard SASL mechanism of course.
1238 <sect3 id="auth-mechanisms-sha">
1239 <title>DBUS_COOKIE_SHA1</title>
1241 The DBUS_COOKIE_SHA1 mechanism is designed to establish that a client
1242 has the ability to read a private file owned by the user being
1243 authenticated. If the client can prove that it has access to a secret
1244 cookie stored in this file, then the client is authenticated.
1245 Thus the security of DBUS_COOKIE_SHA1 depends on a secure home
1249 Authentication proceeds as follows:
1253 The client sends the username it would like to authenticate
1259 The server sends the name of its "cookie context" (see below); a
1260 space character; the integer ID of the secret cookie the client
1261 must demonstrate knowledge of; a space character; then a
1262 hex-encoded randomly-generated challenge string.
1267 The client locates the cookie, and generates its own hex-encoded
1268 randomly-generated challenge string. The client then
1269 concatentates the server's hex-encoded challenge, a ":"
1270 character, its own hex-encoded challenge, another ":" character,
1271 and the hex-encoded cookie. It computes the SHA-1 hash of this
1272 composite string. It sends back to the server the client's
1273 hex-encoded challenge string, a space character, and the SHA-1
1279 The server generates the same concatenated string used by the
1280 client and computes its SHA-1 hash. It compares the hash with
1281 the hash received from the client; if the two hashes match, the
1282 client is authenticated.
1288 Each server has a "cookie context," which is a name that identifies a
1289 set of cookies that apply to that server. A sample context might be
1290 "org_freedesktop_session_bus". Context names must be valid ASCII,
1291 nonzero length, and may not contain the characters slash ("/"),
1292 backslash ("\"), space (" "), newline ("\n"), carriage return ("\r"),
1293 tab ("\t"), or period ("."). There is a default context,
1294 "org_freedesktop_global" that's used by servers that do not specify
1298 Cookies are stored in a user's home directory, in the directory
1299 <filename>~/.dbus-keyrings/</filename>. This directory must
1300 not be readable or writable by other users. If it is,
1301 clients and servers must ignore it. The directory
1302 contains cookie files named after the cookie context.
1305 A cookie file contains one cookie per line. Each line
1306 has three space-separated fields:
1310 The cookie ID number, which must be a non-negative integer and
1311 may not be used twice in the same file.
1316 The cookie's creation time, in UNIX seconds-since-the-epoch
1322 The cookie itself, a hex-encoded random block of bytes.
1328 Only server processes modify the cookie file.
1329 They must do so with this procedure:
1333 Create a lockfile name by appending ".lock" to the name of the
1334 cookie file. The server should attempt to create this file
1335 using <literal>O_CREAT | O_EXCL</literal>. If file creation
1336 fails, the lock fails. Servers should retry for a reasonable
1337 period of time, then they may choose to delete an existing lock
1338 to keep users from having to manually delete a stale
1339 lock. <footnote><para>Lockfiles are used instead of real file
1340 locking <literal>fcntl()</literal> because real locking
1341 implementations are still flaky on network
1342 filesystems.</para></footnote>
1347 Once the lockfile has been created, the server loads the cookie
1348 file. It should then delete any cookies that are old (the
1349 timeout can be fairly short), or more than a reasonable
1350 time in the future (so that cookies never accidentally
1351 become permanent, if the clock was set far into the future
1352 at some point). If no recent keys remain, the
1353 server may generate a new key.
1358 The pruned and possibly added-to cookie file
1359 must be resaved atomically (using a temporary
1360 file which is rename()'d).
1365 The lock must be dropped by deleting the lockfile.
1371 Clients need not lock the file in order to load it,
1372 because servers are required to save the file atomically.
1377 <sect1 id="addresses">
1378 <title>Server Addresses</title>
1380 Server addresses consist of a transport name followed by a colon, and
1381 then an optional, comma-separated list of keys and values in the form key=value.
1382 [FIXME how do you escape colon, comma, and semicolon in the values of the key=value pairs?]
1386 <programlisting>unix:path=/tmp/dbus-test</programlisting>
1387 Which is the address to a unix socket with the path /tmp/dbus-test.
1390 [FIXME clarify if attempting to connect to each is a requirement
1391 or just a suggestion]
1392 When connecting to a server, multiple server addresses can be
1393 separated by a semi-colon. The library will then try to connect
1394 to the first address and if that fails, it'll try to connect to
1395 the next one specified, and so forth. For example
1396 <programlisting>unix:path=/tmp/dbus-test;unix:path=/tmp/dbus-test2</programlisting>
1399 [FIXME we need to specify in detail each transport and its possible arguments]
1400 Current transports include: unix domain sockets (including
1401 abstract namespace on linux), TCP/IP, and a debug/testing transport using
1402 in-process pipes. Future possible transports include one that
1403 tunnels over X11 protocol.
1407 <sect1 id="standard-messages">
1408 <title>Standard Peer-to-Peer Messages</title>
1410 See <xref linkend="message-protocol-types-notation"/> for details on
1411 the notation used in this section.
1413 <sect2 id="standard-messages-ping">
1414 <title><literal>org.freedesktop.Peer.Ping</literal></title>
1417 org.freedesktop.Peer.Ping ()
1421 On receipt of the METHOD_CALL
1422 message <literal>org.freedesktop.Peer.Ping</literal>, an application
1423 should do nothing other than reply with a METHOD_RETURN as usual.
1427 <sect2 id="standard-messages-get-props">
1428 <title><literal>org.freedesktop.Props.Get</literal></title>
1430 [FIXME this is just a bogus made-up method that isn't implemented
1431 or thought through, to save an example of table formatting for the
1432 argument descriptions]
1434 org.freedesktop.Props.Get (in STRING property_name,
1435 out ANY_OR_NIL property_value)
1442 <entry>Argument</entry>
1444 <entry>Description</entry>
1450 <entry>in STRING</entry>
1451 <entry>Name of the property to get</entry>
1455 <entry>out ANY_OR_NIL</entry>
1456 <entry>The value of the property. The type depends on the property.</entry>
1465 <sect1 id="message-bus">
1466 <title>Message Bus Specification</title>
1467 <sect2 id="message-bus-overview">
1468 <title>Message Bus Overview</title>
1470 The message bus accepts connections from one or more applications.
1471 Once connected, applications can send and receive messages from
1472 the message bus, as in the peer-to-peer case.
1475 The message bus keeps track of a set of
1476 <firstterm>services</firstterm>. A service is simply a name, such as
1477 <literal>com.yoyodyne.Screensaver</literal>, which can be
1478 <firstterm>owned</firstterm> by one or more of the connected
1479 applications. The message bus itself always owns the special service
1480 <literal>org.freedesktop.DBus</literal>.
1483 Services may have <firstterm>secondary owners</firstterm>. Secondary owners
1484 of a service are kept in a queue; if the primary owner of a service
1485 disconnects, or releases the service, the next secondary owner becomes
1486 the new owner of the service.
1489 Messages may have a <literal>SERVICE</literal> field (see <xref
1490 linkend="message-protocol-header-fields"/>). When the message bus
1491 receives a message, if the <literal>SERVICE</literal> field is absent, the
1492 message is taken to be a standard peer-to-peer message and interpreted
1493 by the message bus itself. For example, sending
1494 an <literal>org.freedesktop.Peer.Ping</literal> message with no
1495 <literal>SERVICE</literal> will cause the message bus itself to reply
1496 to the ping immediately; the message bus would never make
1497 this message visible to other applications.
1500 If the <literal>SERVICE</literal> field is present, then it indicates a
1501 request for the message bus to route the message. In the usual case,
1502 messages are routed to the owner of the named service.
1503 Messages may also be <firstterm>broadcast</firstterm>
1504 by sending them to the special service
1505 <literal>org.freedesktop.DBus.Broadcast</literal>. Broadcast messages are
1506 sent to all applications with <firstterm>message matching
1507 rules</firstterm> that match the message.
1510 Continuing the <literal>org.freedesktop.Peer.Ping</literal> example, if
1511 the ping message were sent with a <literal>SERVICE</literal> name of
1512 <literal>com.yoyodyne.Screensaver</literal>, then the ping would be
1513 forwarded, and the Yoyodyne Corporation screensaver application would be
1514 expected to reply to the ping. If
1515 <literal>org.freedesktop.Peer.Ping</literal> were sent to
1516 <literal>org.freedesktop.DBus.Broadcast</literal>, then multiple applications
1517 might receive the ping, and all would normally reply to it.
1521 <sect2 id="message-bus-services">
1522 <title>Message Bus Services</title>
1524 A service is a name that identifies a certain application. Each
1525 application connected to the message bus has at least one service name
1526 assigned at connection time and returned in response to the
1527 <literal>org.freedesktop.DBus.Hello</literal> message.
1528 This automatically-assigned service name is called
1529 the application's <firstterm>base service</firstterm>.
1530 Base service names are unique and MUST never be reused for two different
1534 Ownership of the base service is a prerequisite for interaction with
1535 the message bus. It logically follows that the base service is always
1536 the first service that an application comes to own, and the last
1537 service that it loses ownership of.
1540 Base service names must begin with the character ':' (ASCII colon
1541 character); service names that are not base service names must not begin
1542 with this character. (The bus must reject any attempt by an application
1543 to manually create a service name beginning with ':'.) This restriction
1544 categorically prevents "spoofing"; messages sent to a base service name
1545 will always go to a single application instance and that instance only.
1548 An application can request additional service names to be associated
1550 <literal>org.freedesktop.DBus.AcquireService</literal>
1551 message. [FIXME what service names are allowed; ASCII or unicode;
1555 [FIXME this needs more detail, and should move the service-related message
1556 descriptions up into this section perhaps]
1557 Service ownership handling can be specified in the flags part
1558 of the <literal>org.freedesktop.DBus.AcquireService</literal>
1559 message. If an application specifies the
1560 DBUS_SERVICE_FLAGS_PROHIBIT_REPLACEMENT flag, then all applications
1561 trying to acquire the service will be put in a queue. When the
1562 primary owner disconnects from the bus or removes ownership
1563 from the service, the next application in the queue will be the
1564 primary owner. If the DBUS_SERVICE_FLAGS_PROHIBIT_REPLACEMENT
1565 flag is not specified, then the primary owner will lose
1566 ownership whenever another application requests ownership of the
1570 When a client disconnects from the bus, all the services that
1571 the clients own are deleted, or in the case of a service that
1572 prohibits replacement, ownership is transferred to the next
1573 client in the queue, if any.
1576 <sect2 id="message-bus-routing">
1577 <title>Message Bus Message Routing</title>
1579 When a message is received by the message bus, the message's
1580 <literal>sndr</literal> header field MUST be set to the base service of
1581 the application which sent the message. If the service already has
1582 a <literal>sndr</literal> field, the pre-existing field is replaced.
1583 This rule means that a replies are always sent to the base service name,
1584 i.e. to the same application that sent the message being replied to.
1587 [FIXME go into detail about broadcast, multicast, unicast, etc.]
1590 <sect2 id="message-bus-activation">
1591 <title>Message Bus Service Activation</title>
1593 <firstterm>Activation</firstterm> means to locate a service
1594 owner for a service that is currently unowned. For now, it
1595 means to launch an executable that will take ownership of
1596 a particular service.
1599 To find an executable corresponding to a particular service, the bus
1600 daemon looks for <firstterm>service description files</firstterm>.
1601 Service description files define a mapping from service names to
1602 executables. Different kinds of message bus will look for these files
1603 in different places, see <xref linkend="message-bus-types"/>.
1606 [FIXME the file format should be much better specified than
1607 "similar to .desktop entries" esp. since desktop entries are
1608 already badly-specified. ;-)] Service description files have
1609 the ".service" file extension. The message bus will only load
1610 service description files ending with .service; all other
1611 files will be ignored. The file format is similar to that of
1613 url="http://www.freedesktop.org/standards/desktop-entry-spec/desktop-entry-spec.html">desktop
1614 entries</ulink>. All service description files must be in
1615 UTF-8 encoding. To ensure that there will be no name
1616 collisions, service files must be namespaced using the same
1617 mechanism as messages and service names.
1620 <title>Example service description file</title>
1622 # Sample service description file
1624 Name=org.gnome.ConfigurationDatabase
1625 Exec=/usr/libexec/gconfd-2
1630 When an application requests a service to be activated, the
1631 bus daemon tries to find it in the list of activation
1632 entries. It then tries to spawn the executable associated with
1633 it. If this fails, it will report an error. [FIXME what
1634 happens if two .service files offer the same service; what
1635 kind of error is reported, should we have a way for the client
1639 The executable launched will have the environment variable
1640 <literal>DBUS_ACTIVATION_ADDRESS</literal> set to the address of the
1641 message bus so it can connect and register the appropriate services.
1644 The executable being launched may want to know whether the message bus
1645 activating it is one of the well-known message buses (see <xref
1646 linkend="message-bus-types"/>). To facilitate this, the bus MUST also set
1647 the <literal>DBUS_ACTIVATION_BUS_TYPE</literal> environment variable if it is one
1648 of the well-known buses. The currently-defined values for this variable
1649 are <literal>system</literal> for the systemwide message bus,
1650 and <literal>session</literal> for the per-login-session message
1651 bus. The activated executable must still connect to the address given
1652 in <literal>DBUS_ACTIVATION_ADDRESS</literal>, but may assume that the
1653 resulting connection is to the well-known bus.
1656 [FIXME there should be a timeout somewhere, either specified
1657 in the .service file, by the client, or just a global value
1658 and if the client being activated fails to connect within that
1659 timeout, an error should be sent back.]
1663 <sect2 id="message-bus-types">
1664 <title>Well-known Message Bus Instances</title>
1666 Two standard message bus instances are defined here, along with how
1667 to locate them and where their service files live.
1669 <sect3 id="message-bus-types-login">
1670 <title>Login session message bus</title>
1672 Each time a user logs in, a <firstterm>login session message
1673 bus</firstterm> may be started. All applications in the user's login
1674 session may interact with one another using this message bus.
1677 The address of the login session message bus is given
1678 in the <literal>DBUS_SESSION_BUS_ADDRESS</literal> environment
1679 variable. If that variable is not set, applications may
1680 also try to read the address from the X Window System root
1681 window property <literal>_DBUS_SESSION_BUS_ADDRESS</literal>.
1682 The root window property must have type <literal>STRING</literal>.
1683 The environment variable should have precedence over the
1684 root window property.
1687 [FIXME specify location of .service files, probably using
1688 DESKTOP_DIRS etc. from basedir specification, though login session
1689 bus is not really desktop-specific]
1692 <sect3 id="message-bus-types-system">
1693 <title>System message bus</title>
1695 A computer may have a <firstterm>system message bus</firstterm>,
1696 accessible to all applications on the system. This message bus may be
1697 used to broadcast system events, such as adding new hardware devices,
1698 changes in the printer queue, and so forth.
1701 The address of the login session message bus is given
1702 in the <literal>DBUS_SYSTEM_BUS_ADDRESS</literal> environment
1703 variable. If that variable is not set, applications should try
1704 to connect to the well-known address
1705 <literal>unix:path=/var/run/dbus/system_bus_socket</literal>.
1708 The D-BUS reference implementation actually honors the
1709 <literal>$(localstatedir)</literal> configure option
1710 for this address, on both client and server side.
1715 [FIXME specify location of system bus .service files]
1720 <sect2 id="message-bus-messages">
1721 <title>Message Bus Messages</title>
1723 The special message bus service <literal>org.freedesktop.DBus</literal>
1724 responds to a number of messages, allowing applications to
1725 interact with the message bus.
1728 <sect3 id="bus-messages-hello">
1729 <title><literal>org.freedesktop.DBus.Hello</literal></title>
1740 <entry>Argument</entry>
1742 <entry>Description</entry>
1748 <entry>STRING</entry>
1749 <entry>Name of the service assigned to the application</entry>
1756 Before an application is able to send messages to other
1757 applications it must send the
1758 <literal>org.freedesktop.DBus.Hello</literal> message to the
1759 message bus service. If an application tries to send a
1760 message to another application, or a message to the message
1761 bus service that isn't the
1762 <literal>org.freedesktop.DBus.Hello</literal> message, it
1763 will be disconnected from the bus. If a client wishes to
1764 disconnect from the bus, it just has to disconnect from the
1765 transport used. No de-registration message is necessary.
1768 The reply message contains the name of the application's base service.
1771 <sect3 id="bus-messages-list-services">
1772 <title><literal>org.freedesktop.DBus.ListServices</literal></title>
1776 STRING_ARRAY ListServices ()
1783 <entry>Argument</entry>
1785 <entry>Description</entry>
1791 <entry>STRING_ARRAY</entry>
1792 <entry>Array of strings where each string is the name of a service</entry>
1799 Returns a list of all existing services registered with the message bus.
1802 <sect3 id="bus-messages-service-exists">
1803 <title><literal>org.freedesktop.DBus.ServiceExists</literal></title>
1807 BOOLEAN ServiceExists (in STRING service_name)
1814 <entry>Argument</entry>
1816 <entry>Description</entry>
1822 <entry>STRING</entry>
1823 <entry>Name of the service</entry>
1833 <entry>Argument</entry>
1835 <entry>Description</entry>
1841 <entry>BOOLEAN</entry>
1842 <entry>Return value, true if the service exists</entry>
1849 Checks if a service with a specified name exists.
1853 <sect3 id="bus-messages-acquire-service">
1854 <title><literal>org.freedesktop.DBus.AcquireService</literal></title>
1858 UINT32 AcquireService (in STRING service_name)
1865 <entry>Argument</entry>
1867 <entry>Description</entry>
1873 <entry>STRING</entry>
1874 <entry>Name of the service</entry>
1878 <entry>UINT32</entry>
1879 <entry>Flags</entry>
1889 <entry>Argument</entry>
1891 <entry>Description</entry>
1897 <entry>UINT32</entry>
1898 <entry>Return value</entry>
1905 Tries to become owner of a specific service. The flags
1906 specified can be the following values logically ORed together:
1912 <entry>Identifier</entry>
1913 <entry>Value</entry>
1914 <entry>Description</entry>
1919 <entry>DBUS_SERVICE_FLAGS_PROHIBIT_REPLACEMENT</entry>
1922 If the application succeeds in being the owner of the specified service,
1923 then ownership of the service can't be transferred until the service
1924 disconnects. If this flag is not set, then any application trying to become
1925 the owner of the service will succeed and the previous owner will be
1926 sent a <literal>org.freedesktop.DBus.ServiceLost</literal> message.
1930 <entry>DBUS_SERVICE_FLAGS_REPLACE_EXISTING</entry>
1932 <entry>Try to replace the current owner if there is one. If this flag
1933 is not set the application will only become the owner of the service if
1934 there is no current owner.</entry>
1940 [FIXME if it's one of the following values, why are the values
1941 done as flags instead of just 0, 1, 2, 3, 4]
1942 The return value can be one of the following values:
1948 <entry>Identifier</entry>
1949 <entry>Value</entry>
1950 <entry>Description</entry>
1955 <entry>DBUS_SERVICE_REPLY_PRIMARY_OWNER</entry>
1957 <entry>The application is now the primary owner of the service.</entry>
1960 <entry>DBUS_SERVICE_REPLY_IN_QUEUE</entry>
1962 <entry>The service already has an owner which do not want to give up ownership and therefore the application has been put in a queue.</entry>
1965 <entry>DBUS_SERVICE_REPLY_SERVICE_EXISTS</entry>
1967 <entry>The service does already have a primary owner, and DBUS_SERVICE_FLAG_REPLACE_EXISTING was not specified when trying to acquire the service.</entry>
1970 <entry>DBUS_SERVICE_REPLY_ALREADY_OWNER</entry>
1972 <entry>The application trying to request ownership of the service is already the owner of it.</entry>
1979 <sect3 id="bus-messages-service-acquired">
1980 <title><literal>org.freedesktop.DBus.ServiceAcquired</literal></title>
1984 ServiceAcquired (in STRING service_name)
1991 <entry>Argument</entry>
1993 <entry>Description</entry>
1999 <entry>STRING</entry>
2000 <entry>Name of the service</entry>
2004 <entry>UINT32</entry>
2005 <entry>Flags</entry>
2012 This message is sent to a specific application when it becomes the
2013 primary owner of a service.
2016 <sect3 id="bus-messages-service-lost">
2017 <title><literal>org.freedesktop.DBus.ServiceLost</literal></title>
2021 ServiceLost (in STRING service_name)
2028 <entry>Argument</entry>
2030 <entry>Description</entry>
2036 <entry>STRING</entry>
2037 <entry>Name of the service</entry>
2041 <entry>UINT32</entry>
2042 <entry>Flags</entry>
2049 This message is sent to a specific application when it loses primary
2050 ownership of a service.
2052 [FIXME instead of ServiceLost/ServiceCreated going only to
2053 a specific app, why not just OwnerChanged that covers both
2054 lost and created and changed owner and deleted]
2058 <sect3 id="bus-messages-service-created">
2059 <title><literal>org.freedesktop.DBus.ServiceCreated</literal></title>
2063 ServiceCreated (in STRING service_name)
2070 <entry>Argument</entry>
2072 <entry>Description</entry>
2078 <entry>STRING</entry>
2079 <entry>Name of the service</entry>
2083 <entry>UINT32</entry>
2084 <entry>Flags</entry>
2091 This message is broadcast to all applications when a service has been
2092 successfully registered on the message bus.
2096 <sect3 id="bus-messages-service-deleted">
2097 <title><literal>org.freedesktop.DBus.ServiceDeleted</literal></title>
2101 ServiceDeleted (in STRING service_name)
2108 <entry>Argument</entry>
2110 <entry>Description</entry>
2116 <entry>STRING</entry>
2117 <entry>Name of the service</entry>
2121 <entry>UINT32</entry>
2122 <entry>Flags</entry>
2129 This message is broadcast to all applications when a service has been
2130 deleted from the message bus.
2134 <sect3 id="bus-messages-activate-service">
2135 <title><literal>org.freedesktop.DBus.ActivateService</literal></title>
2139 UINT32 ActivateService (in STRING service_name, in UINT32 flags)
2146 <entry>Argument</entry>
2148 <entry>Description</entry>
2154 <entry>STRING</entry>
2155 <entry>Name of the service to activate</entry>
2159 <entry>UINT32</entry>
2160 <entry>Flags (currently not used)</entry>
2170 <entry>Argument</entry>
2172 <entry>Description</entry>
2178 <entry>UINT32</entry>
2179 <entry>Return value</entry>
2184 Tries to launch the executable associated with a service. For more information, see <xref linkend="message-bus-activation"/>.
2186 [FIXME need semantics in much more detail here; for example,
2187 if I activate a service then send it a message, is the message
2188 queued for the new service or is there a race]
2191 The return value can be one of the following values:
2196 <entry>Identifier</entry>
2197 <entry>Value</entry>
2198 <entry>Description</entry>
2203 <entry>DBUS_ACTIVATION_REPLY_ACTIVATED</entry>
2205 <entry>The service was activated successfully.</entry>
2208 <entry>DBUS_ACTIVATION_REPLY_ALREADY_ACTIVE</entry>
2210 <entry>The service is already active.</entry>
2219 <sect3 id="bus-messages-get-service-owner">
2220 <title><literal>org.freedesktop.DBus.GetServiceOwner</literal></title>
2224 STRING GetServiceOwner (in STRING service_name)
2231 <entry>Argument</entry>
2233 <entry>Description</entry>
2239 <entry>STRING</entry>
2240 <entry>Name of the service to query</entry>
2250 <entry>Argument</entry>
2252 <entry>Description</entry>
2258 <entry>STRING</entry>
2259 <entry>Return value, a base service name</entry>
2264 Returns the base service name of the primary owner of the
2265 service in argument. If the requested service isn't active,
2267 <literal>org.freedesktop.DBus.Error.ServiceHasNoOwner</literal> error.
2271 <sect3 id="bus-messages-out-of-memory">
2272 <title><literal>org.freedesktop.DBus.Error.NoMemory</literal></title>
2280 Sent by the message bus when it can't process a message due to an out of memory failure.
2284 <sect3 id="bus-messages-service-does-not-exist">
2285 <title><literal>org.freedesktop.DBus.Error.ServiceDoesNotExist</literal></title>
2289 void ServiceDoesNotExist (in STRING error)
2293 Sent by the message bus as a reply to a client that tried to send a message to a service that doesn't exist.
2300 <appendix id="implementation-notes">
2301 <title>Implementation notes</title>
2302 <sect1 id="implementation-notes-subsection">
2310 <glossary><title>Glossary</title>
2312 This glossary defines some of the terms used in this specification.
2315 <glossentry id="term-activation"><glossterm>Activation</glossterm>
2318 The process of creating an owner for a particular service,
2319 typically by launching an executable.
2324 <glossentry id="term-base-service"><glossterm>Base Service</glossterm>
2327 The special service automatically assigned to an application by the
2328 message bus. This service may never change owner, and the service
2329 name will be unique (never reused during the lifetime of the
2335 <glossentry id="term-broadcast"><glossterm>Broadcast</glossterm>
2338 A message sent to the special <literal>org.freedesktop.DBus.Broadcast</literal>
2339 service; the message bus will forward the broadcast message
2340 to all applications that have expressed interest in it.
2345 <glossentry id="term-message"><glossterm>Message</glossterm>
2348 A message is the atomic unit of communication via the D-BUS
2349 protocol. It consists of a <firstterm>header</firstterm> and a
2350 <firstterm>body</firstterm>; the body is made up of
2351 <firstterm>arguments</firstterm>.
2356 <glossentry id="term-message-bus"><glossterm>Message Bus</glossterm>
2359 The message bus is a special application that forwards
2360 or broadcasts messages between a group of applications
2361 connected to the message bus. It also manages
2362 <firstterm>services</firstterm>.
2367 <glossentry id="namespace"><glossterm>Namespace</glossterm>
2370 Used to prevent collisions when defining message and service
2371 names. The convention used is the same as Java uses for
2372 defining classes: a reversed domain name.
2377 <glossentry id="term-object"><glossterm>Object</glossterm>
2380 Each application contains <firstterm>objects</firstterm>,
2381 which have <firstterm>interfaces</firstterm> and
2382 <firstterm>methods</firstterm>. Objects are referred to
2383 by a name, called a <firstterm>path</firstterm> or
2384 <firstterm>object reference</firstterm>.
2389 <glossentry id="term-path"><glossterm>Path</glossterm>
2392 Object references (object names) in D-BUS are
2393 organized into a filesystem-style hierarchy, so
2394 each object is named by a path. As in LDAP,
2395 there's no difference between "files" and "directories";
2396 a path can refer to an object, while still having
2397 child objects below it.
2402 <glossentry id="peer-to-peer"><glossterm>Peer-to-peer</glossterm>
2405 An application talking directly to another application, without going through a message bus.
2409 <glossentry id="term-secondary-owner"><glossterm>Secondary service owner</glossterm>
2412 Each service has a primary owner; messages sent to the service name
2413 go to the primary owner. However, certain services also maintain
2414 a queue of secondary owners "waiting in the wings." If
2415 the primary owner releases the service, then the first secondary
2416 owner in the queue automatically becomes the primary owner.
2420 <glossentry id="term-service"><glossterm>Service</glossterm>
2423 A service is simply a named list of applications. For example, the
2424 hypothetical <literal>com.yoyodyne.Screensaver</literal> service might
2425 accept messages that affect a screensaver from Yoyodyne Corporation.
2426 An application is said to <firstterm>own</firstterm> a service if the
2427 message bus has associated the application with the service name.
2428 Services may also have <firstterm>secondary owners</firstterm> (see
2429 <xref linkend="term-secondary-owner"/>).
2433 <glossentry id="term-service-name"><glossterm>Service name</glossterm>
2436 The name used when referring to a service. If the service is
2437 a base service it has a unique service name, for example
2438 ":1-20", and otherwise it should be namespaced.
2442 <glossentry id="term-service-description-files"><glossterm>Service Description Files</glossterm>
2445 ".service files" tell the bus how to activate a particular service.
2446 See <xref linkend="term-activation"/>