1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-09 13:57:42 +03:00

64388 Commits

Author SHA1 Message Date
Luca Boccassi
92c5d3ff30
Merge pull request #27529 from DaanDeMeyer/kernel-top
mkosi: A few kernel build QOL improvements
2023-05-04 19:17:37 +01:00
Daan De Meyer
5ebf0b321f mkosi: Disable a bunch of useless configs when building a kernel
Let's speed up the kernel build a bit by disabling some stuff we
don't use.
2023-05-04 19:05:12 +02:00
Lennart Poettering
57485012c2
Merge pull request #27525 from poettering/creds-empty-gone
suppress per-service credentials dir when empty
2023-05-04 16:22:54 +02:00
Daan De Meyer
bfb7635544 mkosi: Look for mkosi.kernel/ in the top level directory
Let's make this slightly easier to use by looking for mkosi.kernel/
in the top level directory instead of in mkosi.presets/20-final/.
2023-05-04 15:45:42 +02:00
Lennart Poettering
3aaa376342 execute: remove credentials dir again when empty
This is closely related to the previous commit: if the credentials dir
is empty and nothing mounted on it, let's remove it again.

This will in particular happen if we decided to not actually install the
mount we prepared for the credentials because it is empty. In that case
the mount point inode is already there, and with this we'll remove it.
Primary effect, users will see ENOENT rather than EACCESS when trying to
access it, which should be preferable, given we already handle that
nicely in our credential consumption code.

This should also be useful on systems where we lack any privs to create
mounts, and thus operate on a regular dir anyway.
2023-05-04 12:10:06 +02:00
Lennart Poettering
21dd1de659 execute: suppress credentials mount if empty
Let's avoid creating another mount in the system if it's empty anyway.

This is mostl a cosmetic thing in one (pretty common) special case: if
creds settings are used in a unit but no creds actually available to be
passed.

