]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_uid_get_state.xml
man: add a mapping for external manpages
[thirdparty/systemd.git] / man / sd_uid_get_state.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_uid_get_state" conditional='HAVE_PAM'>
0b3b020a
LP
25
26 <refentryinfo>
27 <title>sd_uid_get_state</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_uid_get_state</refentrytitle>
42 <manvolnum>3</manvolnum>
43 </refmeta>
44
45 <refnamediv>
46 <refname>sd_uid_get_state</refname>
47 <refname>sd_uid_is_on_seat</refname>
48 <refname>sd_uid_get_sessions</refname>
49 <refname>sd_uid_get_seats</refname>
623538c3 50 <refname>sd_uid_get_display</refname>
0b3b020a
LP
51 <refpurpose>Determine login state of a specific Unix user ID</refpurpose>
52 </refnamediv>
53
54 <refsynopsisdiv>
55 <funcsynopsis>
56 <funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
57
58 <funcprototype>
59 <funcdef>int <function>sd_uid_get_state</function></funcdef>
bd08f242 60 <paramdef>uid_t <parameter>uid</parameter></paramdef>
3b3d7d06 61 <paramdef>char **<parameter>state</parameter></paramdef>
0b3b020a
LP
62 </funcprototype>
63
64 <funcprototype>
65 <funcdef>int <function>sd_uid_is_on_seat</function></funcdef>
bd08f242 66 <paramdef>uid_t <parameter>uid</parameter></paramdef>
0b3b020a 67 <paramdef>int <parameter>require_active</parameter></paramdef>
3b3d7d06 68 <paramdef>const char *<parameter>seat</parameter></paramdef>
0b3b020a
LP
69 </funcprototype>
70
71 <funcprototype>
72 <funcdef>int <function>sd_uid_get_sessions</function></funcdef>
bd08f242 73 <paramdef>uid_t <parameter>uid</parameter></paramdef>
0b3b020a 74 <paramdef>int <parameter>require_active</parameter></paramdef>
3b3d7d06 75 <paramdef>char ***<parameter>sessions</parameter></paramdef>
0b3b020a
LP
76 </funcprototype>
77
78 <funcprototype>
79 <funcdef>int <function>sd_uid_get_seats</function></funcdef>
bd08f242 80 <paramdef>uid_t <parameter>uid</parameter></paramdef>
0b3b020a 81 <paramdef>int <parameter>require_active</parameter></paramdef>
3b3d7d06 82 <paramdef>char ***<parameter>seats</parameter></paramdef>
0b3b020a 83 </funcprototype>
623538c3
ZJS
84
85 <funcprototype>
86 <funcdef>int <function>sd_uid_get_display</function></funcdef>
87 <paramdef>uid_t <parameter>uid</parameter></paramdef>
88 <paramdef>char **<parameter>session</parameter></paramdef>
89 </funcprototype>
0b3b020a
LP
90 </funcsynopsis>
91 </refsynopsisdiv>
92
93 <refsect1>
94 <title>Description</title>
95
96 <para><function>sd_uid_get_state()</function> may be
97 used to determine the login state of a specific Unix
98 user identifier. The following states are currently
99 known: <literal>offline</literal> (user not logged in
100 at all), <literal>lingering</literal> (user not logged
101 in, but some user services running),
102 <literal>online</literal> (user logged in, but not
7ea9cb91
LP
103 active, i.e. has no session in the foreground),
104 <literal>active</literal> (user logged in, and has at
105 least one active session, i.e. one session in the
106 foreground), <literal>closing</literal> (user not
107 logged in, and not lingering, but some processes are
108 still around). In the future additional states might
0b3b020a
LP
109 be defined, client code should be written to be robust
110 in regards to additional state strings being
111 returned. The returned string needs to be freed with
112 the libc
5aded369 113 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
0b3b020a
LP
114 call after use.</para>
115
116 <para><function>sd_uid_is_on_seat()</function> may be
117 used to determine whether a specific user is logged in
118 or active on a specific seat. Accepts a Unix user
119 identifier and a seat identifier string as
120 parameters. The <parameter>require_active</parameter>
79640424 121 parameter is a boolean value. If non-zero (true), this
0b3b020a
LP
122 function will test if the user is active (i.e. has a
123 session that is in the foreground and accepting user
124 input) on the specified seat, otherwise (false) only
125 if the user is logged in (and possibly inactive) on
126 the specified seat.</para>
127
128 <para><function>sd_uid_get_sessions()</function> may
129 be used to determine the current sessions of the
bb31a4ac 130 specified user. Accepts a Unix user identifier as
0b3b020a 131 parameter. The <parameter>require_active</parameter>
d18dff43
LP
132 parameter controls whether the returned list shall
133 consist of only those sessions where the user is
134 currently active (&gt; 0), where the user is currently
135 online but possibly inactive (= 0), or
136 logged in at all but possibly closing the session (&lt; 0). The call returns a
74d00578 137 <constant>NULL</constant> terminated string array of session identifiers in
d18dff43
LP
138 <parameter>sessions</parameter> which needs to be
139 freed by the caller with the libc
5aded369 140 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
595aae37
LP
141 call after use, including all the strings
142 referenced. If the string array parameter is passed as
79640424 143 <constant>NULL</constant>, the array will not be filled in, but the return
595aae37 144 code still indicates the number of current
74d00578 145 sessions. Note that instead of an empty array <constant>NULL</constant> may
595aae37
LP
146 be returned and should be considered equivalent to an
147 empty array.</para>
0b3b020a 148
494a6682 149 <para>Similarly, <function>sd_uid_get_seats()</function>
0b3b020a
LP
150 may be used to determine the list of seats on which
151 the user currently has sessions. Similar semantics
152 apply, however note that the user may have
153 multiple sessions on the same seat as well as sessions
154 with no attached seat and hence the number of entries
155 in the returned array may differ from the one returned
156 by <function>sd_uid_get_sessions()</function>.</para>
623538c3
ZJS
157
158 <para><function>sd_uid_get_display()</function>
159 returns the name of the "primary" session of a user.
160 If the user has graphical sessions, it will be the
161 oldest graphical session. Otherwise, it will be the
162 oldest open session.</para>
0b3b020a
LP
163 </refsect1>
164
165 <refsect1>
166 <title>Return Value</title>
167
b040723e 168 <para>On success,
0b3b020a 169 <function>sd_uid_get_state()</function> returns 0 or a
79640424 170 positive integer. If the test succeeds,
0b3b020a 171 <function>sd_uid_is_on_seat()</function> returns a
b040723e 172 positive integer; if it fails,
0b3b020a
LP
173 0. <function>sd_uid_get_sessions()</function> and
174 <function>sd_uid_get_seats()</function> return the
623538c3
ZJS
175 number of entries in the returned arrays.
176 <function>sd_uid_get_display()</function> returns
177 a non-negative code on success. On failure,
0b3b020a
LP
178 these calls return a negative errno-style error
179 code.</para>
180 </refsect1>
181
182 <refsect1>
183 <title>Notes</title>
184
623538c3
ZJS
185 <para>Functions described here are available as a
186 shared library, and can be compiled and linked to
187 using the
5aded369 188 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
623538c3
ZJS
189 entry.</para>
190 </refsect1>
191
192 <refsect1>
193 <title>History</title>
194
195 <function>sd_uid_get_state()</function>,
0b3b020a 196 <function>sd_uid_is_on_seat()</function>,
623538c3
ZJS
197 <function>sd_uid_get_sessions()</function>,
198 and <function>sd_uid_get_seats()</function> functions
199 were added in systemd-31.
200
201 <para><function>sd_uid_get_display()</function> was
202 added in systemd-213.</para>
0b3b020a
LP
203 </refsect1>
204
205 <refsect1>
206 <title>See Also</title>
207
208 <para>
209 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
cb07866b 210 <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
595aae37 211 <citerefentry><refentrytitle>sd_pid_get_owner_uid</refentrytitle><manvolnum>3</manvolnum></citerefentry>
0b3b020a
LP
212 </para>
213 </refsect1>
214
215</refentry>