chiark / gitweb /
man: Split sd_randomize(3) from sd_id128_get_{machine,boot}(3)
[elogind.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">
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                 <refpurpose>Determine login state of a specific Unix user ID</refpurpose>
51         </refnamediv>
52
53         <refsynopsisdiv>
54                 <funcsynopsis>
55                         <funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
56
57                         <funcprototype>
58                                 <funcdef>int <function>sd_uid_get_state</function></funcdef>
59                                 <paramdef>uid_t <parameter>uid</parameter></paramdef>
60                                 <paramdef>char** <parameter>state</parameter></paramdef>
61                         </funcprototype>
62
63                         <funcprototype>
64                                 <funcdef>int <function>sd_uid_is_on_seat</function></funcdef>
65                                 <paramdef>uid_t <parameter>uid</parameter></paramdef>
66                                 <paramdef>int <parameter>require_active</parameter></paramdef>
67                                 <paramdef>const char* <parameter>seat</parameter></paramdef>
68                         </funcprototype>
69
70                         <funcprototype>
71                                 <funcdef>int <function>sd_uid_get_sessions</function></funcdef>
72                                 <paramdef>uid_t <parameter>uid</parameter></paramdef>
73                                 <paramdef>int <parameter>require_active</parameter></paramdef>
74                                 <paramdef>char*** <parameter>sessions</parameter></paramdef>
75                         </funcprototype>
76
77                         <funcprototype>
78                                 <funcdef>int <function>sd_uid_get_seats</function></funcdef>
79                                 <paramdef>uid_t <parameter>uid</parameter></paramdef>
80                                 <paramdef>int <parameter>require_active</parameter></paramdef>
81                                 <paramdef>char*** <parameter>seats</parameter></paramdef>
82                         </funcprototype>
83                 </funcsynopsis>
84         </refsynopsisdiv>
85
86         <refsect1>
87                 <title>Description</title>
88
89                 <para><function>sd_uid_get_state()</function> may be
90                 used to determine the login state of a specific Unix
91                 user identifier. The following states are currently
92                 known: <literal>offline</literal> (user not logged in
93                 at all), <literal>lingering</literal> (user not logged
94                 in, but some user services running),
95                 <literal>online</literal> (user logged in, but not
96                 active, i.e. has no session in the foreground),
97                 <literal>active</literal> (user logged in, and has at
98                 least one active session, i.e. one session in the
99                 foreground), <literal>closing</literal> (user not
100                 logged in, and not lingering, but some processes are
101                 still around). In the future additional states might
102                 be defined, client code should be written to be robust
103                 in regards to additional state strings being
104                 returned. The returned string needs to be freed with
105                 the libc
106                 <citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
107                 call after use.</para>
108
109                 <para><function>sd_uid_is_on_seat()</function> may be
110                 used to determine whether a specific user is logged in
111                 or active on a specific seat. Accepts a Unix user
112                 identifier and a seat identifier string as
113                 parameters. The <parameter>require_active</parameter>
114                 parameter is a boolean. If non-zero (true) this
115                 function will test if the user is active (i.e. has a
116                 session that is in the foreground and accepting user
117                 input) on the specified seat, otherwise (false) only
118                 if the user is logged in (and possibly inactive) on
119                 the specified seat.</para>
120
121                 <para><function>sd_uid_get_sessions()</function> may
122                 be used to determine the current sessions of the
123                 specified user. Acceptes a Unix user identifier as
124                 parameter. The <parameter>require_active</parameter>
125                 boolean parameter controls whether the returned list
126                 shall consist of only those sessions where the user is
127                 currently active (true) or where the user is currently
128                 logged in at all, possibly inactive (false). The call
129                 returns a NULL terminated string array of session
130                 identifiers in <parameter>sessions</parameter> which
131                 needs to be freed by the caller with the libc
132                 <citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
133                 call after use, including all the strings
134                 referenced. If the string array parameter is passed as
135                 NULL the array will not be filled in, but the return
136                 code still indicates the number of current
137                 sessions. Note that instead of an empty array NULL may
138                 be returned and should be considered equivalent to an
139                 empty array.</para>
140
141                 <para>Similar, <function>sd_uid_get_seats()</function>
142                 may be used to determine the list of seats on which
143                 the user currently has sessions. Similar semantics
144                 apply, however note that the user may have
145                 multiple sessions on the same seat as well as sessions
146                 with no attached seat and hence the number of entries
147                 in the returned array may differ from the one returned
148                 by <function>sd_uid_get_sessions()</function>.</para>
149         </refsect1>
150
151         <refsect1>
152                 <title>Return Value</title>
153
154                 <para>On success
155                 <function>sd_uid_get_state()</function> returns 0 or a
156                 positive integer. If the test succeeds
157                 <function>sd_uid_is_on_seat()</function> returns a
158                 positive integer, if it fails
159                 0. <function>sd_uid_get_sessions()</function> and
160                 <function>sd_uid_get_seats()</function> return the
161                 number of entries in the returned arrays. On failure,
162                 these calls return a negative errno-style error
163                 code.</para>
164         </refsect1>
165
166         <refsect1>
167                 <title>Notes</title>
168
169                 <para>The <function>sd_uid_get_state()</function>,
170                 <function>sd_uid_is_on_seat()</function>,
171                 <function>sd_uid_get_sessions()</function>, and
172                 <function>sd_uid_get_seats()</function> interfaces are
173                 available as shared library, which can be compiled and
174                 linked to with the <literal>libsystemd-login</literal>
175                 <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
176                 file.</para>
177         </refsect1>
178
179         <refsect1>
180                 <title>See Also</title>
181
182                 <para>
183                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
184                         <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
185                         <citerefentry><refentrytitle>sd_pid_get_owner_uid</refentrytitle><manvolnum>3</manvolnum></citerefentry>
186                 </para>
187         </refsect1>
188
189 </refentry>