1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-07 17:17:44 +03:00
Commit Graph

61781 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
ca6ce62d2a manager: execute generators in a mount namespace "sandbox"
When generators are executed during early boot, /tmp might not be available
yet. This causes problems with bash, because here-docs don't work. Even
non-shell code can often assume that /tmp is available. This limitation is
known to trip up people, and when the code is tested on a "normal" system,
everything works.

We can solve this nicely, and get another small benefit, by making most of the
file system read-only and "punching holes" for some dirs that should be
writable. The generator code runs with full privileges and can do anything it
wants by writing appropriate systemd units, so it doesn't make much sense to do
any significant sandboxing around generators. But making root read-only is nice
because it can catch stupid mistakes where the generator tries to write to a
wrong path or something like that. We effectively also get a "private /tmp" for
the generators, which protects them against existing files in /tmp.

The path does the following:
when executing generators, we fork, and the child unshares root and makes
it recursively read-only, with the exception of /sys and /run. Error handling
is permissive — if some of this setup fails, we're in the same state as
before the patch.

Fixes #24430.
2022-12-14 22:12:44 +01:00
Zbigniew Jędrzejewski-Szmek
61ef30515b shared: add new safe_fork flag FORK_PRIVATE_TMP
If the flag is set, we mount /tmp/ in a way that is suitable for generators and
other quick jobs.

Unfortunately I had to move some code from shared/mount-util.c to
basic/mountpoint-util.c. The functions that are moved are very thin wrappers
around mount(2), so this doesn't actually change much in the code split between
libbasic and libshared.

Implications for the host would be weird if a private mount namespace is not
used, so assert on FORK_NEW_MOUNTNS when the flag is used.
2022-12-14 22:12:44 +01:00
Nick Rosbrook
3a9ca23036 journal: skip part of test-journal-interleaving if no machine-id exists
When executed on a systemd with an empty /etc/machine-id,
test-journal-interleaving fails in test_sequence_numbers_one() when
re-opening the existing "two.journal". This is because opening the
existing journal file with managed_journal_file_open() causes
journal_file_verify_header() to be called. This function tries to
compare the current machine-id to the machine-id in the journal file
header, but does not handle the case where the machine-id is empty or
non-existent.

Check if we have an initialized machine-id before executing this portion
of the test.
2022-12-14 13:58:12 -05:00
Nick Rosbrook
2c6b738bad test-load-fragment: simplify machine-id check 2022-12-14 13:58:12 -05:00
Nick Rosbrook
a635b6279c test-unit-name: simplify machine-id check 2022-12-14 13:58:12 -05:00
Nick Rosbrook
079fcdd04f test-fs-util: skip part of test_chase_symlinks if machine-id is not initialized
The part of test_chase_symlink in test-fs-util that calls
sd_id128_get_machine will fail if /etc/machine-id is empty, so skip this
block if the machine-id is not initialized.
2022-12-14 13:58:12 -05:00
Nick Rosbrook
415eb50570 test-id128: simplify machine-id check
This also ensures that the test is skipped when /etc/machine-id exists,
but is not initialized.
2022-12-14 13:58:12 -05:00
Yu Watanabe
f74a7cb45c unit: check more specific path to be written by systemd-binfmt
Follow-up for 41807efb15.
Replaces #25690.
2022-12-15 03:36:27 +09:00
Yu Watanabe
94ba5b1532 binfmt: check if binfmt is mounted before applying rules 2022-12-15 03:36:27 +09:00
Yu Watanabe
5aaa79ce96 binfmt-util: also check if binfmt is mounted in read-write 2022-12-15 03:36:24 +09:00
Yu Watanabe
713e6e631d timesync: ignore IPv6 addresses when the kernel does not support IPv6
Fixes #25728.
2022-12-15 03:30:13 +09:00
Yu Watanabe
a51a9684c9 binfmt-util: split out binfmt_mounted()
No functional changes, just refactoring and preparation for later
commits.
2022-12-15 03:26:39 +09:00
Yu Watanabe
dc1752ea72 stat-util: introduce fd_is_read_only_fs()
Then, reimplement path_is_read_only_fs() by the function to avoid race.
2022-12-15 03:25:09 +09:00
Lennart Poettering
a04709c1ac efi: add common implementation for loop finding EFI configuration tables 2022-12-14 19:16:54 +01:00
Lennart Poettering
50b0b0d351 efi: add efi_guid_equal() helper 2022-12-14 19:16:54 +01:00
Lennart Poettering
5c6c587ce2
Merge pull request #25575 from brauner/nspawn.socket_surgery
nspawn: reduce number of sockets
2022-12-14 18:36:44 +01:00
Yu Watanabe
30a3181504
Merge pull request #25734 from yuwata/sd-id128
sd-id128: several followups
2022-12-15 02:23:03 +09:00
Felix Riemann
9b4e04f0cd timesync: Keep trying to connect even if the socket cannot be opened
This makes sure that after a server could not be contacted due to a
socket error, other (possibly working) NTP servers in the list of
configured NTP servers are (re-)tried.

