| 1 |
<?xml version="1.0"?> |
| 2 |
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
| 3 |
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> |
| 4 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 5 |
|
| 6 |
<refentry id="capsule_.service" |
| 7 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 8 |
|
| 9 |
<refentryinfo> |
| 10 |
<title>[email protected]</title> |
| 11 |
<productname>systemd</productname> |
| 12 |
</refentryinfo> |
| 13 |
|
| 14 |
<refmeta> |
| 15 |
<refentrytitle>[email protected]</refentrytitle> |
| 16 |
<manvolnum>5</manvolnum> |
| 17 |
</refmeta> |
| 18 |
|
| 19 |
<refnamediv> |
| 20 |
<refname>[email protected]</refname> |
| 21 |
<refpurpose>System unit for the capsule service manager</refpurpose> |
| 22 |
</refnamediv> |
| 23 |
|
| 24 |
<refsynopsisdiv> |
| 25 |
<para><filename>capsule@<replaceable>NAME</replaceable>.service</filename></para> |
| 26 |
</refsynopsisdiv> |
| 27 |
|
| 28 |
<refsect1> |
| 29 |
<title>Description</title> |
| 30 |
|
| 31 |
<para>Service managers for capsules run in |
| 32 |
<filename>capsule@<replaceable>NAME</replaceable>.service</filename> system units, with the capsule name as the |
| 33 |
instance identifier. Capsules are way to run additional instances of the service manager, under dynamic |
| 34 |
user IDs, i.e. UIDs that are allocated when the capsule service manager is started, and released when it |
| 35 |
is stopped.</para> |
| 36 |
|
| 37 |
<para>In many ways <filename>[email protected]</filename> is similar to the per-user |
| 38 |
<filename>[email protected]</filename> service manager, but there are a few important distinctions:</para> |
| 39 |
|
| 40 |
<itemizedlist> |
| 41 |
<listitem><para>The capsule service manager utilizes <varname>DynamicUser=</varname> (see |
| 42 |
<citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>) to |
| 43 |
allocate a new UID dynamically on invocation. The user name is automatically generated from the capsule |
| 44 |
name, by prefixing <literal>c-</literal>. The UID is released when the service is terminated. The user |
| 45 |
service manager on the other hand operates under a statically allocated user ID that must be |
| 46 |
pre-existing, before the user service manager is invoked.</para></listitem> |
| 47 |
|
| 48 |
<listitem><para>User service managers register themselves with <citerefentry |
| 49 |
project='man-pages'><refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum></citerefentry>, capsule |
| 50 |
service managers do not.</para></listitem> |
| 51 |
|
| 52 |
<listitem><para>User service managers typically read their configuration from a |
| 53 |
<varname>$HOME</varname> directory below <filename>/home/</filename>, capsule service managers from a |
| 54 |
<varname>$HOME</varname> directory below <filename>/var/lib/capsules/</filename>.</para></listitem> |
| 55 |
|
| 56 |
<listitem><para>User service managers are collectively contained in the <filename>user.slice</filename> |
| 57 |
unit, capsule service managers in <filename>capsule.slice</filename>. Also see |
| 58 |
<citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para></listitem> |
| 59 |
|
| 60 |
<listitem><para>User service managers start the user unit <filename>default.target</filename> |
| 61 |
initially. Capsule service managers invoke the user unit <filename>[email protected]</filename> |
| 62 |
instead.</para></listitem> |
| 63 |
</itemizedlist> |
| 64 |
|
| 65 |
<para>The capsule service manager and the capsule's bus broker can be reached via the |
| 66 |
<option>--capsule=</option> switch to |
| 67 |
<citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
| 68 |
<citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry> and |
| 69 |
<citerefentry><refentrytitle>busctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para> |
| 70 |
|
| 71 |
<para>New capsules can be started via a simple <command>systemctl start |
| 72 |
capsule@<replaceable>NAME</replaceable>.service</command> command, and stopped via <command>systemctl |
| 73 |
stop capsule@<replaceable>NAME</replaceable>.service</command>. Starting a capsule will implicitly create |
| 74 |
a home directory <filename>/var/lib/capsules/<replaceable>NAME</replaceable>/</filename>, if missing. A |
| 75 |
runtime directory is created as <filename>/run/capsules/<replaceable>NAME</replaceable>/</filename>. To |
| 76 |
remove these resources use <command>systemctl clean capsule@<replaceable>NAME</replaceable>.service</command>, |
| 77 |
for example with the <option>--what=all</option> switch.</para> |
| 78 |
|
| 79 |
<para>The <filename>[email protected]</filename> unit invokes a <command>systemd --user</command> |
| 80 |
service manager process. This means unit files are looked for according to the sames rules as for regular user |
| 81 |
service managers, for example in |
| 82 |
<filename>/var/lib/capsules/<replaceable>NAME</replaceable>/.config/systemd/user/</filename>.</para> |
| 83 |
|
| 84 |
<para>Capsule names may be chosen freely by the user, however, they must be suitable as UNIX filenames |
| 85 |
(i.e. 255 characters max, and contain no <literal>/</literal>), and when prefixed with |
| 86 |
<literal>c-</literal> be suitable as a user name matching strict POSIX rules, see <ulink |
| 87 |
url="https://systemd.io/USER_NAMES">User/Group Name Syntax</ulink> for details.</para> |
| 88 |
|
| 89 |
<xi:include href="version-info.xml" xpointer="v256"/> |
| 90 |
</refsect1> |
| 91 |
|
| 92 |
<refsect1> |
| 93 |
<title>Examples</title> |
| 94 |
<example> |
| 95 |
<title>Create a new capsule, invoke two programs in it (one interactively), terminate it, and clean everything up</title> |
| 96 |
|
| 97 |
<programlisting># systemctl start [email protected] |
| 98 |
# systemd-run --capsule=tatze --unit=sleeptest.service sleep 999 |
| 99 |
# systemctl --capsule=tatze status sleeptest.service |
| 100 |
# systemd-run -t --capsule=tatze bash |
| 101 |
# systemctl --capsule=tatze stop sleeptest.service |
| 102 |
# systemctl stop [email protected] |
| 103 |
# systemctl clean --all [email protected]</programlisting> |
| 104 |
</example> |
| 105 |
</refsect1> |
| 106 |
|
| 107 |
<refsect1> |
| 108 |
<title>See Also</title> |
| 109 |
<para><simplelist type="inline"> |
| 110 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 111 |
<member><citerefentry><refentrytitle>[email protected]</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 112 |
<member><citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 113 |
<member><citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 114 |
<member><citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 115 |
<member><citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry></member> |
| 116 |
<member><citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 117 |
<member><citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 118 |
<member><citerefentry><refentrytitle>busctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 119 |
<member><citerefentry project='man-pages'><refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
| 120 |
</simplelist></para> |
| 121 |
</refsect1> |
| 122 |
</refentry> |