]> git.proxmox.com Git - systemd.git/blob - man/sd_uid_get_sessions.html
783423bc52ccdb84b50474ab9f257f7569b12435
[systemd.git] / man / sd_uid_get_sessions.html
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sd_uid_get_state</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
2 a.headerlink {
3 color: #c60f0f;
4 font-size: 0.8em;
5 padding: 0 4px 0 4px;
6 text-decoration: none;
7 visibility: hidden;
8 }
9
10 a.headerlink:hover {
11 background-color: #c60f0f;
12 color: white;
13 }
14
15 h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
16 visibility: visible;
17 }
18 </style><a href="index.html">Index </a>·
19 <a href="systemd.directives.html">Directives </a>·
20 <a href="../python-systemd/index.html">Python </a>·
21 <a href="../libudev/index.html">libudev </a>·
22 <a href="../libudev/index.html">gudev </a><span style="float:right">systemd 208</span><hr><div class="refentry"><a name="sd_uid_get_state"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_uid_get_state, sd_uid_is_on_seat, sd_uid_get_sessions, sd_uid_get_seats — Determine login state of a specific Unix user ID</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;systemd/sd-login.h&gt;</pre><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_uid_get_state</b>(</code></td><td>uid_t <var class="pdparam">uid</var>, </td></tr><tr><td> </td><td>char** <var class="pdparam">state</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_uid_is_on_seat</b>(</code></td><td>uid_t <var class="pdparam">uid</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">require_active</var>, </td></tr><tr><td> </td><td>const char* <var class="pdparam">seat</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_uid_get_sessions</b>(</code></td><td>uid_t <var class="pdparam">uid</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">require_active</var>, </td></tr><tr><td> </td><td>char*** <var class="pdparam">sessions</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_uid_get_seats</b>(</code></td><td>uid_t <var class="pdparam">uid</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">require_active</var>, </td></tr><tr><td> </td><td>char*** <var class="pdparam">seats</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm274686615328"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description"></a></h2><p><code class="function">sd_uid_get_state()</code> may be
23 used to determine the login state of a specific Unix
24 user identifier. The following states are currently
25 known: "<code class="literal">offline</code>" (user not logged in
26 at all), "<code class="literal">lingering</code>" (user not logged
27 in, but some user services running),
28 "<code class="literal">online</code>" (user logged in, but not
29 active, i.e. has no session in the foreground),
30 "<code class="literal">active</code>" (user logged in, and has at
31 least one active session, i.e. one session in the
32 foreground), "<code class="literal">closing</code>" (user not
33 logged in, and not lingering, but some processes are
34 still around). In the future additional states might
35 be defined, client code should be written to be robust
36 in regards to additional state strings being
37 returned. The returned string needs to be freed with
38 the libc
39 <a href="free.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a>
40 call after use.</p><p><code class="function">sd_uid_is_on_seat()</code> may be
41 used to determine whether a specific user is logged in
42 or active on a specific seat. Accepts a Unix user
43 identifier and a seat identifier string as
44 parameters. The <em class="parameter"><code>require_active</code></em>
45 parameter is a boolean value. If non-zero (true), this
46 function will test if the user is active (i.e. has a
47 session that is in the foreground and accepting user
48 input) on the specified seat, otherwise (false) only
49 if the user is logged in (and possibly inactive) on
50 the specified seat.</p><p><code class="function">sd_uid_get_sessions()</code> may
51 be used to determine the current sessions of the
52 specified user. Accepts a Unix user identifier as
53 parameter. The <em class="parameter"><code>require_active</code></em>
54 parameter controls whether the returned list shall
55 consist of only those sessions where the user is
56 currently active (&gt; 0), where the user is currently
57 online but possibly inactive (= 0), or
58 logged in at all but possibly closing the session (&lt; 0). The call returns a
59 <code class="constant">NULL</code> terminated string array of session identifiers in
60 <em class="parameter"><code>sessions</code></em> which needs to be
61 freed by the caller with the libc
62 <a href="free.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a>
63 call after use, including all the strings
64 referenced. If the string array parameter is passed as
65 <code class="constant">NULL</code>, the array will not be filled in, but the return
66 code still indicates the number of current
67 sessions. Note that instead of an empty array <code class="constant">NULL</code> may
68 be returned and should be considered equivalent to an
69 empty array.</p><p>Similar, <code class="function">sd_uid_get_seats()</code>
70 may be used to determine the list of seats on which
71 the user currently has sessions. Similar semantics
72 apply, however note that the user may have
73 multiple sessions on the same seat as well as sessions
74 with no attached seat and hence the number of entries
75 in the returned array may differ from the one returned
76 by <code class="function">sd_uid_get_sessions()</code>.</p></div><div class="refsect1"><a name="idm274686574336"></a><h2 id="Return Value">Return Value<a class="headerlink" title="Permalink to this headline" href="#Return%20Value"></a></h2><p>On success
77 <code class="function">sd_uid_get_state()</code> returns 0 or a
78 positive integer. If the test succeeds,
79 <code class="function">sd_uid_is_on_seat()</code> returns a
80 positive integer, if it fails
81 0. <code class="function">sd_uid_get_sessions()</code> and
82 <code class="function">sd_uid_get_seats()</code> return the
83 number of entries in the returned arrays. On failure,
84 these calls return a negative errno-style error
85 code.</p></div><div class="refsect1"><a name="idm274686570032"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes"></a></h2><p>The <code class="function">sd_uid_get_state()</code>,
86 <code class="function">sd_uid_is_on_seat()</code>,
87 <code class="function">sd_uid_get_sessions()</code>, and
88 <code class="function">sd_uid_get_seats()</code> interfaces are
89 available as shared library, which can be compiled and
90 linked to with the <code class="constant">libsystemd-login</code> <a href="pkg-config.html"><span class="citerefentry"><span class="refentrytitle">pkg-config</span>(1)</span></a>
91 file.</p></div><div class="refsect1"><a name="idm274686676912"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also"></a></h2><p>
92 <a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
93 <a href="sd-login.html"><span class="citerefentry"><span class="refentrytitle">sd-login</span>(3)</span></a>,
94 <a href="sd_pid_get_owner_uid.html"><span class="citerefentry"><span class="refentrytitle">sd_pid_get_owner_uid</span>(3)</span></a>
95 </p></div></div></body></html>