1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-09 01:18:19 +03:00
Commit Graph

56628 Commits

Author SHA1 Message Date
Lennart Poettering
fe81e346c8 man: document recent changes
This drops documentation of KERNEL_INSTALL_MACHINE_ID as machine-info
field (though we'll still read it for compat).

This updates the kernel-install man page to always say "ENTRY-TOKEN"
instead of "MACHINE-ID" where appropriate, to clear the confusion up
between the two.

This also tries to fix how we denote env vars (always prefix with $ and
without = suffix), and other vars (without $ but with = suffix)

Other fixes.
2022-03-11 11:39:34 +01:00
Lennart Poettering
c73cf41844 kernel-install: add new "inspect" verb, showing paths and parameters we discovered 2022-03-11 11:39:34 +01:00
Lennart Poettering
6637cf9db6 kernel-install: search harder for kernel image/initrd drop-in dir
If not explicitly configured, let's search a bit harder for the
ENTRY_TOKEN, and let's try the machine ID, the IMAGE_ID and ID fields of
/etc/os-release and finally "Default", all below potential $XBOOTLDR.
2022-03-11 11:34:34 +01:00
Lennart Poettering
953b61004c kernel-install: only generate systemd.boot_id= in kernel command line if used for naming the boot loader spec files/dirs
Now that we can distinguish the naming of the boot loader spec
dirs/files and the machine ID let's tweak the logic for suffixing the
kernel cmdline with systemd.boot_id=: let's only do that when we
actually need the boot ID for naming these dirs/files. If we don't,
let's not bother.

This should be beneficial for "golden" images that shall not carry any
machine IDs at all, i.e acquire their identity only once the final
userspace is actually reached.
2022-03-11 11:34:34 +01:00
Lennart Poettering
3907044ffa kernel-install: add a new $ENTRY_TOKEN variable for naming boot entries
This cleans up naming of boot loader spec boot entries a bit (i.e. the
naming of the .conf snippet files, and the directory in $BOOT where the
kernel images and initrds are placed), and isolates it from the actual machine
ID concept.

Previously there was a sinlge concept for both things, because typically
the entries are just named after the machine ID. However one could also
use a different identifier, i.e. not a 128bit ID in which cases issues
pop up everywhere. For example, the "machine-id" field in the generated
snippets would not be a machine ID anymore, and the newly added
systemd.machine_id= kernel parameter would possibly get passed invalid
data.

Hence clean this up:

$MACHINE_ID → always a valid 128bit ID.

$ENTRY_TOKEN → usually the $MACHINE_ID but can be any other string too.
This is used to name the directory to put kernels/initrds in. It's also
used for naming the *.conf snippets that implement the Boot Loader Type
1 spec.
2022-03-11 11:34:34 +01:00
Lennart Poettering
11ce3ea2f2 kernel-install: don't try to persist used machine ID locally
This reworks the how machine ID used by the boot loader spec snippet
generation logic. Instead of persisting it automatically to /etc/ we'll
append it via systemd.machined_id= to the kernel command line, and thus
persist it in the generated boot loader spec snippets instead. This has
nice benefits:

  1. We do not collide with read-only root
  2. The machine ID remains stable across factory reset, so that we can
     safely recognize the path in $BOOT we drop our kernel images in
     again, i.e. kernel updates will work correctly and safely across
     kernel factory resets.
  3. Previously regular systems had different machine IDs while in
     initrd and after booting into the host system. With this change
     they will now have the same.

This then drops implicit persisting of KERNEL_INSTALL_MACHINE_ID, as its
unnecessary then. The field is still honoured though, for compat
reasons.

This also drops the "Default" fallback previously used, as it actually
is without effect, the randomized ID generation already took precedence
in all cases. This means $MACHNE_ID/KERNEL_INSTALL_MACHINE_ID are now
guaranteed to look like a proper machine ID, which is useful for us,
given you need it that way to be able to pass it to the
systemd.machine_id= kernel command line option.
2022-03-11 11:34:34 +01:00
Lennart Poettering
15e152acd1
Merge pull request #22618 from yuwata/network-safe-string
network: dhcp-server: refuse unsafe filename
2022-03-11 11:33:07 +01:00
Marcel Hellwig
37035235df fix signature of sd_journal_print_with_location in docs 2022-03-11 11:32:20 +01:00
Clyde Byrd III
1015da0930 gitignore: ignore mkosi.installdir 2022-03-11 09:34:04 +00:00
Yu Watanabe
6278e42878 network: dhcp: rename NextServer= and Filename= settings
And make the settings configures DHCP option 66 and 67.

Follow-ups for #22615.
Fixes #22661.
2022-03-11 10:14:57 +09:00
Luca Boccassi
0d3c36641d
Merge pull request #22701 from poettering/raise-memlock
pid1/nspawn: raise RLIMIT_MEMLOCK to 8M matching kernel 5.16's new default
2022-03-11 01:09:33 +00:00
Clyde Byrd III
f4ca32a1bc core/dbus-job: Use new way of specifying sd-bus vtable parameter names 2022-03-11 09:00:18 +09:00
Lennart Poettering
0da2bb7414 hostname-util: normalize get_pretty_hostname() call semantics
get_pretty_hostname() so far had semantics not in line with our usual
ones: the return parameter was actually freed before the return string
written into it, because that's what parse_env_file() does. Moreover,
when the value was not set it would return NULL but succeed.

Let's normalize this, and only fill in the return value if there's
something set, and never read from it, like we usually do with return
parameter, and in particular those named "ret_xyz".

The existing callers don't really care about the differences, but it's
nicer to normalize behaviour to minimize surprises.
2022-03-10 23:05:44 +00:00
Luca Boccassi
bed1f67874
Merge pull request #22705 from mrc0mmand/pretty_hostname_specifier
core: introduce %R specifier for pretty hostname
2022-03-10 21:45:34 +00:00
Frantisek Sumsal
217d4a1164 cgls: mangle user-provided unit names
so the CLI interface is now similar to `systemctl`, i.e. if no unit name
suffix is provided, assume `.service`.

Fixes: #20492

Before:
```
$ systemd-cgls --unit user@1000
Failed to query unit control group path: Invalid argument
Failed to list cgroup tree: Invalid argument
```

After:
```
$ build/systemd-cgls --unit user@1000
Unit user@1000.service (/user.slice/user-1000.slice/user@1000.service):
├─session.slice (#4939)
│ ├─pipewire-pulse.service (#5203)
│ │ └─7711 /usr/bin/pipewire-pulse
...
```
2022-03-10 20:47:30 +00:00
Luca Boccassi
24759d8f08 core: support ExtensionDirectories in user manager
Unprivileged overlayfs is supported since Linux 5.11. The only
change needed to get ExtensionDirectories to work is to avoid
hard-coding the staging directory to the system manager runtime
directory, everything else just works (TM).
2022-03-10 20:38:10 +00:00
Temuri Doghonadze
270fd40da5 po: Translated using Weblate (Georgian)
Currently translated at 100.0% (189 of 189 strings)

Co-authored-by: Temuri Doghonadze <temuri.doghonadze@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/ka/
Translation: systemd/main
2022-03-10 18:45:50 +00:00
Frantisek Sumsal
6ceb0a4094 core: introduce %R specifier for pretty hostname
Resolves: #20054
2022-03-10 19:03:22 +01:00
Lennart Poettering
69a21030b1
Merge pull request #22460 from bluca/monitor_refactor
core: split $MONITOR_METADATA and return it only if a single unit triggers OnFailure/OnSuccess
2022-03-10 18:34:20 +01:00
Lennart Poettering
852b62507b pid1,nspawn: raise default RLIMIT_MEMLOCK to 8M
This mirrors a similar check in Linux kernel 5.16
(9dcc38e2813e0cd3b195940c98b181ce6ede8f20) that raised the
RLIMIT_MEMLOCK to 8M.

This change does two things: raise the default limit for nspawn
containers (where we try to mimic closely what the kernel does), and
bump it when running on old kernels which still have the lower setting.

Fixes: #16300
See: https://lwn.net/Articles/876288/
2022-03-10 18:30:24 +01:00
Lennart Poettering
eadb4f19b3 main: add 'const' on two function arguments 2022-03-10 18:30:24 +01:00
Luca Boccassi
a8c5363ba9
Merge pull request #22682 from bluca/start_skip
core: do not return 'skipped' when Condition*= fail with StartUnitWithFlags()
2022-03-10 17:25:44 +00:00
Luca Boccassi
e2cb73c946
Merge pull request #22695 from poettering/crash-handle-refactor
pid1: add comment clarifying not to use memory allocation from crash handler
2022-03-10 16:42:50 +00:00
Frantisek Sumsal
b6e78cdde1 core: be a bit more defensive when resolving specifiers 2022-03-10 17:29:29 +01:00
Zbigniew Jędrzejewski-Szmek
a257c941ad manager: pass monitor metadata in more cases
The first ExecStartPre or the first ExecStart commands would get the metadata,
but not the subsequent ones. Also check that we do not pass it in
ExecStartPost.
2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek
02de9614d4 manager: prevent cleanup of triggering units before we start the handler
This fixes the following case:
OnFailure= would be spawned correctly, but OnSuccess= would be
spawned without the MONITOR_* metadata, because we'd "collect" the unit
that started successfully. So let's block cleanup while we have a job
running for the handler. The job cannot last infinitely, so at some point
we'll be able to collect both.
2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek
7a5049c780 manager/service: when we have multiple candidates to handle, warn
This would be very confusing to users, so let's warn if they configured the
same handler for multiple units and we're not running it as expected.
2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek
edbf8984a4 manager/service: when we spawn, say why
We already logged what we are spawning, but not so much why. Let's
add this, so it's easier to distinguish execstartpre/execstart/execstartpost
and such.
2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek
82acee149c manager: log how many OnSuccess/OnFailure jobs were started 2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek
adf769b06c manager: adjust comment 2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek
fb1381662b various: align vertically for ease of reading 2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek
f086cca248 TEST-68: enhance testing of chained commands
The test would fail when the the same handler was used for multiple
*failing* units. We need to call 'reset-failed' to let the manager forget
about the earlier ones.

systemd-analyze log-target console is removed, because it's easier to follow
the logs if logging it to the journal.
2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek
ff7b9a2693 TEST-68-PROPAGATE-EXIT-STATUS: deobfuscate shell code and fix typo
After the cleanup, it was fairly easy to see the wrong variable name ;)
2022-03-10 14:43:14 +00:00
Luca Boccassi
3fbd5f2007 NEWS: note backward-incompatible MONITOR_METADATA change 2022-03-10 14:43:14 +00:00
Luca Boccassi
c19c4ab148 test: cover template OnFailure/OnSuccess handlers in TEST-68-PROPAGATE-EXIT-STATUS 2022-03-10 14:43:14 +00:00
Luca Boccassi
95c81c55b2 core: split $MONITOR_METADATA and return it only if a single unit triggers OnFailure/OnSuccess
Remove the list logic, and simply skip passing metadata if more than one
unit triggered an OnFailure/OnSuccess handler.
Instead of a single env var to loop over, provide each separate item
as its own variable.

