dbus-marshal-validate: Check brackets in signature nest correctly
[platform/upstream/dbus.git] / doc / dbus-daemon.1.xml.in
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3                    "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
4 <refentry id='dbusdaemon1'>
5
6 <!--  dbus&bsol;-daemon manual page.
7  Copyright (C) 2003,2008 Red Hat, Inc. -->
8
9 <refmeta>
10 <refentrytitle>dbus-daemon</refentrytitle>
11 <manvolnum>1</manvolnum>
12 <refmiscinfo class="manual">User Commands</refmiscinfo>
13 <refmiscinfo class="source">D-Bus</refmiscinfo>
14 <refmiscinfo class="version">@DBUS_VERSION@</refmiscinfo>
15 </refmeta>
16 <refnamediv>
17 <refname>dbus-daemon</refname>
18 <refpurpose>Message bus daemon</refpurpose>
19 </refnamediv>
20 <!-- body begins here -->
21 <refsynopsisdiv id='synopsis'>
22 <cmdsynopsis>
23   <command>dbus-daemon</command></cmdsynopsis>
24 <cmdsynopsis>
25   <command>dbus-daemon</command>    <arg choice='opt'>--version </arg>
26     <arg choice='opt'>--session </arg>
27     <arg choice='opt'>--system </arg>
28     <arg choice='opt'>--config-file=<replaceable>FILE</replaceable></arg>
29     <arg choice='opt'><arg choice='plain'>--print-address </arg><arg choice='opt'><replaceable>=DESCRIPTOR</replaceable></arg></arg>
30     <arg choice='opt'><arg choice='plain'>--print-pid </arg><arg choice='opt'><replaceable>=DESCRIPTOR</replaceable></arg></arg>
31     <arg choice='opt'>--fork </arg>
32     <arg choice='opt'>--nosyslog </arg>
33     <arg choice='opt'>--syslog </arg>
34     <arg choice='opt'>--syslog-only </arg>
35     <sbr/>
36 </cmdsynopsis>
37 </refsynopsisdiv>
38
39
40 <refsect1 id='description'><title>DESCRIPTION</title>
41 <para><command>dbus-daemon</command> is the D-Bus message bus daemon. See
42 <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink> for more information about
43 the big picture. D-Bus is first a library that provides one-to-one
44 communication between any two applications; <command>dbus-daemon</command> is an
45 application that uses this library to implement a message bus
46 daemon. Multiple programs connect to the message bus daemon and can
47 exchange messages with one another.</para>
48
49 <para>There are two standard message bus instances: the systemwide message bus
50 (installed on many systems as the "messagebus" init service) and the
51 per-user-login-session message bus (started each time a user logs in).
52 <command>dbus-daemon</command> is used for both of these instances, but with
53 a different configuration file.</para>
54
55 <para>The --session option is equivalent to
56 "--config-file=@EXPANDED_DATADIR@/dbus-1/session.conf" and the --system
57 option is equivalent to
58 "--config-file=@EXPANDED_DATADIR@/dbus-1/system.conf". By creating
59 additional configuration files and using the --config-file option,
60 additional special-purpose message bus daemons could be created.</para>
61
62 <para>The systemwide daemon is normally launched by an init script,
63 standardly called simply "messagebus".</para>
64
65 <para>The systemwide daemon is largely used for broadcasting system events,
66 such as changes to the printer queue, or adding/removing devices.</para>
67
68 <para>The per-session daemon is used for various interprocess communication
69 among desktop applications (however, it is not tied to X or the GUI
70 in any way).</para>
71
72 <para>SIGHUP will cause the D-Bus daemon to PARTIALLY reload its
73 configuration file and to flush its user/group information caches. Some
74 configuration changes would require kicking all apps off the bus; so they will
75 only take effect if you restart the daemon. Policy changes should take effect
76 with SIGHUP.</para>
77
78 </refsect1>
79
80 <refsect1 id='options'><title>OPTIONS</title>
81 <para>The following options are supported:</para>
82 <variablelist remap='TP'>
83   <varlistentry>
84   <term><option>--config-file=FILE</option></term>
85   <listitem>
86 <para>Use the given configuration file.</para>
87   </listitem>
88   </varlistentry>
89   <varlistentry>
90   <term><option>--fork</option></term>
91   <listitem>
92 <para>Force the message bus to fork and become a daemon, even if
93 the configuration file does not specify that it should.
94 In most contexts the configuration file already gets this
95 right, though. This option is not supported on Windows.</para>
96   </listitem>
97   </varlistentry>
98   <varlistentry>
99   <term><option>--nofork</option></term>
100   <listitem>
101     <para>Force the message bus not to fork and become a daemon, even if
102       the configuration file specifies that it should. On Windows,
103       the dbus-daemon never forks, so this option is allowed but does
104       nothing.</para>
105   </listitem>
106   </varlistentry>
107   <varlistentry>
108   <term><option>--print-address[=DESCRIPTOR]</option></term>
109   <listitem>
110 <para>Print the address of the message bus to standard output, or
111 to the given file descriptor. This is used by programs that
112 launch the message bus.</para>
113   </listitem>
114   </varlistentry>
115   <varlistentry>
116   <term><option>--print-pid[=DESCRIPTOR]</option></term>
117   <listitem>
118 <para>Print the process ID of the message bus to standard output, or
119 to the given file descriptor. This is used by programs that
120 launch the message bus.</para>
121   </listitem>
122   </varlistentry>
123   <varlistentry>
124   <term><option>--session</option></term>
125   <listitem>
126 <para>Use the standard configuration file for the per-login-session message
127 bus.</para>
128   </listitem>
129   </varlistentry>
130   <varlistentry>
131   <term><option>--system</option></term>
132   <listitem>
133 <para>Use the standard configuration file for the systemwide message bus.</para>
134   </listitem>
135   </varlistentry>
136   <varlistentry>
137   <term><option>--version</option></term>
138   <listitem>
139 <para>Print the version of the daemon.</para>
140   </listitem>
141   </varlistentry>
142   <varlistentry>
143   <term><option>--introspect</option></term>
144   <listitem>
145 <para>Print the introspection information for all D-Bus internal interfaces.</para>
146   </listitem>
147   </varlistentry>
148   <varlistentry>
149   <term><option>--address[=ADDRESS]</option></term>
150   <listitem>
151     <para>Set the address to listen on. This option overrides the address
152       configured in the configuration file via the
153       <literal>&lt;listen&gt;</literal> directive.
154       See the documentation of that directive for more details.</para>
155   </listitem>
156   </varlistentry>
157   <varlistentry>
158   <term><option>--systemd-activation</option></term>
159   <listitem>
160 <para>Enable systemd-style service activation. Only useful in conjunction
161 with the systemd system and session manager on Linux.</para>
162   </listitem>
163   </varlistentry>
164   <varlistentry>
165   <term><option>--nopidfile</option></term>
166   <listitem>
167 <para>Don't write a PID file even if one is configured in the configuration
168 files.</para>
169
170   </listitem>
171   </varlistentry>
172
173   <varlistentry>
174     <term><option>--syslog</option></term>
175     <listitem>
176       <para>Force the message bus to use the system log for messages,
177         in addition to writing to standard error, even if the configuration
178         file does not specify that it should. On Unix, this uses
179         the syslog; on Windows, this uses OutputDebugString().</para>
180     </listitem>
181   </varlistentry>
182
183   <varlistentry>
184     <term><option>--syslog-only</option></term>
185     <listitem>
186       <para>Force the message bus to use the system log for messages,
187         and <emphasis>not</emphasis> duplicate them to standard error.
188         On Unix, this uses the syslog; on Windows, this uses
189         OutputDebugString().</para>
190     </listitem>
191   </varlistentry>
192
193   <varlistentry>
194     <term><option>--nosyslog</option></term>
195     <listitem>
196       <para>Force the message bus to use only standard error for messages,
197         even if the configuration file specifies that it should use
198         the system log.</para>
199     </listitem>
200   </varlistentry>
201
202 </variablelist>
203 </refsect1>
204
205 <refsect1 id='configuration_file'><title>CONFIGURATION FILE</title>
206 <para>A message bus daemon has a configuration file that specializes it
207 for a particular application. For example, one configuration
208 file might set up the message bus to be a systemwide message bus,
209 while another might set it up to be a per-user-login-session bus.</para>
210
211 <para>The configuration file also establishes resource limits, security
212 parameters, and so forth.</para>
213
214 <para>The configuration file is not part of any interoperability
215 specification and its backward compatibility is not guaranteed; this
216 document is documentation, not specification.</para>
217
218 <para>The standard systemwide and per-session message bus setups are
219 configured in the files "@EXPANDED_DATADIR@/dbus-1/system.conf" and
220 "@EXPANDED_DATADIR@/dbus-1/session.conf".  These files normally
221 &lt;include&gt; a system-local.conf or session-local.conf in
222 @EXPANDED_SYSCONFDIR@/dbus-1; you can put local
223 overrides in those files to avoid modifying the primary configuration
224 files.</para>
225
226
227 <para>The configuration file is an XML document. It must have the following
228 doctype declaration:</para>
229 <literallayout remap='.nf'>
230
231    &lt;!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
232     "<ulink url='http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd'>http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd</ulink>"&gt;
233
234 </literallayout> <!-- .fi -->
235
236
237 <para>The following elements may be present in the configuration file.</para>
238
239 <itemizedlist remap='TP'>
240
241   <listitem><para><emphasis remap='I'>&lt;busconfig&gt;</emphasis></para></listitem>
242
243
244 </itemizedlist>
245
246 <para>Root element.</para>
247
248 <itemizedlist remap='TP'>
249
250   <listitem><para><emphasis remap='I'>&lt;type&gt;</emphasis></para></listitem>
251
252
253 </itemizedlist>
254
255 <para>The well-known type of the message bus. Currently known values are
256 "system" and "session"; if other values are set, they should be
257 either added to the D-Bus specification, or namespaced.  The last
258 &lt;type&gt; element "wins" (previous values are ignored). This element
259 only controls which message bus specific environment variables are
260 set in activated clients.  Most of the policy that distinguishes a
261 session bus from the system bus is controlled from the other elements
262 in the configuration file.</para>
263
264
265 <para>If the well-known type of the message bus is "session", then the
266 DBUS_STARTER_BUS_TYPE environment variable will be set to "session"
267 and the DBUS_SESSION_BUS_ADDRESS environment variable will be set
268 to the address of the session bus.  Likewise, if the type of the
269 message bus is "system", then the DBUS_STARTER_BUS_TYPE environment
270 variable will be set to "system" and the DBUS_SYSTEM_BUS_ADDRESS
271 environment variable will be set to the address of the system bus
272 (which is normally well known anyway).</para>
273
274
275 <para>Example: &lt;type&gt;session&lt;/type&gt;</para>
276
277 <itemizedlist remap='TP'>
278
279   <listitem><para><emphasis remap='I'>&lt;include&gt;</emphasis></para></listitem>
280
281
282 </itemizedlist>
283
284 <para>Include a file &lt;include&gt;filename.conf&lt;/include&gt; at this point.  If the
285 filename is relative, it is located relative to the configuration file
286 doing the including.</para>
287
288
289 <para>&lt;include&gt; has an optional attribute "ignore_missing=(yes|no)"
290 which defaults to "no" if not provided. This attribute
291 controls whether it's a fatal error for the included file
292 to be absent.</para>
293
294 <itemizedlist remap='TP'>
295
296   <listitem><para><emphasis remap='I'>&lt;includedir&gt;</emphasis></para></listitem>
297
298
299 </itemizedlist>
300
301 <para>Include all files in &lt;includedir&gt;foo.d&lt;/includedir&gt; at this
302 point. Files in the directory are included in undefined order.
303 Only files ending in ".conf" are included.</para>
304
305
306 <para>This is intended to allow extension of the system bus by particular
307 packages. For example, if CUPS wants to be able to send out
308 notification of printer queue changes, it could install a file to
309 @EXPANDED_DATADIR@/dbus-1/system.d or
310 @EXPANDED_SYSCONFDIR@/dbus-1/system.d that allowed all apps to receive
311 this message and allowed the printer daemon user to send it.</para>
312
313 <itemizedlist remap='TP'>
314
315   <listitem><para><emphasis remap='I'>&lt;user&gt;</emphasis></para></listitem>
316
317
318 </itemizedlist>
319
320 <para>The user account the daemon should run as, as either a username or a
321 UID. If the daemon cannot change to this UID on startup, it will exit.
322 If this element is not present, the daemon will not change or care
323 about its UID.</para>
324
325
326 <para>The last &lt;user&gt; entry in the file "wins", the others are ignored.</para>
327
328
329 <para>The user is changed after the bus has completed initialization.  So
330 sockets etc. will be created before changing user, but no data will be
331 read from clients before changing user. This means that sockets
332 and PID files can be created in a location that requires root
333 privileges for writing.</para>
334
335 <itemizedlist remap='TP'>
336
337   <listitem><para><emphasis remap='I'>&lt;fork&gt;</emphasis></para></listitem>
338
339
340 </itemizedlist>
341
342 <para>If present, the bus daemon becomes a real daemon (forks
343 into the background, etc.). This is generally used
344 rather than the --fork command line option.</para>
345
346 <itemizedlist remap='TP'>
347
348   <listitem><para><emphasis remap='I'>&lt;keep_umask&gt;</emphasis></para></listitem>
349
350
351 </itemizedlist>
352
353 <para>If present, the bus daemon keeps its original umask when forking.
354 This may be useful to avoid affecting the behavior of child processes.</para>
355
356 <itemizedlist remap='TP'>
357
358   <listitem><para><emphasis remap='I'>&lt;syslog&gt;</emphasis></para></listitem>
359
360
361 </itemizedlist>
362
363 <para>If present, the bus daemon will log to syslog. The
364   --syslog, --syslog-only and --nosyslog command-line options take precedence
365   over this setting.</para>
366
367 <itemizedlist remap='TP'>
368
369   <listitem><para><emphasis remap='I'>&lt;pidfile&gt;</emphasis></para></listitem>
370
371
372 </itemizedlist>
373
374 <para>If present, the bus daemon will write its pid to the specified file.
375 The --nopidfile command-line option takes precedence over this setting.</para>
376
377 <itemizedlist remap='TP'>
378
379   <listitem><para><emphasis remap='I'>&lt;allow_anonymous&gt;</emphasis></para></listitem>
380
381
382 </itemizedlist>
383
384 <para>If present, connections that authenticated using the ANONYMOUS
385 mechanism will be authorized to connect. This option has no practical
386 effect unless the ANONYMOUS mechanism has also been enabled using the
387 <emphasis remap='I'>&lt;auth&gt;</emphasis> element, described below.</para>
388
389 <para>Using this directive in the configuration of the well-known
390   system bus or the well-known session bus will make that bus insecure
391   and should never be done. Similarly, on custom bus types, using this
392   directive will usually make the custom bus insecure, unless its
393   configuration has been specifically designed to prevent anonymous
394   users from causing damage or escalating privileges.</para>
395
396 <itemizedlist remap='TP'>
397
398   <listitem><para><emphasis remap='I'>&lt;listen&gt;</emphasis></para></listitem>
399
400
401 </itemizedlist>
402
403 <para>Add an address that the bus should listen on. The
404 address is in the standard D-Bus format that contains
405 a transport name plus possible parameters/options.</para>
406
407 <para>On platforms other than Windows, <literal>unix</literal>-based
408   transports (<literal>unix</literal>, <literal>systemd</literal>,
409   <literal>launchd</literal>) are the default for both the well-known
410   system bus and the well-known session bus, and are strongly
411   recommended.</para>
412
413 <para>
414   On Windows, <literal>unix</literal>-based transports are not available,
415   so TCP-based transports must be used.
416   Similar to remote X11, the <literal>tcp</literal> and
417   <literal>nonce-tcp</literal> transports have no integrity or
418   confidentiality protection, so they should normally only be
419   used across the local loopback interface, for example using an
420   address like <literal>tcp:host=127.0.0.1</literal> or
421   <literal>nonce-tcp:host=localhost</literal>. In particular,
422   configuring the well-known system bus or the well-known session
423   bus to listen on a non-loopback TCP address is insecure.
424 </para>
425 <para>
426   Developers are sometimes tempted to use remote TCP as a debugging
427   tool. However, if this functionality is left enabled in finished
428   products, the result will be dangerously insecure. Instead of
429   using remote TCP, developers should <ulink
430     url="https://lists.freedesktop.org/archives/dbus/2018-April/017447.html"
431     >relay connections via Secure Shell or a similar protocol</ulink>.
432   <!-- TODO: Ideally someone would write a more formal guide to
433        remote D-Bus debugging, and we could link to that instead -->
434 </para>
435 <para>
436   Remote TCP connections were historically sometimes used to share
437   a single session bus between login sessions of the same user on
438   different machines within a trusted local area network, in
439   conjunction with unencrypted remote X11, a NFS-shared home
440   directory and NIS (YP) authentication. This is insecure against
441   an attacker on the same LAN and should be considered strongly
442   deprecated; more specifically, it is insecure in the same ways
443   and for the same reasons as unencrypted remote X11 and NFSv2/NFSv3.
444   The D-Bus maintainers
445   recommend using a separate session bus per (user, machine) pair,
446   only accessible from within that machine.
447 </para>
448
449 <para>Example: &lt;listen&gt;unix:path=/tmp/foo&lt;/listen&gt;</para>
450
451
452 <para>Example: &lt;listen&gt;tcp:host=localhost,port=1234&lt;/listen&gt;</para>
453
454
455 <para>If there are multiple &lt;listen&gt; elements, then the bus listens
456 on multiple addresses. The bus will pass its address to
457 started services or other interested parties with
458 the last address given in &lt;listen&gt; first. That is,
459 apps will try to connect to the last &lt;listen&gt; address first.</para>
460
461
462 <para>tcp sockets can accept IPv4 addresses, IPv6 addresses or hostnames.
463 If a hostname resolves to multiple addresses, the server will bind
464 to all of them. The family=ipv4 or family=ipv6 options can be used
465 to force it to bind to a subset of addresses</para>
466
467
468 <para>Example: &lt;listen&gt;tcp:host=localhost,port=0,family=ipv4&lt;/listen&gt;</para>
469
470
471 <para>A special case is using a port number of zero (or omitting the port),
472 which means to choose an available port selected by the operating
473 system. The port number chosen can be obtained with the
474 --print-address command line parameter and will be present in other
475 cases where the server reports its own address, such as when
476 DBUS_SESSION_BUS_ADDRESS is set.</para>
477
478
479 <para>Example: &lt;listen&gt;tcp:host=localhost,port=0&lt;/listen&gt;</para>
480
481
482 <para>tcp/nonce-tcp addresses also allow a bind=hostname option,
483 used in a listenable address to configure the interface on which
484 the server will listen: either the hostname is the IP address of
485 one of the local machine's interfaces (most commonly 127.0.0.1),
486 a DNS name that resolves to one of those IP addresses, '0.0.0.0'
487 to listen on all IPv4 interfaces simultaneously, or '::'
488 to listen on all IPv4 and IPv6 interfaces simultaneously (if supported
489 by the OS).  If not specified,
490 the default is the same value as "host".</para>
491
492
493 <para>Example: &lt;listen&gt;tcp:host=localhost,bind=0.0.0.0,port=0&lt;/listen&gt;</para>
494
495 <itemizedlist remap='TP'>
496
497   <listitem><para><emphasis remap='I'>&lt;auth&gt;</emphasis></para></listitem>
498
499
500 </itemizedlist>
501
502 <para>Lists permitted authorization mechanisms. If this element doesn't
503 exist, then all known mechanisms are allowed.  If there are multiple
504 &lt;auth&gt; elements, all the listed mechanisms are allowed.  The order in
505 which mechanisms are listed is not meaningful.</para>
506
507 <para>On non-Windows operating systems, allowing only the
508   <literal>EXTERNAL</literal> authentication
509   mechanism is strongly recommended. This is the default for the
510   well-known system bus and for the well-known session bus.</para>
511
512 <para>Example: &lt;auth&gt;EXTERNAL&lt;/auth&gt;</para>
513
514
515 <para>Example: &lt;auth&gt;DBUS_COOKIE_SHA1&lt;/auth&gt;</para>
516
517 <itemizedlist remap='TP'>
518
519   <listitem><para><emphasis remap='I'>&lt;servicedir&gt;</emphasis></para></listitem>
520
521
522 </itemizedlist>
523
524 <para>
525   Adds a directory to search for .service files, which tell the
526   dbus-daemon how to start a program to provide a particular well-known
527   bus name. See the D-Bus Specification for more details about the
528   contents of .service files.
529 </para>
530
531 <para>
532   If a particular service is found in more than one &lt;servicedir&gt;,
533   the first directory listed in the configuration file takes precedence.
534   If two service files providing the same well-known bus name are found
535   in the same directory, it is arbitrary which one will be chosen
536   (this can only happen if at least one of the service files does not
537   have the recommended name, which is its well-known bus name followed
538   by ".service").
539 </para>
540
541 <itemizedlist remap='TP'>
542
543   <listitem><para><emphasis remap='I'>&lt;standard_session_servicedirs/&gt;</emphasis></para></listitem>
544
545
546 </itemizedlist>
547
548 <para>
549   &lt;standard_session_servicedirs/&gt; requests a standard set of
550   session service directories. Its effect is similar to specifying a series
551   of &lt;servicedir/&gt; elements for each of the data directories,
552   in the order given here.
553   It is not exactly equivalent, because there is currently no way
554   to disable directory monitoring or enforce strict service file naming
555   for a &lt;servicedir/&gt;.
556 </para>
557
558 <para>
559   As with &lt;servicedir/&gt; elements, if a particular service is found
560   in more than one service directory, the first directory takes precedence.
561   If two service files providing the same well-known bus name are found
562   in the same directory, it is arbitrary which one will be chosen
563   (this can only happen if at least one of the service files does not
564   have the recommended name, which is its well-known bus name followed
565   by ".service").
566 </para>
567
568 <para>
569   On Unix, the standard session service directories are:
570   <itemizedlist>
571     <listitem>
572       <para>
573         <emphasis>$XDG_RUNTIME_DIR</emphasis>/dbus-1/services,
574         if XDG_RUNTIME_DIR is set (see the XDG Base Directory
575         Specification for details of XDG_RUNTIME_DIR):
576         this location is suitable for transient services created at runtime
577         by systemd generators (see
578         <citerefentry>
579           <refentrytitle>systemd.generator</refentrytitle>
580           <manvolnum>7</manvolnum>
581         </citerefentry>),
582         session managers or other session infrastructure.
583         It is an extension provided by the reference implementation
584         of dbus-daemon, and is not standardized in the D-Bus Specification.
585       </para>
586       <para>
587         Unlike the other standard session service directories, this directory
588         enforces strict naming for the service files: the filename must be
589         exactly the well-known bus name of the service, followed by
590         ".service".
591       </para>
592       <para>
593         Also unlike the other standard session service directories, this
594         directory is never monitored with
595         <citerefentry>
596           <refentrytitle>inotify</refentrytitle>
597           <manvolnum>7</manvolnum>
598         </citerefentry>
599         or similar APIs. Programs that create service files in this directory
600         while a dbus-daemon is running are expected to call the dbus-daemon's
601         ReloadConfig() method after they have made changes.
602       </para>
603     </listitem>
604     <listitem>
605       <para>
606         <emphasis>$XDG_DATA_HOME</emphasis>/dbus-1/services,
607         where XDG_DATA_HOME defaults to ~/.local/share
608         (see the XDG Base Directory Specification): this location is
609         specified by the D-Bus Specification, and is suitable for per-user,
610         locally-installed software.
611       </para>
612     </listitem>
613     <listitem>
614       <para>
615         <emphasis>directory</emphasis>/dbus-1/services for each
616         directory in XDG_DATA_DIRS, where XDG_DATA_DIRS defaults to
617         /usr/local/share:/usr/share
618         (see the XDG Base Directory Specification): these locations are
619         specified by the D-Bus Specification. The defaults are suitable
620         for software installed locally by a system administrator
621         (/usr/local/share) or for software installed from operating system
622         packages (/usr/share). Per-user or system-wide configuration that
623         sets the XDG_DATA_DIRS environment variable can extend this search
624         path to cover installations in other locations, for example
625         ~/.local/share/flatpak/exports/share/ and
626         /var/lib/flatpak/exports/share/ when
627         <citerefentry>
628           <refentrytitle>flatpak</refentrytitle>
629           <manvolnum>1</manvolnum>
630         </citerefentry>
631         is used.
632       </para>
633     </listitem>
634     <listitem>
635       <para>
636         <emphasis>${datadir}</emphasis>/dbus-1/services
637         for the <emphasis>${datadir}</emphasis> that was specified when
638         dbus was compiled, typically /usr/share: this location is an
639         extension provided by the reference dbus-daemon implementation,
640         and is suitable for software stacks installed alongside dbus-daemon.
641       </para>
642     </listitem>
643   </itemizedlist>
644 </para>
645
646 <para>The "XDG Base Directory Specification" can be found at
647 <ulink url='http://freedesktop.org/wiki/Standards/basedir-spec'>http://freedesktop.org/wiki/Standards/basedir-spec</ulink> if it hasn't moved,
648 otherwise try your favorite search engine.</para>
649
650 <para>
651   On Windows, the standard session service directories are:
652   <itemizedlist>
653     <listitem>
654       <para>
655         <emphasis>%CommonProgramFiles%</emphasis>/dbus-1/services
656         if %CommonProgramFiles% is set: this location is suitable for
657         system-wide installed software packages
658       </para>
659     </listitem>
660     <listitem>
661       <para>
662         A share/dbus-1/services directory found in the same
663         directory hierarchy (prefix) as the dbus-daemon: this location
664         is suitable for software stacks installed alongside dbus-daemon
665       </para>
666     </listitem>
667   </itemizedlist>
668 </para>
669
670
671 <para>The &lt;standard_session_servicedirs/&gt; option is only relevant to the
672 per-user-session bus daemon defined in
673 @EXPANDED_SYSCONFDIR@/dbus-1/session.conf. Putting it in any other
674 configuration file would probably be nonsense.</para>
675
676 <itemizedlist remap='TP'>
677
678   <listitem><para><emphasis remap='I'>&lt;standard_system_servicedirs/&gt;</emphasis></para></listitem>
679
680
681 </itemizedlist>
682
683 <para>&lt;standard_system_servicedirs/&gt; specifies the standard system-wide
684   activation directories that should be searched for service files.
685   As with session services, the first directory listed has highest
686   precedence.</para>
687
688 <para>
689   On Unix, the standard session service directories are:
690   <itemizedlist>
691     <listitem>
692       <para>
693         /usr/local/share/dbus-1/system-services: this location is
694         specified by the D-Bus Specification, and is suitable for
695         software installed locally by the system administrator
696       </para>
697     </listitem>
698     <listitem>
699       <para>
700         /usr/share/dbus-1/system-services: this location is
701         specified by the D-Bus Specification, and is suitable for
702         software installed by operating system packages
703       </para>
704     </listitem>
705     <listitem>
706       <para>
707         <emphasis>${datadir}</emphasis>/dbus-1/system-services
708         for the <emphasis>${datadir}</emphasis> that was specified when
709         dbus was compiled, typically /usr/share: this location is an
710         extension provided by the reference dbus-daemon implementation,
711         and is suitable for software stacks installed alongside dbus-daemon
712       </para>
713     </listitem>
714     <listitem>
715       <para>
716         /lib/dbus-1/system-services: this location is
717         specified by the D-Bus Specification, and was intended for
718         software installed by operating system packages and used during
719         early boot (but it should be considered deprecated, because
720         the reference dbus-daemon is not designed to be available during
721         early boot)
722       </para>
723     </listitem>
724   </itemizedlist>
725 </para>
726
727 <para>
728   On Windows, there is no standard system bus, so there are no standard
729   system bus directories either.
730 </para>
731
732 <para>The &lt;standard_system_servicedirs/&gt; option is only relevant to the
733 per-system bus daemon defined in
734 @EXPANDED_DATADIR@/dbus-1/system.conf. Putting it in any other
735 configuration file would probably be nonsense.</para>
736
737 <itemizedlist remap='TP'>
738
739   <listitem><para><emphasis remap='I'>&lt;servicehelper/&gt;</emphasis></para></listitem>
740
741
742 </itemizedlist>
743
744 <para>&lt;servicehelper/&gt; specifies the setuid helper that is used to launch
745 system daemons with an alternate user. Typically this should be
746 the dbus-daemon-launch-helper executable in located in libexec.</para>
747
748
749 <para>The &lt;servicehelper/&gt; option is only relevant to the per-system bus daemon
750 defined in @EXPANDED_DATADIR@/dbus-1/system.conf. Putting it in any other
751 configuration file would probably be nonsense.</para>
752
753 <itemizedlist remap='TP'>
754
755   <listitem><para><emphasis remap='I'>&lt;limit&gt;</emphasis></para></listitem>
756
757
758 </itemizedlist>
759
760 <para>&lt;limit&gt; establishes a resource limit. For example:</para>
761 <literallayout remap='.nf'>
762   &lt;limit name="max_message_size"&gt;64&lt;/limit&gt;
763   &lt;limit name="max_completed_connections"&gt;512&lt;/limit&gt;
764 </literallayout> <!-- .fi -->
765
766
767 <para>The name attribute is mandatory.
768 Available limit names are:</para>
769 <literallayout remap='.nf'>
770       "max_incoming_bytes"         : total size in bytes of messages
771                                      incoming from a single connection
772       "max_incoming_unix_fds"      : total number of unix fds of messages
773                                      incoming from a single connection
774       "max_outgoing_bytes"         : total size in bytes of messages
775                                      queued up for a single connection
776       "max_outgoing_unix_fds"      : total number of unix fds of messages
777                                      queued up for a single connection
778       "max_message_size"           : max size of a single message in
779                                      bytes
780       "max_message_unix_fds"       : max unix fds of a single message
781       "service_start_timeout"      : milliseconds (thousandths) until
782                                      a started service has to connect
783       "auth_timeout"               : milliseconds (thousandths) a
784                                      connection is given to
785                                      authenticate
786       "pending_fd_timeout"         : milliseconds (thousandths) a
787                                      fd is given to be transmitted to
788                                      dbus-daemon before disconnecting the
789                                      connection
790       "max_completed_connections"  : max number of authenticated connections
791       "max_incomplete_connections" : max number of unauthenticated
792                                      connections
793       "max_connections_per_user"   : max number of completed connections from
794                                      the same user
795       "max_pending_service_starts" : max number of service launches in
796                                      progress at the same time
797       "max_names_per_connection"   : max number of names a single
798                                      connection can own
799       "max_match_rules_per_connection": max number of match rules for a single
800                                         connection
801       "max_replies_per_connection" : max number of pending method
802                                      replies per connection
803                                      (number of calls-in-progress)
804       "reply_timeout"              : milliseconds (thousandths)
805                                      until a method call times out
806 </literallayout> <!-- .fi -->
807
808
809 <para>The max incoming/outgoing queue sizes allow a new message to be queued
810 if one byte remains below the max. So you can in fact exceed the max
811 by max_message_size.</para>
812
813
814 <para>max_completed_connections divided by max_connections_per_user is the
815 number of users that can work together to denial-of-service all other users by using
816 up all connections on the systemwide bus.</para>
817
818
819 <para>Limits are normally only of interest on the systemwide bus, not the user session
820 buses.</para>
821
822 <itemizedlist remap='TP'>
823
824   <listitem><para><emphasis remap='I'>&lt;policy&gt;</emphasis></para></listitem>
825
826
827 </itemizedlist>
828
829 <para>The &lt;policy&gt; element defines a security policy to be applied to a particular
830 set of connections to the bus. A policy is made up of
831 &lt;allow&gt; and &lt;deny&gt; elements. Policies are normally used with the systemwide bus;
832 they are analogous to a firewall in that they allow expected traffic
833 and prevent unexpected traffic.</para>
834
835
836 <para>
837   Currently, the system bus has a default-deny policy for sending method calls
838   and owning bus names, and a default-allow policy for receiving messages,
839   sending signals, and sending a single success or error reply for each
840   method call that does not have the <literal>NO_REPLY</literal> flag.
841   Sending more than the expected number of replies is not allowed.
842 </para>
843
844
845 <para>In general, it is best to keep system services as small, targeted programs which
846 run in their own process and provide a single bus name.  Then, all that is needed
847 is an &lt;allow&gt; rule for the "own" permission to let the process claim the bus
848 name, and a "send_destination" rule to allow traffic from some or all uids to
849 your service.</para>
850
851
852 <para>The &lt;policy&gt; element has one of four attributes:</para>
853 <literallayout remap='.nf'>
854   context="(default|mandatory)"
855   at_console="(true|false)"
856   user="username or userid"
857   group="group name or gid"
858 </literallayout> <!-- .fi -->
859
860
861 <para>Policies are applied to a connection as follows:</para>
862 <literallayout remap='.nf'>
863    - all context="default" policies are applied
864    - all group="connection's user's group" policies are applied
865      in undefined order
866    - all user="connection's auth user" policies are applied
867      in undefined order
868    - all at_console="true" policies are applied
869    - all at_console="false" policies are applied
870    - all context="mandatory" policies are applied
871 </literallayout> <!-- .fi -->
872
873
874 <para>Policies applied later will override those applied earlier,
875 when the policies overlap. Multiple policies with the same
876 user/group/context are applied in the order they appear
877 in the config file.</para>
878
879 <variablelist remap='TP'>
880   <varlistentry>
881   <term><emphasis remap='I'>&lt;deny&gt;</emphasis></term>
882   <listitem>
883 <para><emphasis remap='I'>&lt;allow&gt;</emphasis></para>
884
885   </listitem>
886   </varlistentry>
887 </variablelist>
888
889 <para>A &lt;deny&gt; element appears below a &lt;policy&gt; element and prohibits some
890 action. The &lt;allow&gt; element makes an exception to previous &lt;deny&gt;
891 statements, and works just like &lt;deny&gt; but with the inverse meaning.</para>
892
893
894 <para>The possible attributes of these elements are:</para>
895 <literallayout remap='.nf'>
896    send_interface="interface_name" | "*"
897    send_member="method_or_signal_name" | "*"
898    send_error="error_name" | "*"
899    send_broadcast="true" | "false"
900    send_destination="name" | "*"
901    send_type="method_call" | "method_return" | "signal" | "error" | "*"
902    send_path="/path/name" | "*"
903
904    receive_interface="interface_name" | "*"
905    receive_member="method_or_signal_name" | "*"
906    receive_error="error_name" | "*"
907    receive_sender="name" | "*"
908    receive_type="method_call" | "method_return" | "signal" | "error" | "*"
909    receive_path="/path/name" | "*"
910
911    send_requested_reply="true" | "false"
912    receive_requested_reply="true" | "false"
913
914    eavesdrop="true" | "false"
915
916    own="name" | "*"
917    own_prefix="name"
918    user="username" | "*"
919    group="groupname" | "*"
920 </literallayout> <!-- .fi -->
921
922
923 <para>Examples:</para>
924 <literallayout remap='.nf'>
925    &lt;deny send_destination="org.freedesktop.Service" send_interface="org.freedesktop.System" send_member="Reboot"/&gt;
926    &lt;deny send_destination="org.freedesktop.System"/&gt;
927    &lt;deny receive_sender="org.freedesktop.System"/&gt;
928    &lt;deny user="john"/&gt;
929    &lt;deny group="enemies"/&gt;
930 </literallayout> <!-- .fi -->
931
932
933 <para>The &lt;deny&gt; element's attributes determine whether the deny "matches" a
934 particular action. If it matches, the action is denied (unless later
935 rules in the config file allow it).</para>
936
937 <para>
938   Rules with one or more of the <literal>send_</literal>* family of attributes
939   are checked in order when a connection attempts to send a message. The last
940   rule that matches the message determines whether it may be sent.
941   The well-known session bus normally allows sending any message.
942   The well-known system bus normally allows sending any signal, selected
943   method calls to the <command>dbus-daemon</command>, and exactly one
944   reply to each previously-sent method call (either success or an error).
945   Either of these can be overridden by configuration; on the system bus,
946   services that will receive method calls must install configuration that
947   allows them to do so, usually via rules of the form
948   <literal>&lt;policy context="default"&gt;&lt;allow send_destination="&hellip;"/&gt;&lt;policy&gt;</literal>.
949 </para>
950
951 <para>
952   Rules with one or more of the <literal>receive_</literal>* family of
953   attributes, or with the <literal>eavesdrop</literal> attribute and no others,
954   are checked for each recipient of a message (there might be more than one
955   recipient if the message is a broadcast or a connection is eavesdropping).
956   The last rule that matches the message determines whether it may be received.
957   The well-known session bus normally allows receiving any message, including
958   eavesdropping. The well-known system bus normally allows receiving any
959   message that was not eavesdropped (any unicast message addressed to the
960   recipient, and any broadcast message).
961 </para>
962
963 <para>
964   The <literal>eavesdrop</literal>, <literal>min_fds</literal> and
965   <literal>max_fds</literal> attributes are modifiers that can be applied
966   to either <literal>send_</literal>* or <literal>receive_</literal>*
967   rules, and are documented below.
968 </para>
969
970 <para>send_destination and receive_sender rules mean that messages may not be
971 sent to or received from the *owner* of the given name, not that
972 they may not be sent *to that name*. That is, if a connection
973 owns services A, B, C, and sending to A is denied, sending to B or C
974 will not work either. As a special case,
975 <literal>send_destination="*"</literal> matches any message
976 (whether it has a destination specified or not), and
977 <literal>receive_sender="*"</literal> similarly matches any message.</para>
978
979 <para>
980   Rules with <literal>send_broadcast="true"</literal> match signal messages
981   with no destination (broadcasts). Rules with
982   <literal>send_broadcast="false"</literal> are the inverse: they match any
983   unicast destination (unicast signals, together with all method calls, replies
984   and errors) but do not match messages with no destination (broadcasts). This
985   is not the same as <literal>send_destination="*"</literal>, which matches any
986   sent message, regardless of whether it has a destination or not.
987 </para>
988
989 <para>
990   The other <literal>send_</literal>* and <literal>receive_</literal>*
991   attributes are purely textual/by-value matches against the given field in
992   the message header, except that for the attributes where it is allowed,
993   <literal>*</literal> matches any message (whether it has the relevant
994   header field or not). For example, <literal>send_interface="*"</literal>
995   matches any sent message, even if it does not contain an interface header
996   field. More complex glob matching such as <literal>foo.bar.*</literal> is
997   not allowed.
998 </para>
999
1000 <para>"Eavesdropping" occurs when an application receives a message that
1001 was explicitly addressed to a name the application does not own, or
1002 is a reply to such a message. Eavesdropping thus only applies to
1003 messages that are addressed to services and replies to such messages
1004 (i.e. it does not apply to signals).</para>
1005
1006 <para>For &lt;allow&gt;, eavesdrop="true" indicates that the rule matches even
1007 when eavesdropping. eavesdrop="false" is the default and means that
1008 the rule only allows messages to go to their specified recipient.
1009 For &lt;deny&gt;, eavesdrop="true" indicates that the rule matches
1010 only when eavesdropping. eavesdrop="false" is the default for &lt;deny&gt;
1011 also, but here it means that the rule applies always, even when
1012 not eavesdropping. The eavesdrop attribute can only be combined with
1013 send and receive rules (with send_* and receive_* attributes).</para>
1014
1015 <para>The [send|receive]_requested_reply attribute works similarly to the eavesdrop
1016 attribute. It controls whether the &lt;deny&gt; or &lt;allow&gt; matches a reply
1017 that is expected (corresponds to a previous method call message).
1018 This attribute only makes sense for reply messages (errors and method
1019 returns), and is ignored for other message types.</para>
1020
1021
1022 <para>For &lt;allow&gt;, [send|receive]_requested_reply="true" is the default and indicates that
1023 only requested replies are allowed by the
1024 rule. [send|receive]_requested_reply="false" means that the rule allows any reply
1025 even if unexpected.</para>
1026
1027
1028 <para>For &lt;deny&gt;, [send|receive]_requested_reply="false" is the default but indicates that
1029 the rule matches only when the reply was not
1030 requested. [send|receive]_requested_reply="true" indicates that the rule applies
1031 always, regardless of pending reply state.</para>
1032
1033 <para>
1034   The <literal>min_fds</literal> and <literal>max_fds</literal> attributes
1035   modify either <literal>send_</literal>* or <literal>receive_</literal>*
1036   rules. A rule with the <literal>min_fds</literal> attribute only matches
1037   messages if they have at least that many Unix file descriptors attached.
1038   Conversely, a rule with the <literal>max_fds</literal> attribute only
1039   matches messages if they have no more than that many file descriptors
1040   attached. In practice, rules with these attributes will most commonly
1041   take the form
1042   <literal>&lt;allow send_destination="&hellip;" max_fds="0"/&gt;</literal>,
1043   <literal>&lt;deny send_destination="&hellip;" min_fds="1"/&gt;</literal> or
1044   <literal>&lt;deny receive_sender="*" min_fds="1"/&gt;</literal>.
1045 </para>
1046
1047 <para>
1048   Rules with the <literal>user</literal> or <literal>group</literal>
1049   attribute are checked when a new connection to the message bus is
1050   established, and control whether the connection can continue.
1051   Each of these attributes cannot be combined with any other
1052   attribute. As a special case, both <literal>user="*"</literal> and
1053   <literal>group="*"</literal> match any connection. If there are
1054   no rules of this form, the default is to allow connections from the same
1055   user ID that owns the <command>dbus-daemon</command> process. The well-known
1056   session bus normally uses that default behaviour, while the well-known
1057   system bus normally allows any connection.
1058 </para>
1059
1060 <para>
1061   Rules with the <literal>own</literal> or <literal>own_prefix</literal>
1062   attribute are checked when a connection attempts to own a well-known bus
1063   names. As a special case, <literal>own="*"</literal> matches any well-known
1064   bus name. The well-known session bus normally allows any connection to
1065   own any name, while the well-known system bus normally does not allow any
1066   connection to own any name, except where allowed by further configuration.
1067   System services that will own a name must install configuration that allows
1068   them to do so, usually via rules of the form
1069   <literal>&lt;policy user="some-system-user"&gt;&lt;allow own="&hellip;"/&gt;&lt;/policy&gt;</literal>.
1070 </para>
1071
1072 <para>&lt;allow own_prefix="a.b"/&gt; allows you to own the name "a.b" or any
1073 name whose first dot-separated elements are "a.b": in particular,
1074 you can own "a.b.c" or "a.b.c.d", but not "a.bc" or "a.c".
1075 This is useful when services like Telepathy and ReserveDevice
1076 define a meaning for subtrees of well-known names, such as
1077 org.freedesktop.Telepathy.ConnectionManager.(anything)
1078 and org.freedesktop.ReserveDevice1.(anything).</para>
1079
1080
1081 <para>It does not make sense to deny a user or group inside a &lt;policy&gt;
1082 for a user or group; user/group denials can only be inside
1083 context="default" or context="mandatory" policies.</para>
1084
1085
1086 <para>A single &lt;deny&gt; rule may specify combinations of attributes such as
1087 send_destination and send_interface and send_type. In this case, the
1088 denial applies only if both attributes match the message being denied.
1089 e.g. &lt;deny send_interface="foo.bar" send_destination="foo.blah"/&gt; would
1090 deny messages with the given interface AND the given bus name.
1091 To get an OR effect you specify multiple &lt;deny&gt; rules.</para>
1092
1093
1094 <para>You can't include both send_ and receive_ attributes on the same
1095 rule, since "whether the message can be sent" and "whether it can be
1096 received" are evaluated separately.</para>
1097
1098
1099 <para>Be careful with send_interface/receive_interface, because the
1100 interface field in messages is optional.  In particular, do NOT
1101 specify &lt;deny send_interface="org.foo.Bar"/&gt;!  This will cause
1102 no-interface messages to be blocked for all services, which is
1103 almost certainly not what you intended.  Always use rules of
1104 the form: &lt;deny send_interface="org.foo.Bar" send_destination="org.foo.Service"/&gt;</para>
1105
1106 <itemizedlist remap='TP'>
1107
1108   <listitem><para><emphasis remap='I'>&lt;selinux&gt;</emphasis></para></listitem>
1109
1110
1111 </itemizedlist>
1112
1113 <para>The &lt;selinux&gt; element contains settings related to Security Enhanced Linux.
1114 More details below.</para>
1115
1116 <itemizedlist remap='TP'>
1117
1118   <listitem><para><emphasis remap='I'>&lt;associate&gt;</emphasis></para></listitem>
1119
1120
1121 </itemizedlist>
1122
1123 <para>An &lt;associate&gt; element appears below an &lt;selinux&gt; element and
1124 creates a mapping. Right now only one kind of association is possible:</para>
1125 <literallayout remap='.nf'>
1126    &lt;associate own="org.freedesktop.Foobar" context="foo_t"/&gt;
1127 </literallayout> <!-- .fi -->
1128
1129
1130 <para>This means that if a connection asks to own the name
1131 "org.freedesktop.Foobar" then the source context will be the context
1132 of the connection and the target context will be "foo_t" - see the
1133 short discussion of SELinux below.</para>
1134
1135
1136 <para>Note, the context here is the target context when requesting a name,
1137 NOT the context of the connection owning the name.</para>
1138
1139
1140 <para>There's currently no way to set a default for owning any name, if
1141 we add this syntax it will look like:</para>
1142 <literallayout remap='.nf'>
1143    &lt;associate own="*" context="foo_t"/&gt;
1144 </literallayout> <!-- .fi -->
1145 <para>If you find a reason this is useful, let the developers know.
1146 Right now the default will be the security context of the bus itself.</para>
1147
1148
1149 <para>If two &lt;associate&gt; elements specify the same name, the element
1150 appearing later in the configuration file will be used.</para>
1151
1152 <itemizedlist remap='TP'>
1153
1154   <listitem><para><emphasis remap='I'>&lt;apparmor&gt;</emphasis></para></listitem>
1155
1156
1157 </itemizedlist>
1158
1159 <para>The &lt;apparmor&gt; element is used to configure AppArmor mediation on
1160 the bus. It can contain one attribute that specifies the mediation mode:</para>
1161
1162 <literallayout remap='.nf'>
1163    &lt;apparmor mode="(enabled|disabled|required)"/&gt;
1164 </literallayout> <!-- .fi -->
1165
1166 <para>The default mode is "enabled". In "enabled" mode, AppArmor mediation
1167 will be performed if AppArmor support is available in the kernel. If it is not
1168 available, dbus-daemon will start but AppArmor mediation will not occur. In
1169 "disabled" mode, AppArmor mediation is disabled. In "required" mode, AppArmor
1170 mediation will be enabled if AppArmor support is available, otherwise
1171 dbus-daemon will refuse to start.</para>
1172
1173 <para>The AppArmor mediation mode of the bus cannot be changed after the bus
1174 starts. Modifying the mode in the configuration file and sending a SIGHUP
1175 signal to the daemon has no effect on the mediation mode.</para>
1176
1177 </refsect1>
1178
1179 <refsect1 id='selinux'><title>SELinux</title>
1180 <para>See <ulink url='http://www.nsa.gov/selinux/'>http://www.nsa.gov/selinux/</ulink> for full details on SELinux. Some useful excerpts:</para>
1181
1182
1183 <para>Every subject (process) and object (e.g. file, socket, IPC object,
1184 etc) in the system is assigned a collection of security attributes,
1185 known as a security context. A security context contains all of the
1186 security attributes associated with a particular subject or object
1187 that are relevant to the security policy.</para>
1188
1189
1190 <para>In order to better encapsulate security contexts and to provide
1191 greater efficiency, the policy enforcement code of SELinux typically
1192 handles security identifiers (SIDs) rather than security contexts. A
1193 SID is an integer that is mapped by the security server to a security
1194 context at runtime.</para>
1195
1196
1197 <para>When a security decision is required, the policy enforcement code
1198 passes a pair of SIDs (typically the SID of a subject and the SID of
1199 an object, but sometimes a pair of subject SIDs or a pair of object
1200 SIDs), and an object security class to the security server. The object
1201 security class indicates the kind of object, e.g. a process, a regular
1202 file, a directory, a TCP socket, etc.</para>
1203
1204
1205 <para>Access decisions specify whether or not a permission is granted for a
1206 given pair of SIDs and class. Each object class has a set of
1207 associated permissions defined to control operations on objects with
1208 that class.</para>
1209
1210
1211 <para>D-Bus performs SELinux security checks in two places.</para>
1212
1213
1214 <para>First, any time a message is routed from one connection to another
1215 connection, the bus daemon will check permissions with the security context of
1216 the first connection as source, security context of the second connection
1217 as target, object class "dbus" and requested permission "send_msg".</para>
1218
1219
1220 <para>If a security context is not available for a connection
1221 (impossible when using UNIX domain sockets), then the target
1222 context used is the context of the bus daemon itself.
1223 There is currently no way to change this default, because we're
1224 assuming that only UNIX domain sockets will be used to
1225 connect to the systemwide bus. If this changes, we'll
1226 probably add a way to set the default connection context.</para>
1227
1228
1229 <para>Second, any time a connection asks to own a name,
1230 the bus daemon will check permissions with the security
1231 context of the connection as source, the security context specified
1232 for the name in the config file as target, object
1233 class "dbus" and requested permission "acquire_svc".</para>
1234
1235
1236 <para>The security context for a bus name is specified with the
1237 &lt;associate&gt; element described earlier in this document.
1238 If a name has no security context associated in the
1239 configuration file, the security context of the bus daemon
1240 itself will be used.</para>
1241
1242 </refsect1>
1243
1244 <refsect1 id='apparmor'><title>AppArmor</title>
1245 <para>The AppArmor confinement context is stored when applications connect to
1246 the bus. The confinement context consists of a label and a confinement mode.
1247 When a security decision is required, the daemon uses the confinement context
1248 to query the AppArmor policy to determine if the action should be allowed or
1249 denied and if the action should be audited.</para>
1250
1251 <para>The daemon performs AppArmor security checks in three places.</para>
1252
1253 <para>First, any time a message is routed from one connection to another
1254 connection, the bus daemon will check permissions with the label of the first
1255 connection as source, label and/or connection name of the second connection as
1256 target, along with the bus name, the path name, the interface name, and the
1257 member name. Reply messages, such as method_return and error messages, are
1258 implicitly allowed if they are in response to a message that has already been
1259 allowed.</para>
1260
1261 <para>Second, any time a connection asks to own a name, the bus daemon will
1262 check permissions with the label of the connection as source, the requested
1263 name as target, along with the bus name.</para>
1264
1265 <para>Third, any time a connection attempts to eavesdrop, the bus daemon will
1266 check permissions with the label of the connection as the source, along with
1267 the bus name.</para>
1268
1269 <para>AppArmor rules for bus mediation are not stored in the bus configuration
1270 files. They are stored in the application's AppArmor profile. Please see
1271 <emphasis remap='I'>apparmor.d(5)</emphasis> for more details.</para>
1272
1273 </refsect1>
1274
1275 <refsect1 id='debugging'><title>DEBUGGING</title>
1276 <para>If you're trying to figure out where your messages are going or why
1277 you aren't getting messages, there are several things you can try.</para>
1278
1279 <para>Remember that the system bus is heavily locked down and if you
1280 haven't installed a security policy file to allow your message
1281 through, it won't work. For the session bus, this is not a concern.</para>
1282
1283 <para>The simplest way to figure out what's happening on the bus is to run
1284 the <emphasis remap='I'>dbus-monitor</emphasis> program, which comes with the D-Bus
1285 package. You can also send test messages with <emphasis remap='I'>dbus-send</emphasis>. These
1286 programs have their own man pages.</para>
1287
1288 <para>If you want to know what the daemon itself is doing, you might consider
1289 running a separate copy of the daemon to test against. This will allow you
1290 to put the daemon under a debugger, or run it with verbose output, without
1291 messing up your real session and system daemons.</para>
1292
1293 <para>To run a separate test copy of the daemon, for example you might open a terminal
1294 and type:</para>
1295 <literallayout remap='.nf'>
1296   DBUS_VERBOSE=1 dbus-daemon --session --print-address
1297 </literallayout> <!-- .fi -->
1298
1299 <para>The test daemon address will be printed when the daemon starts. You will need
1300 to copy-and-paste this address and use it as the value of the
1301 DBUS_SESSION_BUS_ADDRESS environment variable when you launch the applications
1302 you want to test. This will cause those applications to connect to your
1303 test bus instead of the DBUS_SESSION_BUS_ADDRESS of your real session bus.</para>
1304
1305 <para>DBUS_VERBOSE=1 will have NO EFFECT unless your copy of D-Bus
1306 was compiled with verbose mode enabled. This is not recommended in
1307 production builds due to performance impact. You may need to rebuild
1308 D-Bus if your copy was not built with debugging in mind. (DBUS_VERBOSE
1309 also affects the D-Bus library and thus applications using D-Bus; it may
1310 be useful to see verbose output on both the client side and from the daemon.)</para>
1311
1312 <para>If you want to get fancy, you can create a custom bus
1313 configuration for your test bus (see the session.conf and system.conf
1314 files that define the two default configurations for example). This
1315 would allow you to specify a different directory for .service files,
1316 for example.</para>
1317
1318 </refsect1>
1319
1320 <refsect1 id='author'><title>AUTHOR</title>
1321 <para>See <ulink url='http://www.freedesktop.org/software/dbus/doc/AUTHORS'>http://www.freedesktop.org/software/dbus/doc/AUTHORS</ulink></para>
1322
1323 </refsect1>
1324
1325 <refsect1 id='bugs'><title>BUGS</title>
1326 <para>Please send bug reports to the D-Bus mailing list or bug tracker,
1327 see <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink></para>
1328 </refsect1>
1329 </refentry>