1
0
mirror of https://github.com/systemd/systemd synced 2026-04-03 13:44:55 +02:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Frantisek Sumsal
b131e8d3a4 test: ignore EC from the second systemctl status -a as well
There is a TOCTOU in the `systemctl status` where a unit might change
its state during the initial ListUnitsByPatterns call and the subsequent
individual GetAll calls, which then makes the systemctl call fail even
if the unit that was originally pulled in was active/running:

[ 1922.040463] TEST-26-SYSTEMCTL.sh[117]: + systemctl status -a --state active,running,plugged
[ 1922.051423] systemd[1]: Got message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=ListUnitsByPatterns  cookie=1 reply_cookie=0 signature=asas error-name=n/a error-message=n/a
[ 1922.052501] systemd[1]: Sent message type=method_return sender=org.freedesktop.systemd1 destination=n/a path=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 signature=a(ssssssouso) error-name=n/a error-message=n/a
[ 1922.052650] systemd[1]: Got message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1/unit/_2d_2emount interface=org.freedesktop.DBus.Properties member=GetAll  cookie=2 reply_cookie=0 signature=s error-name=n/a error-message=n/a
...
[ 1922.222061] systemd-hostnamed[424]: Idle for 30s, exiting.
...
[ 1922.224961] systemd[1]: systemd-hostnamed.service: Got notification message from PID 424: STOPPING=1, STATUS=Shutting down...
[ 1922.224983] systemd[1]: systemd-hostnamed.service: Changed running ->stop-sigterm
...
[ 1922.228984] systemd[1]: Got message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1/unit/systemd_2dhostnamed_2eservice interface=org.freedesktop.DBus.Properties member=GetAll  cookie=41 reply_cookie=0 signature=s error-name=n/a error-message=n/a
[ 1922.234402] systemd[1]: Sent message type=method_return sender=org.freedesktop.systemd1 destination=n/a path=n/a interface=n/a member=n/a cookie=43 reply_cookie=41 signature=a{sv} error-name=n/a error-message=n/a

Since in this case we care mostly about the code paths the command
triggers, ignore its exit code as we do for the previous one.

Resolves: #39612
2025-11-10 21:31:09 +00:00
Luca Boccassi
69ab56aa19
systemd-analyze shell completion improvements (#39673) 2025-11-10 20:06:09 +00:00
Jelle van der Waa
1e29036afc shell-completion: zsh: add completion for systemd-analyze inspect-elf 2025-11-10 20:10:06 +01:00
Jelle van der Waa
49ff5ad6e6 shell-completion: bash: add systemd-analyze image-policy completion 2025-11-10 20:09:53 +01:00
Jelle van der Waa
7112e08cec shell-completion: zsh: add missing completions for systemd-analyze
Adds missing simple verbs which already exist in bash completion.
2025-11-10 20:09:42 +01:00
Jelle van der Waa
60c68080b7 shell-completion: zsh: add systemd-analyze architectures completion 2025-11-10 20:09:01 +01:00
3 changed files with 24 additions and 2 deletions

View File

@ -68,7 +68,7 @@ _systemd_analyze() {
) )
local -A VERBS=( local -A VERBS=(
[STANDALONE]='time blame unit-files unit-paths exit-status compare-versions calendar timestamp timespan pcrs nvpcrs srk has-tpm2 smbios11 chid' [STANDALONE]='time blame unit-files unit-paths exit-status compare-versions calendar timestamp timespan pcrs nvpcrs srk has-tpm2 smbios11 chid image-policy'
[CRITICAL_CHAIN]='critical-chain' [CRITICAL_CHAIN]='critical-chain'
[DOT]='dot' [DOT]='dot'
[DUMP]='dump' [DUMP]='dump'

View File

@ -11,6 +11,11 @@
_files -W '(/run/systemd/ /etc/systemd/ /usr/lib/systemd/)' -P 'systemd/' _files -W '(/run/systemd/ /etc/systemd/ /usr/lib/systemd/)' -P 'systemd/'
} }
(( $+functions[_systemd-analyze_inspect-elf] )) ||
_systemd-analyze_inspect-elf() {
_files
}
(( $+functions[_systemd-analyze_critical-chain] )) || (( $+functions[_systemd-analyze_critical-chain] )) ||
_systemd-analyze_critical-chain() { _systemd-analyze_critical-chain() {
local -a _units local -a _units
@ -40,6 +45,13 @@
_describe -t groups 'file system groups' _groups || compadd "$@" _describe -t groups 'file system groups' _groups || compadd "$@"
} }
(( $+functions[_systemd-analyze_architectures] )) ||
_systemd-analyze_architectures() {
local -a _architectures
_architectures=( $(systemd-analyze --quiet --no-pager --no-legend architectures | { while read -r a b; do echo " $a"; done; } 2>/dev/null) )
_describe -t architectures 'architectures' _architectures || compadd "$@"
}
(( $+functions[_systemd-analyze_plot] )) || (( $+functions[_systemd-analyze_plot] )) ||
_systemd-analyze_plot() { _systemd-analyze_plot() {
local -a _options local -a _options
@ -82,6 +94,13 @@
'dlopen-metadata:Parse and print ELF dlopen metadata' 'dlopen-metadata:Parse and print ELF dlopen metadata'
'has-tpm2:Report whether TPM2 support is available' 'has-tpm2:Report whether TPM2 support is available'
'transient-settings:List transient settings for unit types' 'transient-settings:List transient settings for unit types'
'architectures:List known architectures'
'smbios11:List strings passed via SMBIOS Type #11'
'chid:List local CHIDs'
'compare-versions:Compare two version strings'
'image-policy:Analyze image policy string'
'pcrs:Show TPM2 PCRs and their names'
'srk:Write TPM2 SRK (to FILE)'
# log-level, log-target, service-watchdogs have been deprecated # log-level, log-target, service-watchdogs have been deprecated
) )

View File

@ -359,7 +359,10 @@ systemctl show systemd-logind.service
systemctl status systemctl status
# Ignore the exit code in this case, as it might try to load non-existing units # Ignore the exit code in this case, as it might try to load non-existing units
systemctl status -a >/dev/null || : systemctl status -a >/dev/null || :
systemctl status -a --state active,running,plugged >/dev/null # Ditto - there is a window between the first ListUnitsByByPatterns and the querying of individual units in
# which some units might change their state (e.g. running -> stop-sigterm), which then causes systemctl to
# return EC > 0
systemctl status -a --state active,running,plugged >/dev/null || :
systemctl status "systemd-*.timer" systemctl status "systemd-*.timer"
systemctl status "systemd-journald*.socket" systemctl status "systemd-journald*.socket"
systemctl status "sys-devices-*-ttyS0.device" systemctl status "sys-devices-*-ttyS0.device"