Commit Graph

69142 Commits

Author SHA1 Message Date
Lennart Poettering
ffc1ec73b3 pid1: add ProtectSystem= as system-wide configuration, and default it to true in the initrd
This adds a new ProtectSystem= setting that mirrors the option of the
same of services, but in a more restrictive way. If enabled will remount
/usr/ to read-only, very early at boot. Takes a special value "auto"
(which is the default) which is equivalent to true in the initrd, and
false otherwise.

Unlike the per-service option we don't support full/strict modes, but
the door is open to eventually support that too if it makes sense. It's
not entirely trivial though as we have very little mounted this early,
and hence the mechanism might not apply 1:1. Hence in this PR is a
conservative first step.

My primary goal with this is to lock down initrds a bit, since they
conceptually are mostly immutable, but they are unpacked into a mutable
tmpfs. let's tighten the screws a bit on that, and at least make /usr/
immutable.

This is particularly nice on USIs (i.e. Unified System Images, that pack
a whole OS into a UKI without transitioning out of it), such as
diskomator.
2023-12-06 22:10:20 +01:00
Daan De Meyer
8e3dc737b2 Merge pull request #30241 from poettering/journalctl-short-file-switch
journalctl: add short option "-i" for "--file="
2023-12-06 22:07:41 +01:00
Zbigniew Jędrzejewski-Szmek
f8d67130b8 coredump: keep core files for two weeks
We have two mechanisms that remove old coredumps: systemd-coredump has
parameters based on disk use / remaining disk free, and systemd-tmpfiles does
cleanup based on time. The first mechanism should prevent us from using too much
disk space in case something is crashing continuously or there are very large
core files.

The limit of 3 days makes it likely that the core file will be gone by the time
the admin looks at the issue. E.g. if something crashes on Friday, the coredump
would likely be gone before people are back on Monday to look at it.
2023-12-06 22:05:20 +01:00
Alan Liang
67001c2534 core: add specifier expansion to AllowedCPUs= and friends 2023-12-06 22:04:28 +01:00
Topi Miettinen
58c6e75f26 network/networkd-address: don't set up firewall rules here
Don't set up firewall rules when we're just initializing the firewall context
for NFT sets.

Fixes: #30257
2023-12-06 22:04:00 +01:00
Mike Yuan
374c29fc88 shared/killall: correctly warn about rootfs daemon's root
Follow-up for 9e615117da

We'll typically send signals to all remaining processes in the following
cases:

1. pid1 (in initrd) when transitioning from initrd to sysroot: SIGTERM
2. pid1 (in sysroot) before transitioning back to initrd (exitrd): SIGTERM + SIGKILL
3. systemd-shutdown (in exitrd): SIGTERM + SIGKILL

'warn_rootfs' is set to true only when we're not in initrd and we're
sending SIGKILL, which means the second case. So, we want to emit the
warning when the root of the storage daemon IS the same as that of pid1,
rather than the other way around.

The condition is spuriously reversed in the offending commit.
2023-12-06 22:03:35 +01:00
Frantisek Sumsal
b28940ca10 loginctl: show a nicer error message when no session/seat is available
When calling loginctl {seat,session}-status without arguments, show a nicer
error message in case there's no suitable session/seat attached to the calling
tty.

Before:
~# loginctl seat-status
Could not get properties: Unknown object '/org/freedesktop/login1/seat/auto'.
~# systemd-run -q -t loginctl seat-status
Could not get properties: Unknown object '/org/freedesktop/login1/seat/auto'.
~# systemd-run -q -t loginctl session-status
Could not get properties: Unknown object '/org/freedesktop/login1/session/auto'.

After:
~# build/loginctl seat-status
Failed to get path for seat 'auto': Session '1' has no seat.
~# systemd-run -q -t build/loginctl seat-status
Failed to get path for seat 'auto': Caller does not belong to any known session and doesn't own any suitable session.
~# systemd-run -q -t build/loginctl session-status
Failed to get path for session 'auto': Caller does not belong to any known session and doesn't own any suitable session.

