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