chiark / gitweb /
man: drop unused <authorgroup> tags from man sources
[elogind.git] / man / sd-login.xml
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">
4
5 <!--
6   SPDX-License-Identifier: LGPL-2.1+
7 -->
8
9 <refentry id="sd-login" conditional='HAVE_PAM'
10   xmlns:xi="http://www.w3.org/2001/XInclude">
11
12   <refentryinfo>
13     <title>sd-login</title>
14     <productname>systemd</productname>
15   </refentryinfo>
16
17   <refmeta>
18     <refentrytitle>sd-login</refentrytitle>
19     <manvolnum>3</manvolnum>
20   </refmeta>
21
22   <refnamediv>
23     <refname>sd-login</refname>
24     <refpurpose>APIs for
25     tracking logins</refpurpose>
26   </refnamediv>
27
28   <refsynopsisdiv>
29     <funcsynopsis>
30       <funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
31     </funcsynopsis>
32
33     <cmdsynopsis>
34       <command>pkg-config --cflags --libs libelogind</command>
35     </cmdsynopsis>
36   </refsynopsisdiv>
37
38   <refsect1>
39     <title>Description</title>
40
41     <para><filename>sd-login.h</filename> provides APIs to introspect
42     and monitor seat, login session and user status information on the
43     local system. </para>
44
45     <para>Note that these APIs only allow purely passive access and
46     monitoring of seats, sessions and users. To actively make changes
47     to the seat configuration, terminate login sessions, or switch
48     session on a seat you need to utilize the D-Bus API of
49     systemd-logind, instead.</para>
50
51     <para>These functions synchronously access data in
52     <filename>/proc</filename>, <filename>/sys/fs/cgroup</filename>
53     and <filename>/run</filename>. All of these are virtual file
54     systems, hence the runtime cost of the accesses is relatively
55     cheap.</para>
56
57     <para>It is possible (and often a very good choice) to mix calls
58     to the synchronous interface of <filename>sd-login.h</filename>
59     with the asynchronous D-Bus interface of systemd-logind. However,
60     if this is done you need to think a bit about possible races since
61     the stream of events from D-Bus and from
62     <filename>sd-login.h</filename> interfaces such as the login
63     monitor are asynchronous and not ordered against each
64     other.</para>
65
66     <para>If the functions return string arrays, these are generally
67     <constant>NULL</constant> terminated and need to be freed by the
68     caller with the libc
69     <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
70     call after use, including the strings referenced therein.
71     Similarly, individual strings returned need to be freed, as
72     well.</para>
73
74     <para>As a special exception, instead of an empty string array
75     <constant>NULL</constant> may be returned, which should be treated
76     equivalent to an empty string array.</para>
77
78     <para>See
79     <citerefentry><refentrytitle>sd_pid_get_session</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
80     <citerefentry><refentrytitle>sd_uid_get_state</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
81     <citerefentry><refentrytitle>sd_session_is_active</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
82     <citerefentry><refentrytitle>sd_seat_get_active</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
83     <citerefentry><refentrytitle>sd_get_seats</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
84     <citerefentry><refentrytitle>sd_login_monitor_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
85     for more information about the functions
86     implemented.</para>
87   </refsect1>
88
89   <refsect1>
90     <title>Definition of Terms</title>
91
92     <variablelist>
93       <varlistentry>
94         <term>seat</term>
95
96         <listitem><para>A seat consists of all hardware devices assigned to a specific
97         workplace. It consists of at least one graphics device, and usually also includes
98         keyboard, mouse. It can also include video cameras, sound cards and more. Seats
99         are identified by seat names, which are strings (&lt;= 255 characters), that start
100         with the four characters <literal>seat</literal> followed by at least one
101         character from the range [a-zA-Z0-9], <literal>_</literal> and
102         <literal>-</literal>. They are suitable for use as file names. Seat names may or
103         may not be stable and may be reused if a seat becomes available again.
104         </para></listitem>
105       </varlistentry>
106
107       <varlistentry>
108         <term>session</term>
109
110         <listitem><para>A session is defined by the time a user is logged in until they
111         log out. A session is bound to one or no seats (the latter for 'virtual' ssh
112         logins). Multiple sessions can be attached to the same seat, but only one of them
113         can be active, the others are in the background. A session is identified by a
114         short string.</para>
115
116         <para>
117         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
118         ensures that audit sessions are identical to systemd sessions, and uses the audit
119         session ID as session ID in systemd (if auditing is enabled). In general the
120         session identifier is a short string consisting only of [a-zA-Z0-9],
121         <literal>_</literal> and <literal>-</literal>, suitable for use as a file name.
122         Session IDs are unique on the local machine and are
123         never reused as long as the machine is online. A user (the way we know it on UNIX)
124         corresponds to the person using a computer. A single user can have multiple
125         sessions open at the same time. A user is identified by a numeric user id (UID) or
126         a user name (a string). A multi-session system allows multiple user sessions on
127         the same seat at the same time. A multi-seat system allows multiple independent
128         seats that can be individually and simultaneously used by different users.</para>
129         </listitem>
130       </varlistentry>
131     </variablelist>
132
133     <para>All hardware devices that are eligible to being assigned to a seat, are assigned
134     to one. A device can be assigned to only one seat at a time. If a device is not
135     assigned to any particular other seat it is implicitly assigned to the special default
136     seat called <literal>seat0</literal>.</para>
137
138     <para>Note that hardware like printers, hard disks or network cards is generally not
139     assigned to a specific seat. They are available to all seats equally. (Well, with one
140     exception: USB sticks can be assigned to a seat.)</para>
141
142     <para><literal>seat0</literal> always exists.</para>
143   </refsect1>
144
145   <refsect1>
146     <title>udev Rules</title>
147
148     <para>Assignment of hardware devices to seats is managed inside the udev database, via
149     settings on the devices:</para>
150
151     <variablelist>
152       <varlistentry>
153         <term>Tag <literal>seat</literal></term>
154
155         <listitem><para>When set, a device is eligible to be assigned to a seat. This tag
156         is set for graphics devices, mice, keyboards, video cards, sound cards and
157         more. Note that some devices like sound cards consist of multiple subdevices
158         (i.e. a PCM for input and another one for output). This tag will be set only for
159         the originating device, not for the individual subdevices. A UI for configuring
160         assignment of devices to seats should enumerate and subscribe to all devices with
161         this tag set and show them in the UI. Note that USB hubs can be assigned to a seat
162         as well, in which case all (current and future) devices plugged into it will also
163         be assigned to the same seat (unless they are explicitly assigned to another
164         seat).
165         </para></listitem>
166       </varlistentry>
167
168       <varlistentry>
169         <term>Tag <literal>master-of-seat</literal></term>
170
171         <listitem><para>When set, this device is enough for a seat to be considered
172         existent. This tag is usually set for the framebuffer device of graphics cards. A
173         seat hence consists of an arbitrary number of devices marked with the
174         <literal>seat</literal> tag, but (at least) one of these devices needs to be
175         tagged with <literal>master-of-seat</literal> before the seat is actually
176         considered to be around.</para></listitem>
177       </varlistentry>
178
179       <varlistentry>
180         <term>Property <varname>ID_SEAT</varname></term>
181
182         <listitem><para>This property specifies the name of the seat a specific device is
183         assigned to. If not set the device is assigned to <literal>seat0</literal>. Also,
184         to speed up enumeration of hardware belonging to a specific seat, the seat is also
185         set as tag on the device. I.e. if the property
186         <varname>ID_SEAT=seat-waldo</varname> is set for a device, the tag
187         <literal>seat-waldo</literal> will be set as well. Note that if a device is
188         assigned to <literal>seat0</literal>, it will usually not carry such a tag and you
189         need to enumerate all devices and check the <varname>ID_SEAT</varname> property
190         manually. Again, if a device is assigned to seat0 this is visible on the device in
191         two ways: with a property <varname>ID_SEAT=seat0</varname> and with no property
192         <varname>ID_SEAT</varname> set for it at all.</para></listitem>
193       </varlistentry>
194
195       <varlistentry>
196         <term>Property <varname>ID_AUTOSEAT</varname></term>
197
198         <listitem><para>When set to <literal>1</literal>, this device automatically
199         generates a new and independent seat, which is named after the path of the
200         device. This is set for specialized USB hubs like the Plugable devices, which when
201         plugged in should create a hotplug seat without further configuration.</para>
202         </listitem>
203       </varlistentry>
204
205       <varlistentry>
206         <term>Property <varname>ID_FOR_SEAT</varname></term>
207
208         <listitem><para>When creating additional (manual) seats starting from a graphics
209         device this is a good choice to name the seat after. It is created from the path
210         of the device. This is useful in UIs for configuring seats: as soon as you create
211         a new seat from a graphics device, read this property and prefix it with
212         <literal>seat-</literal> and use it as name for the seat.</para></listitem>
213       </varlistentry>
214     </variablelist>
215
216     <para>A seat exists only and exclusively because a properly tagged device with the
217     right <varname>ID_SEAT</varname> property exists. Besides udev rules there is no
218     persistent data about seats stored on disk.</para>
219
220     <para>Note that
221     <citerefentry><refentrytitle>systemd-logind</refentrytitle><manvolnum>8</manvolnum></citerefentry>
222     manages ACLs on a number of device classes, to allow user code to access the device
223     nodes attached to a seat as long as the user has an active session on it. This is
224     mostly transparent to applications. As mentioned above, for certain user software it
225     might be a good idea to watch whether they can access device nodes instead of thinking
226     about seats.</para>
227   </refsect1>
228
229   <xi:include href="libelogind-pkgconfig.xml" />
230
231   <refsect1>
232     <title>See Also</title>
233     <para>
234       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
235       <citerefentry><refentrytitle>sd_pid_get_session</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
236       <citerefentry><refentrytitle>sd_uid_get_state</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
237       <citerefentry><refentrytitle>sd_session_is_active</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
238       <citerefentry><refentrytitle>sd_seat_get_active</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
239       <citerefentry><refentrytitle>sd_get_seats</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
240       <citerefentry><refentrytitle>sd_login_monitor_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
241       <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
242       <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
243     </para>
244
245     <para>
246       <ulink url="https://www.freedesktop.org/wiki/Software/systemd/multiseat">Multi-Seat on Linux</ulink>
247       for an introduction to multi-seat support on Linux and the background for this set of APIs.
248     </para>
249   </refsect1>
250
251 </refentry>