]>
Commit | Line | Data |
---|---|---|
663996b3 MS |
1 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sd_session_is_active</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>· | |
e3bff60a | 22 | <a href="../libudev/index.html">gudev </a><span style="float:right">systemd 220</span><hr><div class="refentry"><a name="sd_session_is_active"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_session_is_active, sd_session_is_remote, sd_session_get_state, sd_session_get_uid, sd_session_get_seat, sd_session_get_service, sd_session_get_type, sd_session_get_class, sd_session_get_desktop, sd_session_get_display, sd_session_get_tty, sd_session_get_vt, sd_session_get_remote_host, sd_session_get_remote_user — Determine state of a specific session</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_session_is_active</b>(</code></td><td>const char *<var class="pdparam">session</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_session_is_remote</b>(</code></td><td>const char *<var class="pdparam">session</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_session_get_state</b>(</code></td><td>const char *<var class="pdparam">session</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_session_get_uid</b>(</code></td><td>const char *<var class="pdparam">session</var>, </td></tr><tr><td> </td><td>uid_t *<var class="pdparam">uid</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_session_get_seat</b>(</code></td><td>const char *<var class="pdparam">session</var>, </td></tr><tr><td> </td><td>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_session_get_service</b>(</code></td><td>const char *<var class="pdparam">session</var>, </td></tr><tr><td> </td><td>char **<var class="pdparam">service</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_session_get_type</b>(</code></td><td>const char *<var class="pdparam">session</var>, </td></tr><tr><td> </td><td>char **<var class="pdparam">type</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_session_get_class</b>(</code></td><td>const char *<var class="pdparam">session</var>, </td></tr><tr><td> </td><td>char **<var class="pdparam">class</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_session_get_desktop</b>(</code></td><td>const char *<var class="pdparam">session</var>, </td></tr><tr><td> </td><td>char **<var class="pdparam">desktop</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_session_get_display</b>(</code></td><td>const char *<var class="pdparam">session</var>, </td></tr><tr><td> </td><td>char **<var class="pdparam">display</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_session_get_remote_host</b>(</code></td><td>const char *<var class="pdparam">session</var>, </td></tr><tr><td> </td><td>char **<var class="pdparam">remote_host</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_session_get_remote_user</b>(</code></td><td>const char *<var class="pdparam">session</var>, </td></tr><tr><td> </td><td>char **<var class="pdparam">remote_user</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_session_get_tty</b>(</code></td><td>const char *<var class="pdparam">session</var>, </td></tr><tr><td> </td><td>char **<var class="pdparam">tty</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_session_get_vt</b>(</code></td><td>const char *<var class="pdparam">session</var>, </td></tr><tr><td> </td><td>unsigned int *<var class="pdparam">vt</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm140689458568224"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description">¶</a></h2><p><code class="function">sd_session_is_active()</code> may be used to |
e735f4d4 MP |
23 | determine whether the session identified by the specified session |
24 | identifier is currently active (i.e. currently in the foreground | |
25 | and available for user input) or not.</p><p><code class="function">sd_session_is_remote()</code> may be used to | |
26 | determine whether the session identified by the specified session | |
27 | identifier is a remote session (i.e. its remote host is known) or | |
28 | not.</p><p><code class="function">sd_session_get_state()</code> may be used to | |
29 | determine the state of the session identified by the specified | |
30 | session identifier. The following states are currently known: | |
31 | "<code class="literal">online</code>" (session logged in, but session not | |
32 | active, i.e. not in the foreground), "<code class="literal">active</code>" | |
33 | (session logged in and active, i.e. in the foreground), | |
34 | "<code class="literal">closing</code>" (session nominally logged out, but some | |
35 | processes belonging to it are still around). In the future | |
36 | additional states might be defined, client code should be written | |
37 | to be robust in regards to additional state strings being | |
38 | returned. This function is a more generic version of | |
39 | <code class="function">sd_session_is_active()</code>. The returned string | |
40 | needs to be freed with the libc | |
41 | <a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a> | |
42 | call after use.</p><p><code class="function">sd_session_get_uid()</code> may be used to | |
43 | determine the user identifier of the Unix user the session | |
44 | identified by the specified session identifier belongs to.</p><p><code class="function">sd_session_get_seat()</code> may be used to | |
45 | determine the seat identifier of the seat the session identified | |
46 | by the specified session identifier belongs to. Note that not all | |
47 | sessions are attached to a seat, this call will fail for them. The | |
48 | returned string needs to be freed with the libc | |
49 | <a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a> | |
50 | call after use.</p><p><code class="function">sd_session_get_service()</code> may be used to | |
51 | determine the name of the service (as passed during PAM session | |
52 | setup) that registered the session identified by the specified | |
53 | session identifier. The returned string needs to be freed with the | |
54 | libc | |
55 | <a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a> | |
56 | call after use.</p><p><code class="function">sd_session_get_type()</code> may be used to | |
57 | determine the type of the session identified by the specified | |
58 | session identifier. The returned string is one of | |
59 | "<code class="literal">x11</code>", "<code class="literal">wayland</code>", | |
60 | "<code class="literal">tty</code>", "<code class="literal">mir</code>" or | |
61 | "<code class="literal">unspecified</code>" and needs to be freed with the libc | |
62 | <a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a> | |
63 | call after use.</p><p><code class="function">sd_session_get_class()</code> may be used to | |
64 | determine the class of the session identified by the specified | |
65 | session identifier. The returned string is one of | |
66 | "<code class="literal">user</code>", "<code class="literal">greeter</code>", | |
67 | "<code class="literal">lock-screen</code>", or "<code class="literal">background</code>" | |
68 | and needs to be freed with the libc | |
69 | <a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a> | |
70 | call after use.</p><p><code class="function">sd_session_get_desktop()</code> may be used to | |
71 | determine the brand of the desktop running on the session | |
72 | identified by the specified session identifier. This field can be | |
73 | set freely by desktop environments and does not follow any special | |
74 | formatting. However, desktops are strongly recommended to use the | |
75 | same identifiers and capitalization as for | |
76 | <code class="varname">$XDG_CURRENT_DESKTOP</code>, as defined by the <a class="ulink" href="http://standards.freedesktop.org/desktop-entry-spec/latest/" target="_top">Desktop | |
77 | Entry Specification</a>. The returned string needs to be freed | |
78 | with the libc | |
79 | <a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a> | |
80 | call after use.</p><p><code class="function">sd_session_get_display()</code> may be used to | |
81 | determine the X11 display of the session identified by the | |
82 | specified session identifier. The returned string needs to be | |
83 | freed with the libc | |
84 | <a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a> | |
85 | call after use.</p><p><code class="function">sd_session_get_remote_host()</code> may be | |
86 | used to determine the remote hostname of the session identified by | |
87 | the specified session identifier. The returned string needs to be | |
88 | freed with the libc | |
89 | <a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a> | |
90 | call after use.</p><p><code class="function">sd_session_get_remote_user()</code> may be | |
91 | used to determine the remote username of the session identified by | |
92 | the specified session identifier. The returned string needs to be | |
93 | freed with the libc | |
94 | <a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a> | |
95 | call after use. Note that this value is rarely known to the | |
96 | system, and even then should not be relied on.</p><p><code class="function">sd_session_get_tty()</code> may be used to | |
97 | determine the TTY device of the session identified by the | |
98 | specified session identifier. The returned string needs to be | |
99 | freed with the libc | |
100 | <a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a> | |
101 | call after use.</p><p><code class="function">sd_session_get_vt()</code> may be used to | |
102 | determine the VT number of the session identified by the specified | |
103 | session identifier. This function will return an error if the seat | |
104 | does not support VTs.</p><p>If the <code class="varname">session</code> parameter of any of these | |
105 | functions is passed as <code class="constant">NULL</code>, the operation is | |
106 | executed for the session the calling process is a member of, if | |
e3bff60a | 107 | there is any.</p></div><div class="refsect1"><a name="idm140689461855952"></a><h2 id="Return Value">Return Value<a class="headerlink" title="Permalink to this headline" href="#Return%20Value">¶</a></h2><p>If the test succeeds, |
e735f4d4 MP |
108 | <code class="function">sd_session_is_active()</code> and |
109 | <code class="function">sd_session_is_remote()</code> return a | |
110 | positive integer; if it fails, 0. On success, | |
111 | <code class="function">sd_session_get_state()</code>, | |
112 | <code class="function">sd_session_get_uid()</code>, | |
113 | <code class="function">sd_session_get_seat()</code>, | |
114 | <code class="function">sd_session_get_service()</code>, | |
115 | <code class="function">sd_session_get_type()</code>, | |
116 | <code class="function">sd_session_get_class()</code>, | |
117 | <code class="function">sd_session_get_display()</code>, | |
118 | <code class="function">sd_session_get_remote_user()</code>, | |
119 | <code class="function">sd_session_get_remote_host()</code> and | |
120 | <code class="function">sd_session_get_tty()</code> return 0 or | |
121 | a positive integer. On failure, these calls return a | |
e3bff60a | 122 | negative errno-style error code.</p></div><div class="refsect1"><a name="idm140689461845952"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes">¶</a></h2><p>The <code class="function">sd_session_is_active()</code>, |
e735f4d4 MP |
123 | <code class="function">sd_session_get_state()</code>, |
124 | <code class="function">sd_session_get_uid()</code>, | |
125 | <code class="function">sd_session_get_seat()</code>, | |
126 | <code class="function">sd_session_get_service()</code>, | |
127 | <code class="function">sd_session_get_type()</code>, | |
128 | <code class="function">sd_session_get_class()</code>, | |
129 | <code class="function">sd_session_get_display()</code>, | |
130 | <code class="function">sd_session_get_remote_host()</code>, | |
131 | <code class="function">sd_session_get_remote_user()</code> and | |
132 | <code class="function">sd_session_get_tty()</code> | |
133 | interfaces are available as a shared library, which can | |
134 | be compiled and linked to with the | |
135 | <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> | |
e3bff60a | 136 | file.</p></div><div class="refsect1"><a name="idm140689461835104"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also">¶</a></h2><p> |
e735f4d4 MP |
137 | <a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>, |
138 | <a href="sd-login.html"><span class="citerefentry"><span class="refentrytitle">sd-login</span>(3)</span></a>, | |
139 | <a href="sd_pid_get_session.html"><span class="citerefentry"><span class="refentrytitle">sd_pid_get_session</span>(3)</span></a> | |
140 | </p></div></div></body></html> |