1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-07 01:27:11 +03:00
The systemd System and Service Manager
Go to file
David Herrmann 118ecf3242 logind: introduce session-devices
A session-device is a device that is bound to a seat and used by a
session-controller to run the session. This currently includes DRM, fbdev
and evdev devices. A session-device can be created via RequestDevice() on
the dbus API of the session. You can drop it via ReleaseDevice() again.
Once the session is destroyed or you drop control of the session, all
session-devices are automatically destroyed.

Session devices follow the session "active" state. A device can be
active/running or inactive/paused. Whenever a session is not the active
session, no session-device of it can be active. That is, if a session is
not in foreground, all session-devices are paused.
Whenever a session becomes active, all devices are resumed/activated by
logind. If it fails, a device may stay paused.

With every session-device you request, you also get a file-descriptor
back. logind keeps a copy of this fd and uses kernel specific calls to
pause/resume the file-descriptors. For example, a DRM fd is muted
by logind as long as a given session is not active. Hence, the fd of the
application is also muted. Once the session gets active, logind unmutes
the fd and the application will get DRM access again.
This, however, requires kernel support. DRM devices provide DRM-Master for
synchronization, evdev devices have EVIOCREVOKE (pending on
linux-input-ML). fbdev devices do not provide such synchronization methods
(and never will).
Note that for evdev devices, we call EVIOCREVOKE once a session gets
inactive. However, this cannot be undone (the fd is still valid but mostly
unusable). So we reopen a new fd once the session is activated and send it
together with the ResumeDevice() signal.

With this infrastructure in place, compositors can now run without
CAP_SYS_ADMIN (that is, without being root). They use RequestControl() to
acquire a session and listen for devices via udev_monitor. For every
device they want to open, they call RequestDevice() on logind. This
returns a fd which they can use now. They no longer have to open the
devices themselves or call any privileged ioctls. This is all done by
logind.
Session-switches are still bound to VTs. Hence, compositors will get
notified via the usual VT mechanisms and can cleanup their state. Once the
VT switch is acknowledged as usual, logind will get notified via sysfs and
pause the old-session's devices and resume the devices of the new session.

To allow using this infrastructure with systems without VTs, we provide
notification signals. logind sends PauseDevice("force") dbus signals to
the current session controller for every device that it pauses. And it
sends ResumeDevice signals for every device that it resumes. For
seats with VTs this is sent _after_ the VT switch is acknowledged. Because
the compositor already acknowledged that it cleaned-up all devices.
However, for seats without VTs, this is used to notify the active
compositor that the session is about to be deactivated. That is, logind
sends PauseDevice("force") for each active device and then performs the
session-switch. The session-switch changes the "Active" property of the
session which can be monitored by the compositor. The new session is
activated and the ResumeDevice events are sent.

For seats without VTs, this is a forced session-switch. As this is not
backwards-compatible (xserver actually crashes, weston drops the related
devices, ..) we also provide an acknowledged session-switch. Note that
this is never used for sessions with VTs. You use the acknowledged
VT-switch on these seats.

An acknowledged session switch sends PauseDevice("pause") instead of
PauseDevice("force") to the active session. It schedules a short timeout
and waits for the session to acknowledge each of them with
PauseDeviceComplete(). Once all are acknowledged, or the session ran out
of time, a PauseDevice("force") is sent for all remaining active devices
and the session switch is performed.
Note that this is only partially implemented, yet, as we don't allow
multi-session without VTs, yet. A follow up commit will hook it up and
implemented the acknowledgements+timeout.

The implementation is quite simple. We use major/minor exclusively to
identify devices on the bus. On RequestDevice() we retrieve the
udev_device from the major/minor and search for an existing "Device"
object. If no exists, we create it. This guarantees us that we are
notified whenever the device changes seats or is removed.

We create a new SessionDevice object and link it to the related Session
and Device. Session->devices is a hashtable to lookup SessionDevice
objects via major/minor. Device->session_devices is a linked list so we
can release all linked session-devices once a device vanishes.

Now we only have to hook this up in seat_set_active() so we correctly
change device states during session-switches. As mentioned earlier, these
are forced state-changes as VTs are currently used exclusively for
multi-session implementations.