(While we are at it this also does one more minor optimization: it
adjusts the MS_RDONLY/MS_NOSUID/… flags of the source mount we are about
to MS_MOVE into the right place only if we actually really move it, and
if we instead unmount it again we won't bother with the flags either)
2023-05-04 12:10:01 +02:00
Arthur Shau
9107ef5637
run: change sd_bus_call_method to bus_call_method (#27518)
Migrates the sd_bus_call_method code in run.c to use bus-locator.h api
2023-05-04 09:41:10 +08:00
Mike Yuan
397067b818
Merge pull request #27513 from mrc0mmand/journal-tests
test: a couple more TEST-04-JOURNAL follow-ups
2023-05-04 09:19:48 +08:00
Yu Watanabe
6cb105b877 core: fix use of uninitialized value
Fixes https://github.com/systemd/systemd/pull/27504#issuecomment-1533354787.
2023-05-04 00:33:33 +01:00
Lennart Poettering
b96cc40a95 cryptsetup: downgrade a bunch of log messages that to LOG_WARNING
In all these cases we ignore the failure, hence per our rule the log
level should be below LOG_ERR. Fix that.
2023-05-04 05:03:16 +09:00
Lennart Poettering
ea0f3289a2 mount-util: simplify mount_switch_root() a bit
There's no need to fchdir() out of the rootfs and back into it around
the umount2(), hence don't.

This brings the logic closer to what the pivot_root() man page suggests.

While we are at it, always operate based on fds, once we opened the
original dir, and pass the path string along only for generating
messages (i.e. as "decoration").

Add tests for both code paths: the pivot_root() one and the MS_MOUNT.
2023-05-03 20:52:19 +01:00
Daan De Meyer
64ff6ad494 mkosi: Use kernel-kvmsmall package on opensuse
Let's save on image size by using the kernel build for KVM from
opensuse.
2023-05-03 20:49:41 +01:00
Lennart Poettering
5d63c7eb83
Merge pull request #27450 from poettering/switch-root-modernize
pid1: modernize switch root logic a bit
2023-05-03 20:12:20 +02:00
Frantisek Sumsal
b003e2c7a6 test: clean up the test script even further
Most notably:
  - use `systemd-id128 new` instead of `journalctl --new-id128`
  - move all temporary files to /tmp
  - wrap repetitive checks in a function
2023-05-03 18:32:00 +02:00
Lennart Poettering
ef25552e8b core: minor coding style modernization in mount.c 2023-05-03 18:26:39 +02:00
Lennart Poettering
0de3431871 sd-daemon: add sd_pid_notify_barrier() call and use it in systemd-notify
Previously we'd honour --pid= from the main notification we send, but
not from the barrier. This is confusing at best. Let's fix that.
2023-05-03 18:21:42 +02:00
Lennart Poettering
ca71b1d966
Merge pull request #27510 from poettering/notify-barrier-pid-1-tweaks
pid 1 notify barrier handling tweaks
2023-05-03 18:21:14 +02:00
Lennart Poettering
09e766e70b notify: don't send EXIT_STATUS= notify message from systemd-notify
In 623a00020f116d8e9c70608a9e4f7cc978342441 code was added that our
various programs send a notification message with their exit status on
exit. This is great, but it becomes utterly confusing in systemd-notify,
whose primary purpose is to send such messages after all, and sending an
implicit one in addition to the primary one is particularly confusing,
when debugging things.

Let's hence just drop the implicit message. systemd-notify's exit status
is after all indicative primarily because sd_notify() failed, and hence
it's pretty pointless to then send that fact as another sd_notify()
message.

(Primary reason for this patch is simply that it confused the hell out
of me, when debugging sd_notify() issues)

Follow-up for: 623a00020f116d8e9c70608a9e4f7cc978342441
2023-05-03 18:03:05 +02:00
Lennart Poettering
1408912282 update TODO 2023-05-03 17:55:55 +02:00
Lennart Poettering
9a22b098d2 base-filesystem: unify common parts of base_filesystem_create_fd() branches
The error handling and fchmodat() invocation is pretty much the same in
the directory and symlink branches, hence make them the same.

No real change in behaviour. Just refactoring.
2023-05-03 17:55:55 +02:00
Lennart Poettering
8aefedce14 base-filesystem: add new helper base_filesystem_create_fd() that operates on an fd, instead of a path
This also changes the open flags from
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW to
O_DIRECTORY|O_CLOEXEC. O_RDONLY is redundant, since O_RDONLY is zero
anyway, and O_DIRECTORY pins the acces mode enough: it doesn't allow
read()/write() anyway when specified. O_NONBLOCK is also pointless given
that O_DIRECTORY is specified, it has no meaning on directories. (It is
useful if we don't know much about the inode we are opening, and could
be a device node or fifo, but the O_DIRECTORY excludes that case.)

O_NOFOLLOW is dropped since there's really no point in blocking out the
initial entrypoint being a symlink. Once we pinned the the root of the
tree it might make sense to restrict symlink use below it, but for the
entrypoint itself it doesn't matter.
2023-05-03 17:55:55 +02:00
Lennart Poettering
f2c1d491a5 switch-root: don't require /mnt/ when switching root into host OS
So far, we invoked pivot_root() specifying /mnt/ as second argument,
which then unmounted right-after. We'd create /mnt/ if needed. This
sucks, because it means /mnt/ must strictly be pre-created on immutable
images.

Remove this limitation, by using pivot_root() with "." as source and
target, which will result in two stacked mounts afterwards: the new one
underneath, the old one ontop. We can then simply unmount the top one,
and have what we want without needing any extra /mnt/ dir.

Since we don't need /mnt/ anymore we can get rid of the extra
unmount_old_root parameter and simply specify it as NULL if we don't
want the old mount to stick around.
2023-05-03 17:55:55 +02:00
Frantisek Sumsal
8077d99fd2 test: vacuum the journal after the "stress test"
To make the rest of the test significantly faster.
2023-05-03 17:37:09 +02:00
Frantisek Sumsal
23f83ba768 test: slightly extend checks on corrupted journals 2023-05-03 17:32:36 +02:00
Frantisek Sumsal
c4039ceb9e test: further extend our collection of corrupted journals
And make adding them slightly easier.

Provides coverage for b5335da7a5.
2023-05-03 17:22:37 +02:00
Lennart Poettering
7b0a126751 manager: add debug logging about BARRIER=1 messages 2023-05-03 14:58:17 +02:00
Lennart Poettering
4627645442 manager: simplify manager_process_barrier_fd() a bit 2023-05-03 14:58:17 +02:00
Yu Watanabe
a76dc1f3a0
Merge pull request #27504 from mrc0mmand/fuzz-manager-serialize
test: add a simple fuzzer for manager serialization
2023-05-03 21:45:26 +09:00
Zbigniew Jędrzejewski-Szmek
3f7e77fae1 test_ukify: fix two failing tests
Fixup for 22ad038ac6e4fe5e4a68555f0e70bd0a16fb5616 and
3fc5eed47091363247012454df458e1a3303bf12. It seems that the tests are
not executed properly in CI. Nevertheless, test-ukify appears in logs:

rpm-build:fedora-rawhide-x86_64:
 409/1191 systemd / test-ukify    OK   0.16s

This is strange.
2023-05-03 12:29:41 +02:00
Zbigniew Jędrzejewski-Szmek
cb3b451e11 test_ukify: fix loop iteration
We'd try to access 'linux' or 'initrd' after failing to set it.
2023-05-03 12:29:41 +02:00
Zbigniew Jędrzejewski-Szmek
b62ee354dd meson: allow building .standalone on demand
We can always build the standalone version whenever we build the normal version
(the dependencies are the same). In most builds standalone binaries would be
disabled. But it is occasionally useful to have them for testing, so move the
conditional to install:, so the binaries can be build by giving the explicit
target name.

The default of 'build_by_default' for executable() is sadly true (since meson
0.38.0), so need to specify build_by_default: too.

Also add systemd-shutdown.standalone to public_programs for additional testing.
2023-05-03 12:29:41 +02:00
Zbigniew Jędrzejewski-Szmek
9a01fe3906 meson: avoid building executables that won't be installed
When executable() or custom_target() has install: that is conditional as is
false (i.e. not install:true), it won't be built by default. (build_by_default:
defaults to install:). But if that program is added to public_programs, it will
be build by default because it is pulled in by the test, effectively defeating
the disablement.

While at it, make 'ukify' follow the same pattern as 'kernel-install'.
They will be used later together.
2023-05-03 12:29:41 +02:00
Zbigniew Jędrzejewski-Szmek
d9c8f075af ukify: add missing header
This file is installed, so it should have the long header.
2023-05-03 12:29:41 +02:00
Zbigniew Jędrzejewski-Szmek
50f4add445 ukify: use UPPERCASE for parameter names
We generally nowadays use UPPERCASE for parameters in variuos help text.
Let's be consistent here too, and also drop duplicated 'usage:':
$ ukify -h
usage: ukify [options…] LINUX INITRD…
       ukify -h | --help

Build and sign Unified Kernel Images

positional arguments:
  LINUX                 vmlinuz file [.linux section]
  INITRD…               initrd files [.initrd section]
...
2023-05-03 12:29:41 +02:00
Zbigniew Jędrzejewski-Szmek
d3533162d1 90-loaderentry: make sure that variables are set
We unconditionally use the variables later on, so let's make sure
that they were passed as expected.
2023-05-03 12:29:40 +02:00
Frantisek Sumsal
740831076c shared: reject empty attachment path 2023-05-03 10:09:53 +02:00
Frantisek Sumsal
1febf60f9d shared: ignore invalid valink socket fd when deserializing 2023-05-03 10:09:53 +02:00
Frantisek Sumsal
45b1017488 core: fix NULL pointer dereference during deserialization 2023-05-03 10:09:53 +02:00
Frantisek Sumsal
24e6759cbc test: add a simple fuzzer for manager serialization 2023-05-03 10:09:53 +02:00
Yu Watanabe
406004a6c3
Merge pull request #27499 from yuwata/sd-journal-fix-loop
sd-journal: check .next_entry_array_offset earlier
2023-05-03 13:30:47 +09:00
Yu Watanabe
de6eb806ff Revert "sd-journal: introduce simple loop detection for entry array objects"
This reverts commit a8fbcc0e3c033a43e511550052cace6b0dcf3df7.

The commit is not necessary, as the invalid entry array object is
filtered earlier by the previous commit.
2023-05-03 06:41:25 +09:00
Yu Watanabe
b5335da7a5 sd-journal: check .next_entry_array_offset earlier
Then, if it is invalid, refuse to use the entry array object.

Follow-up for a8fbcc0e3c033a43e511550052cace6b0dcf3df7.
Fixes #27489.
2023-05-03 06:41:21 +09:00
Jan Janssen
ec232e4abd boot: Use correct memory type for allocations
We were using the wrong memory type when allocating pool memory. This
does not seem to cause a problem on x86, but the kernel will fail to
boot at least on ARM in QEMU.

This is caused by mixing different allocation types which ended up
breaking the kernel or EDK2 during boot services exit. Commit
2f3c3b0bee5534f2338439f04b0aa517479f8b76 appears to fix this boot
failure because it was replacing the gnu-efi xpool_print with xasprintf
thereby unifying the allocation type.
But this same issue can also happen without this fix somehow when the
random-seed logic is in use.

Fixes: #27371
2023-05-02 22:38:15 +01:00
msizanoen1
845824acdd core: check for SERVICE_RELOAD_NOTIFY in manager_dbus_is_running
This ensures that systemd won't erronously disconnect from the system
bus in case a bus recheck is triggered immediately after the bus service
emits `RELOADING=1`.

This fixes an issue where systemd-logind sometimes randomly stops
receiving `UnitRemoved` after a system update.

This also handles SERVICE_RELOAD_SIGNAL just in case somebody ever
creates a D-Bus broker implementation that uses `Type=notify-reload`.
2023-05-03 00:14:35 +09:00
Lennart Poettering
5789c60973 journal: handle EADDRNOTAVAIL in two more cases gracefully
Follow-up for #27488.
2023-05-03 00:13:40 +09:00
Yu Watanabe
c19b827802
Merge pull request #27493 from poettering/generate-sym-test-tweaks
fixes/additions for generate-sym-test
2023-05-03 00:12:48 +09:00
Mike Yuan
5e15fec23d
Merge pull request #27492 from poettering/base-filesystem-000
base-filesystem: create /proc, /sys, /dev mount points as 555
2023-05-02 20:53:35 +08:00
Luca Boccassi
b8fba0cded generators: skip private tmpfs if /tmp does not exist
When spawning generators within a sandbox we want a private /tmp, but it
might not exist, and on some systems we might be unable to create it
because users want a BTRFS subvolume instead.

Fixes https://github.com/systemd/systemd/issues/27436
2023-05-02 12:28:09 +02:00
Daan De Meyer
a3b076f641 tree-wide: Handle EADDRNOTAVAIL as journal corruption
Journal corruption is not only indicated by EBADMSG but also by
EADDRNOTAVAIL so treat that as corruption in a few more cases.
2023-05-02 12:17:41 +02:00
Lennart Poettering
2a10774caa mount-setup: use size_t when iterating through array indexes 2023-05-02 12:06:03 +02:00