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