Resolves: #25199
2023-12-06 22:02:44 +01:00
Daan De Meyer
3ed6f7a57e Merge pull request #30340 from yuwata/repart-error-handling-ftruncate
repart: fix coding style of error handling
2023-12-06 22:02:01 +01:00
Daan De Meyer
96675f5c14 Merge pull request #30343 from keszybz/ukify-genkey
Raise error if 'ukify genkey' is called with no output arguments
2023-12-06 22:01:41 +01:00
Luca Boccassi
d5401e36dc Merge pull request #30332 from bluca/softreboot_pivot_in_place
switch-root: also check that mount IDs are the same, not just inodes
2023-12-06 21:01:13 +00:00
Luca Boccassi
f9a284f02d Merge pull request #30214 from bluca/wants_mounts_for
Add WantsMountsFor= and use it in the cryptsetup generator
2023-12-06 21:00:37 +00:00
Luca Boccassi
db11bab38c NEWS: finalize for v255 2023-12-06 20:32:40 +00:00
Luca Boccassi
fa8e6bb3b2 Merge pull request #30334 from DaanDeMeyer/repart-fixes
repart: Add Minimize=best to --make-ddi= partition definitions
2023-12-06 20:29:04 +00:00
Lennart Poettering
261ee3d539 README: mention Matrix channel 2023-12-06 18:27:16 +00:00
Luca Boccassi
5c1557888f Merge pull request #30341 from bluca/news
Update hwdb and NEWS
2023-12-06 16:57:29 +00:00
Daan De Meyer
1500fe38b2 test: Add test case for --make-ddi=sysext
Also make sure that the sysext is big enough to not fit in the
minimum partition size so we know Minimize= is being used.
2023-12-06 12:18:32 +01:00
Daan De Meyer
ebd6606515 repart: Add Minimize=best to --make-ddi= partition definitions
Otherwise, repart won't calculate the minimal size of the partition
automatically and things will fail once the partitions exceed the
minimal partition size (10M).
2023-12-06 11:54:48 +01:00
Zbigniew Jędrzejewski-Szmek
f3d50fb2c6 ukify: raise error if genkey is called with no output arguments
The idea is that genkey is called with either
--secureboot-private-key= + --secureboot-certificate=, and then it
writes those, or with --pcr-private-key + optionally --pcr-public-key
and then it writes those, or both. But when called with no arguments
whatsover, it did nothing.

