]>
Commit | Line | Data |
---|---|---|
60f067b4 JS |
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>· | |
5eef597e | 22 | <a href="../libudev/index.html">gudev </a><span style="float:right">systemd 217</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, sd_uid_get_display — 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><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_display</b>(</code></td><td>uid_t <var class="pdparam">uid</var>, </td></tr><tr><td> </td><td>char **<var class="pdparam">session</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm214177844416"></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 |
60f067b4 JS |
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 | |
5eef597e | 39 | <a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a> |
60f067b4 JS |
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 (> 0), where the user is currently | |
57 | online but possibly inactive (= 0), or | |
58 | logged in at all but possibly closing the session (< 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 | |
5eef597e | 62 | <a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a> |
60f067b4 JS |
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>Similarly, <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><p><code class="function">sd_uid_get_display()</code> | |
77 | returns the name of the "primary" session of a user. | |
78 | If the user has graphical sessions, it will be the | |
79 | oldest graphical session. Otherwise, it will be the | |
5eef597e | 80 | oldest open session.</p></div><div class="refsect1"><a name="idm214181723120"></a><h2 id="Return Value">Return Value<a class="headerlink" title="Permalink to this headline" href="#Return%20Value">¶</a></h2><p>On success, |
60f067b4 JS |
81 | <code class="function">sd_uid_get_state()</code> returns 0 or a |
82 | positive integer. If the test succeeds, | |
83 | <code class="function">sd_uid_is_on_seat()</code> returns a | |
84 | positive integer; if it fails, | |
85 | 0. <code class="function">sd_uid_get_sessions()</code> and | |
86 | <code class="function">sd_uid_get_seats()</code> return the | |
87 | number of entries in the returned arrays. | |
88 | <code class="function">sd_uid_get_display()</code> returns | |
89 | a non-negative code on success. On failure, | |
90 | these calls return a negative errno-style error | |
5eef597e | 91 | code.</p></div><div class="refsect1"><a name="idm214181718240"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes">¶</a></h2><p>Functions described here are available as a |
60f067b4 JS |
92 | shared library, and can be compiled and linked to |
93 | using the | |
5eef597e MP |
94 | <code class="constant">libsystemd</code> <a href="http://linux.die.net/man/1/pkg-config"><span class="citerefentry"><span class="refentrytitle">pkg-config</span>(1)</span></a> |
95 | entry.</p></div><div class="refsect1"><a name="idm214181715280"></a><h2 id="History">History<a class="headerlink" title="Permalink to this headline" href="#History">¶</a></h2><code class="function">sd_uid_get_state()</code>, | |
60f067b4 JS |
96 | <code class="function">sd_uid_is_on_seat()</code>, |
97 | <code class="function">sd_uid_get_sessions()</code>, | |
98 | and <code class="function">sd_uid_get_seats()</code> functions | |
99 | were added in systemd-31. | |
100 | ||
101 | <p><code class="function">sd_uid_get_display()</code> was | |
5eef597e | 102 | added in systemd-213.</p></div><div class="refsect1"><a name="idm214181710688"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also">¶</a></h2><p> |
60f067b4 JS |
103 | <a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>, |
104 | <a href="sd-login.html"><span class="citerefentry"><span class="refentrytitle">sd-login</span>(3)</span></a>, | |
105 | <a href="sd_pid_get_owner_uid.html"><span class="citerefentry"><span class="refentrytitle">sd_pid_get_owner_uid</span>(3)</span></a> | |
106 | </p></div></div></body></html> |