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 This file is part of elogind.
7 SPDX-License-Identifier: LGPL-2.1+
10 Copyright 2010 Lennart Poettering
13 <refentry id="sd_seat_get_active" conditional='HAVE_PAM'
14 xmlns:xi="http://www.w3.org/2001/XInclude">
17 <title>sd_seat_get_active</title>
18 <productname>elogind</productname>
22 <contrib>Developer</contrib>
23 <firstname>Lennart</firstname>
24 <surname>Poettering</surname>
25 <email>lennart@poettering.net</email>
31 <refentrytitle>sd_seat_get_active</refentrytitle>
32 <manvolnum>3</manvolnum>
36 <refname>sd_seat_get_active</refname>
37 <refname>sd_seat_get_sessions</refname>
38 <refname>sd_seat_can_multi_session</refname>
39 <refname>sd_seat_can_tty</refname>
40 <refname>sd_seat_can_graphical</refname>
41 <refpurpose>Determine state of a specific seat</refpurpose>
46 <funcsynopsisinfo>#include <elogind/sd-login.h></funcsynopsisinfo>
49 <funcdef>int <function>sd_seat_get_active</function></funcdef>
50 <paramdef>const char *<parameter>seat</parameter></paramdef>
51 <paramdef>char **<parameter>session</parameter></paramdef>
52 <paramdef>uid_t *<parameter>uid</parameter></paramdef>
56 <funcdef>int <function>sd_seat_get_sessions</function></funcdef>
57 <paramdef>const char *<parameter>seat</parameter></paramdef>
58 <paramdef>char ***<parameter>sessions</parameter></paramdef>
59 <paramdef>uid_t **<parameter>uid</parameter></paramdef>
60 <paramdef>unsigned int *<parameter>n_uids</parameter></paramdef>
64 <funcdef>int <function>sd_seat_can_multi_session</function></funcdef>
65 <paramdef>const char *<parameter>seat</parameter></paramdef>
69 <funcdef>int <function>sd_seat_can_tty</function></funcdef>
70 <paramdef>const char *<parameter>seat</parameter></paramdef>
74 <funcdef>int <function>sd_seat_can_graphical</function></funcdef>
75 <paramdef>const char *<parameter>seat</parameter></paramdef>
81 <title>Description</title>
83 <para><function>sd_seat_get_active()</function> may be used to
84 determine which session is currently active on a seat, if there is
85 any. Returns the session identifier and the user identifier of the
86 Unix user the session is belonging to. Either the session or the
87 user identifier parameter can be passed <constant>NULL</constant>,
88 in case only one of the parameters shall be queried. The returned
89 string needs to be freed with the libc
90 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
91 call after use.</para>
93 <para><function>sd_seat_get_sessions()</function> may be used to
94 determine all sessions on the specified seat. Returns two arrays,
95 one (<constant>NULL</constant> terminated) with the session
96 identifiers of the sessions and one with the user identifiers of
97 the Unix users the sessions belong to. An additional parameter may
98 be used to return the number of entries in the latter array. This
99 value is the same the return value, if the latter is nonnegative.
100 The two arrays and the last parameter may be passed as
101 <constant>NULL</constant> in case these values need not to be
102 determined. The arrays and the strings referenced by them need to
103 be freed with the libc
104 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
105 call after use. Note that instead of an empty array
106 <constant>NULL</constant> may be returned and should be considered
107 equivalent to an empty array.</para>
109 <para><function>sd_seat_can_multi_session()</function> may be used
110 to determine whether a specific seat is capable of multi-session,
111 i.e. allows multiple login sessions in parallel (with only one
112 being active at a time).</para>
114 <para><function>sd_seat_can_tty()</function> may be used to
115 determine whether a specific seat provides TTY functionality, i.e.
116 is useful as a text console.</para>
118 <para><function>sd_seat_can_graphical()</function> may be used to
119 determine whether a specific seat provides graphics functionality,
120 i.e. is useful as a graphics display.</para>
122 <para>If the <varname>seat</varname> parameter of any of these
123 functions is passed as <constant>NULL</constant>, the operation is
124 executed for the seat of the session of the calling process, if
129 <title>Return Value</title>
131 <para> On success, <function>sd_seat_get_active()</function>
132 returns 0 or a positive integer. On success,
133 <function>sd_seat_get_sessions()</function> returns the number of
134 entries in the session identifier array. If the test succeeds,
135 <function>sd_seat_can_multi_session</function>,
136 <function>sd_seat_can_tty</function> and
137 <function>sd_seat_can_graphical</function> return a positive
138 integer, if it fails 0. On failure, these calls return a negative
139 errno-style error code.</para>
143 <title>Errors</title>
145 <para>Returned errors may indicate the following problems:</para>
150 <term><constant>-ENODATA</constant></term>
152 <listitem><para>The given field is not specified for the described
158 <term><constant>-ENXIO</constant></term>
160 <listitem><para>The specified seat is unknown.</para>
165 <term><constant>-EINVAL</constant></term>
167 <listitem><para>An input parameter was invalid (out of range,
168 or NULL, where that is not accepted).</para></listitem>
172 <term><constant>-ENOMEM</constant></term>
174 <listitem><para>Memory allocation failed.</para></listitem>
179 <xi:include href="libelogind-pkgconfig.xml" />
182 <title>See Also</title>
185 <!-- 0 /// elogind is in section 8
186 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
188 <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
190 <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
191 <citerefentry><refentrytitle>sd_session_get_seat</refentrytitle><manvolnum>3</manvolnum></citerefentry>