]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_seat_get_active.xml
verify: use manager_load_startable_unit_or_warn() to load units for verification
[thirdparty/systemd.git] / man / sd_seat_get_active.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 This file is part of systemd.
9
10 Copyright 2010 Lennart Poettering
11
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
16
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 -->
25
26 <refentry id="sd_seat_get_active" conditional='HAVE_PAM'>
27
28 <refentryinfo>
29 <title>sd_seat_get_active</title>
30 <productname>systemd</productname>
31
32 <authorgroup>
33 <author>
34 <contrib>Developer</contrib>
35 <firstname>Lennart</firstname>
36 <surname>Poettering</surname>
37 <email>lennart@poettering.net</email>
38 </author>
39 </authorgroup>
40 </refentryinfo>
41
42 <refmeta>
43 <refentrytitle>sd_seat_get_active</refentrytitle>
44 <manvolnum>3</manvolnum>
45 </refmeta>
46
47 <refnamediv>
48 <refname>sd_seat_get_active</refname>
49 <refname>sd_seat_get_sessions</refname>
50 <refname>sd_seat_can_multi_session</refname>
51 <refname>sd_seat_can_tty</refname>
52 <refname>sd_seat_can_graphical</refname>
53 <refpurpose>Determine state of a specific seat</refpurpose>
54 </refnamediv>
55
56 <refsynopsisdiv>
57 <funcsynopsis>
58 <funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
59
60 <funcprototype>
61 <funcdef>int <function>sd_seat_get_active</function></funcdef>
62 <paramdef>const char *<parameter>seat</parameter></paramdef>
63 <paramdef>char **<parameter>session</parameter></paramdef>
64 <paramdef>uid_t *<parameter>uid</parameter></paramdef>
65 </funcprototype>
66
67 <funcprototype>
68 <funcdef>int <function>sd_seat_get_sessions</function></funcdef>
69 <paramdef>const char *<parameter>seat</parameter></paramdef>
70 <paramdef>char ***<parameter>sessions</parameter></paramdef>
71 <paramdef>uid_t **<parameter>uid</parameter></paramdef>
72 <paramdef>unsigned int *<parameter>n_uids</parameter></paramdef>
73 </funcprototype>
74
75 <funcprototype>
76 <funcdef>int <function>sd_seat_can_multi_session</function></funcdef>
77 <paramdef>const char *<parameter>seat</parameter></paramdef>
78 </funcprototype>
79
80 <funcprototype>
81 <funcdef>int <function>sd_seat_can_tty</function></funcdef>
82 <paramdef>const char *<parameter>seat</parameter></paramdef>
83 </funcprototype>
84
85 <funcprototype>
86 <funcdef>int <function>sd_seat_can_graphical</function></funcdef>
87 <paramdef>const char *<parameter>seat</parameter></paramdef>
88 </funcprototype>
89 </funcsynopsis>
90 </refsynopsisdiv>
91
92 <refsect1>
93 <title>Description</title>
94
95 <para><function>sd_seat_get_active()</function> may be used to
96 determine which session is currently active on a seat, if there is
97 any. Returns the session identifier and the user identifier of the
98 Unix user the session is belonging to. Either the session or the
99 user identifier parameter can be passed <constant>NULL</constant>,
100 in case only one of the parameters shall be queried. The returned
101 string needs to be freed with the libc
102 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
103 call after use.</para>
104
105 <para><function>sd_seat_get_sessions()</function> may be used to
106 determine all sessions on the specified seat. Returns two arrays,
107 one (<constant>NULL</constant> terminated) with the session
108 identifiers of the sessions and one with the user identifiers of
109 the Unix users the sessions belong to. An additional parameter may
110 be used to return the number of entries in the latter array. This
111 value is the same the return value, if the latter is nonnegative.
112 The two arrays and the last parameter may be passed as
113 <constant>NULL</constant> in case these values need not to be
114 determined. The arrays and the strings referenced by them need to
115 be freed with the libc
116 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
117 call after use. Note that instead of an empty array
118 <constant>NULL</constant> may be returned and should be considered
119 equivalent to an empty array.</para>
120
121 <para><function>sd_seat_can_multi_session()</function> may be used
122 to determine whether a specific seat is capable of multi-session,
123 i.e. allows multiple login sessions in parallel (with only one
124 being active at a time).</para>
125
126 <para><function>sd_seat_can_tty()</function> may be used to
127 determine whether a specific seat provides TTY functionality, i.e.
128 is useful as a text console.</para>
129
130 <para><function>sd_seat_can_graphical()</function> may be used to
131 determine whether a specific seat provides graphics functionality,
132 i.e. is useful as a graphics display.</para>
133
134 <para>If the <varname>seat</varname> parameter of any of these
135 functions is passed as <constant>NULL</constant>, the operation is
136 executed for the seat of the session of the calling process, if
137 there is any.</para>
138 </refsect1>
139
140 <refsect1>
141 <title>Return Value</title>
142
143 <para> On success, <function>sd_seat_get_active()</function>
144 returns 0 or a positive integer. On success,
145 <function>sd_seat_get_sessions()</function> returns the number of
146 entries in the session identifier array. If the test succeeds,
147 <function>sd_seat_can_multi_session</function>,
148 <function>sd_seat_can_tty</function> and
149 <function>sd_seat_can_graphical</function> return a positive
150 integer, if it fails 0. On failure, these calls return a negative
151 errno-style error code.</para>
152 </refsect1>
153
154 <refsect1>
155 <title>Errors</title>
156
157 <para>Returned errors may indicate the following problems:</para>
158
159 <variablelist>
160
161 <varlistentry>
162 <term><constant>-ENODATA</constant></term>
163
164 <listitem><para>The given field is not specified for the described
165 seat.</para>
166 </listitem>
167 </varlistentry>
168
169 <varlistentry>
170 <term><constant>-ENXIO</constant></term>
171
172 <listitem><para>The specified seat is unknown.</para>
173 </listitem>
174 </varlistentry>
175
176 <varlistentry>
177 <term><constant>-EINVAL</constant></term>
178
179 <listitem><para>An input parameter was invalid (out of range,
180 or NULL, where that is not accepted).</para></listitem>
181 </varlistentry>
182
183 <varlistentry>
184 <term><constant>-ENOMEM</constant></term>
185
186 <listitem><para>Memory allocation failed.</para></listitem>
187 </varlistentry>
188 </variablelist>
189 </refsect1>
190
191 <refsect1>
192 <title>Notes</title>
193
194 <para>The <function>sd_seat_get_active()</function>,
195 <function>sd_seat_get_sessions()</function>,
196 <function>sd_seat_can_multi_session()</function>,
197 <function>sd_seat_can_tty()</function> and
198 <function>sd_seat_can_graphical()</function> interfaces are
199 available as a shared library, which can be compiled and linked to
200 with the
201 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
202 file.</para>
203 </refsect1>
204
205 <refsect1>
206 <title>See Also</title>
207
208 <para>
209 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
210 <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
211 <citerefentry><refentrytitle>sd_session_get_seat</refentrytitle><manvolnum>3</manvolnum></citerefentry>
212 </para>
213 </refsect1>
214
215 </refentry>