sd_session_is_active.xml revision 49ebd11fb0ea6af249990439bf0690641e8be559
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering<?xml version='1.0'?> <!--*-nxml-*-->
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering<!--
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering This file is part of systemd.
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
44f44a29cc1346c0783d679374ce98d81bf6400cLennart Poettering Copyright 2010 Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering systemd is free software; you can redistribute it and/or modify it
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering under the terms of the GNU Lesser General Public License as published by
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering (at your option) any later version.
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering systemd is distributed in the hope that it will be useful, but
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering Lesser General Public License for more details.
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering You should have received a copy of the GNU Lesser General Public License
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering-->
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
dfdebb1b925332352966804303b2516a6506a429Zbigniew Jędrzejewski-Szmek<refentry id="sd_session_is_active" conditional='HAVE_PAM'>
dfdebb1b925332352966804303b2516a6506a429Zbigniew Jędrzejewski-Szmek
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refentryinfo>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <title>sd_session_is_active</title>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <productname>systemd</productname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <authorgroup>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <author>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <contrib>Developer</contrib>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <firstname>Lennart</firstname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <surname>Poettering</surname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <email>lennart@poettering.net</email>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </author>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </authorgroup>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </refentryinfo>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refmeta>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refentrytitle>sd_session_is_active</refentrytitle>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <manvolnum>3</manvolnum>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </refmeta>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refnamediv>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refname>sd_session_is_active</refname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refname>sd_session_is_remote</refname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refname>sd_session_get_state</refname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refname>sd_session_get_uid</refname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refname>sd_session_get_seat</refname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refname>sd_session_get_service</refname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refname>sd_session_get_type</refname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refname>sd_session_get_class</refname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refname>sd_session_get_display</refname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refname>sd_session_get_tty</refname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refname>sd_session_get_vt</refname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refname>sd_session_get_remote_host</refname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refname>sd_session_get_remote_user</refname>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refpurpose>Determine state of a specific session</refpurpose>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </refnamediv>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refsynopsisdiv>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcsynopsis>
6db2742802b70938f0f2d373110ed734d4fb9813Zbigniew Jędrzejewski-Szmek <funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcdef>int <function>sd_session_is_active</function></funcdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>const char* <parameter>session</parameter></paramdef>
79640424059328268b9fb6c5fa8eb777b27a177eJan Engelhardt </funcprototype>
9adf646d0ae85192027319e2f47f2d092a298d99Lennart Poettering
6db2742802b70938f0f2d373110ed734d4fb9813Zbigniew Jędrzejewski-Szmek <funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcdef>int <function>sd_session_is_remote</function></funcdef>
79640424059328268b9fb6c5fa8eb777b27a177eJan Engelhardt <paramdef>const char* <parameter>session</parameter></paramdef>
6db2742802b70938f0f2d373110ed734d4fb9813Zbigniew Jędrzejewski-Szmek </funcprototype>
6db2742802b70938f0f2d373110ed734d4fb9813Zbigniew Jędrzejewski-Szmek
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcdef>int <function>sd_session_get_state</function></funcdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>const char* <parameter>session</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>char** <parameter>state</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcdef>int <function>sd_session_get_uid</function></funcdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>const char* <parameter>session</parameter></paramdef>
dfdebb1b925332352966804303b2516a6506a429Zbigniew Jędrzejewski-Szmek <paramdef>uid_t* <parameter>uid</parameter></paramdef>
dfdebb1b925332352966804303b2516a6506a429Zbigniew Jędrzejewski-Szmek </funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcdef>int <function>sd_session_get_seat</function></funcdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>const char* <parameter>session</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>char** <parameter>seat</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
79640424059328268b9fb6c5fa8eb777b27a177eJan Engelhardt <funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcdef>int <function>sd_session_get_service</function></funcdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>const char* <parameter>session</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>char** <parameter>service</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcdef>int <function>sd_session_get_type</function></funcdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>const char* <parameter>session</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>char** <parameter>type</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcdef>int <function>sd_session_get_class</function></funcdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>const char* <parameter>session</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>char** <parameter>class</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
16dad32e437fdf2ffca03cc60a083d84bd31886fAndrew Eikum <funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcdef>int <function>sd_session_get_display</function></funcdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>const char* <parameter>session</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>char** <parameter>display</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcdef>int <function>sd_session_get_remote_host</function></funcdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>const char* <parameter>session</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>char** <parameter>remote_host</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcdef>int <function>sd_session_get_remote_user</function></funcdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>const char* <parameter>session</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>char** <parameter>remote_user</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcdef>int <function>sd_session_get_tty</function></funcdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>const char* <parameter>session</parameter></paramdef>
79640424059328268b9fb6c5fa8eb777b27a177eJan Engelhardt <paramdef>char** <parameter>tty</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <funcdef>int <function>sd_session_get_vt</function></funcdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>const char* <parameter>session</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <paramdef>unsigned int* <parameter>vt</parameter></paramdef>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </funcprototype>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </funcsynopsis>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering </refsynopsisdiv>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <refsect1>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <title>Description</title>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <para><function>sd_session_is_active()</function> may
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering be used to determine whether the session identified by
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering the specified session identifier is currently active
b040723ea412209e0edf54647fa5aa4287411507Jan Engelhardt (i.e. currently in the foreground and available for
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering user input) or not.</para>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <para><function>sd_session_is_remote()</function> may
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering be used to determine whether the session identified by
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering the specified session identifier is a remote session
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering (i.e. its remote host is known) or not.</para>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <para><function>sd_session_get_state()</function> may
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering be used to determine the state of the session
845c53246f73a505f12bb7f685a530045fa60a40Zbigniew Jędrzejewski-Szmek identified by the specified session identifier. The
6db2742802b70938f0f2d373110ed734d4fb9813Zbigniew Jędrzejewski-Szmek following states are currently known:
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <literal>online</literal> (session logged in, but
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering session not active, i.e. not in the foreground),
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <literal>active</literal> (session logged in and
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering active, i.e. in the foreground),
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <literal>closing</literal> (session nominally logged
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering out, but some processes belonging to it are still
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering around). In the future additional states might be
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering defined, client code should be written to be robust in
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering regards to additional state strings being
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering returned. This function is a more generic version of
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <function>sd_session_is_active()</function>. The returned
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering string needs to be freed with the libc
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering call after use.</para>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <para><function>sd_session_get_uid()</function> may be
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering used to determine the user identifier of the Unix user the session
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering identified by the specified session identifier belongs
6db2742802b70938f0f2d373110ed734d4fb9813Zbigniew Jędrzejewski-Szmek to.</para>
73e231abde39f22097df50542c745e01de879836Jan Engelhardt
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <para><function>sd_session_get_seat()</function> may
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering be used to determine the seat identifier of the seat
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering the session identified by the specified session
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering identifier belongs to. Note that not all sessions are
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering attached to a seat, this call will fail for them. The
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering returned string needs to be freed with the libc
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering call after use.</para>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering <para><function>sd_session_get_service()</function>
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering may be used to determine the name of the service (as
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering passed during PAM session setup) that registered the
9aac0b2c19c558b853da7a6d67a0929b2d44dee4Lennart Poettering session identified by the specified session
identifier. The returned string needs to be freed with
the libc
<citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call after use.</para>
<para><function>sd_session_get_type()</function> may
be used to determine the type of the session
identified by the specified session identifier. The
returned string is one of <literal>x11</literal>,
<literal>wayland</literal>, <literal>tty</literal> or
<literal>unspecified</literal> and needs to be freed
with the libc
<citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call after use.</para>
<para><function>sd_session_get_class()</function> may
be used to determine the class of the session
identified by the specified session identifier. The
returned string is one of <literal>user</literal>,
<literal>greeter</literal>,
<literal>lock-screen</literal>, or
<literal>background</literal> and needs to be freed
with the libc
<citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call after use.</para>
<para><function>sd_session_get_display()</function>
may be used to determine the X11 display of the
session identified by the specified session
identifier. The returned string needs to be
freed with the libc
<citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call after use.</para>
<para><function>sd_session_get_remote_host()</function>
may be used to determine the remote hostname of the
session identified by the specified session
identifier. The returned string needs to be
freed with the libc
<citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call after use.</para>
<para><function>sd_session_get_remote_user()</function>
may be used to determine the remote username of the
session identified by the specified session
identifier. The returned string needs to be
freed with the libc
<citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call after use. Note that this value is rarely known
to the system, and even then should not be relied on.</para>
<para><function>sd_session_get_tty()</function>
may be used to determine the TTY device of the
session identified by the specified session
identifier. The returned string needs to be
freed with the libc
<citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call after use.</para>
<para><function>sd_session_get_vt()</function>
may be used to determine the VT number of the
session identified by the specified session
identifier. This function will return an error if
the seat does not support VTs.</para>
<para>If the <varname>session</varname> parameter of
any of these functions is passed as
<constant>NULL</constant>, the operation is executed
for the session the calling process is a member of, if
there is any.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>If the test succeeds,
<function>sd_session_is_active()</function> and
<function>sd_session_is_remote()</function> return a
positive integer; if it fails, 0. On success,
<function>sd_session_get_state()</function>,
<function>sd_session_get_uid()</function>,
<function>sd_session_get_seat()</function>,
<function>sd_session_get_service()</function>,
<function>sd_session_get_type()</function>,
<function>sd_session_get_class()</function>,
<function>sd_session_get_display()</function>,
<function>sd_session_get_remote_user()</function>,
<function>sd_session_get_remote_host()</function> and
<function>sd_session_get_tty()</function> return 0 or
a positive integer. On failure, these calls return a
negative errno-style error code.</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>The <function>sd_session_is_active()</function>,
<function>sd_session_get_state()</function>,
<function>sd_session_get_uid()</function>,
<function>sd_session_get_seat()</function>,
<function>sd_session_get_service()</function>,
<function>sd_session_get_type()</function>,
<function>sd_session_get_class()</function>,
<function>sd_session_get_display()</function>,
<function>sd_session_get_remote_host()</function>,
<function>sd_session_get_remote_user()</function> and
<function>sd_session_get_tty()</function>
interfaces are available as a shared library, which can
be compiled and linked to with the
<constant>libsystemd-login</constant> <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
file.</para>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_pid_get_session</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>