]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_uid_get_state.xml
zsh_completion: Split out zsh _coredumpctl
[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>
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>
bd08f242 59 <paramdef>uid_t <parameter>uid</parameter></paramdef>
0b3b020a
LP
60 <paramdef>char** <parameter>state</parameter></paramdef>
61 </funcprototype>
62
63 <funcprototype>
64 <funcdef>int <function>sd_uid_is_on_seat</function></funcdef>
bd08f242 65 <paramdef>uid_t <parameter>uid</parameter></paramdef>
0b3b020a
LP
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>
bd08f242 72 <paramdef>uid_t <parameter>uid</parameter></paramdef>
0b3b020a
LP
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>
bd08f242 79 <paramdef>uid_t <parameter>uid</parameter></paramdef>
0b3b020a
LP
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
7ea9cb91
LP
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
0b3b020a
LP
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>
d18dff43 114 parameter is a boolean value. If non-zero (true) this
0b3b020a
LP
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
bb31a4ac 123 specified user. Accepts a Unix user identifier as
0b3b020a 124 parameter. The <parameter>require_active</parameter>
d18dff43
LP
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
74d00578 130 <constant>NULL</constant> terminated string array of session identifiers in
d18dff43
LP
131 <parameter>sessions</parameter> which needs to be
132 freed by the caller with the libc
0b3b020a 133 <citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
595aae37
LP
134 call after use, including all the strings
135 referenced. If the string array parameter is passed as
74d00578 136 <constant>NULL</constant> the array will not be filled in, but the return
595aae37 137 code still indicates the number of current
74d00578 138 sessions. Note that instead of an empty array <constant>NULL</constant> may
595aae37
LP
139 be returned and should be considered equivalent to an
140 empty array.</para>
0b3b020a
LP
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
1e158d27 175 linked to with the <constant>libsystemd-login</constant> <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
0b3b020a
LP
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>,
cb07866b 184 <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
595aae37 185 <citerefentry><refentrytitle>sd_pid_get_owner_uid</refentrytitle><manvolnum>3</manvolnum></citerefentry>
0b3b020a
LP
186 </para>
187 </refsect1>
188
189</refentry>