1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="sd_get_seats" conditional='HAVE_PAM'
7 xmlns:xi="http://www.w3.org/2001/XInclude">
10 <title>sd_get_seats</title>
11 <productname>systemd</productname>
15 <refentrytitle>sd_get_seats</refentrytitle>
16 <manvolnum>3</manvolnum>
20 <refname>sd_get_seats</refname>
21 <refname>sd_get_sessions</refname>
22 <refname>sd_get_uids</refname>
23 <refname>sd_get_machine_names</refname>
24 <refpurpose>Determine available seats, sessions, logged in users and virtual machines/containers</refpurpose>
29 <funcsynopsisinfo>#include <systemd/sd-login.h></funcsynopsisinfo>
32 <funcdef>int <function>sd_get_seats</function></funcdef>
33 <paramdef>char ***<parameter>seats</parameter></paramdef>
37 <funcdef>int <function>sd_get_sessions</function></funcdef>
38 <paramdef>char ***<parameter>sessions</parameter></paramdef>
42 <funcdef>int <function>sd_get_uids</function></funcdef>
43 <paramdef>uid_t **<parameter>users</parameter></paramdef>
47 <funcdef>int <function>sd_get_machine_names</function></funcdef>
48 <paramdef>char ***<parameter>machines</parameter></paramdef>
55 <title>Description</title>
57 <para><function>sd_get_seats()</function> may be used to determine
58 all currently available local seats. Returns the number of seat
59 identifiers and if the input pointer is non-<constant>NULL</constant>, a
60 <constant>NULL</constant>-terminated array of seat identifiers
61 is stored at the address.
62 The returned array and all strings it references need to be freed
64 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
65 call after use. Note that instead of an empty array
66 <constant>NULL</constant> may be returned and should be considered
67 equivalent to an empty array.</para>
69 <para>Similarly, <function>sd_get_sessions()</function> may be
70 used to determine all current login sessions.</para>
72 <para>Similarly, <function>sd_get_uids()</function> may be used to
73 determine all Unix users who currently have login sessions.</para>
75 <para>Similarly, <function>sd_get_machine_names()</function> may
76 be used to determine all current virtual machines and containers
79 <para>Note that the returned lists are not sorted and in an
80 undefined order.</para>
84 <title>Return Value</title>
86 <para>On success, <function>sd_get_seats()</function>, <function>sd_get_sessions()</function>,
87 <function>sd_get_uids()</function> and <function>sd_get_machine_names()</function> return the number of
88 entries in the arrays. On failure, these calls return a negative errno-style error code.</para>
93 <para>Returned errors may indicate the following problems:</para>
98 <term><constant>-ENOMEM</constant></term>
100 <listitem><para>Memory allocation failed.</para></listitem>
106 <xi:include href="libsystemd-pkgconfig.xml" />
109 <title>History</title>
110 <para><function>sd_get_machine_names()</function> was added in version 203.</para>
114 <title>See Also</title>
117 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
118 <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
119 <citerefentry><refentrytitle>sd_session_get_seat</refentrytitle><manvolnum>3</manvolnum></citerefentry>