Fixes https://github.com/systemd/systemd/issues/22370
2022-03-10 14:43:14 +00:00
Luca Boccassi
169bb1dee9 NEWS: note backward-incompatible change in StartUnitWithFlags() 2022-03-10 13:18:28 +00:00
Luca Boccassi
ee3ae55e75 core: do not return 'skipped' when Condition*= fail with StartUnitWithFlags()
Backward incompatible change to avoid returning 'skipped' if a condition causes
a job activation to be skipped when using StartUnitWithFlags().
Job results are broadcasted, so it is theoretically possible that existing
software could get confused if they see this result.

Replaces https://github.com/systemd/systemd/pull/22369
2022-03-10 13:16:21 +00:00
Luca Boccassi
bd844eae23
Merge pull request #22685 from bluca/user_root_dir
core: support MountAPIVFS and RootDirectory in user manager
2022-03-10 13:12:19 +00:00
Lennart Poettering
898c9a6f97 pid1: split out crash handler logic into its own .c/.h file
This stuff is sufficiently different from the rest of main.c, let's move
it to its own .c/.h file, to make main.c a bit shorter.

No code changes, just some refactoring.
2022-03-10 13:45:14 +01:00
Lennart Poettering
4fba096ba1 pid1: add comment to crash handler about memory allocations 2022-03-10 13:45:09 +01:00
Yu Watanabe
999fc88331
Merge pull request #22595 from poettering/logind-action-refact
logind: some minor refactoring around logind's HandleAction logic
2022-03-10 20:56:15 +09:00
Luca Boccassi
ea63a260d4 core: support MountAPIVFS and RootDirectory in user manager
The only piece missing was to somehow make /proc appear in the
new user+mount namespace. It is not possible to mount a new
/proc instance, not even with hidepid=invisible,subset=pid, in
a user namespace unless a PID namespace is created too (and also
at the same time as the other namespaces, it is not possible to
mount a new /proc in a child process that creates a PID namespace
forked from a parent that created a user+mount namespace, it has
to happen at the same time).

