<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 204</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 <systemd/sd-login.h></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="idm259768435792"></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
+ <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 <systemd/sd-login.h></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
+ 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
+ "<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
+ "<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
+ 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
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
+ 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
currently active (> 0), where the user is currently
online but possibly inactive (= 0), or
logged in at all but possibly closing the session (< 0). The call returns a
- NULL terminated string array of session identifiers in
+ <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
- NULL the array will not be filled in, but the return
+ <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 NULL may
+ 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
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="idm259772319936"></a><h2 id="Return Value">Return Value<a class="headerlink" title="Permalink to this headline" href="#Return%20Value">¶</a></h2><p>On success
+ 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
+ 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="idm259772315744"></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.</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="literal">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="idm259772302592"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also">¶</a></h2><p>
+ 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>