Commit Graph
573 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 1d640a044f analyze: do not print timestamps before "start of userspace"
We have the following timestamp status:

  $ systemctl show systemd-fsck-root.service | grep InactiveExitTimestamp
  InactiveExitTimestamp=Thu 2023-11-02 12:27:24 CET
  InactiveExitTimestampMonotonic=15143158

  $ systemctl show | grep UserspaceTimestamp
  UserspaceTimestamp=Thu 2023-11-02 12:27:25 CET
  UserspaceTimestampMonotonic=15804273

i.e. UserspaceTimestamp is before InactiveExit of systemd-fsck-root.service.
This is fine, but on display, we'd subtract those values and print a huge
negative value bogusly:

  $ build/systemd-analyze critical-chain systemd-remount-fs.service
  The time when unit became active or started is printed after the "@" character.
  The time the unit took to start is printed after the "+" character.

  systemd-remount-fs.service +137ms
  └─systemd-fsck-root.service @584542y 2w 2d 20h 1min 48.890s +45ms
    └─systemd-journald.socket
      └─system.slice
        └─-.slice

In fact, list_dependencies_print() already had a branch where the check that
'times->activating > boot->userspace_time', but it didn't cover all cases. So
make it cover both branches, and also change to '>=', since it's fine if
something happened with the same timestamp.

With the patch:

  $ build/systemd-analyze critical-chain systemd-remount-fs.service
  The time when unit became active or started is printed after the "@" character.
  The time the unit took to start is printed after the "+" character.

  systemd-remount-fs.service +42ms
  └─systemd-fsck-root.service
    └─systemd-journald.socket
      └─system.slice
        └─-.slice

Fixes https://github.com/systemd/systemd/issues/17191.
2024-05-20 18:31:32 +02:00
Luca Boccassi 93df5217b9 tree-wide: 'allows to' -> 'allows one to'
As flagged by Lintian
2024-05-14 18:33:27 +02:00
Yu Watanabe 4e494e6aac tree-wise: several cleanups for logging
- drop unnecessary SYNTHETIC_ERRNO() when the logger does not propagate
  error code,
- drop unnecessary '%m' in error message when the error code is
  specified with SYNTHETIC_ERRNO(),
- add missing full stop at the end of log message,
- use RET_GATHER(),
- add missing ", ignoring.",
- upeercase the first letter, etc., etc...
2024-05-01 04:41:06 +09:00
Lennart Poettering 21a3bc6b9f tpm2-util: add generic wrapper tpm2_context_new_or_warn() that wrpas tpm2_context_new and logs about errors
We so far just print a short log message that is not very useful, let's
add some recognizable error codes, and output better log messages if we
can't get TPM stuff to work.

Fixes: #31925
2024-04-22 12:40:09 +02:00
Matteo Croce 854711645b use FOREACH_ELEMENT
Use FOREACH_ELEMENT where possible. Generated with this command,
and checked manually:

    git grep -l 'FOREACH_ARRAY.*ELEMENTSOF' | \
    xargs sed -ri 's/FOREACH_ARRAY\((.*), (.*), (ELEMENTSOF.*)\)/FOREACH_ELEMENT(\1, \2)/'
2024-04-18 17:39:34 +02:00
Luca Boccassi b3f548615f core: rename SoftRebootStartTimestamp -> ShutdownStartTimestamp and generalize
Follow-up for 54f86b86ba
2024-04-17 18:19:27 +01:00
Luca Boccassi 259046cfe8 analyze: show soft-reboot counter next to time deltas 2024-04-16 00:26:05 +01:00
Luca Boccassi 05626b27a0 analyze: reset more timestamps when analyzing soft reboots
Follow-up for 7addfba9c4
2024-04-16 00:26:04 +01:00
Luca Boccassi e6bd341e7d analyze: fix plot with soft-reboot
Clamp times and start counting from when soft-reboot is started
to avoid creating a huge graph, like it's done for the user
instance.
2024-03-27 22:25:45 +00:00
Luca Boccassi 7addfba9c4 analyze: show only current times after soft-reboot
The firmware/loader/kernel times are no longer relevant for the startup
sequence on soft-reboot, so use only the userspace timestamps
2024-03-27 01:27:34 +00:00
Mike Yuan ac97053618 analyze: refuse --global dot/verify
I don't quite understand the rationale of making these
verbs work with --global back in the day. But realistically
they interact with/spawn manager, while there's no
--global runtime scope manager. And to verify/inspect user
units it's sufficient to just use --user.

