Commit Graph

5465 Commits

Author SHA1 Message Date
Luca Boccassi
f00022eb86 Merge pull request #28242 from berrange/cond-sec-cvm
Detect and expose the confidential virtualization technology in various places
2023-07-06 19:14:26 +01:00
Daniel P. Berrangé
a577a61625 add APIs for detecting confidential virtualization
This code uses various CPUID checks to be able to identify

 * AMD SEV
 * AMD SEV-ES
 * AMD SEV-SNP
 * Intel TDX

On HyperV/Azure, it has special checks for detecting SEV-SNP
since the normal CPUID is blocked.

Related: https://github.com/systemd/systemd/issues/27604
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2023-07-06 12:20:04 +01:00
Dan Streetman
3f27ba9954 basic/alloc-util: add greedy_realloc_append()
Add function to perform greedy realloc as well as copying the new data into the
newly allocated space.
2023-07-05 17:33:55 -04:00
Lennart Poettering
6c1d10fe03 update syscall tables for upcoming v254 2023-07-05 23:18:16 +02:00
Lennart Poettering
09d04ad325 core: introduce a new job mode JOB_RESTART_DEPENDENCIES
This new job mode will enqueue a start job for a unit, and all units
depending on the unit will get a restart job enqueued. This is then used
for automatic sevice restarts: the unit itself is only started, the
depending units restarted. This way the unit will not go down
unnecessarily, triggering OnSuccess= needlessly.

This also introduces a new state SERVICE_AUTO_RESTART_QUEUED that is
entered once the restart jobs are enqueued. Previously we'd stay in
SERVICE_AUTO_RESTART, but that's problematic, since we'd lose
information whether we still need to enqueue the restart job during a
serialization/deserialization cycle or not. By having an explicit state
for this we know exactly whether we still need to enqueue the job or
not. It's also good since when we are in SERVICE_AUTO_RESTART_QUEUED we
want to act on unit_start(), but on SERVICE_AUTO_RESTART we want to wait
for the holdoff time to pass before we act on unit_start().

Fixes: #27722
2023-07-03 17:31:25 +02:00
Yu Watanabe
86c2a76e09 Merge pull request #28132 from rpigott/dhcp-captive-portal
Implement RFC8910: captive portal dhcp options
2023-07-03 14:51:56 +09:00
Luca Boccassi
b9d29a2028 Merge pull request #28226 from mrc0mmand/coverity-fixes
A couple of Coverity-related fixes
2023-07-02 15:54:56 +01:00
Frantisek Sumsal
5000cea8d2 tree-wide: explicitly ignore return value in a couple more places
Resolves:
  - CID#1490777
  - CID#1498366
  - CID#1508639
  - CID#1509084
  - CID#1509086
  - CID#1509087
2023-07-02 12:22:45 +02:00
Frantisek Sumsal
9cf7f7a82f virt: drop an unused assignment
As `v` gets overwritten by the following detect_vm_cpuid() call.

Resolves: CID#1509247
2023-07-02 12:22:41 +02:00
Zbigniew Jędrzejewski-Szmek
da89046643 tree-wide: "<n>bit" → "<n>-bit"
In some places, "<n> bits" is used when more appropriate.
2023-07-02 11:10:12 +01:00
Ronan Pigott
7040fd381a dhcp-client: parse RFC8910 captive portal dhcp option 2023-06-29 16:42:16 -07:00
Yu Watanabe
be994c2640 battery-check: several follow-ups
Follow-ups for e3d4148d50.

- add reference to initrd-battery-check.service in man page, and move
  its section from 1 to 8,
- add link to man page in help message,
- introduce ERRNO_IS_NO_PLYMOUTH(),
- propagate error in battery_check_send_plymouth_message(),
- rename battery_check_send_plymouth_message() -> plymouth_send_message(),
- return earlier when the first battery level check passed to reduce
  indentation,
- fix potential use of invalid fd on battery restored,
- do not use emoji for /dev/console,
- add simple test (mostly for coverity),

etc, etc...
2023-06-29 15:41:00 +09:00
Luca Boccassi
f18886fe17 Merge pull request #28164 from poettering/replace-env-var-fixes
pid1: warn about unset+invalid env var names when resolving ExecStart= expressions and similar
2023-06-28 19:40:51 +01:00
Lennart Poettering
4d8eca03e5 Merge pull request #28146 from keszybz/ansi-seq-skip
Pass ANSI sequences through when ellipsizing output
2023-06-28 19:18:27 +02:00
OMOJOLA JOSHUA
e3d4148d50 PID1: detect battery level in initrd and if low refuse continuing to boot, print message and shut down. 2023-06-28 14:48:54 +01:00
Zbigniew Jędrzejewski-Szmek
cb558ab222 string-util: pass ANSI sequences through unchanged
Cutting off in the middle may leave the terminal in a bad state, breaking
further output. But we don't know what a given ANSI sequence does, e.g.
ANSI_NORMAL should not be skipped. But it is also nice to keep various
sequences intact, so that if we had part of the string in blue, and we cut out
the beginning of the blue part, we still want to keep the remainder in color.
So let's just pass them through, stripping out the characters that take up
actual space.

Also, use memcpy_safe as we may end up copying zero bytes when ellipsizing at
the start/end of a string.

Fixes: #24502

This also fixes an ugliness where we would ellipsize string with ANSI
sequences too much, leading to output that was narrower on screen than the
requested length:

  Starting AAAAAAAAAAAAAAAAAAAAA.service
  Starting BBBBBBBBBBBBBBBBBBBBB.service
  Starting LONG…ER.service

Co-authored-by: Jan Janssen <medhefgo@web.de>
2023-06-27 16:55:02 -06:00
Lennart Poettering
f331434d13 env-file: when resolving env vars in command lines, collect list of unset/invalid ones
When resolving environment variables we currently silently resolve unset
and invalid environment variables to empty strings. Let's do this
slightly less silently: log about unset and invalid env vars, but still
resolve them to an empty string.

Fixes: #27036
2023-06-27 13:49:46 +02:00
Lennart Poettering
7658139c01 env-util: make strv_env_get() a static inline wrapper around strv_env_get_n()
Let's make length = SIZE_MAX also mean "call strlen()".
2023-06-27 13:49:46 +02:00
Lennart Poettering
d5ce24c99e env-util: introduce proper flags type ReplaceEnvFlags for replace_env() 2023-06-27 13:49:46 +02:00
Lennart Poettering
10930fbb1c env-util: add explicit size check before strndupa() in strv_env_get_n()
Let's better be safe than sorry.
2023-06-27 13:49:46 +02:00
Lennart Poettering
2b07147e9c env-util: modernize env_name_is_valid_n() a bit
If the size is specified as SIZE_MAX, then imply strlen().
2023-06-27 13:49:46 +02:00
Lennart Poettering
6b9f600772 string-util: add strextendn() helper 2023-06-27 13:49:46 +02:00
Zbigniew Jędrzejewski-Szmek
9579e9a530 basic/utf8: make utf8_encoded_to_unichar() return length of the codepoint 2023-06-23 17:24:42 -06:00
Lennart Poettering
d39cdbb3bf Merge pull request #27330 from YHNdnzj/hibernate-resume-auto
sleep/hibernate-resume: pass hibernate location through efivar for resume without kernel cmdline
2023-06-23 23:03:32 +02:00
Lennart Poettering
031d21bc45 Merge pull request #27843 from yuwata/usleep_safe
time-util: introduce usleep_safe()
2023-06-23 23:03:15 +02:00