Fixes #25728.
2022-12-15 02:21:25 +09:00
MVZ Ludwigsburg
a76d7acae1 hwdb: Add mount matrix for CSL Panther Tab HD 2022-12-15 02:20:43 +09:00
Siddhesh Poyarekar
7929e180aa Use dummy allocator to make accesses defined as per standard
systemd uses malloc_usable_size() everywhere to use memory blocks
obtained through malloc, but that is abuse since the
malloc_usable_size() interface isn't meant for this kind of use, it is
for diagnostics only.  This is also why systemd behaviour is flaky when
built with _FORTIFY_SOURCE.

One way to make this more standard (and hence safer) is to, at every
malloc_usable_size() call, also 'reallocate' the block so that the
compiler can see the larger size.  This is done through a dummy
reallocator whose only purpose is to tell the compiler about the larger
usable size, it doesn't do any actual reallocation.

Florian Weimer pointed out that this doesn't solve the problem of an
allocator potentially growing usable size at will, which will break the
implicit assumption in systemd use that the value returned remains
constant as long as the object is valid.  The safest way to fix that is
for systemd to step away from using malloc_usable_size() like this.

Resolves #22801.
2022-12-14 17:49:47 +01:00
Yu Watanabe
f0d8358c24 man: update documents for sd_id128_get_invocation() 2022-12-15 00:07:17 +09:00
Yu Watanabe
75fa1f25c0 sd-id128: also refuse an empty invocation ID 2022-12-15 00:07:17 +09:00
Yu Watanabe
786b652c89 sd-id128: allow sd_id128_get_machine() and friend to be called with NULL
It may be useful to check if the machine ID or friends is set or not.
2022-12-15 00:07:17 +09:00
Yu Watanabe
e8a6625422 sd-id128: make sd_id128_get_machine() or friends return -EUCLEAN when an ID is in an invalid format
EINVAL suggests that the caller passes an invalid argument. EIO is
for "input/output error", i.e. the error you'd get if the disk or
file system is borked, and this error code could be returned by the
underlying read/write functions.

