1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
<refentry id="sd_bus_set_address"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_bus_set_address</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>sd_bus_set_address</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_bus_set_address</refname>
<refname>sd_bus_get_address</refname>
<refname>sd_bus_set_exec</refname>
<refpurpose>Set or query the address of the bus connection</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_bus_set_address</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>const char *<parameter>address</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_get_address</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>const char **<parameter>address</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_set_exec</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>const char *<parameter>path</parameter></paramdef>
<paramdef>char *const *<parameter>argv</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_bus_set_address()</function> configures a list of addresses of bus brokers to try to
connect to from a subsequent
<citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry> call.
The argument is a <literal>;</literal>-separated list of addresses to try. Each item must be one of the
following:
</para>
<itemizedlist>
<listitem>
<para>A unix socket address specified as
<literal>unix:guid=<replaceable>guid</replaceable>,path=<replaceable>path</replaceable></literal> or
<literal>unix:guid=<replaceable>guid</replaceable>,abstract=<replaceable>path</replaceable></literal>.
Exactly one of the <varname>path=</varname> and <varname>abstract=</varname> keys must be present,
while <varname>guid=</varname> is optional.</para>
</listitem>
<listitem>
<para>A TCP socket address specified as
<literal>tcp:[guid=<replaceable>guid</replaceable>,][host=<replaceable>host</replaceable>][,port=<replaceable>port</replaceable>][,family=<replaceable>family</replaceable>]</literal>.
One or both of the <varname>host=</varname> and <varname>port=</varname> keys must be present, while
the rest is optional. <replaceable>family</replaceable> may be either <option>ipv4</option> or
<option>ipv6</option>.</para>
</listitem>
<listitem>
<para>An executable to spawn specified as
<literal>unixexec:guid=<replaceable>guid</replaceable>,path=<replaceable>path</replaceable>,argv1=<replaceable>argument</replaceable>,argv2=<replaceable>argument</replaceable>,...</literal>.
The <varname>path=</varname> key must be present, while <varname>guid=</varname> is optional.</para>
</listitem>
<listitem>
<para>A machine (container) to connect to specified as
<literal>x-machine-unix:guid=<replaceable>guid</replaceable>,machine=<replaceable>machine</replaceable>,pid=<replaceable>pid</replaceable></literal>.
Exactly one of the <varname>machine=</varname> and <varname>pid=</varname> keys must be present,
while <varname>guid=</varname> is optional. <parameter>machine</parameter> is the name of a local
container. See
<citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry> for
more information about the "machine" concept. <literal>machine=.host</literal> may be used to specify
the host machine. A connection to the standard system bus socket inside of the specified machine will
be created.</para>
</listitem>
</itemizedlist>
<para>In all cases, parameter <parameter>guid</parameter> is an identifier of the remote peer, in the
syntax accepted by
<citerefentry><refentrytitle>sd_id128_from_string</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
If specified, the identifier returned by the peer after the connection is established will be checked and
the connection will be rejected in case of a mismatch.</para>
<para>Note that the addresses passed to <function>sd_bus_set_address()</function> may not be verified
immediately. If they are invalid, an error may be returned e.g. from a subsequent call to
<citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
<para><function>sd_bus_get_address()</function> returns any previously set addresses. In addition to
being explicitly set by <function>sd_bus_set_address()</function>, the address will also be set
automatically by
<citerefentry><refentrytitle>sd_bus_open</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
similar calls, based on environment variables or built-in defaults.</para>
<para><function>sd_bus_set_exec()</function> is a shorthand function for setting a
<literal>unixexec</literal> address that spawns the given executable with the given arguments.
If <parameter>argv</parameter> is <constant>NULL</constant>, the given executable is spawned
without any extra arguments.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success, these functions return a non-negative integer. On failure, they return a negative
errno-style error code.</para>
<refsect2>
<title>Errors</title>
<para>Returned errors may indicate the following problems:</para>
<variablelist>
<varlistentry>
<term><constant>-EINVAL</constant></term>
<listitem><para>The input parameters <parameter>bus</parameter> or <parameter>address</parameter> are <constant>NULL</constant>.
</para>
<xi:include href="version-info.xml" xpointer="v246"/></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOPKG</constant></term>
<listitem><para>The bus object <parameter>bus</parameter> could not be resolved.</para>
<xi:include href="version-info.xml" xpointer="v246"/>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>-EPERM</constant></term>
<listitem><para>The input parameter <parameter>bus</parameter> is in a wrong state
(<function>sd_bus_set_address()</function> may only be called once on a newly-created bus object).</para>
<xi:include href="version-info.xml" xpointer="v246"/>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>-ECHILD</constant></term>
<listitem><para>The bus object <parameter>bus</parameter> was created in a different
process.</para>
<xi:include href="version-info.xml" xpointer="v246"/>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENODATA</constant></term>
<listitem><para>The bus object <parameter>bus</parameter> has no address configured.</para>
<xi:include href="version-info.xml" xpointer="v246"/>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
<xi:include href="libsystemd-pkgconfig.xml" />
<refsect1>
<title>History</title>
<para><function>sd_bus_set_address()</function>,
<function>sd_bus_get_address()</function>, and
<function>sd_bus_set_exec()</function> were added in version 246.</para>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>
|