]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_session_is_active.xml
load-fragment: remove wrong ifdef guard
[thirdparty/systemd.git] / man / sd_session_is_active.xml
CommitLineData
0b3b020a
LP
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 This file is part of systemd.
7
8 Copyright 2010 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
0b3b020a
LP
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 18 Lesser General Public License for more details.
0b3b020a 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
0b3b020a
LP
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22-->
23
56ba3c78 24<refentry id="sd_session_is_active" conditional='HAVE_PAM'>
0b3b020a
LP
25
26 <refentryinfo>
27 <title>sd_session_is_active</title>
28 <productname>systemd</productname>
29
30 <authorgroup>
31 <author>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
36 </author>
37 </authorgroup>
38 </refentryinfo>
39
40 <refmeta>
41 <refentrytitle>sd_session_is_active</refentrytitle>
42 <manvolnum>3</manvolnum>
43 </refmeta>
44
45 <refnamediv>
46 <refname>sd_session_is_active</refname>
c573f8f8 47 <refname>sd_session_is_remote</refname>
7ea9cb91 48 <refname>sd_session_get_state</refname>
0b3b020a
LP
49 <refname>sd_session_get_uid</refname>
50 <refname>sd_session_get_seat</refname>
eff40633 51 <refname>sd_session_get_service</refname>
81e0d956
LP
52 <refname>sd_session_get_type</refname>
53 <refname>sd_session_get_class</refname>
c72d5456 54 <refname>sd_session_get_desktop</refname>
81e0d956 55 <refname>sd_session_get_display</refname>
c84f5e4a 56 <refname>sd_session_get_tty</refname>
44ded3ab 57 <refname>sd_session_get_vt</refname>
c573f8f8
MAP
58 <refname>sd_session_get_remote_host</refname>
59 <refname>sd_session_get_remote_user</refname>
0b3b020a
LP
60 <refpurpose>Determine state of a specific session</refpurpose>
61 </refnamediv>
62
63 <refsynopsisdiv>
64 <funcsynopsis>
65 <funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
66
67 <funcprototype>
68 <funcdef>int <function>sd_session_is_active</function></funcdef>
3b3d7d06 69 <paramdef>const char *<parameter>session</parameter></paramdef>
0b3b020a
LP
70 </funcprototype>
71
5b04fe60
MM
72 <funcprototype>
73 <funcdef>int <function>sd_session_is_remote</function></funcdef>
3b3d7d06 74 <paramdef>const char *<parameter>session</parameter></paramdef>
5b04fe60
MM
75 </funcprototype>
76
7ea9cb91
LP
77 <funcprototype>
78 <funcdef>int <function>sd_session_get_state</function></funcdef>
3b3d7d06
JE
79 <paramdef>const char *<parameter>session</parameter></paramdef>
80 <paramdef>char **<parameter>state</parameter></paramdef>
7ea9cb91
LP
81 </funcprototype>
82
0b3b020a
LP
83 <funcprototype>
84 <funcdef>int <function>sd_session_get_uid</function></funcdef>
3b3d7d06
JE
85 <paramdef>const char *<parameter>session</parameter></paramdef>
86 <paramdef>uid_t *<parameter>uid</parameter></paramdef>
0b3b020a
LP
87 </funcprototype>
88
89 <funcprototype>
90 <funcdef>int <function>sd_session_get_seat</function></funcdef>
3b3d7d06
JE
91 <paramdef>const char *<parameter>session</parameter></paramdef>
92 <paramdef>char **<parameter>seat</parameter></paramdef>
0b3b020a 93 </funcprototype>
eff40633
LP
94
95 <funcprototype>
96 <funcdef>int <function>sd_session_get_service</function></funcdef>
3b3d7d06
JE
97 <paramdef>const char *<parameter>session</parameter></paramdef>
98 <paramdef>char **<parameter>service</parameter></paramdef>
eff40633 99 </funcprototype>
81e0d956
LP
100
101 <funcprototype>
102 <funcdef>int <function>sd_session_get_type</function></funcdef>
3b3d7d06
JE
103 <paramdef>const char *<parameter>session</parameter></paramdef>
104 <paramdef>char **<parameter>type</parameter></paramdef>
81e0d956
LP
105 </funcprototype>
106
107 <funcprototype>
108 <funcdef>int <function>sd_session_get_class</function></funcdef>
3b3d7d06
JE
109 <paramdef>const char *<parameter>session</parameter></paramdef>
110 <paramdef>char **<parameter>class</parameter></paramdef>
81e0d956
LP
111 </funcprototype>
112
c72d5456
DH
113 <funcprototype>
114 <funcdef>int <function>sd_session_get_desktop</function></funcdef>
115 <paramdef>const char *<parameter>session</parameter></paramdef>
116 <paramdef>char **<parameter>desktop</parameter></paramdef>
117 </funcprototype>
118
81e0d956
LP
119 <funcprototype>
120 <funcdef>int <function>sd_session_get_display</function></funcdef>
3b3d7d06
JE
121 <paramdef>const char *<parameter>session</parameter></paramdef>
122 <paramdef>char **<parameter>display</parameter></paramdef>
81e0d956 123 </funcprototype>
c84f5e4a 124
5b04fe60
MM
125 <funcprototype>
126 <funcdef>int <function>sd_session_get_remote_host</function></funcdef>
3b3d7d06
JE
127 <paramdef>const char *<parameter>session</parameter></paramdef>
128 <paramdef>char **<parameter>remote_host</parameter></paramdef>
5b04fe60
MM
129 </funcprototype>
130
131 <funcprototype>
132 <funcdef>int <function>sd_session_get_remote_user</function></funcdef>
3b3d7d06
JE
133 <paramdef>const char *<parameter>session</parameter></paramdef>
134 <paramdef>char **<parameter>remote_user</parameter></paramdef>
5b04fe60
MM
135 </funcprototype>
136
c84f5e4a
LP
137 <funcprototype>
138 <funcdef>int <function>sd_session_get_tty</function></funcdef>
3b3d7d06
JE
139 <paramdef>const char *<parameter>session</parameter></paramdef>
140 <paramdef>char **<parameter>tty</parameter></paramdef>
c84f5e4a 141 </funcprototype>
44ded3ab
GC
142
143 <funcprototype>
144 <funcdef>int <function>sd_session_get_vt</function></funcdef>
3b3d7d06
JE
145 <paramdef>const char *<parameter>session</parameter></paramdef>
146 <paramdef>unsigned int *<parameter>vt</parameter></paramdef>
44ded3ab 147 </funcprototype>
0b3b020a
LP
148 </funcsynopsis>
149 </refsynopsisdiv>
150
151 <refsect1>
152 <title>Description</title>
153
154 <para><function>sd_session_is_active()</function> may
155 be used to determine whether the session identified by
156 the specified session identifier is currently active
157 (i.e. currently in the foreground and available for
158 user input) or not.</para>
159
5b04fe60
MM
160 <para><function>sd_session_is_remote()</function> may
161 be used to determine whether the session identified by
162 the specified session identifier is a remote session
163 (i.e. its remote host is known) or not.</para>
164
7ea9cb91
LP
165 <para><function>sd_session_get_state()</function> may
166 be used to determine the state of the session
167 identified by the specified session identifier. The
168 following states are currently known:
169 <literal>online</literal> (session logged in, but
170 session not active, i.e. not in the foreground),
171 <literal>active</literal> (session logged in and
172 active, i.e. in the foreground),
173 <literal>closing</literal> (session nominally logged
174 out, but some processes belonging to it are still
175 around). In the future additional states might be
176 defined, client code should be written to be robust in
177 regards to additional state strings being
178 returned. This function is a more generic version of
179 <function>sd_session_is_active()</function>. The returned
180 string needs to be freed with the libc
5aded369 181 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
7ea9cb91
LP
182 call after use.</para>
183
0b3b020a
LP
184 <para><function>sd_session_get_uid()</function> may be
185 used to determine the user identifier of the Unix user the session
186 identified by the specified session identifier belongs
187 to.</para>
188
189 <para><function>sd_session_get_seat()</function> may
190 be used to determine the seat identifier of the seat
191 the session identified by the specified session
192 identifier belongs to. Note that not all sessions are
193 attached to a seat, this call will fail for them. The
194 returned string needs to be freed with the libc
5aded369 195 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
0b3b020a 196 call after use.</para>
eff40633
LP
197
198 <para><function>sd_session_get_service()</function>
199 may be used to determine the name of the service (as
200 passed during PAM session setup) that registered the
201 session identified by the specified session
202 identifier. The returned string needs to be freed with
203 the libc
5aded369 204 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
eff40633 205 call after use.</para>
81e0d956
LP
206
207 <para><function>sd_session_get_type()</function> may
208 be used to determine the type of the session
209 identified by the specified session identifier. The
210 returned string is one of <literal>x11</literal>,
9541666b
DH
211 <literal>wayland</literal>, <literal>tty</literal>,
212 <literal>mir</literal> or <literal>unspecified</literal> and
213 needs to be freed with the libc
5aded369 214 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
81e0d956
LP
215 call after use.</para>
216
217 <para><function>sd_session_get_class()</function> may
218 be used to determine the class of the session
219 identified by the specified session identifier. The
220 returned string is one of <literal>user</literal>,
cc400110
LP
221 <literal>greeter</literal>,
222 <literal>lock-screen</literal>, or
223 <literal>background</literal> and needs to be freed
81e0d956 224 with the libc
5aded369 225 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
81e0d956
LP
226 call after use.</para>
227
c72d5456
DH
228 <para><function>sd_session_get_desktop()</function> may
229 be used to determine the brand of the desktop running on
230 the session identified by the specified session identifier.
231 This field can be set freely by desktop environments and
232 does not follow any special formatting. However, desktops
233 are strongly recommended to use the same identifiers and
234 capitalization as for
235 <varname>$XDG_CURRENT_DESKTOP</varname>, as defined by
236 the <ulink
237 url="http://standards.freedesktop.org/desktop-entry-spec/latest/">Desktop
238 Entry
239 Specification</ulink>. The returned string needs to be
240 freed with the libc
241 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
242 call after use.</para>
243
81e0d956
LP
244 <para><function>sd_session_get_display()</function>
245 may be used to determine the X11 display of the
246 session identified by the specified session
a485210c 247 identifier. The returned string needs to be
81e0d956 248 freed with the libc
5aded369 249 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
81e0d956 250 call after use.</para>
50b1678a 251
5b04fe60
MM
252 <para><function>sd_session_get_remote_host()</function>
253 may be used to determine the remote hostname of the
254 session identified by the specified session
255 identifier. The returned string needs to be
256 freed with the libc
5aded369 257 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
5b04fe60
MM
258 call after use.</para>
259
260 <para><function>sd_session_get_remote_user()</function>
261 may be used to determine the remote username of the
262 session identified by the specified session
263 identifier. The returned string needs to be
264 freed with the libc
5aded369 265 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
5b04fe60
MM
266 call after use. Note that this value is rarely known
267 to the system, and even then should not be relied on.</para>
268
c84f5e4a
LP
269 <para><function>sd_session_get_tty()</function>
270 may be used to determine the TTY device of the
271 session identified by the specified session
a485210c 272 identifier. The returned string needs to be
c84f5e4a 273 freed with the libc
5aded369 274 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
c84f5e4a
LP
275 call after use.</para>
276
44ded3ab
GC
277 <para><function>sd_session_get_vt()</function>
278 may be used to determine the VT number of the
279 session identified by the specified session
280 identifier. This function will return an error if
281 the seat does not support VTs.</para>
282
74d00578
ZJS
283 <para>If the <varname>session</varname> parameter of
284 any of these functions is passed as
79640424 285 <constant>NULL</constant>, the operation is executed
74d00578
ZJS
286 for the session the calling process is a member of, if
287 there is any.</para>
0b3b020a
LP
288 </refsect1>
289
290 <refsect1>
291 <title>Return Value</title>
292
79640424 293 <para>If the test succeeds,
5b04fe60
MM
294 <function>sd_session_is_active()</function> and
295 <function>sd_session_is_remote()</function> return a
b040723e 296 positive integer; if it fails, 0. On success,
20747498 297 <function>sd_session_get_state()</function>,
eff40633 298 <function>sd_session_get_uid()</function>,
20747498
LP
299 <function>sd_session_get_seat()</function>,
300 <function>sd_session_get_service()</function>,
301 <function>sd_session_get_type()</function>,
c84f5e4a 302 <function>sd_session_get_class()</function>,
5b04fe60
MM
303 <function>sd_session_get_display()</function>,
304 <function>sd_session_get_remote_user()</function>,
305 <function>sd_session_get_remote_host()</function> and
c84f5e4a 306 <function>sd_session_get_tty()</function> return 0 or
0b3b020a
LP
307 a positive integer. On failure, these calls return a
308 negative errno-style error code.</para>
309 </refsect1>
310
311 <refsect1>
312 <title>Notes</title>
313
314 <para>The <function>sd_session_is_active()</function>,
20747498 315 <function>sd_session_get_state()</function>,
eff40633 316 <function>sd_session_get_uid()</function>,
20747498
LP
317 <function>sd_session_get_seat()</function>,
318 <function>sd_session_get_service()</function>,
319 <function>sd_session_get_type()</function>,
c84f5e4a 320 <function>sd_session_get_class()</function>,
5b04fe60
MM
321 <function>sd_session_get_display()</function>,
322 <function>sd_session_get_remote_host()</function>,
323 <function>sd_session_get_remote_user()</function> and
c84f5e4a 324 <function>sd_session_get_tty()</function>
494a6682 325 interfaces are available as a shared library, which can
c84f5e4a 326 be compiled and linked to with the
5aded369 327 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
0b3b020a
LP
328 file.</para>
329 </refsect1>
330
331 <refsect1>
332 <title>See Also</title>
333
334 <para>
335 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
cb07866b 336 <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
595aae37 337 <citerefentry><refentrytitle>sd_pid_get_session</refentrytitle><manvolnum>3</manvolnum></citerefentry>
0b3b020a
LP
338 </para>
339 </refsect1>
340
341</refentry>