systemd-sysupdate copies the "user.uapi.match_…" extended attributes of files
in UAPI.16 manifests onto the files it installs, which restrict the
files to specific systems (hostname, machine ID, machine tags, os-release
image/OS ID and version). Let's honour them when picking entries from
.v/ directories too: entries whose extended attributes don't match the
local system are skipped, as if they didn't exist. The system properties
are only loaded once an entry actually carries one of the attributes.
Entries referenced literally, i.e. without making use of .v/ logic, are
not filtered.
This may be turned off with the new PICK_IGNORE_XATTR_MATCH flag, which
systemd-vpick exposes as --match-xattr=no.
Working out how long the service manager keeps restarting a failing service
takes the exponential backoff formula from systemd.service(5) and a manual
simulation of the start rate limit. Getting either wrong means a service
that's supposed to fail after a while is restarted forever.
Let's add a restart-delays command that does both. It lists each restart
until the delay stops growing, with the total of the delays up to that
restart, and then says whether the start rate limit rejects a restart and
when. Like security, it reads the settings of loaded units from the service
manager, or loads unit files with --offline=yes. With --json=, it prints the
same data as a JSON object.
The command computes the delays with the same functions as the service
manager. It checks the start rate limit with ratelimit_below_at() for each
restart until the delay stops growing. After that, every restart waits the
same delay. We then compute the rejected restart from the number of starts
that the current window of the rate limit still allows.
A small tool that generates file manifests of plain directory trees in
the four formats manifest-util knows (simple list, SHA256SUMS, mtree,
UAPI.16), and verifies directory trees against such manifests. It
works on plain directories only, i.e. does not dissect images, for that
systemd-dissect --uapi16/--sha256sums/--mtree/--list remain available
and share the same code.
The format is selected with --format=, and the fields to include or
check with --field= (defaulting to what systemd-dissect emits). For
mtree manifests --hash= selects SHA512 instead of SHA256. All
positional arguments are optional: the directory defaults to the
current directory, "make" writes to standard output unless a file is
specified, and "verify" reads the manifest from standard input unless a
file is specified.
Generation fails if inodes had to be skipped or some of their metadata
had to be omitted (for example because of missing privileges), unless
--graceful is specified, in which case we only insist that the
top-level inode is covered.
"hostnamectl tags --apply" asks systemd-hostnamed to apply the
machine-tags.d/ configuration via the new ApplyTags() Varlink call.
As the call is only available via Varlink, the switch is not supported
together with --host= or --machine=.
When providing ad-hoc protocol upgrade support to existing programs
via the `varlinkctl serve` command it is often useful/desirable
to limit it to a certain polkit action. So we add a new flag called
`--polkit-action=` here that does exactly this. The protocol upgrade
is only allowed when the given polkit action is allowed for the
user.
Thanks to Lennart for suggesting this in PR#43994
- Missing '--' for compgen, and '-o nospace' and '-o dirnames' are
for compopt rather than compgen,
- add missing '-1' completion.
- argument of --cpu is optional, hence it must be concatenated with '=',
- drop unnecessary assignments for cur and prev.
Then, make it possible to specify core by the UUID in coredumpctl.
This is typically useful to specify a crash that the same executable
crashes multiple times, as PID may not be unique.
Add "varlinkctl monitor" which connects to systemd-varlink-monitord and
displays captured varlink messages in real time, with both pretty-printed
and JSON-SEQ output modes. Supports filtering by --pid, --path, and
--uid. Includes integration tests covering pre-existing sockets, new
sockets, filtering, large message reassembly, garbage data handling, and
JSON output validation.
Installing an update might make further updates available, for example
because the update ships new or changed transfer files, components, or
system extensions containing such files. Hence add a new --loop=N
switch, which runs the update logic repeatedly, re-reading all
definitions each time, until either nothing is installed anymore, or N
iterations have been done.
If --reboot is specified the reboot is requested once, after the last
iteration.
Not specifying --loop= is equivalent to --loop=1, i.e. the behaviour
remains unchanged.
systemctl: add new "systemctl wait" command
It's quite useful being able to wait for a unit to be terminated and see
its exit data, just like we do it for systemd-run, without triggering
any other operation (which is what systemctl stop would do).
Fixes: #32017
The root row in systemd-cgtop previously displayed whole-system RAM
usage read from /proc/meminfo (MemTotal - MemAvailable), not a cgroup
sum. This is a pragmatic fallback — the kernel intentionally does not
expose memory.current on the v2 root cgroup (see the existing
is_root_cgroup() comment about avoiding 'multiple truth about system
state'), so cgtop picked /proc/meminfo to fill the gap.
Nevertheless, that caued the '/' row to provide different information
than every other row in the table:
- All child rows: 'what is this cgroup charged for?' (anon + file
+ sock + shmem attributable to the cgroup).
- Root row: 'what is the whole system using?' (includes kernel
slab, vmalloc, pagetables, zram mem_used, and anything not
attributable to any cgroup).
On a typical desktop the root row can read ~10 GB while the sum of
direct children is ~5 GB, with no explanation visible in the tool
itself.
This commit:
1. Introduces --root-memory= command line option.
2. Flips the default for the root row to the sum of memory.current
over its direct children.
3. Adds a '/' interactive key that toggles between the two modes.
4. Updates the interactive help string ('?' / 'h'), the man page,
and the bash completion for the new option.
Inside a container (detect_container() > 0), is_root_cgroup() already
returns false, so none of this applies — the container's '/' still
reads memory.current from the namespaced cgroup as before.
Co-authored-by: Zbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
It's quite useful being able to wait for a unit to be terminated and see
its exit data, just like we do it for systemd-run, without triggering
any other operation (which is what systemctl stop would do).
Fixes: #32017
It's nice to use --attach since it validates our images. So far, it
strictly insisted on checking that the image was a DDI however, which
limits its use for certain usecases.
Add "--relax" to address this limitation.
zsh only ever offered unit names after `systemctl show`, since
_systemctl_show() was sharing the same completion function as
is-active/status/preset/etc., none of which recognize `-`-prefixed
words at all. This meant `systemctl show --<TAB>` and
`systemctl show --property <TAB>` produced no completions, even
though the same options complete fine before the subcommand word
(bash has always completed both cases correctly).
Give `show` its own completion function that first tries the
existing global option specs (now pulled out into a `_sys_arguments`
array so they can be reused) via _arguments, falling back to unit
name completion for everything else. The unit-name fallback is
factored into a shared _systemctl_non_template_units() helper so it
isn't duplicated between _systemctl_show() and the existing
NONTEMPLATE_UNITS loop.
While doing so, fix pre-existing bugs in that option list which this
change makes newly reachable (and, for the filters below, newly
relevant) after `show`:
- `-P` was documented as a bare `--privileged[Acquire privileges
before execution]` flag, which systemctl does not have. `-P NAME`
is actually short-only and equivalent to `--value --property=NAME`
(src/systemctl/systemctl.c); it now completes property names the
same way `-p`/`--property` do, and is grouped next to them instead
of sitting in `--privileged`'s old, unrelated slot.
- `-p`/`--property`, `-t`/`--type`, and `--state` all lacked the `*`
repeatability prefix, so completion stopped offering each after its
first use even though systemctl accumulates all three
(parse_property_argument()/parse_types_argument()/
parse_states_argument(), all via strv_consume()). `_loginctl`
already uses the correct `'*'{-p+,--property=}...` form for -p.
-t/--type and --state are both documented as filters that apply to
`show` specifically (man/systemctl.xml), same as -p/--property.
- `--value`, documented specifically for `show` ("When showing
properties, only print the value"), was missing from the zsh
completion entirely, though bash already completes it.
- `-M`/`--machine=` (OPTION_COMMON_MACHINE) was likewise missing,
despite directly affecting `show`'s bus transport the same way the
already-present `-H`/`--host` does; `_loginctl`/`_busctl` already
have the matching `_sd_machines`-backed spec.
Also switch both `_arguments` call sites to splice `_sys_arguments`
as `"$_sys_arguments[@]"` rather than bare, matching the prevailing
quoted-array idiom used by five other completions in this directory
(_systemd-hwdb, _userdbctl, _systemd-id128, _updatectl,
_systemd-sysupdate) and avoiding the unquoted form's behavior of
silently eliding any element that becomes empty.
Fixes#37463
Create the file with open_tmpfile_linkable_at().
Write the recovery key and trailing newline to the temporary fd.
Set the final mode to 0600 before publishing it.
Link it into place with link_tmpfile_at(..., LINK_TMPFILE_SYNC).
The `restart` verb was added to machinectl as a convenience alias for
`reboot`, but its shell completions were never updated. Add it to both
the bash and zsh completions.
Several verbs in the STANDALONE bucket accept --json=, but that bucket only
offers --help --version --system --user --global --no-pager, so completion
never suggested the option for them.
Split those verbs out into a new STANDALONE_JSON bucket that additionally
offers --json=off/pretty/short. The verbs are moved rather than copied, as
${VERBS[*]} is used to complete the verb list itself.
Add a new --no-reconfigure flag to 'networkctl reload' that reloads
.network and .netdev files from disk without reconfiguring any network
interfaces. This may be useful to avoid reconfiguring multiple interfaces
simultaneously when multiple .network files are updated, or when an updated
.network file is applied to multiple interfaces.
On the networkd side, manager_reload() gains a reconfigure_links parameter
that gates the per-link reconfiguration loop. A new io.systemd.Network.Reload
varlink method is added that exposes this as an optional reconfigureLinks
boolean (defaults to true). Both plain 'networkctl reload' and
'--no-reconfigure' now unconditionally call this method first. If an older
networkd returns MethodNotFound, plain reload falls back to
io.systemd.service.Reload for backward compatibility; '--no-reconfigure'
fails with a clear error in that case.
The zsh completion for timedatectl was missing three commands ('show',
'ntp-servers', 'revert') and five options (--monitor, -p/--property=,
-a/--all, --value, -P) that are already present in the bash completion,
documented in the man page, and implemented in the binary.
Fixes#16507