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