chiark / gitweb /
man: sd_readahead is not actually available in libsystemd-daemon
[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 General Public License as published by
12   the Free Software Foundation; either version 2 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   General Public License for more details.
19
20   You should have received a copy of the GNU 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>pid</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>pid</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>pid</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>pid</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), <literal>active</literal> (user logged in on
97                 an active seat). In the future additional states might
98                 be defined, client code should be written to be robust
99                 in regards to additional state strings being
100                 returned. The returned string needs to be freed with
101                 the libc
102                 <citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
103                 call after use.</para>
104
105                 <para><function>sd_uid_is_on_seat()</function> may be
106                 used to determine whether a specific user is logged in
107                 or active on a specific seat. Accepts a Unix user
108                 identifier and a seat identifier string as
109                 parameters. The <parameter>require_active</parameter>
110                 parameter is a boolean. If non-zero (true) this
111                 function will test if the user is active (i.e. has a
112                 session that is in the foreground and accepting user
113                 input) on the specified seat, otherwise (false) only
114                 if the user is logged in (and possibly inactive) on
115                 the specified seat.</para>
116
117                 <para><function>sd_uid_get_sessions()</function> may
118                 be used to determine the current sessions of the
119                 specified user. Acceptes a Unix user identifier as
120                 parameter. The <parameter>require_active</parameter>
121                 boolean parameter controls whether the returned list
122                 shall consist of only those sessions where the user is
123                 currently active (true) or where the user is currently
124                 logged in at all, possibly inactive (false). The call
125                 returns a NULL terminated string array of session
126                 identifiers in <parameter>sessions</parameter> which
127                 needs to be freed by the caller with the libc
128                 <citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
129                 call after use, including all the strings referenced. If
130                 the string array parameter is passed as NULL the array
131                 will not be filled in, but the return code still
132                 indicates the number of current sessions.</para>
133
134                 <para>Similar, <function>sd_uid_get_seats()</function>
135                 may be used to determine the list of seats on which
136                 the user currently has sessions. Similar semantics
137                 apply, however note that the user may have
138                 multiple sessions on the same seat as well as sessions
139                 with no attached seat and hence the number of entries
140                 in the returned array may differ from the one returned
141                 by <function>sd_uid_get_sessions()</function>.</para>
142         </refsect1>
143
144         <refsect1>
145                 <title>Return Value</title>
146
147                 <para>On success
148                 <function>sd_uid_get_state()</function> returns 0 or a
149                 positive integer. If the test succeeds
150                 <function>sd_uid_is_on_seat()</function> returns a
151                 positive integer, if it fails
152                 0. <function>sd_uid_get_sessions()</function> and
153                 <function>sd_uid_get_seats()</function> return the
154                 number of entries in the returned arrays. On failure,
155                 these calls return a negative errno-style error
156                 code.</para>
157         </refsect1>
158
159         <refsect1>
160                 <title>Notes</title>
161
162                 <para>The <function>sd_uid_get_state()</function>,
163                 <function>sd_uid_is_on_seat()</function>,
164                 <function>sd_uid_get_sessions()</function>, and
165                 <function>sd_uid_get_seats()</function> interfaces are
166                 available as shared library, which can be compiled and
167                 linked to with the <literal>libsystemd-login</literal>
168                 <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
169                 file.</para>
170         </refsect1>
171
172         <refsect1>
173                 <title>See Also</title>
174
175                 <para>
176                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
177                         <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
178                         <citerefentry><refentrytitle>sd_pid_get_owner_uid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
179                 </para>
180         </refsect1>
181
182 </refentry>