1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 This file is part of systemd.
8 Copyright 2014 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="sd_bus_negotiate_fds" conditional="ENABLE_KDBUS">
27 <title>sd_bus_negotiate_fds</title>
28 <productname>systemd</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>sd_bus_negotiate_fds</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_bus_negotiate_fds</refname>
47 <refname>sd_bus_negotiate_timestamps</refname>
48 <refname>sd_bus_negotiate_creds</refname>
50 <refpurpose>Control feature negotiation on bus connections</refpurpose>
55 <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
58 <funcdef>int <function>sd_bus_negotiate_fds</function></funcdef>
59 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
60 <paramdef>int <parameter>b</parameter></paramdef>
64 <funcdef>int <function>sd_bus_negotiate_timestamp</function></funcdef>
65 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
66 <paramdef>int <parameter>b</parameter></paramdef>
70 <funcdef>int <function>sd_bus_negotiate_creds</function></funcdef>
71 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
72 <paramdef>int <parameter>b</parameter></paramdef>
78 <title>Description</title>
80 <para><function>sd_bus_negotiate_fds()</function> controls whether
81 file descriptor passing shall be negotiated for the specified bus
82 connection. It takes a bus object and a boolean, which, when true,
83 enables file descriptor passing, and, when false, disables it. Note
84 that not all transports and servers support file descriptor
85 passing. To find out whether file descriptor passing is available
86 after negotiation, use
87 <citerefentry><refentrytitle>sd_bus_can_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>
88 and pass <constant>SD_BUS_TYPE_UNIX_FD</constant>. Note that file
89 descriptor passing is always enabled for both sending and
90 receiving or for neither, but never only in one direction. By
91 default, file descriptor passing is negotiated for all
94 <para>Note that when bus activation is used, it is highly
95 recommended to set the <option>AcceptFileDescriptors=</option>
96 setting in the <filename>.busname</filename> unit file to the same
97 setting as negotiated by the program ultimately activated. By
98 default, file descriptor passing is enabled for both.</para>
100 <para><function>sd_bus_negotiate_timestamps()</function> controls
101 whether implicit sender timestamps shall be attached automatically
102 to all incoming messages. Takes a bus object and a boolean, which,
103 when true, enables timestamping, and, when false, disables it. If
105 <citerefentry><refentrytitle>sd_bus_message_get_monotonic_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
106 <citerefentry><refentrytitle>sd_bus_message_get_realtime_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
107 <citerefentry><refentrytitle>sd_bus_message_get_seqno</refentrytitle><manvolnum>3</manvolnum></citerefentry>
108 fail with <constant>-ENODATA</constant> on incoming messages. Note
109 that not all transports support timestamping of messages. On local
110 transports, the timestamping is applied by the kernel and cannot be
111 manipulated by userspace.</para>
113 <para><function>sd_bus_negotiate_creds()</function> controls
114 whether implicit sender credentials shall be attached
115 automatically to all incoming messages. Takes a bus object and a
116 bit mask value, which controls which credential parameters are
117 attached. If this is not used,
118 <citerefentry><refentrytitle>sd_bus_message_get_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>
119 fails with <constant>-ENODATA</constant> on incoming
120 messages. Note that not all transports support attaching sender
121 credentials to messages, or do not support all types of sender
122 credential parameters. On local transports, the sender credentials
123 are attached by the kernel and cannot be manipulated by
124 userspace. By default, no sender credentials are attached.</para>
126 <para>These functions may be called only before the connection has
128 <citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
132 <title>Return Value</title>
134 <para>On success, these functions returns 0 or a
135 positive integer. On failure, they return a negative errno-style
140 <title>Errors</title>
142 <para>Returned errors may indicate the following problems:</para>
146 <term><varname>-EPERM</varname></term>
148 <listitem><para>The bus connection has already been started.</para></listitem>
156 <para><function>sd_bus_negotiate_fs()</function> and the other
157 functions described here are available as a shared library, which
158 can be compiled and linked to with the
159 <constant>libsystemd</constant> <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
164 <title>See Also</title>
167 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
168 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
169 <citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
170 <citerefentry><refentrytitle>sd_bus_message_can_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
171 <citerefentry><refentrytitle>sd_bus_message_get_monotonic_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
172 <citerefentry><refentrytitle>sd_bus_message_get_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>