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