2020-03-18 15:22:29 +03:00
<?xml version='1.0'?>
< !DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
2023-12-25 17:48:33 +03:00
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
2020-11-09 07:23:58 +03:00
<!-- SPDX - License - Identifier: LGPL - 2.1 - or - later -->
2020-03-18 15:22:29 +03:00
<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>
2020-04-11 22:57:36 +03:00
<refname > sd_bus_set_exec</refname>
2020-03-18 15:22:29 +03:00
<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>
2020-04-11 22:57:36 +03:00
<paramdef > const char *<parameter > address</parameter> </paramdef>
2020-03-18 15:22:29 +03:00
</funcprototype>
<funcprototype >
<funcdef > int <function > sd_bus_get_address</function> </funcdef>
<paramdef > sd_bus *<parameter > bus</parameter> </paramdef>
2020-04-11 22:57:36 +03:00
<paramdef > const char **<parameter > address</parameter> </paramdef>
2020-03-18 15:22:29 +03:00
</funcprototype>
2020-04-11 22:57:36 +03:00
<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>
2020-03-18 15:22:29 +03:00
</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>
2020-04-11 22:57:36 +03:00
2020-03-18 15:22:29 +03:00
<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>
2020-04-11 22:57:36 +03:00
2020-03-18 15:22:29 +03:00
<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>
2020-04-11 22:57:36 +03:00
2020-11-10 00:38:36 +03:00
<para > <function > sd_bus_set_exec()</function> is a shorthand function for setting a
2020-04-11 22:57:36 +03:00
<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>
2020-03-18 15:22:29 +03:00
</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> .
2023-08-22 19:52:36 +03:00
</para>
<xi:include href= "version-info.xml" xpointer= "v246" /> </listitem>
2020-03-18 15:22:29 +03:00
</varlistentry>
<varlistentry >
<term > <constant > -ENOPKG</constant> </term>
<listitem > <para > The bus object <parameter > bus</parameter> could not be resolved.</para>
2023-08-22 19:52:36 +03:00
<xi:include href= "version-info.xml" xpointer= "v246" />
2020-03-18 15:22:29 +03:00
</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>
2023-08-22 19:52:36 +03:00
<xi:include href= "version-info.xml" xpointer= "v246" />
2020-03-18 15:22:29 +03:00
</listitem>
</varlistentry>
<varlistentry >
<term > <constant > -ECHILD</constant> </term>
<listitem > <para > The bus object <parameter > bus</parameter> was created in a different
process.</para>
2023-08-22 19:52:36 +03:00
<xi:include href= "version-info.xml" xpointer= "v246" />
2020-03-18 15:22:29 +03:00
</listitem>
</varlistentry>
<varlistentry >
<term > <constant > -ENODATA</constant> </term>
<listitem > <para > The bus object <parameter > bus</parameter> has no address configured.</para>
2023-08-22 19:52:36 +03:00
<xi:include href= "version-info.xml" xpointer= "v246" />
2020-03-18 15:22:29 +03:00
</listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
<xi:include href= "libsystemd-pkgconfig.xml" />
2023-09-04 15:46:35 +03:00
<refsect1 >
<title > History</title>
2023-09-18 19:44:26 +03:00
<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>
2023-09-04 15:46:35 +03:00
</refsect1>
2020-03-18 15:22:29 +03:00
<refsect1 >
<title > See Also</title>
2023-12-22 21:09:32 +03:00
<para > <simplelist type= "inline" >
<member > <citerefentry > <refentrytitle > systemd</refentrytitle> <manvolnum > 1</manvolnum> </citerefentry> </member>
<member > <citerefentry > <refentrytitle > sd-bus</refentrytitle> <manvolnum > 3</manvolnum> </citerefentry> </member>
<member > <citerefentry > <refentrytitle > sd_bus_new</refentrytitle> <manvolnum > 3</manvolnum> </citerefentry> </member>
<member > <citerefentry > <refentrytitle > sd_bus_start</refentrytitle> <manvolnum > 3</manvolnum> </citerefentry> </member>
<member > <citerefentry > <refentrytitle > systemd-machined.service</refentrytitle> <manvolnum > 8</manvolnum> </citerefentry> </member>
<member > <citerefentry > <refentrytitle > machinectl</refentrytitle> <manvolnum > 1</manvolnum> </citerefentry> </member>
</simplelist> </para>
2020-03-18 15:22:29 +03:00
</refsect1>
</refentry>