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">
6 SPDX-License-Identifier: LGPL-2.1+
8 Copyright 2010 Lennart Poettering
11 <refentry id="sd_seat_get_active" conditional='HAVE_PAM'
12 xmlns:xi="http://www.w3.org/2001/XInclude">
15 <title>sd_seat_get_active</title>
16 <productname>elogind</productname>
20 <contrib>Developer</contrib>
21 <firstname>Lennart</firstname>
22 <surname>Poettering</surname>
23 <email>lennart@poettering.net</email>
29 <refentrytitle>sd_seat_get_active</refentrytitle>
30 <manvolnum>3</manvolnum>
34 <refname>sd_seat_get_active</refname>
35 <refname>sd_seat_get_sessions</refname>
36 <refname>sd_seat_can_multi_session</refname>
37 <refname>sd_seat_can_tty</refname>
38 <refname>sd_seat_can_graphical</refname>
39 <refpurpose>Determine state of a specific seat</refpurpose>
44 <funcsynopsisinfo>#include <elogind/sd-login.h></funcsynopsisinfo>
47 <funcdef>int <function>sd_seat_get_active</function></funcdef>
48 <paramdef>const char *<parameter>seat</parameter></paramdef>
49 <paramdef>char **<parameter>session</parameter></paramdef>
50 <paramdef>uid_t *<parameter>uid</parameter></paramdef>
54 <funcdef>int <function>sd_seat_get_sessions</function></funcdef>
55 <paramdef>const char *<parameter>seat</parameter></paramdef>
56 <paramdef>char ***<parameter>sessions</parameter></paramdef>
57 <paramdef>uid_t **<parameter>uid</parameter></paramdef>
58 <paramdef>unsigned int *<parameter>n_uids</parameter></paramdef>
62 <funcdef>int <function>sd_seat_can_multi_session</function></funcdef>
63 <paramdef>const char *<parameter>seat</parameter></paramdef>
67 <funcdef>int <function>sd_seat_can_tty</function></funcdef>
68 <paramdef>const char *<parameter>seat</parameter></paramdef>
72 <funcdef>int <function>sd_seat_can_graphical</function></funcdef>
73 <paramdef>const char *<parameter>seat</parameter></paramdef>
79 <title>Description</title>
81 <para><function>sd_seat_get_active()</function> may be used to
82 determine which session is currently active on a seat, if there is
83 any. Returns the session identifier and the user identifier of the
84 Unix user the session is belonging to. Either the session or the
85 user identifier parameter can be passed <constant>NULL</constant>,
86 in case only one of the parameters shall be queried. The returned
87 string needs to be freed with the libc
88 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
89 call after use.</para>
91 <para><function>sd_seat_get_sessions()</function> may be used to
92 determine all sessions on the specified seat. Returns two arrays,
93 one (<constant>NULL</constant> terminated) with the session
94 identifiers of the sessions and one with the user identifiers of
95 the Unix users the sessions belong to. An additional parameter may
96 be used to return the number of entries in the latter array. This
97 value is the same the return value, if the latter is nonnegative.
98 The two arrays and the last parameter may be passed as
99 <constant>NULL</constant> in case these values need not to be
100 determined. The arrays and the strings referenced by them need to
101 be freed with the libc
102 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
103 call after use. Note that instead of an empty array
104 <constant>NULL</constant> may be returned and should be considered
105 equivalent to an empty array.</para>
107 <para><function>sd_seat_can_multi_session()</function> may be used
108 to determine whether a specific seat is capable of multi-session,
109 i.e. allows multiple login sessions in parallel (with only one
110 being active at a time).</para>
112 <para><function>sd_seat_can_tty()</function> may be used to
113 determine whether a specific seat provides TTY functionality, i.e.
114 is useful as a text console.</para>
116 <para><function>sd_seat_can_graphical()</function> may be used to
117 determine whether a specific seat provides graphics functionality,
118 i.e. is useful as a graphics display.</para>
120 <para>If the <varname>seat</varname> parameter of any of these
121 functions is passed as <constant>NULL</constant>, the operation is
122 executed for the seat of the session of the calling process, if
127 <title>Return Value</title>
129 <para> On success, <function>sd_seat_get_active()</function>
130 returns 0 or a positive integer. On success,
131 <function>sd_seat_get_sessions()</function> returns the number of
132 entries in the session identifier array. If the test succeeds,
133 <function>sd_seat_can_multi_session</function>,
134 <function>sd_seat_can_tty</function> and
135 <function>sd_seat_can_graphical</function> return a positive
136 integer, if it fails 0. On failure, these calls return a negative
137 errno-style error code.</para>
141 <title>Errors</title>
143 <para>Returned errors may indicate the following problems:</para>
148 <term><constant>-ENODATA</constant></term>
150 <listitem><para>The given field is not specified for the described
156 <term><constant>-ENXIO</constant></term>
158 <listitem><para>The specified seat is unknown.</para>
163 <term><constant>-EINVAL</constant></term>
165 <listitem><para>An input parameter was invalid (out of range,
166 or NULL, where that is not accepted).</para></listitem>
170 <term><constant>-ENOMEM</constant></term>
172 <listitem><para>Memory allocation failed.</para></listitem>
177 <xi:include href="libelogind-pkgconfig.xml" />
180 <title>See Also</title>
183 <!-- 0 /// elogind is in section 8
184 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
186 <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
188 <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
189 <citerefentry><refentrytitle>sd_session_get_seat</refentrytitle><manvolnum>3</manvolnum></citerefentry>