Use the host's /proc with a bind-mount as a fallback for this
case. User session services would already run with it, so
nothing is lost.
2022-03-10 10:21:03 +00:00
licunlong
28c5859fa3 main: drop get_process_cmdline from crash handler
get_process_cmdline calls malloc, which should be avoid in signal handler.

Fixes: #22690
2022-03-10 09:19:50 +01:00
Yu Watanabe
71a9e3a304 dhcp: list all known message type 2022-03-10 14:47:28 +09:00
Yu Watanabe
3d80c57b7e sd-dhcp6-client: rename timezone options
To make them follow corresponding DHCPv4 options.
2022-03-10 14:47:28 +09:00
Yu Watanabe
3cb62efef8 dhcp: list all known DHCP options 2022-03-10 14:47:28 +09:00
Yu Watanabe
fa787a13e2 conf-parser: introduce config_parse_dns_name() and config_parse_hostname()
This makes nspawn refuse hostnames which are invalid DNS domain names.
2022-03-10 14:47:19 +09:00
Yu Watanabe
1aaab93621 network: refuse string which contains non-safe or non-ascii characters for Filename=
The string will be used when the client load additional config file to
boot, and it must be a valid path or url. Hence, let's refuse non-safe or
non-characters.
2022-03-10 14:43:48 +09:00
Yu Watanabe
e289ce7f67 conf-parser: introduce CONFIG_PARSE_STRING_ASCII flag
When the flag is set, the string which contains non-ascii characters
will be refused.
2022-03-10 14:43:48 +09:00