Fixes #31911
2024-03-24 01:28:28 +08:00
Mike Yuan 147e7b4446 analyze-dot: also show BindsTo= in --require 2024-03-24 01:28:28 +08:00
Mike Yuan de91848c3a analyze-dot: minor modernization 2024-03-24 01:28:28 +08:00
Mike Yuan 3efb597b07 analyze-security: use FOREACH_ARRAY 2024-03-24 01:11:14 +08:00
Zbigniew Jędrzejewski-Szmek 55222b75a6 systemd-analyze: use strdup_to() 2024-03-20 15:18:21 +01:00
Zbigniew Jędrzejewski-Szmek ec596fe34e Merge pull request #30480 from keszybz/kernel-install-more-paths
Read kernel-install config from /run/kernel too
2024-03-08 08:25:07 +01:00
Mike Yuan 7dfc71399d path-lookup: rename lookup_paths_free -> _done
This is stack-allocated, so update to match our usual rules.
2024-03-07 02:01:57 +08:00
Lennart Poettering f4a63ce25f dissect-image: add flag for explicitly enabling userspace verity signature checking
let's make userspace verity signature checking optional. This adds a
dissection flag to enable the logic and patches through all our users to
enable it by default, thus effectively not changing anything from the
status quo ante. However, know we have a knob to turn this off in
certain scenarios.
2024-02-28 16:17:40 +01:00
Zbigniew Jędrzejewski-Szmek 8f43182847 various: use modern strv helpers
If we're building a strv, let's just use strv_new() with the CONF_PATHS macro,
which gives as an exploded string set.
2024-02-28 11:10:34 +01:00
Zbigniew Jędrzejewski-Szmek 0615abef62 analyze: always recommend saving the output to a file
The command will refuse to write to a TTY, so give a strong hint
that redirecting to a file is recommended. This makes the synopsis,
man page text, and --help output consistent.

Also drop the space after the redirection operator everywhere.
2024-02-20 19:35:58 +00:00
Yu Watanabe 142f0e9517 analyze: skip to check ExecCommand for .mount and .swap units
They are not set by a unit file, but dynamically generated.

Fixes a bug caused by abf0ccc1c6.

Fixes #31396.
2024-02-20 11:59:10 +00:00
Mike Yuan e9a46668c3 macro: rename VA_ARGS_FOREACH to FOREACH_ARGUMENT
"VA_ARGS" is kinda confusing, as the macro just iterates through
all arguments passed and has nothing to do with va_arg.
2024-01-24 21:21:57 +08:00
Antonio Alvarez Feijoo 5e16328506 analyze: clarify that security --offline=true requires an argument
Without `--root` or `--image`, the `security` command inspects all currently
loaded service units if no unit name is specified. But with `--root` or
`--image` with `--offline=true`, the `security` command exits silently if no
unit name is specified.

Also, fixed description of `--root` and `--image` in the man page, and added
missing `--unit` option to help text.
2024-01-11 12:19:20 +00:00
Antonio Alvarez Feijoo ca02969379 analyze: man and --help fixes
man:
- `verify` requires an argument
- `security` does not require an argument
- `fdstore` requires an argument
- `image-policy` requires an argument

`--help` text:
- missing `image-policy` command
- `cat-config` requires NAME or PATH
2024-01-09 10:11:59 +01:00
Antonio Alvarez Feijoo 7c0e0bbb6b analyze: fix -q option
Follow-up to 52117f5af8
2024-01-09 09:05:50 +01:00
Mike Yuan bdd2036e81 hexdecoct: make unbase64mem and unhexmem always use SIZE_MAX 2024-01-09 03:59:15 +09:00
Lennart Poettering d4fee8941a confext: make sure we pick up configuration extensions passed to us from the stub
With fixes from Maanya Goenka.
2024-01-03 11:23:27 +01:00
Luca Boccassi 5df839e99f analyze: allow --no-legend with architectures verb
It prints a table with a header, allow omitting it

