]>
Commit | Line | Data |
---|---|---|
514094f9 | 1 | <?xml version='1.0'?> |
a8c42bb8 LP |
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>systemd</productname> | |
a8c42bb8 LP |
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>systemd-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>systemd</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 | |
787dfb82 | 62 | partitions. (These must be regular files, with the <filename>.raw</filename> suffix.)</para></listitem> |
a8c42bb8 LP |
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 | |
83f72cd6 LP |
104 | <filename>/run/systemd/system.attached/</filename> instead of |
105 | <filename>/etc/systemd/system.attached/</filename>. Images attached with this option set hence remain attached | |
106 | only until the next reboot, while they are normally attached persistently.</para></listitem> | |
a8c42bb8 LP |
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 | |
83f72cd6 LP |
170 | <filename>/etc/systemd/system.attached/</filename> directory (or |
171 | <filename>/run/systemd/system.attached/</filename> — depending whether <option>--runtime</option> is | |
172 | specified, see above), which is included in the built-in unit search path of the system service | |
173 | manager.</para></listitem> | |
a8c42bb8 LP |
174 | |
175 | <listitem><para>For unit files of type <filename>.service</filename> a drop-in is added to these copies that | |
176 | adds <varname>RootDirectory=</varname> or <varname>RootImage=</varname> settings (see | |
177 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for | |
178 | details), that ensures these services are run within the file system of the originating portable service | |
179 | image.</para></listitem> | |
180 | ||
181 | <listitem><para>A second drop-in is created: the "profile" drop-in, that may contain additional security | |
182 | settings (and other settings). A number of profiles are available by default but administrators may define | |
183 | their own ones. See below.</para></listitem> | |
184 | ||
185 | <listitem><para>If the portable service image file is not already in the search path (see below), a symbolic | |
186 | link to it is created in <filename>/etc/portables/</filename> or | |
187 | <filename>/run/portables/</filename>, to make sure it is included in it.</para></listitem> | |
188 | </orderedlist> | |
189 | ||
190 | <para>By default all unit files whose names start with a prefix generated from the image's file name are copied | |
191 | out. Specifically, the prefix is determined from the image file name with any suffix such as | |
1b2ad5d9 | 192 | <filename>.raw</filename> removed, truncated at the first occurrence of and underscore character |
a8c42bb8 LP |
193 | (<literal>_</literal>), if there is one. The underscore logic is supposed to be used to versioning so that the |
194 | an image file <filename>foobar_47.11.raw</filename> will result in a unit file matching prefix of | |
195 | <filename>foobar</filename>. This prefix is then compared with all unit files names contained in the image in | |
196 | the usual directories, but only unit file names where the prefix is followed by <literal>-</literal>, | |
197 | <literal>.</literal> or <literal>@</literal> are considered. Example: if a portable service image file is named | |
198 | <filename>foobar_47.11.raw</filename> then by default all its unit files with names such as | |
199 | <filename>foobar-quux-waldi.service</filename>, <filename>foobar.service</filename> or | |
200 | <filename>foobar@.service</filename> will be considered. It's possible to override the matching prefix: all | |
201 | strings listed on the command line after the image file name are considered prefixes, overriding the implicit | |
202 | logic where the prefix is derived from the image file name.</para> | |
203 | ||
204 | <para>By default, after the unit files are attached the service manager's configuration is reloaded, except | |
205 | when <option>--no-reload</option> is specified (see above). This ensures that the new units made available to | |
206 | the service manager are seen by it.</para> | |
207 | </listitem> | |
208 | </varlistentry> | |
209 | ||
210 | <varlistentry> | |
211 | <term><command>detach</command> <replaceable>IMAGE</replaceable></term> | |
212 | ||
213 | <listitem><para>Detaches a portable service image from the host. This undoes the operations executed by the | |
214 | <command>attach</command> command above, and removes the unit file copies, drop-ins and image symlink | |
215 | again. This command expects an image name or path as parameter. Note that if a path is specified only the last | |
216 | component of it (i.e. the file or directory name itself, not the path to it) is used for finding matching unit | |
217 | files. This is a convencience feature to allow all arguments passed as <command>attach</command> also to | |
218 | <command>detach</command>.</para></listitem> | |
219 | </varlistentry> | |
220 | ||
221 | <varlistentry> | |
222 | <term><command>inspect</command> <replaceable>IMAGE</replaceable> [<replaceable>PREFIX…</replaceable>]</term> | |
223 | ||
224 | <listitem><para>Extracts various metadata from a portable service image and presents it to the | |
225 | caller. Specifically, the | |
226 | <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> file of the | |
227 | image is retrieved as well as all matching unit files. By default a short summary showing the most relevant | |
228 | metadata in combination with a list of matching unit files is shown (that is the unit files | |
229 | <command>attach</command> would install to the host system). If combined with <option>--cat</option> (see | |
230 | above), the <filename>os-release</filename> data and the units files' contents is displayed unprocessed. This | |
231 | command is useful to determine whether an image qualifies as portable service image, and which unit files are | |
232 | included. This command expects the path to the image as parameter, optionally followed by a list of unit file | |
233 | prefixes to consider, similar to the <command>attach</command> command described above.</para> | |
234 | </listitem> | |
235 | </varlistentry> | |
236 | ||
237 | <varlistentry> | |
238 | <term><command>is-attached</command> <replaceable>IMAGE</replaceable></term> | |
239 | ||
240 | <listitem><para>Determines whether the specified image is currently attached or not. Unless combined with the | |
241 | <option>--quiet</option> switch this will show a short state identifier for the image. Specifically:</para> | |
242 | ||
243 | <table> | |
244 | <title>Image attachment states</title> | |
245 | <tgroup cols='2'> | |
246 | <colspec colname='state'/> | |
247 | <colspec colname='description'/> | |
248 | <thead> | |
249 | <row> | |
250 | <entry>State</entry> | |
251 | <entry>Description</entry> | |
252 | </row> | |
253 | </thead> | |
254 | <tbody> | |
255 | <row> | |
256 | <entry><option>detached</option></entry> | |
257 | <entry>The image is currently not attached.</entry> | |
258 | </row> | |
259 | <row> | |
260 | <entry><option>attached</option></entry> | |
261 | <entry>The image is currently attached, i.e. its unit files have been made available to the host system.</entry> | |
262 | </row> | |
263 | <row> | |
264 | <entry><option>attached-runtime</option></entry> | |
1b2ad5d9 | 265 | <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 |
266 | </row> |
267 | <row> | |
268 | <entry><option>enabled</option></entry> | |
269 | <entry>The image is currently attached, and at least one unit file associated with it has been enabled.</entry> | |
270 | </row> | |
271 | <row> | |
272 | <entry><option>enabled-runtime</option></entry> | |
273 | <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> | |
274 | </row> | |
275 | <row> | |
276 | <entry><option>running</option></entry> | |
277 | <entry>The image is currently attached, and at least one unit file associated with it is running.</entry> | |
278 | </row> | |
279 | <row> | |
280 | <entry><option>running-runtime</option></entry> | |
281 | <entry>The image is currently attached transiently, and at least one unit file associated with it is running.</entry> | |
282 | </row> | |
283 | </tbody> | |
284 | </tgroup> | |
285 | </table> | |
286 | ||
287 | </listitem> | |
288 | </varlistentry> | |
289 | ||
290 | <varlistentry> | |
291 | <term><command>read-only</command> <replaceable>IMAGE</replaceable> [<replaceable>BOOL</replaceable>]</term> | |
292 | ||
293 | <listitem><para>Marks or (unmarks) a portable service image read-only. Takes an image name, followed by a | |
294 | boolean as arguments. If the boolean is omitted, positive is implied, i.e. the image is marked | |
295 | read-only.</para></listitem> | |
296 | </varlistentry> | |
297 | ||
298 | <varlistentry> | |
299 | <term><command>remove</command> <replaceable>IMAGE</replaceable>…</term> | |
300 | ||
301 | <listitem><para>Removes one or more portable service images. Note that this command will only remove the | |
1b2ad5d9 | 302 | specified image path itself — it refers to a symbolic link then the symbolic link is removed and not the |
a8c42bb8 LP |
303 | image it points to.</para></listitem> |
304 | </varlistentry> | |
305 | ||
306 | <varlistentry> | |
c2b67dc6 | 307 | <term><command>set-limit</command> [<replaceable>IMAGE</replaceable>] <replaceable>BYTES</replaceable></term> |
a8c42bb8 LP |
308 | |
309 | <listitem><para>Sets the maximum size in bytes that a specific portable service image, or all images, may grow | |
310 | up to on disk (disk quota). Takes either one or two parameters. The first, optional parameter refers to a | |
311 | portable service image name. If specified, the size limit of the specified image is changed. If omitted, the | |
312 | overall size limit of the sum of all images stored locally is changed. The final argument specifies the size | |
313 | limit in bytes, possibly suffixed by the usual K, M, G, T units. If the size limit shall be disabled, specify | |
314 | <literal>-</literal> as size.</para> | |
315 | ||
316 | <para>Note that per-image size limits are only supported on btrfs file systems. Also, depending on | |
317 | <varname>BindPaths=</varname> settings in the portable service's unit files directories from the host might be | |
318 | visible in the image environment during runtime which are not affected by this setting, as only the image | |
319 | itself is counted against this limit.</para></listitem> | |
320 | </varlistentry> | |
321 | ||
322 | </variablelist> | |
323 | ||
324 | </refsect1> | |
325 | ||
326 | <refsect1> | |
327 | <title>Files and Directories</title> | |
328 | ||
329 | <para>Portable service images are preferably stored in <filename>/var/lib/portables/</filename>, but are also | |
330 | searched for in <filename>/etc/portables/</filename>, <filename>/run/systemd/portables/</filename>, | |
331 | <filename>/usr/local/lib/portables/</filename> and <filename>/usr/lib/portables/</filename>. It's recommended not | |
332 | to place image files directly in <filename>/etc/portables/</filename> or | |
333 | <filename>/run/systemd/portables/</filename> (as these are generally not suitable for storing large or non-textual | |
334 | data), but use these directories only for linking images located elsewhere into the image search path.</para> | |
83f72cd6 LP |
335 | |
336 | <para>When a portable service image is attached, matching unit files are copied onto the host into the | |
337 | <filename>/etc/systemd/system.attached/</filename> and <filename>/run/systemd/system.attached/</filename> | |
338 | directories. When an image is detached, the unit files are removed again from these directories.</para> | |
a8c42bb8 LP |
339 | </refsect1> |
340 | ||
341 | <refsect1> | |
342 | <title>Profiles</title> | |
343 | ||
344 | <para>When portable service images are attached a "profile" drop-in is linked in, which may be used to enforce | |
345 | additional security (and other) restrictions locally. Four profile drop-ins are defined by default, and shipped in | |
346 | <filename>/usr/lib/systemd/portable/profile/</filename>. Additional, local profiles may be defined by placing them | |
347 | in <filename>/etc/systemd/portable/profile/</filename>. The default profiles are:</para> | |
348 | ||
349 | <table> | |
350 | <title>Profiles</title> | |
351 | <tgroup cols='2'> | |
352 | <colspec colname='state'/> | |
353 | <colspec colname='description'/> | |
354 | <thead> | |
355 | <row> | |
356 | <entry>Name</entry> | |
357 | <entry>Description</entry> | |
358 | </row> | |
359 | </thead> | |
360 | <tbody> | |
361 | <row> | |
362 | <entry><filename>default</filename></entry> | |
363 | <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> | |
364 | </row> | |
365 | <row> | |
366 | <entry><filename>nonetwork</filename></entry> | |
367 | <entry>Very similar to <filename>default</filename>, but networking is turned off for any services of the portable service image.</entry> | |
368 | </row> | |
369 | <row> | |
370 | <entry><filename>strict</filename></entry> | |
371 | <entry>A profile with very strict settings. This profile excludes IPC (D-Bus) and network access.</entry> | |
372 | </row> | |
373 | <row> | |
374 | <entry><filename>trusted</filename></entry> | |
375 | <entry>A profile with very relaxed settings. In this profile the services run with full privileges.</entry> | |
376 | </row> | |
377 | </tbody> | |
378 | </tgroup> | |
379 | </table> | |
380 | ||
381 | <para>For details on this profiles, and their effects please have a look at their precise definitions, | |
382 | e.g. <filename>/usr/lib/systemd/portable/profile/default/service.conf</filename> and similar.</para> | |
383 | </refsect1> | |
384 | ||
385 | <refsect1> | |
386 | <title>Exit status</title> | |
387 | ||
388 | <para>On success, 0 is returned, a non-zero failure code otherwise.</para> | |
389 | </refsect1> | |
390 | ||
391 | <xi:include href="less-variables.xml" /> | |
392 | ||
393 | <refsect1> | |
394 | <title>See Also</title> | |
395 | <para> | |
396 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
397 | <citerefentry><refentrytitle>systemd-portabled.service</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
398 | </para> | |
399 | </refsect1> | |
400 | ||
401 | </refentry> |