Let's make the functions return an unambiguous error code.
2022-12-15 00:07:13 +09:00
Yu Watanabe
7a12328735 timesync: downgrade log message about unsupported address family
As this is mostly not user's fault.
2022-12-14 23:55:21 +09:00
David Tardon
cc137d53e3 swap: tell swapon to reinitialize swap if needed
If the page size of a swap space doesn't match the page size of the
currently running kernel, swapon will fail. Let's instruct it to
reinitialize the swap space instead.
2022-12-14 15:48:10 +01:00
Luca Boccassi
e146136304
Merge pull request #25717 from bluca/reload
manager: log reload() sender and allow rate-limiting
2022-12-14 15:45:22 +01:00
Yu Watanabe
bdc11d26d1 NEWS: fix typo 2022-12-14 20:41:42 +09:00
Yu Watanabe
56b7f112ed locale-setup: avoid TOCTOU in reading locale.conf 2022-12-14 20:18:58 +09:00
Yu Watanabe
00afa6a38f locale-setup: make failure in stat() critical
The file was created by this function. Hence, the failure is something
critical.
2022-12-14 20:18:58 +09:00
Yu Watanabe
50359113e9 locale-setup: clear partially loaded context on failure 2022-12-14 20:18:58 +09:00
Yu Watanabe
018befcff6 locale-setup: split locale_context_load() into small pieces
No functional change, just refactoring and preparation for later
commits.
2022-12-14 20:18:58 +09:00
Yu Watanabe
7294912f18 localed: avoid TOCTOU in loading config 2022-12-14 20:18:58 +09:00
Yu Watanabe
649512b934 env-file: introduce parse_env_file_fd() 2022-12-14 20:18:58 +09:00
Yu Watanabe
dd57a22e6a env-file: several cleanups
- add missing assertions,
- rename function arguments for storing results,
- add typedef for callback.
2022-12-14 20:18:58 +09:00
Yu Watanabe
0ec8777e18
Merge pull request #25726 from dtardon/cleanups
Several small cleanups
2022-12-14 20:17:56 +09:00
Yu Watanabe
863b620a4a resolve: fix NULL-pointer dereference
Fixes a bug introduced by 16a6bc5a7a.
Fixes CID#1501514.
2022-12-14 19:10:19 +09:00
Jiayi Chen
b1c4466bba doc: add language decorator on the code block
Add `c` decorator on the code block for applying syntax highlighting.
2022-12-14 18:07:07 +09:00
David Tardon
246caacbb4 btrfs-util: shorten a bit 2022-12-14 09:57:35 +01:00
David Tardon
359e8d76e8 machine: propagate error from machine_new 2022-12-14 09:57:35 +01:00
David Tardon
38f514409a machine: use _cleanup_ in machine_new 2022-12-14 09:57:35 +01:00
David Tardon
d2b6485385 localed-util: use _cleanup_ harder 2022-12-14 09:57:35 +01:00
David Tardon
6323bd1094 busctl-introspect: use _cleanup_ 2022-12-14 09:56:33 +01:00
Zbigniew Jędrzejewski-Szmek
357f5ccbf6
Merge pull request #25689 from YHNdnzj/systemctl-exit-code
systemctl: make is-* return EXIT_PROGRAM_OR_SERVICES_STATUS_UNKNOWN(4) when no unit file is found
2022-12-14 08:37:16 +01:00
Daan De Meyer
8275334bec repart: Rename --skip-partitions to --defer-partitions
Defer is better because it indicates that we still intend to
populate these partitions later.
2022-12-14 13:20:32 +09:00
Luca Boccassi
7fe1e7448f
Merge pull request #25706 from yuwata/hwdb-pointing-stick
hwdb: several fixes for pointing stick
2022-12-14 01:38:55 +01:00
Luca Boccassi
71f7cc6a9e
Merge pull request #25725 from keszybz/oom-policy-fixup
Add missing integration of OOMPolicy in scope units
2022-12-14 01:38:11 +01:00
Daan De Meyer
57db3399c3 mkosi: Enable CONFIG_ZBOOT
Required to boot mkosi images with systemd-boot on aarch64.
2022-12-13 21:27:15 +01:00
Zbigniew Jędrzejewski-Szmek
3b288a2d2b NEWS: add a bunch of entries for v253
During the call today we agreed to work towards -rc1 in January. Nevertheless,
I already started writing this up and I'll push it so it doesn't get lost.

I didn't include all the changes to systemd-repart, because those are still in
flux.
2022-12-13 20:25:59 +01:00
Luca Boccassi
856bfaeb05 manager: add option to rate limit daemon-reload
Reloading is a heavy-weight operation, and currently it is not
possible to stop an orchestrator from spamming reload requests.
Add configuration options to allow rate-limiting.
2022-12-13 18:13:10 +00:00