Everything else are hooks to release all session-devices once the
controller changes or a session is closed or removed.
2013-09-17 17:15:30 -05:00
catalog man: improve grammar and word formatting in numerous man pages 2013-07-02 23:06:22 -04:00
docs doc: disable gtk-doc test again - you are a really annoying piece of software 2013-03-21 15:07:54 +01:00
hwdb keymap: Add Samsung Series 5 [Ultra] 2013-09-16 14:25:44 -05:00
m4 build: check for build/link flags harder 2013-09-16 09:59:16 -05:00
man tmpfiles: add a new "m" line type that adjusts user/group/mode of a file if it exists 2013-09-17 16:55:37 -05:00
po po: add dbus-scope.c to POTFILES.skip 2013-07-04 09:10:44 -04:00
rules backlight: instead of syspath use sysname for identifying backlight devices 2013-08-14 02:55:57 +02:00
shell-completion bash-completion: add systemd-run 2013-09-12 19:36:27 -04:00
src logind: introduce session-devices 2013-09-17 17:15:30 -05:00
sysctl.d sysctl: default - add safe sysrq options 2013-03-15 19:30:53 +01:00
test TEST-03-JOBS/test.sh: do not output the "failed" if it does not exist 2013-09-17 15:19:17 -05:00
tmpfiles.d journald: avoid NSS in journald 2013-09-17 16:55:37 -05:00
units nspawn: update unit file 2013-09-17 11:59:47 -05:00
.dir-locals.el Keep emacs configuration in one configuration file. 2011-03-08 01:53:46 +01:00
.gitignore move utf8 functions from libudev-private.h to utf8.h 2013-09-17 16:31:32 -04:00
.mailmap Add a few entries to .mailmap 2013-01-29 21:31:41 -05:00
.travis.yml test: Make testing work on systems without or old systemd 2013-08-22 00:52:14 -04:00
.vimrc add .vimrc 2012-01-23 04:42:11 +01:00
.ycm_extra_conf.py Add YouCompleteMe configuration 2013-09-16 19:10:03 -04:00
autogen.sh build-sys: use no-tmpl flavour of gtkdocization 2013-08-19 11:30:04 -04:00
CODING_STYLE analyze: various cleanups 2013-03-08 18:58:08 +01:00
configure.ac build-sys: prepare 207 2013-09-13 02:12:16 +02:00
DISTRO_PORTING build-sys: fix spelling of sysvrcndir 2013-01-08 02:37:37 +01:00
introspect.awk build-sys: allow cross-compilation 2010-11-23 22:38:55 +01:00
LICENSE.GPL2 relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
LICENSE.LGPL2.1 licence: remove references to old FSF address 2012-12-17 11:41:31 +01:00
LICENSE.MIT relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
make-directive-index.py man: add CONSTANTS section to systemd.directives(7) 2013-06-26 19:52:00 -04:00
make-man-index.py build-sys,man: use XML entities to substite strings 2013-03-29 20:30:21 -04:00
make-man-rules.py build-sys,man: use XML entities to substite strings 2013-03-29 20:30:21 -04:00
Makefile-man.am sd-login: add a public accessor for the VT number 2013-09-11 19:08:20 +02:00
Makefile.am logind: introduce session-devices 2013-09-17 17:15:30 -05:00
NEWS NEWS: add some clarifications 2013-09-17 13:58:12 -05:00
README README: add SCSI BSG option 2013-09-15 07:29:25 +02:00
TODO Update TODO 2013-09-17 17:15:30 -05:00
xml_helper.py build-sys: force Python to write UTF-8 2013-03-29 20:30:22 -04:00

systemd System and Service Manager

DETAILS:
        http://0pointer.de/blog/projects/systemd.html

WEB SITE:
        http://www.freedesktop.org/wiki/Software/systemd

GIT:
        git://anongit.freedesktop.org/systemd/systemd
        ssh://git.freedesktop.org/git/systemd/systemd

GITWEB:
        http://cgit.freedesktop.org/systemd/systemd

MAILING LIST:
        http://lists.freedesktop.org/mailman/listinfo/systemd-devel
        http://lists.freedesktop.org/mailman/listinfo/systemd-commits

IRC:
        #systemd on irc.freenode.org

BUG REPORTS:
        https://bugs.freedesktop.org/enter_bug.cgi?product=systemd

AUTHOR:
        Lennart Poettering
        Kay Sievers
        ...and many others