There is no implicit value for any of those parameters as input (unlike in
mkosi), so we also don't want to have implicit values when used as output.
But we shouldn't return success if no work was done, this is quite confusing.
2023-12-06 11:46:04 +01:00
Zbigniew Jędrzejewski-Szmek
7b0760ca9c ukify: remove stray line
As requested in review.
2023-12-06 11:44:40 +01:00
Zbigniew Jędrzejewski-Szmek
b6ecab8541 ukify: add test for --secureboot-certificate-validity=
Follow-up for bf35f9c835.
2023-12-06 11:44:40 +01:00
Luca Boccassi
a7418691e4 hwdb: update
ninja -C build update-hwdb
2023-12-06 10:06:50 +00:00
Luca Boccassi
48696c2d37 NEWS: note that newly introduced tools are experimental
So that we can change interfaces for at least one release if needed
2023-12-06 10:00:25 +00:00
Luca Boccassi
e6e335b5d4 NEWS: update contributors list 2023-12-06 09:57:38 +00:00
Roland Singer
bf35f9c835 ukify: fix handling of --secureboot-certificate-validity= (#30315)
Before:
$ python src/ukify/ukify.py genkey --secureboot-private-key=sb2.key --secureboot-certificate=sb2.cert --secureboot-certificate-validity=111
Traceback (most recent call last):
  File "/home/zbyszek/src/systemd-work/src/ukify/ukify.py", line 1660, in <module>
    main()
  File "/home/zbyszek/src/systemd-work/src/ukify/ukify.py", line 1652, in main
    generate_keys(opts)
  File "/home/zbyszek/src/systemd-work/src/ukify/ukify.py", line 943, in generate_keys
    key_pem, cert_pem = generate_key_cert_pair(
                        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zbyszek/src/systemd-work/src/ukify/ukify.py", line 891, in generate_key_cert_pair
    now + ONE_DAY * valid_days
          ~~~~~~~~^~~~~~~~~~~~
TypeError: can't multiply sequence by non-int of type 'datetime.timedelta'

Now:
$ python src/ukify/ukify.py genkey --secureboot-private-key=sb2.key --secureboot-certificate=sb2.cert --secureboot-certificate-validity=111
Writing SecureBoot private key to sb2.key
Writing SecureBoot certificate to sb2.cert

The new code is also clearer.
2023-12-06 10:49:47 +01:00
Mike Yuan
9f08d7f777 repart: use correct errno 2023-12-06 10:03:21 +01:00
Yu Watanabe
6c7f4badea repart: fix coding style of error handling
Follow-up for c4a87b76c3.
2023-12-06 11:35:10 +09:00
Frantisek Sumsal
1ea27bd79e test: load the io controller before checking if io.latency exists
Otherwise the following test gets always skipped.
2023-12-05 19:58:48 +00:00
Daan De Meyer
0689d46a75 repart: Fix sysext definitions for --make-ddi=
CopyFiles= does not support multiple directories separated by
whitespace. Instead the setting has to be specified multiple times.
2023-12-05 19:26:58 +00:00
Luca Boccassi
a14b75e218 selinux: downgrade log about state to trace
It is printed on every invocation of sd-executor, which is noisy and not useful

Follow-up for: bb5232b6a3
2023-12-05 19:25:50 +00:00
Luca Boccassi
f83a74dfb8 switch-root: also check that mount IDs are the same, not just inodes
If /run/nextroot/ has been set up, use it, even if the inodes are
the same. It could be a verity device that is reused, but with
different sub-mounts or other differences. Or the same / tmpfs with
different /usr/ mounts. If it was explicitly set up we should use it.

Use the new helper to check that the mount IDs are also the same,
not just the inodes.
2023-12-05 17:20:27 +00:00
Luca Boccassi
5134e54625 basic: add fds_are_same_mount() helper 2023-12-05 17:20:27 +00:00
Yu Watanabe
829732d40a basic: fix typo 2023-12-05 23:50:25 +09:00
huyubiao
3769ba7570 fix: The example2 in hwdb.xml is unreasonable
use evdev:atkbd:dmi:bvnAcer:bvr:bdXXXXX:bd08/05/2010:svnAcer:pnX123: instead of evdev:atkbd:dmi:bvnAcer:bdXXXXX:bd08/05/2010:svnAcer:pnX123
2023-12-05 14:09:18 +01:00
Luca Boccassi
26522a66a3 Merge pull request #30313 from mrc0mmand/ubuntu-ci
Reduce the number of deny-list files for Ubuntu CI
2023-12-04 18:23:34 +00:00
Yu Watanabe
67bc3c1a8c tools/meson-vcs-tag: the third argument is optional
Follow-up for 1a71ac07ad.
2023-12-04 10:29:52 +00:00
Luca Boccassi
a483c75822 Merge pull request #30314 from DaanDeMeyer/dmi
Document kernel configs required for reading credentials from SMBIOS
2023-12-04 10:29:06 +00:00
Daan De Meyer
6ee9467d4c mkosi: Update comment why we can't use linux-kvm yet 2023-12-04 11:16:52 +01:00
Daan De Meyer
2d05492040 Document kernel configs required for reading credentials from SMBIOS 2023-12-04 11:13:59 +01:00
Frantisek Sumsal
30349b09bd test: reenable TEST-30 on i*86
The original reason for deny-listing it was that it's flaky there. I'm
not sure if that's still the case, but the Ubuntu CI jobs for i*86 are
gone, so this file shouldn't be needed anymore anyway.
2023-12-04 11:12:51 +01:00
Frantisek Sumsal
fc55ef9b69 test: skip TEST-36 on s390x and powerpc
As QEMU there doesn't support NUMA nodes. Also, drop the now unneeded
deny-list file for Ubuntu CI.
2023-12-04 11:12:51 +01:00
Frantisek Sumsal
6743066875 test: check if 'btrfs filesystem' supports 'mkswapfile'
Instead of deny-listing the test on Ubuntu CI, so it gets enabled
automagically once btrfs-progs is updated to a newer version there.
2023-12-04 11:12:51 +01:00
Frantisek Sumsal
a311d4dd30 test: reenable TEST-25-IMPORT in Ubuntu CI
Let's see if #13973 is still an issue.
2023-12-04 10:16:02 +01:00
Luca Boccassi
cc9f4cad8c executor: apply LogLevelMax earlier
SELinux logs before we have a chance to apply it, move it up as it
breaks TEST-04-JOURNAL:

[  408.578624] testsuite-04.sh[11463]: ++ journalctl -b -q -u silent-success.service
[  408.578743] testsuite-04.sh[11098]: + [[ -z Dec 03 13:38:41 H systemd-executor[11459]: SELinux enabled state cached to: disabled ]]

Follow-up for: bb5232b6a3
2023-12-04 11:45:22 +09:00
Yu Watanabe
b88f0fdc87 Merge pull request #30305 from yuwata/seccomp-fix
seccomp: override the default action only when the filter is allow-list
2023-12-04 11:44:58 +09:00
Zbigniew Jędrzejewski-Szmek
8244f394da tests: fix section mapping in test_ukify.py
The regexp only worked if the sections were small enough for the size to
start with "0". I have an initrd that is 0x1078ec7e bytes, so the tests
would spuriously fail.
2023-12-03 12:34:43 +00:00
Luca Boccassi
1707d5daf8 Merge pull request #30297 from keszybz/fixups
A few unrelated fixups for recent commits
2023-12-03 12:34:24 +00:00
Yu Watanabe
78b2ad7d67 seccomp-util: also use ENOSYS for unknown syscalls in seccomp_load_syscall_filter_set()
Follow-up for 2331c02d06.

Note, currently, the function is always called with SCMP_ACT_ALLOW as
the default action, except for the test. So, this should not change
anything in the runtime code.
2023-12-03 18:01:30 +09:00
Yu Watanabe
03c0730ffe seccomp-util: override default action only when the filter is allow-list
Follow-up for 2331c02d06.

Fixes #30304.
2023-12-03 18:00:20 +09:00
Zbigniew Jędrzejewski-Szmek
ccd31de8bf stdio-bridge: return immediately if we can
Follow-up for 0321248b79.
2023-12-02 09:47:45 +01:00
Zbigniew Jędrzejewski-Szmek
9ce3440a6f run: fix bad escaping and memory ownership confusion
arg_description was either set to arg_unit (i.e. a const char*), or to
char *description, the result of allocation in run(). But description
was decorated with _cleanup_, so it would be freed when going out of the
function. Nothing bad would happen, because the program would exit after
exiting from run(), but this is just all too messy.

Also, strv_join(" ") + shell_escape() is not a good way to escape command
lines. In particular, one the join has happened, we cannot distinguish
empty arguments, or arguments with whitespace, etc. We have a helper
function to do the escaping properly, so let's use that.

Fixup for 2c29813da3.
2023-12-02 09:47:45 +01:00