]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_uid_get_state.xml
TODO: Remove Elapsed Time DHCPv6 option as it is done
[thirdparty/systemd.git] / man / sd_uid_get_state.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 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
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
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
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="sd_uid_get_state" conditional='HAVE_PAM'>
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>
50 <refname>sd_uid_get_display</refname>
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>
60 <paramdef>uid_t <parameter>uid</parameter></paramdef>
61 <paramdef>char **<parameter>state</parameter></paramdef>
62 </funcprototype>
63
64 <funcprototype>
65 <funcdef>int <function>sd_uid_is_on_seat</function></funcdef>
66 <paramdef>uid_t <parameter>uid</parameter></paramdef>
67 <paramdef>int <parameter>require_active</parameter></paramdef>
68 <paramdef>const char *<parameter>seat</parameter></paramdef>
69 </funcprototype>
70
71 <funcprototype>
72 <funcdef>int <function>sd_uid_get_sessions</function></funcdef>
73 <paramdef>uid_t <parameter>uid</parameter></paramdef>
74 <paramdef>int <parameter>require_active</parameter></paramdef>
75 <paramdef>char ***<parameter>sessions</parameter></paramdef>
76 </funcprototype>
77
78 <funcprototype>
79 <funcdef>int <function>sd_uid_get_seats</function></funcdef>
80 <paramdef>uid_t <parameter>uid</parameter></paramdef>
81 <paramdef>int <parameter>require_active</parameter></paramdef>
82 <paramdef>char ***<parameter>seats</parameter></paramdef>
83 </funcprototype>
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>
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
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
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
113 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
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>
121 parameter is a boolean value. If non-zero (true), this
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
130 specified user. Accepts a Unix user identifier as
131 parameter. The <parameter>require_active</parameter>
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
137 <constant>NULL</constant> terminated string array of session identifiers in
138 <parameter>sessions</parameter> which needs to be
139 freed by the caller with the libc
140 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
141 call after use, including all the strings
142 referenced. If the string array parameter is passed as
143 <constant>NULL</constant>, the array will not be filled in, but the return
144 code still indicates the number of current
145 sessions. Note that instead of an empty array <constant>NULL</constant> may
146 be returned and should be considered equivalent to an
147 empty array.</para>
148
149 <para>Similarly, <function>sd_uid_get_seats()</function>
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>
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>
163 </refsect1>
164
165 <refsect1>
166 <title>Return Value</title>
167
168 <para>On success,
169 <function>sd_uid_get_state()</function> returns 0 or a
170 positive integer. If the test succeeds,
171 <function>sd_uid_is_on_seat()</function> returns a
172 positive integer; if it fails,
173 0. <function>sd_uid_get_sessions()</function> and
174 <function>sd_uid_get_seats()</function> return the
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,
178 these calls return a negative errno-style error
179 code.</para>
180 </refsect1>
181
182 <refsect1>
183 <title>Notes</title>
184
185 <para>Functions described here are available as a
186 shared library, and can be compiled and linked to
187 using the
188 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
189 entry.</para>
190 </refsect1>
191
192 <refsect1>
193 <title>History</title>
194
195 <function>sd_uid_get_state()</function>,
196 <function>sd_uid_is_on_seat()</function>,
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>
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_pid_get_owner_uid</refentrytitle><manvolnum>3</manvolnum></citerefentry>
212 </para>
213 </refsect1>
214
215 </refentry>