LICENSE:
        LGPLv2.1+ for all code
        - except sd-daemon.[ch] and sd-readahead.[ch] which are MIT
        - except src/shared/MurmurHash3.c which is Public Domain
        - except src/journal/lookup3.c which is Public Domain
        - except src/udev/* which is (currently still) GPLv2, GPLv2+

REQUIREMENTS:
        Linux kernel >= 3.0
          CONFIG_DEVTMPFS
          CONFIG_CGROUPS (it's OK to disable all controllers)
          CONFIG_INOTIFY_USER
          CONFIG_SIGNALFD
          CONFIG_TIMERFD
          CONFIG_EPOLL
          CONFIG_NET
          CONFIG_SYSFS

        Linux kernel >= 3.8 for Smack support

        Udev will fail to work with the legacy layout:
          CONFIG_SYSFS_DEPRECATED=n

        Legacy hotplug slows down the system and confuses udev:
          CONFIG_UEVENT_HELPER_PATH=""

        Userspace firmware loading is deprecated, will go away, and
        sometimes causes problems:
          CONFIG_FW_LOADER_USER_HELPER=n

        Some udev rules and virtualization detection relies on it:
          CONFIG_DMIID

        Mount and bind mount handling might require it:
          CONFIG_FHANDLE

        Support for some SCSI devices serial number retrieval, to
        create additional symlinks in /dev/disk/ and /dev/tape:
          CONFIG_BLK_DEV_BSG

        Optional but strongly recommended:
          CONFIG_IPV6
          CONFIG_AUTOFS4_FS
          CONFIG_TMPFS_POSIX_ACL
          CONFIG_TMPFS_XATTR
          CONFIG_SECCOMP

        For systemd-bootchart a kernel with procfs support and several
        proc output options enabled is required:
          CONFIG_PROC_FS
          CONFIG_SCHEDSTATS
          CONFIG_SCHED_DEBUG

        For UEFI systems:
          CONFIG_EFI_VARS
          CONFIG_EFI_PARTITION

        Note that kernel auditing is broken when used with systemd's
        container code. When using systemd in conjunction with
        containers please make sure to either turn off auditing at
        runtime using the kernel command line option "audit=0", or
        turn it off at kernel compile time using:
          CONFIG_AUDIT=n

        dbus >= 1.4.0
        libcap
        libblkid >= 2.20 (from util-linux) (optional)
        libkmod >= 14 (optional)
        PAM >= 1.1.2 (optional)
        libcryptsetup (optional)
        libaudit (optional)
        libacl (optional)
        libattr (optional)
        libselinux (optional)
        liblzma (optional)
        tcpwrappers (optional)
        libgcrypt (optional)
        libqrencode (optional)
        libmicrohttpd (optional)
        libpython (optional)
        make, gcc, and similar tools

        During runtime you need the following additional dependencies:

        util-linux >= v2.19 (requires fsck -l, agetty -s)
        sulogin (from util-linux >= 2.22 or sysvinit-tools, optional but recommended)
        dracut (optional)
        PolicyKit (optional)

        When building from git you need the following additional dependencies:

        docbook-xsl
        xsltproc
        automake
        autoconf
        libtool
        intltool
        gperf
        gtkdocize (optional)
        python (optional)
        sphinx (optional)
        python-lxml (entirely optional)

        When systemd-hostnamed is used it is strongly recommended to
        install nss-myhostname to ensure that in a world of
        dynamically changing hostnames the hostname stays resolvable
        under all circumstances. In fact, systemd-hostnamed will warn
        if nss-myhostname is not installed.

        Note that D-Bus can link against libsystemd-login.so, which
        results in a cyclic build dependency. To accommodate for this
        please build D-Bus without systemd first, then build systemd,
        then rebuild D-Bus with systemd support.

        To build HTML documentation for python-systemd using sphinx,
        please first install systemd (using 'make install'), and then
        invoke sphinx-build with 'make sphinx-<target>', with <target>
        being 'html' or 'latexpdf'. If using DESTDIR for installation,
        pass the same DESTDIR to 'make sphinx-html' invocation.

USERS AND GROUPS:
        Default udev rules use the following standard system group
        names, which need to be resolvable by getgrnam() at any time,
        even in the very early boot stages, where no other databases
        and network are available:

        tty, dialout, kmem, video, audio, lp, floppy, cdrom, tape, disk

        During runtime the journal daemon requires the
        "systemd-journal" system group to exist. New journal files will
        be readable by this group (but not writable) which may be used
        to grant specific users read access.

        It is also recommended to grant read access to all journal
        files to the system groups "wheel" and "adm" with a command
        like the following in the post installation script of the
        package:

        # setfacl -nm g:wheel:rx,d:g:wheel:rx,g:adm:rx,d:g:adm:rx /var/log/journal/

        The journal gateway daemon requires the
        "systemd-journal-gateway" system user and group to
        exist. During execution this network facing service will drop
        privileges and assume this uid/gid for security reasons.

WARNINGS:
        systemd will warn you during boot if /etc/mtab is not a
        symlink to /proc/mounts. Please ensure that /etc/mtab is a
        proper symlink.

        systemd will warn you during boot if /usr is on a different
        file system than /. While in systemd itself very little will
        break if /usr is on a separate partition many of its
        dependencies very likely will break sooner or later in one
        form or another. For example udev rules tend to refer to
        binaries in /usr, binaries that link to libraries in /usr or
        binaries that refer to data files in /usr. Since these
        breakages are not always directly visible systemd will warn
        about this, since this kind of file system setup is not really
        supported anymore by the basic set of Linux OS components.

        For more information on this issue consult
        http://freedesktop.org/wiki/Software/systemd/separate-usr-is-broken

        To run systemd under valgrind, compile with VALGRIND defined
        (e.g. ./configure CPPFLAGS='... -DVALGRIND=1'). Otherwise,
        false positives will be triggered by code which violates
        some rules but is actually safe.