chiark / gitweb /
ae375343d94fa1935cc8b4db592671ebdaa6c008
[elogind.git] / man / sd_bus_negotiate_fds.xml
1 <?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6   SPDX-License-Identifier: LGPL-2.1+
7
8   Copyright 2014 Lennart Poettering
9 -->
10
11 <refentry id="sd_bus_negotiate_fds" xmlns:xi="http://www.w3.org/2001/XInclude">
12
13   <refentryinfo>
14     <title>sd_bus_negotiate_fds</title>
15     <productname>systemd</productname>
16
17     <authorgroup>
18       <author>
19         <contrib>Developer</contrib>
20         <firstname>Lennart</firstname>
21         <surname>Poettering</surname>
22         <email>lennart@poettering.net</email>
23       </author>
24     </authorgroup>
25   </refentryinfo>
26
27   <refmeta>
28     <refentrytitle>sd_bus_negotiate_fds</refentrytitle>
29     <manvolnum>3</manvolnum>
30   </refmeta>
31
32   <refnamediv>
33     <refname>sd_bus_negotiate_fds</refname>
34     <refname>sd_bus_negotiate_timestamp</refname>
35     <refname>sd_bus_negotiate_creds</refname>
36
37     <refpurpose>Control feature negotiation on bus connections</refpurpose>
38   </refnamediv>
39
40   <refsynopsisdiv>
41     <funcsynopsis>
42       <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
43
44       <funcprototype>
45         <funcdef>int <function>sd_bus_negotiate_fds</function></funcdef>
46         <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
47         <paramdef>int <parameter>b</parameter></paramdef>
48       </funcprototype>
49
50       <funcprototype>
51         <funcdef>int <function>sd_bus_negotiate_timestamp</function></funcdef>
52         <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
53         <paramdef>int <parameter>b</parameter></paramdef>
54       </funcprototype>
55
56       <funcprototype>
57         <funcdef>int <function>sd_bus_negotiate_creds</function></funcdef>
58         <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
59         <paramdef>int <parameter>b</parameter></paramdef>
60         <paramdef>uint64_t <parameter>mask</parameter></paramdef>
61       </funcprototype>
62     </funcsynopsis>
63   </refsynopsisdiv>
64
65   <refsect1>
66     <title>Description</title>
67
68     <para><function>sd_bus_negotiate_fds()</function> controls whether
69     file descriptor passing shall be negotiated for the specified bus
70     connection. It takes a bus object and a boolean, which, when true,
71     enables file descriptor passing, and, when false, disables
72     it. Note that not all transports and servers support file
73     descriptor passing. In particular, networked transports generally
74     do not support file descriptor passing. To find out whether file
75     descriptor passing is available after negotiation, use
76     <citerefentry><refentrytitle>sd_bus_can_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>
77     and pass <constant>SD_BUS_TYPE_UNIX_FD</constant>. Note that file
78     descriptor passing is always enabled for both sending and
79     receiving or for neither, but never only in one direction. By
80     default, file descriptor passing is negotiated for all
81     connections.</para>
82
83     <para><function>sd_bus_negotiate_timestamp()</function> controls whether implicit sender
84     timestamps shall be attached automatically to all incoming messages. Takes a bus object and a
85     boolean, which, when true, enables timestamping, and, when false, disables it.  Use
86     <citerefentry><refentrytitle>sd_bus_message_get_monotonic_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
87     <citerefentry><refentrytitle>sd_bus_message_get_realtime_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
88     <citerefentry><refentrytitle>sd_bus_message_get_seqnum</refentrytitle><manvolnum>3</manvolnum></citerefentry>
89     to query the timestamps of incoming messages. If negotiation is disabled or not supported, these
90     calls will fail with <constant>-ENODATA</constant>. Note that currently no transports support
91     timestamping of messages. By default, message timestamping is not negotiated for
92     connections.</para>
93
94     <para><function>sd_bus_negotiate_creds()</function> controls whether and which implicit sender
95     credentials shall be attached automatically to all incoming messages. Takes a bus object and a
96     boolean indicating whether to enable or disable the credential parts encoded in the bit mask
97     value argument. Note that not all transports support attaching sender credentials to messages,
98     or do not support all types of sender credential parameters, or might suppress them under
99     certain circumstances for individual messages. Specifically, dbus1 only supports
100     <constant>SD_BUS_CREDS_UNIQUE_NAME</constant>. The sender credentials are suitable for
101     authorization decisions. By default, only <constant>SD_BUS_CREDS_WELL_KNOWN_NAMES</constant> and
102     <constant>SD_BUS_CREDS_UNIQUE_NAME</constant> are enabled. In fact, these two credential fields
103     are always sent along and cannot be turned off.</para>
104
105     <para>The <function>sd_bus_negotiate_fds()</function> function may
106     be called only before the connection has been started with
107     <citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Both
108     <function>sd_bus_negotiate_timestamp()</function> and
109     <function>sd_bus_negotiate_creds()</function> may also be called
110     after a connection has been set up. Note that, when operating on a
111     connection that is shared between multiple components of the same
112     program (for example via
113     <citerefentry><refentrytitle>sd_bus_default</refentrytitle><manvolnum>3</manvolnum></citerefentry>),
114     it is highly recommended to only enable additional per message
115     metadata fields, but never disable them again, in order not to
116     disable functionality needed by other components.</para>
117   </refsect1>
118
119   <refsect1>
120     <title>Return Value</title>
121
122     <para>On success, these functions return 0 or a
123     positive integer. On failure, they return a negative errno-style
124     error code.</para>
125   </refsect1>
126
127   <refsect1>
128     <title>Errors</title>
129
130     <para>Returned errors may indicate the following problems:</para>
131
132     <variablelist>
133       <varlistentry>
134         <term><constant>-EPERM</constant></term>
135
136         <listitem><para>The bus connection has already been started.</para></listitem>
137       </varlistentry>
138     </variablelist>
139   </refsect1>
140
141   <xi:include href="libelogind-pkgconfig.xml" />
142
143   <refsect1>
144     <title>See Also</title>
145
146     <para>
147       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
148       <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
149       <citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
150       <citerefentry><refentrytitle>sd_bus_message_can_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
151       <citerefentry><refentrytitle>sd_bus_message_get_monotonic_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
152       <citerefentry><refentrytitle>sd_bus_message_get_realtime_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
153       <citerefentry><refentrytitle>sd_bus_message_get_seqnum</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
154       <citerefentry><refentrytitle>sd_bus_message_get_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>
155     </para>
156   </refsect1>
157
158 </refentry>