Merge branch 'journal'

This commit is contained in:
Lennart Poettering
2011-12-31 00:59:37 +01:00
67 changed files with 10906 additions and 385 deletions

8
.gitignore vendored
View File

@@ -1,3 +1,9 @@
/libsystemd-journal.pc
/libsystemd-id128.pc
systemd-journalctl
systemd-journald
test-id128
test-journal
test-install
org.freedesktop.hostname1.xml
org.freedesktop.locale1.xml
@@ -91,7 +97,7 @@ install-sh
missing
stamp-*
*.stamp
Makefile
/Makefile
ltmain.sh
*.tar.bz2
*.tar.gz

View File

@@ -27,6 +27,14 @@ LIBSYSTEMD_DAEMON_CURRENT=0
LIBSYSTEMD_DAEMON_REVISION=0
LIBSYSTEMD_DAEMON_AGE=0
LIBSYSTEMD_ID128_CURRENT=0
LIBSYSTEMD_ID128_REVISION=0
LIBSYSTEMD_ID128_AGE=0
LIBSYSTEMD_JOURNAL_CURRENT=0
LIBSYSTEMD_JOURNAL_REVISION=0
LIBSYSTEMD_JOURNAL_AGE=0
# Dirs of external packages
dbuspolicydir=@dbuspolicydir@
dbussessionservicedir=@dbussessionservicedir@
@@ -141,7 +149,8 @@ rootbin_PROGRAMS = \
systemd-ask-password \
systemd-tty-ask-password-agent \
systemd-tmpfiles \
systemd-machine-id-setup
systemd-machine-id-setup \
systemd-journalctl
bin_PROGRAMS = \
systemd-cgls \
@@ -180,7 +189,8 @@ rootlibexec_PROGRAMS = \
systemd-detect-virt \
systemd-sysctl \
systemd-logind \
systemd-uaccess
systemd-uaccess \
systemd-journald
if ENABLE_BINFMT
rootlibexec_PROGRAMS += \
@@ -215,11 +225,15 @@ endif
lib_LTLIBRARIES = \
libsystemd-daemon.la \
libsystemd-login.la
libsystemd-login.la \
libsystemd-id128.la \
libsystemd-journal.la
pkginclude_HEADERS = \
src/sd-daemon.h \
src/sd-login.h
src/sd-login.h \
src/sd-id128.h \
src/journal/sd-journal.h
noinst_PROGRAMS = \
test-engine \
@@ -232,7 +246,9 @@ noinst_PROGRAMS = \
test-env-replace \
test-strv \
test-login \
test-install
test-install \
test-id128 \
test-journal
if HAVE_PAM
pamlib_LTLIBRARIES = \
@@ -385,7 +401,8 @@ dist_systemunit_DATA = \
units/quotaon.service \
units/systemd-ask-password-wall.path \
units/systemd-ask-password-console.path \
units/syslog.target
units/syslog.target \
units/systemd-journald.socket
if HAVE_SYSV_COMPAT
dist_systemunit_DATA += \
@@ -406,6 +423,7 @@ nodist_systemunit_DATA = \
units/systemd-stdout-syslog-bridge.service \
units/systemd-shutdownd.service \
units/systemd-logind.service \
units/systemd-journald.service \
units/systemd-kmsg-syslogd.service \
units/systemd-modules-load.service \
units/systemd-vconsole-setup.service \
@@ -469,7 +487,8 @@ EXTRA_DIST = \
units/systemd-stdout-syslog-bridge.service.in \
units/systemd-shutdownd.service.in \
units/systemd-logind.service.in \
units/systemd-kmsg-syslogd.service.in \
units/systemd-journald.service.in \
units/systemd-kmsg-syslogd.service.in \
units/systemd-modules-load.service.in \
units/systemd-vconsole-setup.service.in \
units/systemd-remount-api-vfs.service.in \
@@ -498,11 +517,16 @@ EXTRA_DIST = \
systemd.pc.in \
libsystemd-daemon.pc.in \
libsystemd-login.pc.in \
libsystemd-id128.pc.in \
libsystemd-journal.pc.in \
src/libsystemd-daemon.sym \
src/libsystemd-login.sym \
src/libsystemd-id128.sym \
src/libsystemd-journal.sym \
introspect.awk \
src/73-seat-late.rules.in \
src/99-systemd.rules.in
src/99-systemd.rules.in \
man/custom-html.xsl
if ENABLE_BINFMT
EXTRA_DIST += \
@@ -597,7 +621,9 @@ pkgconfigdata_DATA = \
pkgconfiglib_DATA = \
libsystemd-daemon.pc \
libsystemd-login.pc
libsystemd-login.pc \
libsystemd-id128.pc \
libsystemd-journal.pc
# Passed through intltool only
polkitpolicy_in_files = \
@@ -709,7 +735,8 @@ libsystemd_core_la_SOURCES = \
src/dbus-common.c \
src/sd-daemon.c \
src/install.c \
src/cgroup-attr.c
src/cgroup-attr.c \
src/sd-id128.c
nodist_libsystemd_core_la_SOURCES = \
src/load-fragment-gperf.c \
@@ -772,7 +799,14 @@ EXTRA_DIST += \
src/logind-user.h \
src/logind-acl.h \
src/dbus-loop.h \
src/spawn-agent.h
src/spawn-agent.h \
src/journal/journal-def.h \
src/journal/journal-internal.h \
src/journal/journal-file.h \
src/journal/lookup3.h \
src/journal/compress.h \
src/journal/journal-rate-limit.h \
src/acl-util.h
MANPAGES = \
man/systemd.1 \
@@ -802,6 +836,7 @@ MANPAGES = \
man/daemon.7 \
man/sd-daemon.7 \
man/sd-readahead.7 \
man/sd-login.7 \
man/runlevel.8 \
man/telinit.8 \
man/halt.8 \
@@ -820,7 +855,13 @@ MANPAGES = \
man/modules-load.d.5 \
man/sysctl.d.5 \
man/systemd-ask-password.1 \
man/systemd-loginctl.1
man/systemd-loginctl.1 \
man/sd_pid_get_session.3 \
man/sd_uid_get_state.3 \
man/sd_session_is_active.3 \
man/sd_seat_get_active.3 \
man/sd_get_seats.3 \
man/sd_login_monitor_new.3
if ENABLE_BINFMT
MANPAGES += \
@@ -833,16 +874,44 @@ MANPAGES_ALIAS = \
man/sd_is_socket.3 \
man/sd_is_socket_unix.3 \
man/sd_is_socket_inet.3 \
man/sd_is_mq.3 \
man/sd_notifyf.3 \
man/init.1
man/init.1 \
man/sd_session_get_uid.3 \
man/sd_session_get_seat.3 \
man/sd_pid_get_owner_uid.3 \
man/sd_uid_is_on_seat.3 \
man/sd_uid_get_sessions.3 \
man/sd_uid_get_seats.3 \
man/sd_seat_get_sessions.3 \
man/sd_seat_can_multi_session.3 \
man/sd_get_sessions.3 \
man/sd_get_uids.3 \
man/sd_login_monitor_unref.3 \
man/sd_login_monitor_flush.3 \
man/sd_login_monitor_get_fd.3
man/reboot.8: man/halt.8
man/poweroff.8: man/halt.8
man/sd_is_socket.3: man/sd_is_fifo.3
man/sd_is_socket_unix.3: man/sd_is_fifo.3
man/sd_is_socket_inet.3: man/sd_is_fifo.3
man/sd_is_mq.3: man/sd_is_fifo.3
man/sd_notifyf.3: man/sd_notify.3
man/init.1: man/systemd.1
man/sd_session_get_uid.3: man/sd_session_is_active.3
man/sd_session_get_seat.3: man/sd_session_is_active.3
man/sd_pid_get_owner_uid.3: man/sd_pid_get_session.3
man/sd_uid_is_on_seat.3: man/sd_uid_get_state.3
man/sd_uid_get_sessions.3: man/sd_uid_get_state.3
man/sd_uid_get_seats.3: man/sd_uid_get_state.3
man/sd_seat_get_sessions.3: man/sd_seat_get_active.3
man/sd_seat_can_multi_session.3: man/sd_seat_get_active.3
man/sd_get_sessions.3: man/sd_get_seats.3
man/sd_get_uids.3: man/sd_get_seats.3
man/sd_login_monitor_unref.3: man/sd_login_monitor_new.3
man/sd_login_monitor_flush.3: man/sd_login_monitor_new.3
man/sd_login_monitor_get_fd.3: man/sd_login_monitor_new.3
dist_man_MANS = \
$(MANPAGES) \
@@ -971,6 +1040,90 @@ test_install_CFLAGS = \
test_install_LDADD = \
libsystemd-basic.la
test_id128_SOURCES = \
src/test-id128.c \
src/sd-id128.c
test_id128_CFLAGS = \
$(AM_CFLAGS)
test_id128_LDADD = \
libsystemd-basic.la
test_journal_SOURCES = \
src/journal/test-journal.c \
src/journal/sd-journal.c \
src/journal/journal-file.c \
src/journal/lookup3.c \
src/journal/journal-send.c \
src/sd-id128.c
test_journal_CFLAGS = \
$(AM_CFLAGS)
test_journal_LDADD = \
libsystemd-basic.la
if HAVE_XZ
test_journal_SOURCES += \
src/journal/compress.c
test_journal_CFLAGS += \
$(XZ_CFLAGS)
test_journal_LDADD += \
$(XZ_LIBS)
endif
systemd_journald_SOURCES = \
src/journal/journald.c \
src/journal/sd-journal.c \
src/journal/journal-file.c \
src/journal/lookup3.c \
src/journal/journal-rate-limit.c \
src/sd-id128.c \
src/acl-util.c \
src/cgroup-util.c
systemd_journald_CFLAGS = \
$(AM_CFLAGS) \
$(ACL_CFLAGS)
systemd_journald_LDADD = \
libsystemd-basic.la \
libsystemd-daemon.la \
$(ACL_LIBS)
if HAVE_XZ
systemd_journald_SOURCES += \
src/journal/compress.c
systemd_journald_CFLAGS += \
$(XZ_CFLAGS)
systemd_journald_LDADD += \
$(XZ_LIBS)
endif
systemd_journalctl_SOURCES = \
src/journal/journalctl.c \
src/journal/sd-journal.c \
src/journal/journal-file.c \
src/journal/lookup3.c \
src/sd-id128.c \
src/pager.c
systemd_journalctl_CFLAGS = \
$(AM_CFLAGS)
systemd_journalctl_LDADD = \
libsystemd-basic.la
if HAVE_XZ
systemd_journalctl_SOURCES += \
src/journal/compress.c
systemd_journalctl_CFLAGS += \
$(XZ_CFLAGS)
systemd_journalctl_LDADD += \
$(XZ_LIBS)
endif
systemd_stdout_syslog_bridge_SOURCES = \
src/stdout-syslog-bridge.c \
src/tcpwrap.c
@@ -1115,10 +1268,12 @@ systemd_uaccess_SOURCES = \
if HAVE_ACL
systemd_logind_SOURCES += \
src/logind-acl.c
src/logind-acl.c \
src/acl-util.c
systemd_uaccess_SOURCES += \
src/logind-acl.c
src/logind-acl.c \
src/acl-util.c
endif
systemd_uaccess_CFLAGS = \
@@ -1166,7 +1321,8 @@ systemd_tmpfiles_LDADD = \
systemd_machine_id_setup_SOURCES = \
src/machine-id-setup.c \
src/machine-id-main.c
src/machine-id-main.c \
src/sd-id128.c
systemd_machine_id_setup_CFLAGS = \
$(AM_CFLAGS)
@@ -1592,6 +1748,69 @@ libsystemd-login-install-hook:
libsystemd-login-uninstall-hook:
rm -f $(DESTDIR)$(rootlibdir)/libsystemd-login.so*
libsystemd_id128_la_SOURCES = \
src/sd-id128.c
libsystemd_id128_la_CFLAGS = \
$(AM_CFLAGS) \
-fvisibility=hidden
libsystemd_id128_la_LDFLAGS = \
-shared \
-version-info $(LIBSYSTEMD_ID128_CURRENT):$(LIBSYSTEMD_ID128_REVISION):$(LIBSYSTEMD_ID128_AGE) \
-Wl,--version-script=$(top_srcdir)/src/libsystemd-id128.sym
libsystemd_id128_la_LIBADD = \
libsystemd-basic.la
# move lib from $(libdir) to $(rootlibdir) and update devel link, if needed
libsystemd-id128-install-hook:
if test "$(libdir)" != "$(rootlibdir)"; then \
mkdir -p $(DESTDIR)$(rootlibdir) && \
so_img_name=$$(readlink $(DESTDIR)$(libdir)/libsystemd-id128.so) && \
so_img_rel_target_prefix=$$(echo $(libdir) | sed 's,\(^/\|\)[^/][^/]*,..,g') && \
ln -sf $$so_img_rel_target_prefix$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/libsystemd-id128.so && \
mv $(DESTDIR)$(libdir)/libsystemd-id128.so.* $(DESTDIR)$(rootlibdir); \
fi
libsystemd-id128-uninstall-hook:
rm -f $(DESTDIR)$(rootlibdir)/libsystemd-id128.so*
libsystemd_journal_la_SOURCES = \
src/journal/sd-journal.c \
src/journal/journal-file.c \
src/journal/compress.c \
src/journal/lookup3.c \
src/journal/journal-send.c
libsystemd_journal_la_CFLAGS = \
$(AM_CFLAGS) \
$(XZ_CFLAGS) \
-fvisibility=hidden
libsystemd_journal_la_LDFLAGS = \
-shared \
-version-info $(LIBSYSTEMD_JOURNAL_CURRENT):$(LIBSYSTEMD_JOURNAL_REVISION):$(LIBSYSTEMD_JOURNAL_AGE) \
-Wl,--version-script=$(top_srcdir)/src/libsystemd-journal.sym
libsystemd_journal_la_LIBADD = \
libsystemd-basic.la \
libsystemd-id128.la \
$(XZ_LIBS)
# move lib from $(libdir) to $(rootlibdir) and update devel link, if needed
libsystemd-journal-install-hook:
if test "$(libdir)" != "$(rootlibdir)"; then \
mkdir -p $(DESTDIR)$(rootlibdir) && \
so_img_name=$$(readlink $(DESTDIR)$(libdir)/libsystemd-journal.so) && \
so_img_rel_target_prefix=$$(echo $(libdir) | sed 's,\(^/\|\)[^/][^/]*,..,g') && \
ln -sf $$so_img_rel_target_prefix$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/libsystemd-journal.so && \
mv $(DESTDIR)$(libdir)/libsystemd-journal.so.* $(DESTDIR)$(rootlibdir); \
fi
libsystemd-journal-uninstall-hook:
rm -f $(DESTDIR)$(rootlibdir)/libsystemd-journal.so*
SED_PROCESS = \
$(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
$(SED) -e 's,@rootlibexecdir\@,$(rootlibexecdir),g' \
@@ -1677,7 +1896,7 @@ endif
if HAVE_XSLTPROC
XSLTPROC_FLAGS = \
--nonet \
--param funcsynopsis.style "'ansi'"
--stringparam funcsynopsis.style ansi
XSLTPROC_PROCESS_MAN = \
$(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
@@ -1690,11 +1909,11 @@ XSLTPROC_PROCESS_MAN_IN = \
XSLTPROC_PROCESS_HTML = \
$(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
$(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) http://docbook.sourceforge.net/release/xsl/current/xhtml-1_1/docbook.xsl $<
$(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) man/custom-html.xsl $<
XSLTPROC_PROCESS_HTML_IN = \
$(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
$(XSLTPROC) -o ${@:.in=} $(XSLTPROC_FLAGS) http://docbook.sourceforge.net/release/xsl/current/xhtml-1_1/docbook.xsl $< && \
$(XSLTPROC) -o ${@:.in=} $(XSLTPROC_FLAGS) man/custom-html.xsl $< && \
mv ${@:.in=} $@
man/%.1: man/%.xml
@@ -1808,11 +2027,12 @@ endif
rm -f user && \
$(LN_S) $(pkgsysconfdir)/user user )
( cd $(DESTDIR)$(systemunitdir)/sockets.target.wants && \
rm -f systemd-initctl.socket systemd-stdout-syslog-bridge.socket systemd-shutdownd.socket syslog.socket && \
rm -f systemd-initctl.socket systemd-stdout-syslog-bridge.socket systemd-shutdownd.socket syslog.socket systemd-journald.socket && \
$(LN_S) ../systemd-stdout-syslog-bridge.socket systemd-stdout-syslog-bridge.socket && \
$(LN_S) ../systemd-initctl.socket systemd-initctl.socket && \
$(LN_S) ../systemd-shutdownd.socket systemd-shutdownd.socket && \
$(LN_S) ../syslog.socket syslog.socket )
$(LN_S) ../syslog.socket syslog.socket && \
$(LN_S) ../systemd-journald.socket )
( cd $(DESTDIR)$(systemunitdir)/runlevel1.target.wants && \
rm -f systemd-update-utmp-runlevel.service && \
$(LN_S) ../systemd-update-utmp-runlevel.service systemd-update-utmp-runlevel.service )

12
TODO
View File

@@ -17,8 +17,20 @@ Bugfixes:
* make polkit checks async
* properly handle .mount unit state tracking when two mount points are stacked one on top of another on the exact same mount point.
Features:
* logind: selinux is borked...
* logind: sends SessionNew on Lock()?
* logind: allow showing logout dialog from system
* document that %% can be used to write % in a string that is specifier extended
* check utf8 everywhere
* when an instanced service exits, remove its parent cgroup too if possible.
* Make libselinux, libattr, libcap, libdl dependencies only of the tools which actually need them.

View File

@@ -149,6 +149,19 @@ if test "x$enable_selinux" != "xno"; then
fi
AM_CONDITIONAL(HAVE_SELINUX, [test "$have_selinux" = "yes"])
have_xz=no
AC_ARG_ENABLE(xz, AS_HELP_STRING([--disable-xz], [Disable optional XZ support]))
if test "x$enable_xz" != "xno"; then
PKG_CHECK_MODULES(XZ, [ liblzma ],
[AC_DEFINE(HAVE_XZ, 1, [Define if XZ is available]) have_xz=yes], have_xz=no)
AC_SUBST(XZ_CFLAGS)
AC_SUBST(XZ_LIBS)
if test "x$have_xz" = xno -a "x$enable_xz" = xyes; then
AC_MSG_ERROR([*** Xz support requested but libraries not found])
fi
fi
AM_CONDITIONAL(HAVE_XZ, [test "$have_xz" = "yes"])
AC_ARG_ENABLE([tcpwrap],
AS_HELP_STRING([--disable-tcpwrap],[Disable optional TCP wrappers support]),
[case "${enableval}" in
@@ -591,6 +604,7 @@ AC_MSG_RESULT([
PAM: ${have_pam}
AUDIT: ${have_audit}
SELinux: ${have_selinux}
XZ: ${have_xz}
ACL: ${have_acl}
binfmt: ${have_binfmt}
hostnamed: ${have_hostnamed}

18
libsystemd-id128.pc.in Normal file
View File

@@ -0,0 +1,18 @@
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: systemd
Description: systemd 128 Bit ID Utility Library
URL: @PACKAGE_URL@
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lsystemd-id128
Cflags: -I${includedir}

19
libsystemd-journal.pc.in Normal file
View File

@@ -0,0 +1,19 @@
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: systemd
Description: systemd Journal Utility Library
URL: @PACKAGE_URL@
Version: @PACKAGE_VERSION@
Requires: libsystemd-id128 = @PACKAGE_VERSION@
Libs: -L${libdir} -lsystemd-journal
Cflags: -I${includedir}

29
man/custom-html.xsl Normal file
View File

@@ -0,0 +1,29 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!--
This file is part of systemd.
Copyright 2011 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/>
<!-- Switch things to UTF-8, ISO-8859-1 is soo yesteryear -->
<xsl:output method="html" encoding="UTF-8" indent="no"/>
</xsl:stylesheet>

View File

@@ -50,7 +50,7 @@
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include "sd-daemon.h"</funcsynopsisinfo>
<funcsynopsisinfo>#include &lt;systemd/sd-daemon.h&gt;</funcsynopsisinfo>
</funcsynopsis>
<cmdsynopsis>

146
man/sd-login.xml Normal file
View File

@@ -0,0 +1,146 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
This file is part of systemd.
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
-->
<refentry id="sd-login">
<refentryinfo>
<title>sd-login</title>
<productname>systemd</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Lennart</firstname>
<surname>Poettering</surname>
<email>lennart@poettering.net</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>sd-login</refentrytitle>
<manvolnum>7</manvolnum>
</refmeta>
<refnamediv>
<refname>sd-login</refname>
<refpurpose>APIs for
tracking logins</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
</funcsynopsis>
<cmdsynopsis>
<command>pkg-config --cflags --libs libsystemd-login</command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><filename>sd-login.h</filename> provides APIs to
introspect and monitor seat, login session and user
status information on the local system. </para>
<para>See <ulink
url="http://www.freedesktop.org/wiki/Software/systemd/multiseat">Multi-Seat
on Linux</ulink> for an introduction into multi-seat
support on Linux, the background for this set of APIs.</para>
<para>Note that these APIs only allow purely passive access
and monitoring of seats, sessions and users. To
actively make changes to the seat configuration,
terminate login sessions, or switch session on a seat
you need to utilize the D-Bus API of
systemd-logind, instead.</para>
<para>These functions synchronously access data in
<filename>/proc</filename>,
<filename>/sys/fs/cgroup</filename> and
<filename>/run</filename>. All of these are virtual
file systems, hence the runtime cost of the accesses
is relatively cheap.</para>
<para>It is possible (and often a very good choice) to
mix calls to the synchronous interface of
<filename>sd-login.h</filename> with the asynchronous
D-Bus interface of systemd-logind. However, if this is
done you need to think a bit about possible races
since the stream of events from D-Bus and from
<filename>sd-login.h</filename> interfaces such as the
login monitor are asynchronous and not ordered against
each other.</para>
<para>If the functions return string arrays, these are
generally NULL terminated and need to be freed by the
caller with the libc
<citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call after use, including the strings referenced
therein. Similar, individual strings returned need to
be freed, as well.</para>
<para>As a special exception, instead of an empty
string array NULL may be returned, which should be
treated equivalent to an empty string array.</para>
<para>See
<citerefentry><refentrytitle>sd_pid_get_session</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_uid_get_state</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_session_is_active</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_seat_get_active</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_get_seats</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_login_monitor_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
for more information about the functions
implemented.</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>These APIs are implemented as shared library,
which can be compiled and linked to with the
<literal>libsystemd-login</literal>
<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_pid_get_session</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_uid_get_state</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_session_is_active</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_seat_get_active</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_get_seats</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_login_monitor_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-readahead</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@@ -49,7 +49,7 @@
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include "sd-daemon.h"</funcsynopsisinfo>
<funcsynopsisinfo>#include &lt;systemd/sd-daemon.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_booted</function></funcdef>

127
man/sd_get_seats.xml Normal file
View File

@@ -0,0 +1,127 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
This file is part of systemd.
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
-->
<refentry id="sd_get_seats">
<refentryinfo>
<title>sd_get_seats</title>
<productname>systemd</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Lennart</firstname>
<surname>Poettering</surname>
<email>lennart@poettering.net</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>sd_get_seats</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_get_seats</refname>
<refname>sd_get_sessions</refname>
<refname>sd_get_uids</refname>
<refpurpose>Determine available seats, sessions and logged in users</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_get_seats</function></funcdef>
<paramdef>char*** <parameter>seats</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_get_sessions</function></funcdef>
<paramdef>char*** <parameter>sessions</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_get_uids</function></funcdef>
<paramdef>char*** <parameter>sessions</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_get_seats()</function> may be used
to determine all currently available local
seats. Returns a NULL terminated array of seat
identifiers. The returned array and all strings it
references need to be freed with the libc
<citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call after use. Note that instead of an empty array
NULL may be returned and should be considered
equivalent to an empty array.</para>
<para>Similar, <function>sd_get_sessions()</function> may
be used to determine all current login sessions.</para>
<para>Similar, <function>sd_get_uids()</function> may
be used to determine all Unix users who currently have login sessions.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success <function>sd_get_seats()</function>,
<function>sd_get_sessions()</function> and
<function>sd_get_uids()</function> return the number
of entries in the arrays. On failure, these calls
return a negative errno-style error code.</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>The <function>sd_get_seats()</function>,
<function>sd_get_sessions()</function> and
<function>sd_get_uids()</function> interfaces
are available as shared library, which can be compiled
and linked to with the
<literal>libsystemd-login</literal>
<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>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_session_get_seat</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@@ -53,7 +53,7 @@
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include "sd-daemon.h"</funcsynopsisinfo>
<funcsynopsisinfo>#include &lt;systemd/sd-daemon.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_is_fifo</function></funcdef>

View File

@@ -49,7 +49,7 @@
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include "sd-daemon.h"</funcsynopsisinfo>
<funcsynopsisinfo>#include &lt;systemd/sd-daemon.h&gt;</funcsynopsisinfo>
<funcsynopsisinfo>#define SD_LISTEN_FDS_START 3</funcsynopsisinfo>

View File

@@ -0,0 +1,172 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
This file is part of systemd.
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
-->
<refentry id="sd_login_monitor_new">
<refentryinfo>
<title>sd_login_monitor_new</title>
<productname>systemd</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Lennart</firstname>
<surname>Poettering</surname>
<email>lennart@poettering.net</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>sd_login_monitor_new</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_login_monitor_new</refname>
<refname>sd_login_monitor_unref</refname>
<refname>sd_login_monitor_flush</refname>
<refname>sd_login_monitor_get_fd</refname>
<refpurpose>Monitor login sessions, seats and users</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_login_monitor_new</function></funcdef>
<paramdef>const char* <parameter>category</parameter></paramdef>
<paramdef>sd_login_monitor** <parameter>ret</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>sd_login_monitor* <function>sd_login_monitor_unref</function></funcdef>
<paramdef>sd_login_monitor* <parameter>m</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_login_monitor_flush</function></funcdef>
<paramdef>sd_login_monitor* <parameter>m</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_login_monitor_get_fd</function></funcdef>
<paramdef>sd_login_monitor* <parameter>m</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_login_monitor_new()</function> may
be used to monitor login session, users and seats. Via
a monitor object a file descriptor can be integrated
into an application defined event loop which is woken
up each time a user logs in, logs out or a seat is
added or removed, or a session, user, or seat changes
state otherwise. The first parameter takes a string
which can be either <literal>seat</literal> (to get
only notifications about seats being added, removed or
changed), <literal>session</literal> (to get only
notifications about sessions being created or removed
or changed) or <literal>uid</literal> (to get only
notifications when a user changes state in respect to
logins). If notifications shall be generated in all
these conditions, NULL may be passed. Note that in
future additional categories may be defined. The
second parameter returns a monitor object and needs to
be freed with the
<function>sd_login_monitor_unref()</function> call
after use.</para>
<para><function>sd_login_monitor_unref()</function>
may be used to destroy a monitor object. Note that
this will invalidate any file descriptor returned by
<function>sd_login_monitor_get_fd()</function>.</para>
<para><function>sd_login_monitor_flush()</function>
may be used to reset the wakeup state of the monitor
object. Whenever an event causes the monitor to wake
up the event loop via the file descriptor this
function needs to be called to reset the wake-up
state. If this call is not invoked the file descriptor
will immediately wake up the event loop again.</para>
<para><function>sd_login_monitor_get_fd()</function>
may be used to retrieve the file descriptor of the
monitor object that may be integrated in an
application defined event loop, based around
<citerefentry><refentrytitle>poll</refentrytitle><manvolnum>2</manvolnum></citerefentry>
or a similar interface. The application should include
the returned file descriptor as wake up source for
POLLIN events. Whenever a wake-up is triggered the
file descriptor needs to be reset via
<function>sd_login_monitor_flush()</function>. An
application needs to reread the login state with a
function like
<citerefentry><refentrytitle>sd_get_seats</refentrytitle><manvolnum>3</manvolnum></citerefentry>
or similar to determine what changed.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success
<function>sd_login_monitor_new()</function> and
<function>sd_login_monitor_flush()</function> return 0
or a positive integer. On success
<function>sd_login_monitor_get_fd()</function> returns
a Unix file descriptor. On failure, these calls return
a negative errno-style error code.</para>
<para><function>sd_login_monitor_unref()</function>
always returns NULL.</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>The <function>sd_login_monitor_new()</function>,
<function>sd_login_monitor_unref()</function>, <function>sd_login_monitor_flush()</function> and
<function>sd_login_monitor_get_fd()</function> interfaces
are available as shared library, which can be compiled
and linked to with the
<literal>libsystemd-login</literal>
<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>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_get_seats</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@@ -50,7 +50,7 @@
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include "sd-daemon.h"</funcsynopsisinfo>
<funcsynopsisinfo>#include &lt;systemd/sd-daemon.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_notify</function></funcdef>

135
man/sd_pid_get_session.xml Normal file
View File

@@ -0,0 +1,135 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
This file is part of systemd.
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
-->
<refentry id="sd_pid_get_session">
<refentryinfo>
<title>sd_pid_get_session</title>
<productname>systemd</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Lennart</firstname>
<surname>Poettering</surname>
<email>lennart@poettering.net</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>sd_pid_get_session</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_pid_get_session</refname>
<refname>sd_pid_get_owner_uid</refname>
<refpurpose>Determine session or owner of a session of a specific PID</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_pid_get_session</function></funcdef>
<paramdef>pid_t <parameter>pid</parameter></paramdef>
<paramdef>char** <parameter>session</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_pid_get_owner_uid</function></funcdef>
<paramdef>pid_t <parameter>pid</parameter></paramdef>
<paramdef>uid_t* <parameter>uid</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_pid_get_session()</function> may be
used to determine the login session identifier of a
process identified by the specified process
identifier. The session identifier is a short string,
suitable for usage in file system paths. Note that not
all processes are part of a login session (e.g. system
service processes and user processes that are shared
between multiple sessions of the same user). For
processes not being part of a login session this
function will fail. 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_pid_get_owner_uid()</function> may
be used to determine the Unix user identifier of the
owner of the session of a process identified the
specified PID. Note that this function will succeed
for user processes which are shared between multiple
login sessions of the same user, where
<function>sd_pid_get_session()</function> will
fail. For processes not being part of a login session
and not being a shared process of a user this function
will fail.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success these calls 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_pid_get_session()</function>
and <function>sd_pid_get_owner_uid()</function>
interfaces are available as shared library, which can
be compiled and linked to with the
<literal>libsystemd-login</literal>
<citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
file.</para>
<para>Note that the login session identifier as
returned by <function>sd_pid_get_session()</function>
is completely unrelated to the process session
identifier as returned by
<citerefentry><refentrytitle>getsid</refentrytitle><manvolnum>2</manvolnum></citerefentry>.</para>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_session_is_active</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>getsid</refentrytitle><manvolnum>2</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@@ -49,7 +49,7 @@
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include "sd-daemon.h"</funcsynopsisinfo>
<funcsynopsisinfo>#include "sd-readahead.h"</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_readahead</function></funcdef>
@@ -134,23 +134,17 @@
url="http://cgit.freedesktop.org/systemd/tree/src/sd-readahead.h"/></para>
<para><function>sd_readahead()</function> is
implemented in the reference implementation's
implemented in the reference implementation's drop-in
<filename>sd-readahead.c</filename> and
<filename>sd-readahead.h</filename> files. These
interfaces are available as shared library, which can
be compiled and linked to with the
<literal>libsystemd-daemon</literal>
<citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
file. Alternatively, applications consuming this API
may copy the implementation into their source
tree. For more details about the reference
implementation see
<citerefentry><refentrytitle>sd-readahead</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
<filename>sd-readahead.h</filename> files. It is
recommended that applications consuming this API copy
the implementation into their source tree. For more
details about the reference implementation see
<citerefentry><refentrytitle>sd-readahead</refentrytitle><manvolnum>7</manvolnum></citerefentry></para>
<para>If the reference implementation is used as
drop-in files and -DDISABLE_SYSTEMD is set during
compilation this function will always return 0 and
otherwise become a NOP.</para>
<para>If -DDISABLE_SYSTEMD is set during compilation
this function will always return 0 and otherwise
become a NOP.</para>
</refsect1>
<refsect1>

152
man/sd_seat_get_active.xml Normal file
View File

@@ -0,0 +1,152 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
This file is part of systemd.
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
-->
<refentry id="sd_seat_get_active">
<refentryinfo>
<title>sd_seat_get_active</title>
<productname>systemd</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Lennart</firstname>
<surname>Poettering</surname>
<email>lennart@poettering.net</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>sd_seat_get_active</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_seat_get_active</refname>
<refname>sd_seat_get_sessions</refname>
<refname>sd_seat_can_multi_session</refname>
<refpurpose>Determine state of a specific seat</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_seat_get_active</function></funcdef>
<paramdef>const char* <parameter>seat</parameter></paramdef>
<paramdef>char** <parameter>session</parameter></paramdef>
<paramdef>uid_t* <parameter>uid</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_seat_get_sessions</function></funcdef>
<paramdef>const char* <parameter>seat</parameter></paramdef>
<paramdef>char*** <parameter>sessions</parameter></paramdef>
<paramdef>uid_t** <parameter>uid</parameter></paramdef>
<paramdef>unsigned* <parameter>n_uids</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_seat_can_multi_session</function></funcdef>
<paramdef>const char* <parameter>session</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_seat_get_active()</function> may be
used to determine which session is currently active on
a seat, if there is any. Returns the session
identifier and the user identifier of the Unix user
the session is belonging to. Either the session or the
user identifier parameter can be be passed NULL, in
case only one of the parameters shall be queried. 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_seat_get_sessions()</function> may
be used to determine all sessions on the specified
seat. Returns two arrays, one (NULL terminated) with
the session identifiers of the sessions and one with
the user identifiers of the Unix users the sessions
belong to. An additional parameter may be used to
return the number of entries in the latter array. The
two arrays and the latter parameter may be passed as
NULL in case these values need not to be
determined. The arrays and the strings referenced by
them need to be freed with the libc
<citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call after use. Note that instead of an empty array
NULL may be returned and should be considered
equivalent to an empty array.</para>
<para><function>sd_seat_can_multi_session()</function>
may be used to determine whether a specific seat is
capable of multi-session, i.e. allows multiple login
sessions in parallel (whith only one being active at a
time).</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para> On success
<function>sd_seat_get_active()</function> return
return 0 or a positive integer. On success
<function>sd_seat_get_sessions()</function> returns
the number of entries in the session identifier
array. If the test succeeds
<function>sd_seat_can_multi_session</function> returns
a positive integer, if it fails 0. On failure, these
calls return a negative errno-style error code.</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>The <function>sd_seat_get_active()</function>,
<function>sd_seat_get_sessions()</function>, and
<function>sd_seat_can_multi_session()</function> interfaces
are available as shared library, which can be compiled
and linked to with the
<literal>libsystemd-login</literal>
<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>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_session_get_seat</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@@ -0,0 +1,134 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
This file is part of systemd.
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
-->
<refentry id="sd_session_is_active">
<refentryinfo>
<title>sd_session_is_active</title>
<productname>systemd</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Lennart</firstname>
<surname>Poettering</surname>
<email>lennart@poettering.net</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>sd_session_is_active</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_session_is_active</refname>
<refname>sd_session_get_uid</refname>
<refname>sd_session_get_seat</refname>
<refpurpose>Determine state of a specific session</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_session_is_active</function></funcdef>
<paramdef>const char* <parameter>session</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_session_get_uid</function></funcdef>
<paramdef>const char* <parameter>session</parameter></paramdef>
<paramdef>uid_t* <parameter>uid</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_session_get_seat</function></funcdef>
<paramdef>const char* <parameter>session</parameter></paramdef>
<paramdef>char** <parameter>seat</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_session_is_active()</function> may
be used to determine whether the session identified by
the specified session identifier is currently active
(i.e. currently in the foreground and available for
user input) or not.</para>
<para><function>sd_session_get_uid()</function> may be
used to determine the user identifier of the Unix user the session
identified by the specified session identifier belongs
to.</para>
<para><function>sd_session_get_seat()</function> may
be used to determine the seat identifier of the seat
the session identified by the specified session
identifier belongs to. Note that not all sessions are
attached to a seat, this call will fail for them. The
returned string needs to be freed with the libc
<citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call after use.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>If the test succeeds
<function>sd_session_is_active()</function> returns a
positive integer, if it fails 0. On success
<function>sd_session_get_uid()</function> and
<function>sd_session_get_seat()</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_uid()</function>, and
<function>sd_session_get_seat()</function> interfaces
are available as shared library, which can be compiled
and linked to with the
<literal>libsystemd-login</literal>
<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>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_pid_get_session</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

185
man/sd_uid_get_state.xml Normal file
View File

@@ -0,0 +1,185 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
This file is part of systemd.
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
-->
<refentry id="sd_uid_get_state">
<refentryinfo>
<title>sd_uid_get_state</title>
<productname>systemd</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Lennart</firstname>
<surname>Poettering</surname>
<email>lennart@poettering.net</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>sd_uid_get_state</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_uid_get_state</refname>
<refname>sd_uid_is_on_seat</refname>
<refname>sd_uid_get_sessions</refname>
<refname>sd_uid_get_seats</refname>
<refpurpose>Determine login state of a specific Unix user ID</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_uid_get_state</function></funcdef>
<paramdef>uid_t <parameter>pid</parameter></paramdef>
<paramdef>char** <parameter>state</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_uid_is_on_seat</function></funcdef>
<paramdef>uid_t <parameter>pid</parameter></paramdef>
<paramdef>int <parameter>require_active</parameter></paramdef>
<paramdef>const char* <parameter>seat</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_uid_get_sessions</function></funcdef>
<paramdef>uid_t <parameter>pid</parameter></paramdef>
<paramdef>int <parameter>require_active</parameter></paramdef>
<paramdef>char*** <parameter>sessions</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_uid_get_seats</function></funcdef>
<paramdef>uid_t <parameter>pid</parameter></paramdef>
<paramdef>int <parameter>require_active</parameter></paramdef>
<paramdef>char*** <parameter>seats</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_uid_get_state()</function> may be
used to determine the login state of a specific Unix
user identifier. The following states are currently
known: <literal>offline</literal> (user not logged in
at all), <literal>lingering</literal> (user not logged
in, but some user services running),
<literal>online</literal> (user logged in, but not
active), <literal>active</literal> (user logged in on
an active seat). 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
<citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call after use.</para>
<para><function>sd_uid_is_on_seat()</function> 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 <parameter>require_active</parameter>
parameter is a boolean. 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.</para>
<para><function>sd_uid_get_sessions()</function> may
be used to determine the current sessions of the
specified user. Acceptes a Unix user identifier as
parameter. The <parameter>require_active</parameter>
boolean parameter controls whether the returned list
shall consist of only those sessions where the user is
currently active (true) or where the user is currently
logged in at all, possibly inactive (false). The call
returns a NULL terminated string array of session
identifiers in <parameter>sessions</parameter> which
needs to be freed by the caller with the libc
<citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
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 still indicates the number of current
sessions. Note that instead of an empty array NULL may
be returned and should be considered equivalent to an
empty array.</para>
<para>Similar, <function>sd_uid_get_seats()</function>
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 <function>sd_uid_get_sessions()</function>.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success
<function>sd_uid_get_state()</function> returns 0 or a
positive integer. If the test succeeds
<function>sd_uid_is_on_seat()</function> returns a
positive integer, if it fails
0. <function>sd_uid_get_sessions()</function> and
<function>sd_uid_get_seats()</function> return the
number of entries in the returned arrays. On failure,
these calls return a negative errno-style error
code.</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>The <function>sd_uid_get_state()</function>,
<function>sd_uid_is_on_seat()</function>,
<function>sd_uid_get_sessions()</function>, and
<function>sd_uid_get_seats()</function> interfaces are
available as shared library, which can be compiled and
linked to with the <literal>libsystemd-login</literal>
<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>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_pid_get_owner_uid</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

Some files were not shown because too many files have changed in this diff Show More