PORTABLECTL(1) | portablectl | PORTABLECTL(1) |
NAME
portablectl - Attach, detach or inspect portable service images
SYNOPSIS
portablectl [OPTIONS...] {COMMAND} [NAME...]
DESCRIPTION
portablectl may be used to attach, detach or inspect portable service images. It's primarily a command interfacing with systemd-portabled.service(8).
Portable service images contain an OS file system tree along with systemd(1) unit file information. A service image may be "attached" to the local system. If attached, a set of unit files are copied from the image to the host, and extended with RootDirectory= or RootImage= assignments (in case of service units) pointing to the image file or directory, ensuring the services will run within the file system context of the image.
Portable service images are an efficient way to bundle multiple related services and other units together, and transfer them as a whole between systems. When these images are attached to the local system, the contained units may run in most ways like regular system-provided units, either with full privileges or inside strict sandboxing, depending on the selected configuration. For more details, see Portable Services[1].
Portable service images may be of the following kinds:
COMMANDS
The following commands are understood:
list
Added in version 239.
attach IMAGE [PREFIX...]
When a portable service is attached four operations are executed:
By default, all unit files whose names start with a prefix generated from the image's file name are copied out. Specifically, the prefix is determined from the image file name with any suffix such as .raw removed, truncated at the first occurrence of an underscore character ("_"), if there is one. The underscore logic is supposed to be used to versioning so that the an image file foobar_47.11.raw will result in a unit file matching prefix of foobar. This prefix is then compared with all unit files names contained in the image in the usual directories, but only unit file names where the prefix is followed by "-", "." or "@" are considered. Example: if a portable service image file is named foobar_47.11.raw then by default all its unit files with names such as foobar-quux-waldi.service, foobar.service or foobar@.service will be considered. It's possible to override the matching prefix: all strings listed on the command line after the image file name are considered prefixes, overriding the implicit logic where the prefix is derived from the image file name.
By default, after the unit files are attached the service manager's configuration is reloaded, except when --no-reload is specified (see below). This ensures that the new units made available to the service manager are seen by it.
If --now and/or --enable are passed, the portable services are immediately started (blocking operation unless --no-block is passed) and/or enabled after attaching the image.
In place of the image path a ".v/" versioned directory may be specified, see systemd.v(7) for details.
In place of the directory path a ".v/" versioned directory may be specified, see systemd.v(7) for details.
Added in version 239.
detach IMAGE [PREFIX...]
If --now and/or --enable are passed, the portable services are immediately stopped (blocking operation) and/or disabled before detaching the image. Prefix(es) are also accepted, to be used in case the unit names do not match the image name as described in the attach.
Added in version 239.
reattach IMAGE [PREFIX...]
If --now and/or --enable are passed, the portable services are immediately stopped if removed, started and/or enabled if added, or restarted if updated. Prefixes are also accepted, in the same way as described in the attach case.
Added in version 248.
inspect IMAGE [PREFIX...]
Added in version 239.
is-attached IMAGE
Table 1. Image attachment states
State | Description |
detached | The image is currently not attached. |
attached | The image is currently attached, i.e. its unit files have been made available to the host system. |
attached-runtime | Like attached, but the unit files have been made available transiently only, i.e. the attach command has been invoked with the --runtime option. |
enabled | The image is currently attached, and at least one unit file associated with it has been enabled. |
enabled-runtime | Like enabled, but the unit files have been made available transiently only, i.e. the attach command has been invoked with the --runtime option. |
running | The image is currently attached, and at least one unit file associated with it is running. |
running-runtime | The image is currently attached transiently, and at least one unit file associated with it is running. |
Added in version 239.
read-only IMAGE [BOOL]
Added in version 239.
remove IMAGE...
Added in version 239.
set-limit [IMAGE] BYTES
Note that per-image size limits are only supported on btrfs file systems. Also, depending on BindPaths= settings in the portable service's unit files directories from the host might be visible in the image environment during runtime which are not affected by this setting, as only the image itself is counted against this limit.
Added in version 239.
OPTIONS
The following options are understood:
-q, --quiet
Added in version 239.
-p PROFILE, --profile=PROFILE
Added in version 239.
--copy=
Added in version 239.
--runtime
Added in version 239.
--no-reload
Added in version 239.
--cat
Added in version 239.
--enable
Added in version 245.
--now
Added in version 245.
--no-block
Added in version 245.
--clean
Added in version 256.
--extension=PATH
Note that the same extensions have to be specified, in the same order, when attaching and detaching.
In place of the image path a ".v/" versioned directory may be specified, see systemd.v(7) for details.
In place of the directory path a ".v/" versioned directory may be specified, see systemd.v(7) for details.
Added in version 249.
--force
Added in version 252.
-H, --host=
-M, --machine=
--no-pager
--no-legend
--no-ask-password
-h, --help
--version
FILES AND DIRECTORIES
Portable service images are preferably stored in /var/lib/portables/, but are also searched for in /etc/portables/, /run/systemd/portables/, /usr/local/lib/portables/ and /usr/lib/portables/. It's recommended not to place image files directly in /etc/portables/ or /run/systemd/portables/ (as these are generally not suitable for storing large or non-textual data), but use these directories only for linking images located elsewhere into the image search path.
When a portable service image is attached, matching unit files are copied onto the host into the /etc/systemd/system.attached/ and /run/systemd/system.attached/ directories. When an image is detached, the unit files are removed again from these directories.
PROFILES
When portable service images are attached a "profile" drop-in is linked in, which may be used to enforce additional security (and other) restrictions locally. Four profile drop-ins are defined by default, and shipped in /usr/lib/systemd/portable/profile/. Additional, local profiles may be defined by placing them in /etc/systemd/portable/profile/. The default profiles are:
Table 2. Profiles
Name | Description |
default | This is the default profile if no other profile name is set via the --profile= (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. |
nonetwork | Very similar to default, but networking is turned off for any services of the portable service image. |
strict | A profile with very strict settings. This profile excludes IPC (D-Bus) and network access. |
trusted | A profile with very relaxed settings. In this profile the services run with full privileges. |
For details on these profiles and their effects see their precise
definitions, e.g.
/usr/lib/systemd/portable/profile/default/service.conf and similar.
EXIT STATUS
On success, 0 is returned, a non-zero failure code otherwise.
ENVIRONMENT
$SYSTEMD_LOG_LEVEL
$SYSTEMD_LOG_COLOR
This setting is only useful when messages are written directly to the terminal, because journalctl(1) and other tools that display logs will color messages based on the log level on their own.
$SYSTEMD_LOG_TIME
This setting is only useful when messages are written directly to the terminal or a file, because journalctl(1) and other tools that display logs will attach timestamps based on the entry metadata on their own.
$SYSTEMD_LOG_LOCATION
Note that the log location is often attached as metadata to journal entries anyway. Including it directly in the message text can nevertheless be convenient when debugging programs.
$SYSTEMD_LOG_TID
Note that the this information is attached as metadata to journal entries anyway. Including it directly in the message text can nevertheless be convenient when debugging programs.
$SYSTEMD_LOG_TARGET
$SYSTEMD_LOG_RATELIMIT_KMSG
$SYSTEMD_PAGER, $PAGER
Note: if $SYSTEMD_PAGERSECURE is not set, $SYSTEMD_PAGER and $PAGER can only be used to disable the pager (with "cat" or ""), and are otherwise ignored.
$SYSTEMD_LESS
Users might want to change two options in particular:
K
If the value of $SYSTEMD_LESS does not include "K", and the pager that is invoked is less, Ctrl+C will be ignored by the executable, and needs to be handled by the pager.
X
Note that setting the regular $LESS environment variable has no effect for less invocations by systemd tools.
See less(1) for more discussion.
$SYSTEMD_LESSCHARSET
Note that setting the regular $LESSCHARSET environment variable has no effect for less invocations by systemd tools.
$SYSTEMD_PAGERSECURE
This option takes a boolean argument. When set to true, the "secure mode" of the pager is enabled. In "secure mode", LESSSECURE=1 will be set when invoking the pager, which instructs the pager to disable commands that open or create new files or start new subprocesses. Currently only less(1) is known to understand this variable and implement "secure mode".
When set to false, no limitation is placed on the pager. Setting SYSTEMD_PAGERSECURE=0 or not removing it from the inherited environment may allow the user to invoke arbitrary commands.
When $SYSTEMD_PAGERSECURE is not set, systemd tools attempt to automatically figure out if "secure mode" should be enabled and whether the pager supports it. "Secure mode" is enabled if the effective UID is not the same as the owner of the login session, see geteuid(2) and sd_pid_get_owner_uid(3), or when running under sudo(8) or similar tools ($SUDO_UID is set [2]). In those cases, SYSTEMD_PAGERSECURE=1 will be set and pagers which are not known to implement "secure mode" will not be used at all. Note that this autodetection only covers the most common mechanisms to elevate privileges and is intended as convenience. It is recommended to explicitly set $SYSTEMD_PAGERSECURE or disable the pager.
Note that if the $SYSTEMD_PAGER or $PAGER variables are to be honoured, other than to disable the pager, $SYSTEMD_PAGERSECURE must be set too.
$SYSTEMD_COLORS
$SYSTEMD_URLIFY
SEE ALSO
systemd(1), systemd-sysext(8), org.freedesktop.portable1(5), systemd-portabled.service(8), importctl(1)
NOTES
- 1.
- Portable Services
- 2.
- It is recommended for other tools to set and check $SUDO_UID as appropriate, treating it is a common interface.
systemd 257.7 |