2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="sd_bus_set_description" xmlns:xi="http://www.w3.org/2001/XInclude">
9 <title>sd_bus_set_description</title>
10 <productname>systemd</productname>
14 <refentrytitle>sd_bus_set_description</refentrytitle>
15 <manvolnum>3</manvolnum>
19 <refname>sd_bus_set_description</refname>
20 <refname>sd_bus_get_description</refname>
21 <refname>sd_bus_set_anonymous</refname>
22 <refname>sd_bus_is_anonymous</refname>
23 <refname>sd_bus_set_trusted</refname>
24 <refname>sd_bus_is_trusted</refname>
25 <refname>sd_bus_set_allow_interactive_authorization</refname>
26 <refname>sd_bus_get_allow_interactive_authorization</refname>
27 <refname>sd_bus_get_scope</refname>
28 <refname>sd_bus_get_tid</refname>
29 <refname>sd_bus_get_unique_name</refname>
31 <refpurpose>Set or query properties of a bus object</refpurpose>
36 <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
39 <funcdef>int <function>sd_bus_set_description</function></funcdef>
40 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
41 <paramdef>const char *<parameter>description</parameter></paramdef>
45 <funcdef>int <function>sd_bus_get_description</function></funcdef>
46 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
47 <paramdef>const char **<parameter>description</parameter></paramdef>
51 <funcdef>int <function>sd_bus_set_anonymous</function></funcdef>
52 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
53 <paramdef>int <parameter>b</parameter></paramdef>
57 <funcdef>int <function>sd_bus_is_anonymous</function></funcdef>
58 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
62 <funcdef>int <function>sd_bus_set_trusted</function></funcdef>
63 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
64 <paramdef>int <parameter>b</parameter></paramdef>
68 <funcdef>int <function>sd_bus_is_trusted</function></funcdef>
69 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
73 <funcdef>int <function>sd_bus_set_allow_interactive_authorization</function></funcdef>
74 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
75 <paramdef>int <parameter>b</parameter></paramdef>
79 <funcdef>int <function>sd_bus_get_allow_interactive_authorization</function></funcdef>
80 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
84 <funcdef>int <function>sd_bus_get_scope</function></funcdef>
85 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
86 <paramdef>const char **<parameter>scope</parameter></paramdef>
90 <funcdef>int <function>sd_bus_get_tid</function></funcdef>
91 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
92 <paramdef>pid_t *<parameter>tid</parameter></paramdef>
96 <funcdef>int <function>sd_bus_get_unique_name</function></funcdef>
97 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
98 <paramdef>const char **<parameter>unique</parameter></paramdef>
104 <title>Description</title>
106 <para><function>sd_bus_set_description()</function> sets the description string that is used in
107 logging to the specified string. The string is copied internally and freed when the bus object
108 is deallocated. The <parameter>description</parameter> argument may be
109 <constant>NULL</constant>, in which case the description is unset. This function must be called
110 before the bus is started.</para>
112 <para><function>sd_bus_get_description()</function> returns a description string in
113 <parameter>description</parameter>. This string may have been previously set with
114 <function>sd_bus_set_description()</function> or
115 <citerefentry><refentrytitle>sd_bus_open_with_description</refentrytitle><manvolnum>3</manvolnum></citerefentry>
116 or similar. If not set this way, a default string like <literal>system</literal> or
117 <literal>user</literal> will be returned for the system or user buses, and
118 <constant>-ENXIO</constant> otherwise.</para>
120 <para><function>sd_bus_set_anonymous()</function> enables or disables "anonymous authentication",
121 i.e. lack of authentication, of the bus peer. This function must be called before the bus is
123 <ulink url="view-source:https://dbus.freedesktop.org/doc/dbus-specification.html#auth-mechanisms">
124 D-Bus Authentication Mechanisms</ulink> section of the D-Bus specification for details.</para>
126 <para><function>sd_bus_is_anonymous()</function> returns true if the bus connection allows
127 anonymous authentication (in the sense described in previous paragraph).</para>
129 <para><function>sd_bus_set_trusted()</function> sets the "trusted" state on the
130 <parameter>bus</parameter> object. If true, all connections on the bus are trusted and access to
131 all privileged and unprivileged methods is granted. This function must be called before the bus
134 <para><function>sd_bus_is_trusted()</function> returns true if the bus connection is trusted (in
135 the sense described in previous paragraph).</para>
137 <para><function>sd_bus_set_allow_interactive_authorization()</function> enables or disables
138 interactive authorization for method calls. If true, messages are marked with the
139 <constant>ALLOW_INTERACTIVE_AUTHORIZATION</constant> flag specified by the
140 <ulink url="view-source:https://dbus.freedesktop.org/doc/dbus-specification.html">D-Bus</ulink>
141 specification, informing the receiving side that the caller is prepared to wait for interactive
142 authorization, which might take a considerable time to complete. If this flag is set, the user
143 may be queried for passwords or confirmation via
144 <ulink url="https://www.freedesktop.org/wiki/Software/polkit">polkit</ulink> or a similar
147 <para><function>sd_bus_get_allow_interactive_authorization()</function> returns true if
148 interactive authorization is allowed and false if not.</para>
150 <para><function>sd_bus_get_scope()</function> stores the scope of the given bus object in
151 <parameter>scope</parameter>. The scope of the system bus is <literal>system</literal>. The
152 scope of a user session bus is <literal>user</literal>. If the given bus object is not the
153 system or a user session bus, <function>sd_bus_get_scope()</function> returns an error.</para>
155 <para><function>sd_bus_get_tid()</function> stores the kernel thread id of the thread associated
156 with the given bus object in <parameter>tid</parameter>. If <parameter>bus</parameter> is a
157 default bus object obtained by calling one of the functions of the
158 <citerefentry><refentrytitle>sd_bus_default</refentrytitle><manvolnum>3</manvolnum></citerefentry>
159 family of functions, it stores the thread id of the thread the bus object was created in.
160 Otherwise, if the bus object is attached to an event loop, it stores the thread id of the
161 thread the event loop object was created in. If <parameter>bus</parameter> is not a default bus
162 object and is not attached to an event loop, <function>sd_bus_get_tid()</function> returns an
165 <para><function>sd_bus_get_unique_name()</function> stores the unique name of the bus object on
166 the bus in <parameter>unique</parameter>. See
167 <ulink url="https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus">
168 The D-Bus specification</ulink> for more information on bus names. Note that the caller does not
169 own the string stored in <parameter>unique</parameter> and should not free it.</para>
173 <title>Return Value</title>
175 <para>On success, these functions return a non-negative integer. On failure, they return a
176 negative errno-style error code.</para>
179 <title>Errors</title>
181 <para>Returned errors may indicate the following problems:</para>
185 <term><constant>-EINVAL</constant></term>
187 <listitem><para>An argument is invalid.</para></listitem>
191 <term><constant>-ENOPKG</constant></term>
193 <listitem><para>The bus cannot be resolved.</para></listitem>
197 <term><constant>-EPERM</constant></term>
199 <listitem><para>The bus has already been started.</para></listitem>
203 <term><constant>-ECHILD</constant></term>
205 <listitem><para>The bus was created in a different process, library or module instance.</para></listitem>
209 <term><constant>-ENOMEM</constant></term>
211 <listitem><para>Memory allocation failed.</para></listitem>
215 <term><constant>-ENODATA</constant></term>
217 <listitem><para>The bus object passed to <function>sd_bus_get_scope()</function> was not a
218 system or user session bus.</para>
220 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
224 <term><constant>-ENXIO</constant></term>
226 <listitem><para>The bus object passed to <function>sd_bus_get_tid()</function> was not a
227 default bus object and is not attached to an event loop.</para>
229 <para>The bus object passed to <function>sd_bus_get_description()</function> did
230 not have a <parameter>description</parameter>.</para>
232 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
238 <xi:include href="libsystemd-pkgconfig.xml" />
241 <title>History</title>
242 <para><function>sd_bus_set_description()</function>,
243 <function>sd_bus_get_description()</function>,
244 <function>sd_bus_set_anonymous()</function>,
245 <function>sd_bus_set_trusted()</function>,
246 <function>sd_bus_set_allow_interactive_authorization()</function>, and
247 <function>sd_bus_get_allow_interactive_authorization()</function> were added in version 240.</para>
248 <para><function>sd_bus_is_anonymous()</function>,
249 <function>sd_bus_is_trusted()</function>,
250 <function>sd_bus_get_scope()</function>,
251 <function>sd_bus_get_tid()</function>, and
252 <function>sd_bus_get_unique_name()</function> were added in version 246.</para>
256 <title>See Also</title>
259 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
260 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
261 <citerefentry><refentrytitle>sd_bus_default_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
262 <citerefentry><refentrytitle>sd_bus_default_system</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
263 <citerefentry><refentrytitle>sd_bus_open_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
264 <citerefentry><refentrytitle>sd_bus_open_system</refentrytitle><manvolnum>3</manvolnum></citerefentry>