chiark / gitweb /
core: allow setting RemainAfterExit= for transient services
[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" 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                 <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 value. 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. Accepts a Unix user identifier as
124                 parameter. The <parameter>require_active</parameter>
125                 parameter controls whether the returned list shall
126                 consist of only those sessions where the user is
127                 currently active (&gt; 0), where the user is currently
128                 online but possibly inactive (= 0), or
129                 logged in at all but possibly closing the session (&lt; 0). The call returns a
130                 <constant>NULL</constant> terminated string array of session identifiers in
131                 <parameter>sessions</parameter> which needs to be
132                 freed by the caller with the libc
133                 <citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
134                 call after use, including all the strings
135                 referenced. If the string array parameter is passed as
136                 <constant>NULL</constant> the array will not be filled in, but the return
137                 code still indicates the number of current
138                 sessions. Note that instead of an empty array <constant>NULL</constant> may
139                 be returned and should be considered equivalent to an
140                 empty array.</para>
141
142                 <para>Similar, <function>sd_uid_get_seats()</function>
143                 may be used to determine the list of seats on which
144                 the user currently has sessions. Similar semantics
145                 apply, however note that the user may have
146                 multiple sessions on the same seat as well as sessions
147                 with no attached seat and hence the number of entries
148                 in the returned array may differ from the one returned
149                 by <function>sd_uid_get_sessions()</function>.</para>
150         </refsect1>
151
152         <refsect1>
153                 <title>Return Value</title>
154
155                 <para>On success
156                 <function>sd_uid_get_state()</function> returns 0 or a
157                 positive integer. If the test succeeds
158                 <function>sd_uid_is_on_seat()</function> returns a
159                 positive integer, if it fails
160                 0. <function>sd_uid_get_sessions()</function> and
161                 <function>sd_uid_get_seats()</function> return the
162                 number of entries in the returned arrays. On failure,
163                 these calls return a negative errno-style error
164                 code.</para>
165         </refsect1>
166
167         <refsect1>
168                 <title>Notes</title>
169
170                 <para>The <function>sd_uid_get_state()</function>,
171                 <function>sd_uid_is_on_seat()</function>,
172                 <function>sd_uid_get_sessions()</function>, and
173                 <function>sd_uid_get_seats()</function> interfaces are
174                 available as shared library, which can be compiled and
175                 linked to with the <constant>libsystemd-login</constant> <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>