systemd/man/sd_uid_get_state.html
2014-04-27 12:02:08 +02:00

96 lines
9.3 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>
a.headerlink {
color: #c60f0f;
font-size: 0.8em;
padding: 0 4px 0 4px;
text-decoration: none;
visibility: hidden;
}
a.headerlink:hover {
background-color: #c60f0f;
color: white;
}
h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
visibility: visible;
}
</style><a href="index.html">Index </a>·
<a href="systemd.directives.html">Directives </a>·
<a href="../python-systemd/index.html">Python </a>·
<a href="../libudev/index.html">libudev </a>·
<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
used to determine the login state of a specific Unix
user identifier. The following states are currently
known: "<code class="literal">offline</code>" (user not logged in
at all), "<code class="literal">lingering</code>" (user not logged
in, but some user services running),
"<code class="literal">online</code>" (user logged in, but not
active, i.e. has no session in the foreground),
"<code class="literal">active</code>" (user logged in, and has at
least one active session, i.e. one session in the
foreground), "<code class="literal">closing</code>" (user not
logged in, and not lingering, but some processes are
still around). In the future additional states might
be defined, client code should be written to be robust
in regards to additional state strings being
returned. The returned string needs to be freed with
the libc
<a href="free.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a>
call after use.</p><p><code class="function">sd_uid_is_on_seat()</code> may be
used to determine whether a specific user is logged in
or active on a specific seat. Accepts a Unix user
identifier and a seat identifier string as
parameters. The <em class="parameter"><code>require_active</code></em>
parameter is a boolean value. If non-zero (true), this
function will test if the user is active (i.e. has a
session that is in the foreground and accepting user
input) on the specified seat, otherwise (false) only
if the user is logged in (and possibly inactive) on
the specified seat.</p><p><code class="function">sd_uid_get_sessions()</code> may
be used to determine the current sessions of the
specified user. Accepts a Unix user identifier as
parameter. The <em class="parameter"><code>require_active</code></em>
parameter controls whether the returned list shall
consist of only those sessions where the user is
currently active (&gt; 0), where the user is currently
online but possibly inactive (= 0), or
logged in at all but possibly closing the session (&lt; 0). The call returns a
<code class="constant">NULL</code> terminated string array of session identifiers in
<em class="parameter"><code>sessions</code></em> which needs to be
freed by the caller with the libc
<a href="free.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a>
call after use, including all the strings
referenced. If the string array parameter is passed as
<code class="constant">NULL</code>, the array will not be filled in, but the return
code still indicates the number of current
sessions. Note that instead of an empty array <code class="constant">NULL</code> may
be returned and should be considered equivalent to an
empty array.</p><p>Similar, <code class="function">sd_uid_get_seats()</code>
may be used to determine the list of seats on which
the user currently has sessions. Similar semantics
apply, however note that the user may have
multiple sessions on the same seat as well as sessions
with no attached seat and hence the number of entries
in the returned array may differ from the one returned
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
<code class="function">sd_uid_get_state()</code> returns 0 or a
positive integer. If the test succeeds,
<code class="function">sd_uid_is_on_seat()</code> returns a
positive integer, if it fails
0. <code class="function">sd_uid_get_sessions()</code> and
<code class="function">sd_uid_get_seats()</code> return the
number of entries in the returned arrays. On failure,
these calls return a negative errno-style error
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>,
<code class="function">sd_uid_is_on_seat()</code>,
<code class="function">sd_uid_get_sessions()</code>, and
<code class="function">sd_uid_get_seats()</code> interfaces are
available as shared library, which can be compiled and
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>
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>
<a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
<a href="sd-login.html"><span class="citerefentry"><span class="refentrytitle">sd-login</span>(3)</span></a>,
<a href="sd_pid_get_owner_uid.html"><span class="citerefentry"><span class="refentrytitle">sd_pid_get_owner_uid</span>(3)</span></a>
</p></div></div></body></html>