Debian Codegraph @

man/sd_varlink_server_new.xml

raw
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_varlink_server_new" xmlns:xi="http://www.w3.org/2001/XInclude">
7
8 <refentryinfo>
9 <title>sd_varlink_server_new</title>
10 <productname>systemd</productname>
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>sd_varlink_server_new</refentrytitle>
15 <manvolnum>3</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>sd_varlink_server_new</refname>
20
21 <refpurpose>Allocate Varlink server object</refpurpose>
22 </refnamediv>
23
24 <refsynopsisdiv>
25 <funcsynopsis>
26 <funcsynopsisinfo>#include &lt;systemd/sd-varlink.h&gt;</funcsynopsisinfo>
27
28 <funcprototype>
29 <funcdef>int <function>sd_varlink_server_new</function></funcdef>
30 <paramdef>sd_varlink_server** <parameter>ret</parameter></paramdef>
31 <paramdef>sd_varlink_server_flags_t <parameter>flags</parameter></paramdef>
32 </funcprototype>
33
34 </funcsynopsis>
35 </refsynopsisdiv>
36
37 <refsect1>
38 <title>Description</title>
39
40 <para><function>sd_varlink_server_new()</function> allocates a new Varlink server object. Initially the
41 server does not listen on any socket or file descriptor. The newly allocated server object is returned in
42 the <parameter>ret</parameter> parameter. Use <function>sd_varlink_server_unref()</function> to release
43 the server object again after use.</para>
44
45 <para>The following flags may be passed in the <parameter>flags</parameter> parameter:</para>
46
47 <itemizedlist>
48 <listitem><para><constant>SD_VARLINK_SERVER_ROOT_ONLY</constant>: only allow connections from UID 0
49 (i.e. the root user). This has two effects: any incoming connections is authenticated via
50 <constant>SO_PEERCRED</constant> ensuring the UID reported by the kernel is zero. If this check fails
51 the connection is immediately terminated. Moreover, when binding a socket inode in the file system, the
52 access mode is set to 0600 (rather than 0666). If this option is used connections on
53 non-<constant>AF_UNIX</constant> sockets or via pipes are never permitted.</para></listitem>
54
55 <listitem><para><constant>SD_VARLINK_SERVER_MYSELF_ONLY</constant>: this is very similar to
56 <constant>SD_VARLINK_SERVER_ROOT_ONLY</constant> but enforces that the connecting client's UID must
57 match the server's UID (i.e. the UID this function is invoked as). For servers that run as UID 0 the
58 flags are equivalent. If both flags are specified in combination, connections are allowed by both UID 0
59 and the server's own UID.</para></listitem>
60
61 <listitem><para><constant>SD_VARLINK_SERVER_ACCOUNT_UID</constant>: if set connection accounting per
62 client UID is enabled, and a limit on concurrent connections from the same UID is enforced. The limit can
63 be set via <function>sd_varlink_server_set_connections_per_uid_max()</function>, and defaults to 3/4th
64 of the total concurrent connection limit, as settable via
65 <function>sd_varlink_server_set_connections_max()</function>.</para></listitem>
66
67 <listitem><para><constant>SD_VARLINK_SERVER_INHERIT_USERDATA</constant>: if set the user data field for
68 incoming connection (i.e. <type>sd_varlink</type>) objects (as settable via
69 <function>sd_varlink_set_userdata()</function>) is automatically set to the userdata field of the
70 server (i.e. <type>sd_varlink_server</type>) object (as settable via
71 <function>sd_varlink_server_set_userdata()</function>). If this flag is not specified the connection's
72 user data field will default to <constant>NULL</constant>.</para></listitem>
73
74 <listitem><para><constant>SD_VARLINK_SERVER_INPUT_SENSITIVE</constant>: mark all incoming method call
75 parameters as security sensitive (equivalent to calling
76 <function>sd_json_variant_sensitive()</function>). This is useful for services that deal with secrets
77 and similar, as it ensures that the parameters are kept out of debug logging, and memory used by the
78 parameters is erased after use.</para></listitem>
79
80 <listitem><para><constant>SD_VARLINK_SERVER_ALLOW_FD_PASSING_INPUT</constant>: if set, allow receiving
81 UNIX file descriptors via the connections, equivalent to calling
82 <function>sd_varlink_set_allow_fd_passing_input()</function> immediately for each incoming
83 connection. Note that this only has an effect if <constant>AF_UNIX</constant> sockets are used for
84 communication.</para></listitem>
85
86 <listitem><para><constant>SD_VARLINK_SERVER_ALLOW_FD_PASSING_OUTPUT</constant>: similar, but controls
87 sending of UNIX file descriptors.</para></listitem>
88
89 <listitem><para><constant>SD_VARLINK_SERVER_FD_PASSING_INPUT_STRICT</constant>: this flag can be used
90 in conjunction with <constant>SD_VARLINK_SERVER_ALLOW_FD_PASSING_INPUT</constant>. If so, file
91 descriptor passing is turned off on the listening sockets already, ensuring that the connection sockets
92 derived from it at no time have file descriptor passing enabled. If
93 <constant>SD_VARLINK_SERVER_ALLOW_FD_PASSING_INPUT</constant> is used without
94 <constant>SD_VARLINK_SERVER_FD_PASSING_INPUT_STRICT</constant> then a choice when to prohibit or allow
95 file descriptor passing can still be made after the connection came in, however permitting a time
96 window where file descriptors might already be enqueued, that then need to be dropped
97 again.</para></listitem>
98
99 <listitem><para><constant>SD_VARLINK_SERVER_HANDLE_SIGINT</constant>: if set, and
100 <function>sd_varlink_server_loop_auto()</function> is used, incoming <constant>SIGINT</constant>
101 process signals will be caught gracefully and cause the event loop to exit cleanly.</para></listitem>
102
103 <listitem><para><constant>SD_VARLINK_SERVER_HANDLE_SIGTERM</constant>: similar, but does the same for
104 <constant>SIGTERM</constant>.</para></listitem>
105 </itemizedlist>
106 </refsect1>
107
108 <refsect1>
109 <title>Return Value</title>
110
111 <para>On success, <function>sd_varlink_server_new()</function> returns a non-negative integer. On
112 failure, it returns a negative errno-style error code.</para>
113
114 <refsect2>
115 <title>Errors</title>
116
117 <para>Returned errors may indicate the following problems:</para>
118
119 <variablelist>
120 <varlistentry>
121 <term><constant>-EINVAL</constant></term>
122
123 <listitem><para>An argument is invalid.</para></listitem>
124 </varlistentry>
125 </variablelist>
126 </refsect2>
127 </refsect1>
128
129 <xi:include href="libsystemd-pkgconfig.xml" />
130
131 <refsect1>
132 <title>History</title>
133 <para><function>sd_varlink_server_new()</function> was added in version 257.</para>
134 </refsect1>
135
136 <refsect1>
137 <title>See Also</title>
138
139 <para><simplelist type="inline">
140 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
141 <member><citerefentry><refentrytitle>sd-varlink</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
142 </simplelist></para>
143 </refsect1>
144
145 </refentry>