Follow-up for fb8cc599ed
2023-12-27 17:50:07 +01:00
Yu Watanabe 287a5f1cff Merge pull request #30628 from YHNdnzj/format-table-improvement
Some improvements for format-table
2023-12-25 20:01:32 +09:00
Mike Yuan 2413a0fab4 format-table: introduce table_isempty and use it where appropriate 2023-12-25 17:47:18 +08:00
Yu Watanabe 07e8c3055d tree-wide: drop several doubled space 2023-12-25 02:13:49 +09:00
Mike Yuan c6195c9667 analyze-fdstore: don't log duplicate error
table_print_with_pager() logs print error internally.
2023-12-24 04:27:55 +08:00
Mike Yuan 9e710d2665 analyze-fdstore: ignore table header when checking stored fd count 2023-12-24 04:27:55 +08:00
Yu Watanabe abf0ccc1c6 analyze-verify: verify all executables
ExecStart= and friends for .service and .socket can be specified
multiple times.
This also checks all commands for .mount and .swap, not only for the
current control command.
2023-12-20 23:56:16 +09:00
Frantisek Sumsal 3c4d0ec940 analyze: use strempty() 2023-12-18 17:25:10 +01:00
Yu WatanabeandJeff King 6d9d556579 analyze: also find template unit when a template instance is specified
Fixes a regression caused by 2f6181ad4d.

Fixes #30357.

Co-authored-by: Jeff King <peff@peff.net>
2023-12-11 15:12:38 +09:00
Frantisek Sumsal f57d06c308 analyze: dump system config files with highlighted sections/directives 2023-12-07 15:35:54 +01:00
Yu Watanabe 786a337817 Merge pull request #30060 from poettering/analyze-archs
analyze: add "archs" verb that lists all known architectures
2023-12-07 15:47:30 +09:00
Lennart Poettering bf4ffc43c5 analyze: teach "exit-status" verb json output too 2023-12-06 22:18:14 +01:00
Lennart Poettering 81373a0e28 analyze: teach "capability" verb JSON output too 2023-12-06 22:18:14 +01:00
Lennart Poettering fb8cc599ed analyze: add "architectures" verb that lists all known architectures 2023-12-06 22:18:14 +01:00
Zbigniew Jędrzejewski-Szmek f9568765d4 variuos: fwrite() does not set errno
The man page doesn't even mention errno. It just says that ferror() should
be used to check for errors. Those writes are unlikely to fail, but if they
do, errno might even be 0. Also, we have fflush_and_check() which does
additional paranoia around errno, because we apparently do not trust that
errno will always be set correctly.
2023-12-05 19:18:23 +01:00
Yu Watanabe 33d11a2b69 analyze: return earlier when there is no path to be prepended
Follow-up for 2f6181ad4d.

Addresses the post-merge comment:
https://github.com/systemd/systemd/pull/30172#discussion_r1404209035
2023-11-25 12:52:59 +09:00
Yu Watanabe 2f6181ad4d analyze: do not prepend the current working directory to SYSTEMD_UNIT_PATH needlessly
If the requested unit is not in the current working directory, it is not
necessary to include the current working directory in SYSTEMD_UNIT_PATH.

Follow-up for 45519d13a4.

Fixes #30166.
2023-11-24 05:28:14 +09:00
Yu Watanabe ff7af46edb analyze: set SYSTEMD_UNIT_PATH in verify_generate_path()
Then, rename verify_generate_path() -> verify_set_unit_path().
2023-11-24 05:20:13 +09:00
Yu Watanabe c131e8b706 analyze: shorten code a bit
No functional change, just refactoring.
2023-11-24 05:19:14 +09:00
Yu Watanabe 6636145b3e analyze: drop duplicated :
Before, this returns e.g. "/current_dir::",
After, this returns e.g. "/current_dir:".
2023-11-24 04:44:35 +09:00
Mike Yuan bed6bffc9a analyze: don't open systemd-executor needlessly
Fixes #30162
2023-11-23 20:58:20 +08:00
Mike Yuan 9136de6934 analyze: use FOREACH_ARRAY more 2023-11-23 20:53:46 +08:00
Lennart Poettering d30693f39b analyze: add "srk" verb to extract current srk from TPM2 chip
This is pretty low-level functionality, hence placed in systemd-analyze.
This is useful for working with systemd-cryptenroll --tpm2-device-key=,
as it acquires the SRK without requiring the full tpm2-tss tool set.
2023-11-09 12:48:27 +01:00