]>
Commit | Line | Data |
---|---|---|
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 | |
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 <systemd/sd-login.h></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 | |
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> | |
595aae37 LP |
129 | call after use, including all the strings |
130 | referenced. If the string array parameter is passed as | |
131 | NULL the array will not be filled in, but the return | |
132 | code still indicates the number of current | |
133 | sessions. Note that instead of an empty array NULL may | |
134 | be returned and should be considered equivalent to an | |
135 | empty array.</para> | |
0b3b020a LP |
136 | |
137 | <para>Similar, <function>sd_uid_get_seats()</function> | |
138 | may be used to determine the list of seats on which | |
139 | the user currently has sessions. Similar semantics | |
140 | apply, however note that the user may have | |
141 | multiple sessions on the same seat as well as sessions | |
142 | with no attached seat and hence the number of entries | |
143 | in the returned array may differ from the one returned | |
144 | by <function>sd_uid_get_sessions()</function>.</para> | |
145 | </refsect1> | |
146 | ||
147 | <refsect1> | |
148 | <title>Return Value</title> | |
149 | ||
150 | <para>On success | |
151 | <function>sd_uid_get_state()</function> returns 0 or a | |
152 | positive integer. If the test succeeds | |
153 | <function>sd_uid_is_on_seat()</function> returns a | |
154 | positive integer, if it fails | |
155 | 0. <function>sd_uid_get_sessions()</function> and | |
156 | <function>sd_uid_get_seats()</function> return the | |
157 | number of entries in the returned arrays. On failure, | |
158 | these calls return a negative errno-style error | |
159 | code.</para> | |
160 | </refsect1> | |
161 | ||
162 | <refsect1> | |
163 | <title>Notes</title> | |
164 | ||
165 | <para>The <function>sd_uid_get_state()</function>, | |
166 | <function>sd_uid_is_on_seat()</function>, | |
167 | <function>sd_uid_get_sessions()</function>, and | |
168 | <function>sd_uid_get_seats()</function> interfaces are | |
169 | available as shared library, which can be compiled and | |
170 | linked to with the <literal>libsystemd-login</literal> | |
171 | <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
172 | file.</para> | |
173 | </refsect1> | |
174 | ||
175 | <refsect1> | |
176 | <title>See Also</title> | |
177 | ||
178 | <para> | |
179 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
180 | <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>7</manvolnum></citerefentry>, | |
595aae37 | 181 | <citerefentry><refentrytitle>sd_pid_get_owner_uid</refentrytitle><manvolnum>3</manvolnum></citerefentry> |
0b3b020a LP |
182 | </para> |
183 | </refsect1> | |
184 | ||
185 | </refentry> |