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">
6 This file is part of elogind.
8 Copyright 2010 Lennart Poettering
10 elogind 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.
15 elogind 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.
20 You should have received a copy of the GNU Lesser General Public License
21 along with elogind; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="sd_get_seats" conditional='HAVE_PAM'>
27 <title>sd_get_seats</title>
28 <productname>elogind</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>sd_get_seats</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_get_seats</refname>
47 <refname>sd_get_sessions</refname>
48 <refname>sd_get_uids</refname>
49 <refname>sd_get_machine_names</refname>
50 <refpurpose>Determine available seats, sessions, logged in users and virtual machines/containers</refpurpose>
55 <funcsynopsisinfo>#include <elogind/sd-login.h></funcsynopsisinfo>
58 <funcdef>int <function>sd_get_seats</function></funcdef>
59 <paramdef>char ***<parameter>seats</parameter></paramdef>
63 <funcdef>int <function>sd_get_sessions</function></funcdef>
64 <paramdef>char ***<parameter>sessions</parameter></paramdef>
68 <funcdef>int <function>sd_get_uids</function></funcdef>
69 <paramdef>uid_t **<parameter>users</parameter></paramdef>
73 <funcdef>int <function>sd_get_machine_names</function></funcdef>
74 <paramdef>char ***<parameter>machines</parameter></paramdef>
81 <title>Description</title>
83 <para><function>sd_get_seats()</function> may be used to determine
84 all currently available local seats. Returns the number of seat
85 identifiers and if the input pointer is non-NULL, a
86 <constant>NULL</constant>-terminated array of seat identifiers
87 is stored at the address.
88 The returned array and all strings it references need to be freed
90 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
91 call after use. Note that instead of an empty array
92 <constant>NULL</constant> may be returned and should be considered
93 equivalent to an empty array.</para>
95 <para>Similarly, <function>sd_get_sessions()</function> may be
96 used to determine all current login sessions.</para>
98 <para>Similarly, <function>sd_get_uids()</function> may be used to
99 determine all Unix users who currently have login sessions.</para>
101 <para>Similarly, <function>sd_get_machine_names()</function> may
102 be used to determine all current virtual machines and containers
103 on the system.</para>
105 <para>Note that the returned lists are not sorted and in an
106 undefined order.</para>
110 <title>Return Value</title>
112 <para>On success, <function>sd_get_seats()</function>,
113 <function>sd_get_sessions()</function>,
114 <function>sd_get_uids()</function> and
115 <function>sd_get_machine_names()</function> return the number of
116 entries in the arrays. On failure, these calls return a negative
117 errno-style error code.</para>
122 <title>Errors</title>
124 <para>Returned errors may indicate the following problems:</para>
129 <term><constant>-ENOMEM</constant></term>
131 <listitem><para>Memory allocation failed.</para></listitem>
139 <para>The <function>sd_get_seats()</function>,
140 <function>sd_get_sessions()</function>,
141 <function>sd_get_uids()</function> and
142 <function>sd_get_machine_names()</function> interfaces are
143 available as a shared library, which can be compiled and linked to
145 <constant>libelogind</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
150 <title>See Also</title>
153 <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
154 <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
155 <citerefentry><refentrytitle>sd_session_get_seat</refentrytitle><manvolnum>3</manvolnum></citerefentry>