chiark / gitweb /
Build system: Fix various issues that came from errornous migration.
[elogind.git] / man / portablectl.xml
1 <?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
6
7 <refentry id="portablectl" conditional='ENABLE_PORTABLED'
8     xmlns:xi="http://www.w3.org/2001/XInclude">
9
10   <refentryinfo>
11     <title>portablectl</title>
12     <productname>elogind</productname>
13   </refentryinfo>
14
15   <refmeta>
16     <refentrytitle>portablectl</refentrytitle>
17     <manvolnum>1</manvolnum>
18   </refmeta>
19
20   <refnamediv>
21     <refname>portablectl</refname>
22     <refpurpose>Attach, detach or inspect portable service images</refpurpose>
23   </refnamediv>
24
25   <refsynopsisdiv>
26     <cmdsynopsis>
27       <command>portablectl</command>
28       <arg choice="opt" rep="repeat">OPTIONS</arg>
29       <arg choice="req">COMMAND</arg>
30       <arg choice="opt" rep="repeat">NAME</arg>
31     </cmdsynopsis>
32   </refsynopsisdiv>
33
34   <refsect1>
35     <title>Description</title>
36
37     <para><command>portablectl</command> may be used to attach, detach or inspect portable service images. It's
38     primarily a command interfacing with
39     <citerefentry><refentrytitle>elogind-portabled.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
40
41     <para>Portable service images contain an OS file system tree along with
42     <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>1</manvolnum></citerefentry> unit file
43     information. A service image may be "attached" to the local system. If attached, a set of unit files are copied
44     from the image to the host, and extended with <varname>RootDirectory=</varname> or <varname>RootImage=</varname>
45     assignments (in case of service units) pointing to the image file or directory, ensuring the services will run
46     within the file system context of the image.</para>
47
48     <para>Portable service images are an efficient way to bundle multiple related services and other units together,
49     and transfer them as a whole between systems. When these images are attached the local system the contained units
50     may run in most ways like regular system-provided units, either with full privileges or inside strict sandboxing,
51     depending on the selected configuration.</para>
52
53     <para>Specifically portable service images may be of the following kind:</para>
54
55     <itemizedlist>
56       <listitem><para>Directory trees containing an OS, including the top-level directories <filename>/usr/</filename>,
57       <filename>/etc/</filename>, and so on.</para></listitem>
58
59       <listitem><para>btrfs subvolumes containing OS trees, similar to normal directory trees.</para></listitem>
60
61       <listitem><para>Binary "raw" disk images containing MBR or GPT partition tables and Linux file system
62       partitions.</para></listitem>
63     </itemizedlist>
64
65   </refsect1>
66
67   <refsect1>
68     <title>Options</title>
69
70     <para>The following options are understood:</para>
71
72     <variablelist>
73       <varlistentry>
74         <term><option>-q</option></term>
75         <term><option>--quiet</option></term>
76
77         <listitem><para>Suppresses additional informational output while running.</para></listitem>
78       </varlistentry>
79
80       <varlistentry>
81         <term><option>-p</option> <replaceable>PROFILE</replaceable></term>
82         <term><option>--profile=</option><replaceable>PROFILE</replaceable></term>
83
84         <listitem><para>When attaching an image, select the profile to use. By default the <literal>default</literal>
85         profile is used. For details about profiles, see below.</para></listitem>
86       </varlistentry>
87
88       <varlistentry>
89         <term><option>--copy=</option></term>
90
91         <listitem><para>When attaching an image, select whether to prefer copying or symlinking of files installed into
92         the host system. Takes one of <literal>copy</literal> (to prefer copying of files), <literal>symlink</literal>
93         (to prefer creation of symbolic links) or <literal>auto</literal> for an intermediary mode where security
94         profile drop-ins are symlinked while unit files are copied. Note that this option expresses a preference only,
95         in cases where symbolic links cannot be created — for example when the image operated on is a raw disk image,
96         and hence not directly referentiable from the host file system — copying of files is used
97         unconditionally.</para></listitem>
98       </varlistentry>
99
100       <varlistentry>
101         <term><option>--runtime</option></term>
102
103         <listitem><para>When specified the unit and drop-in files are placed in
104         <filename>/run/systemd/system/</filename> instead of <filename>/etc/systemd/system/</filename>. Images attached
105         with this option set hence remain attached only until the next reboot, while they are normally attached
106         persistently.</para></listitem>
107       </varlistentry>
108
109       <varlistentry>
110         <term><option>--no-reload</option></term>
111
112         <listitem><para>Don't reload the service manager after attaching or detaching a portable service
113         image. Normally the service manager is reloaded to ensure it is aware of added or removed unit
114         files.</para></listitem>
115       </varlistentry>
116
117       <varlistentry>
118         <term><option>--cat</option></term>
119
120         <listitem><para>When inspecting portable service images, show the (unprocessed) contents of the metadata files
121         pulled from the image, instead of brief summaries. Specifically, this will show the
122         <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> and unit file
123         contents of the image.</para></listitem>
124       </varlistentry>
125
126       <xi:include href="user-system-options.xml" xpointer="host" />
127       <xi:include href="user-system-options.xml" xpointer="machine" />
128
129       <xi:include href="standard-options.xml" xpointer="no-pager" />
130       <xi:include href="standard-options.xml" xpointer="no-legend" />
131       <xi:include href="standard-options.xml" xpointer="no-ask-password" />
132       <xi:include href="standard-options.xml" xpointer="help" />
133       <xi:include href="standard-options.xml" xpointer="version" />
134     </variablelist>
135   </refsect1>
136
137   <refsect1>
138     <title>Commands</title>
139
140     <para>The following commands are understood:</para>
141
142     <variablelist>
143
144       <varlistentry>
145         <term><command>list</command></term>
146
147         <listitem><para>List available portable service images. This will list all portable service images discovered
148         in the portable image search paths (see below), along with brief metadata and state information. Note that many
149         of the commands below may both operate on images inside and outside of the search paths. This command is hence
150         mostly a convenience option, the commands are generally not restricted to what this list
151         shows.</para></listitem>
152       </varlistentry>
153
154       <varlistentry>
155         <term><command>attach</command> <replaceable>IMAGE</replaceable> [<replaceable>PREFIX…</replaceable>]</term>
156
157         <listitem><para>Attach a portable service image to the host system. Expects a file system path to a portable
158         service image file or directory as first argument. If the specified path contains no slash character
159         (<literal>/</literal>) it is understood as image filename that is searched for in the portable service image
160         search paths (see below). To reference a file in the current working directory prefix the filename with
161         <literal>./</literal> to avoid this search path logic.</para>
162
163         <para>When a portable service is attached four operations are executed:</para>
164
165         <orderedlist>
166
167           <listitem><para>All unit files of types <filename>.service</filename>, <filename>.socket</filename>,
168           <filename>.target</filename>, <filename>.timer</filename> and <filename>.path</filename> which match the
169           indicated unit file name prefix are copied from the image to the host's
170           <filename>/etc/systemd/system/</filename> directory (or <filename>/run/systemd/system/</filename> — depending
171           whether <option>--runtime</option> is specified, see above).</para></listitem>
172
173           <listitem><para>For unit files of type <filename>.service</filename> a drop-in is added to these copies that
174           adds <varname>RootDirectory=</varname> or <varname>RootImage=</varname> settings (see
175           <citerefentry><refentrytitle>elogind.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
176           details), that ensures these services are run within the file system of the originating portable service
177           image.</para></listitem>
178
179           <listitem><para>A second drop-in is created: the "profile" drop-in, that may contain additional security
180           settings (and other settings). A number of profiles are available by default but administrators may define
181           their own ones. See below.</para></listitem>
182
183           <listitem><para>If the portable service image file is not already in the search path (see below), a symbolic
184           link to it is created in <filename>/etc/portables/</filename> or
185           <filename>/run/portables/</filename>, to make sure it is included in it.</para></listitem>
186         </orderedlist>
187
188         <para>By default all unit files whose names start with a prefix generated from the image's file name are copied
189         out. Specifically, the prefix is determined from the image file name with any suffix such as
190         <filename>.raw</filename> removed, truncated at the first occurrence of and underscore character
191         (<literal>_</literal>), if there is one. The underscore logic is supposed to be used to versioning so that the
192         an image file <filename>foobar_47.11.raw</filename> will result in a unit file matching prefix of
193         <filename>foobar</filename>. This prefix is then compared with all unit files names contained in the image in
194         the usual directories, but only unit file names where the prefix is followed by <literal>-</literal>,
195         <literal>.</literal> or <literal>@</literal> are considered. Example: if a portable service image file is named
196         <filename>foobar_47.11.raw</filename> then by default all its unit files with names such as
197         <filename>foobar-quux-waldi.service</filename>, <filename>foobar.service</filename> or
198         <filename>foobar@.service</filename> will be considered. It's possible to override the matching prefix: all
199         strings listed on the command line after the image file name are considered prefixes, overriding the implicit
200         logic where the prefix is derived from the image file name.</para>
201
202         <para>By default, after the unit files are attached the service manager's configuration is reloaded, except
203         when <option>--no-reload</option> is specified (see above). This ensures that the new units made available to
204         the service manager are seen by it.</para>
205         </listitem>
206       </varlistentry>
207
208       <varlistentry>
209         <term><command>detach</command> <replaceable>IMAGE</replaceable></term>
210
211         <listitem><para>Detaches a portable service image from the host. This undoes the operations executed by the
212         <command>attach</command> command above, and removes the unit file copies, drop-ins and image symlink
213         again. This command expects an image name or path as parameter. Note that if a path is specified only the last
214         component of it (i.e. the file or directory name itself, not the path to it) is used for finding matching unit
215         files. This is a convencience feature to allow all arguments passed as <command>attach</command> also to
216         <command>detach</command>.</para></listitem>
217       </varlistentry>
218
219       <varlistentry>
220         <term><command>inspect</command> <replaceable>IMAGE</replaceable> [<replaceable>PREFIX…</replaceable>]</term>
221
222         <listitem><para>Extracts various metadata from a portable service image and presents it to the
223         caller. Specifically, the
224         <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> file of the
225         image is retrieved as well as all matching unit files. By default a short summary showing the most relevant
226         metadata in combination with a list of matching unit files is shown (that is the unit files
227         <command>attach</command> would install to the host system). If combined with <option>--cat</option> (see
228         above), the <filename>os-release</filename> data and the units files' contents is displayed unprocessed. This
229         command is useful to determine whether an image qualifies as portable service image, and which unit files are
230         included. This command expects the path to the image as parameter, optionally followed by a list of unit file
231         prefixes to consider, similar to the <command>attach</command> command described above.</para>
232         </listitem>
233       </varlistentry>
234
235       <varlistentry>
236         <term><command>is-attached</command> <replaceable>IMAGE</replaceable></term>
237
238         <listitem><para>Determines whether the specified image is currently attached or not. Unless combined with the
239         <option>--quiet</option> switch this will show a short state identifier for the image. Specifically:</para>
240
241         <table>
242           <title>Image attachment states</title>
243           <tgroup cols='2'>
244             <colspec colname='state'/>
245             <colspec colname='description'/>
246             <thead>
247               <row>
248                 <entry>State</entry>
249                 <entry>Description</entry>
250               </row>
251             </thead>
252             <tbody>
253               <row>
254                 <entry><option>detached</option></entry>
255                 <entry>The image is currently not attached.</entry>
256               </row>
257               <row>
258                 <entry><option>attached</option></entry>
259                 <entry>The image is currently attached, i.e. its unit files have been made available to the host system.</entry>
260               </row>
261               <row>
262                 <entry><option>attached-runtime</option></entry>
263                 <entry>Like <option>attached</option>, but the unit files have been made available transiently only, i.e. the <command>attach</command> command has been invoked with the <option>--runtime</option> option.</entry>
264               </row>
265               <row>
266                 <entry><option>enabled</option></entry>
267                 <entry>The image is currently attached, and at least one unit file associated with it has been enabled.</entry>
268               </row>
269               <row>
270                 <entry><option>enabled-runtime</option></entry>
271                 <entry>Like <option>enabled</option>, but the the unit files have been made available transiently only, i.e. the <command>attach</command> command has been invoked with the <option>--runtime</option> option.</entry>
272               </row>
273               <row>
274                 <entry><option>running</option></entry>
275                 <entry>The image is currently attached, and at least one unit file associated with it is running.</entry>
276               </row>
277               <row>
278                 <entry><option>running-runtime</option></entry>
279                 <entry>The image is currently attached transiently, and at least one unit file associated with it is running.</entry>
280               </row>
281             </tbody>
282           </tgroup>
283         </table>
284
285         </listitem>
286       </varlistentry>
287
288       <varlistentry>
289         <term><command>read-only</command> <replaceable>IMAGE</replaceable> [<replaceable>BOOL</replaceable>]</term>
290
291         <listitem><para>Marks or (unmarks) a portable service image read-only. Takes an image name, followed by a
292         boolean as arguments. If the boolean is omitted, positive is implied, i.e. the image is marked
293         read-only.</para></listitem>
294       </varlistentry>
295
296       <varlistentry>
297         <term><command>remove</command> <replaceable>IMAGE</replaceable>…</term>
298
299         <listitem><para>Removes one or more portable service images. Note that this command will only remove the
300         specified image path itself — it refers to a symbolic link then the symbolic link is removed and not the
301         image it points to.</para></listitem>
302       </varlistentry>
303
304       <varlistentry>
305         <term><command>set-limit</command> [<replaceable>IMAGE</replaceable>] <replaceable>BYTES</replaceable></term>
306
307         <listitem><para>Sets the maximum size in bytes that a specific portable service image, or all images, may grow
308         up to on disk (disk quota). Takes either one or two parameters. The first, optional parameter refers to a
309         portable service image name. If specified, the size limit of the specified image is changed. If omitted, the
310         overall size limit of the sum of all images stored locally is changed. The final argument specifies the size
311         limit in bytes, possibly suffixed by the usual K, M, G, T units. If the size limit shall be disabled, specify
312         <literal>-</literal> as size.</para>
313
314         <para>Note that per-image size limits are only supported on btrfs file systems. Also, depending on
315         <varname>BindPaths=</varname> settings in the portable service's unit files directories from the host might be
316         visible in the image environment during runtime which are not affected by this setting, as only the image
317         itself is counted against this limit.</para></listitem>
318       </varlistentry>
319
320     </variablelist>
321
322   </refsect1>
323
324   <refsect1>
325     <title>Files and Directories</title>
326
327     <para>Portable service images are preferably stored in <filename>/var/lib/portables/</filename>, but are also
328     searched for in <filename>/etc/portables/</filename>, <filename>/run/systemd/portables/</filename>,
329     <filename>/usr/local/lib/portables/</filename> and <filename>/usr/lib/portables/</filename>. It's recommended not
330     to place image files directly in <filename>/etc/portables/</filename> or
331     <filename>/run/systemd/portables/</filename> (as these are generally not suitable for storing large or non-textual
332     data), but use these directories only for linking images located elsewhere into the image search path.</para>
333   </refsect1>
334
335   <refsect1>
336     <title>Profiles</title>
337
338     <para>When portable service images are attached a "profile" drop-in is linked in, which may be used to enforce
339     additional security (and other) restrictions locally. Four profile drop-ins are defined by default, and shipped in
340     <filename>/usr/lib/elogind/portable/profile/</filename>. Additional, local profiles may be defined by placing them
341     in <filename>/etc/elogind/portable/profile/</filename>. The default profiles are:</para>
342
343     <table>
344       <title>Profiles</title>
345       <tgroup cols='2'>
346         <colspec colname='state'/>
347         <colspec colname='description'/>
348         <thead>
349           <row>
350             <entry>Name</entry>
351             <entry>Description</entry>
352           </row>
353         </thead>
354         <tbody>
355           <row>
356             <entry><filename>default</filename></entry>
357             <entry>This is the default profile if no other profile name is set via the <option>--profile=</option> (see above). It's fairly restrictive, but should be useful for common, unprivileged system workloads. This includes write access to the logging framework, as well as IPC access to the D-Bus system.</entry>
358           </row>
359           <row>
360             <entry><filename>nonetwork</filename></entry>
361             <entry>Very similar to <filename>default</filename>, but networking is turned off for any services of the portable service image.</entry>
362           </row>
363           <row>
364             <entry><filename>strict</filename></entry>
365             <entry>A profile with very strict settings. This profile excludes IPC (D-Bus) and network access.</entry>
366           </row>
367           <row>
368             <entry><filename>trusted</filename></entry>
369             <entry>A profile with very relaxed settings. In this profile the services run with full privileges.</entry>
370           </row>
371         </tbody>
372       </tgroup>
373     </table>
374
375     <para>For details on this profiles, and their effects please have a look at their precise definitions,
376     e.g. <filename>/usr/lib/elogind/portable/profile/default/service.conf</filename> and similar.</para>
377   </refsect1>
378
379   <refsect1>
380     <title>Exit status</title>
381
382     <para>On success, 0 is returned, a non-zero failure code otherwise.</para>
383   </refsect1>
384
385   <xi:include href="less-variables.xml" />
386
387   <refsect1>
388     <title>See Also</title>
389     <para>
390       <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
391       <citerefentry><refentrytitle>elogind-portabled.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
392     </para>
393   </refsect1>
394
395 </refentry>