Commit Graph
43569 Commits
Author SHA1 Message Date
Lennart Poettering f5fcacdf2c detach-loopback: also decouple from umount.h
Let's introduce LoopbackDevice as replacement for MountPoint, with just
the fields we actually need.
2023-06-02 15:56:06 +02:00
Lennart Poettering 6514a6fd82 detach-md: also decouple structures from umount.h 2023-06-02 15:56:06 +02:00
Lennart Poettering 015937f901 detach-dm: decouple from umount.[ch]
Let's also define our own little structure here with just the fields we
need.
2023-06-02 15:56:06 +02:00
Lennart Poettering a0fb20672d detach-swap: decouple from umount.h
So far detach-swap.[ch] were still using the MountPoint structure to
store swap device info in. Since it was only using a single field of it
sharing the whole structure is kinda pointless. Hence, let's decouple
this and only add the field we really need.
2023-06-02 15:56:06 +02:00
Lennart Poettering 82a1d6d096 umount: split out swap detachment code too 2023-06-02 15:56:06 +02:00
Lennart Poettering 2e2c472b1c umount: split out loopback detach code
Like the similar commits, no actual code changes, just splitting up
large C files.
2023-06-02 15:56:06 +02:00
Lennart Poettering b44411c702 umount: similar as previous commit, split out DM detaching 2023-06-02 15:56:06 +02:00
Lennart Poettering 49427110a0 umount: split out MD detaching code from umount.c
umount.c does so much stuff, and MD detaching is relatively separate,
hence split it out into its own .c/.h file pair.
2023-06-02 15:56:06 +02:00
Lennart Poettering ca6cdd2605 dissect-image: fix partition label version compare
The logic was borked: if we find multiple partitions of the same
designator, we should first prefer the better arch, and then prefer the
better version, and then the first found. Fix that.

Fixes: #27897
2023-06-02 15:54:13 +02:00
Lennart Poettering 2130a2e5a6 fstab-generator: if we mount via roothash=/usrhash= let's imply "ro" mount option
If we discover the root or /usr/ fs via roothash=/usrhash= we know the
file system mounted on it will be read-only, since Verity volumes are by
definition immutable. Hence, let's imply the "ro" mount option for them.

This way the "kernel: /dev/mapper/usr: Can't open blockdev" boot-time
log message goes away, reported here:

https://github.com/systemd/systemd/issues/27682

(I do wonder though why erofs even tries to open the block device as
writable, that sounds utterly pointless for a file system that carries
the fact it is read-only even in the name...)
2023-06-02 13:31:31 +02:00
Frantisek Sumsal 014e811e86 Merge pull request #27891 from mrc0mmand/more-tests-again
test: improve systemd-pstore tests & add a couple of tests for systemd-run
2023-06-02 10:05:17 +02:00
Frantisek Sumsal f8b21a08aa socket: avoid memory leak on incomplete SocketPort object
==1==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 17 byte(s) in 1 object(s) allocated from:
    #0 0x7fc096c7243b in strdup (/lib64/libasan.so.8+0x7243b)
    #1 0x7fc095db3899 in bus_socket_set_transient_property ../src/core/dbus-socket.c:386
    #2 0x7fc095db5140 in bus_socket_set_property ../src/core/dbus-socket.c:460
    #3 0x7fc095dd20f1 in bus_unit_set_properties ../src/core/dbus-unit.c:2473
    #4 0x7fc095d87d53 in transient_unit_from_message ../src/core/dbus-manager.c:1025
    #5 0x7fc095d8872f in method_start_transient_unit ../src/core/dbus-manager.c:1112
    #6 0x7fc0944ddf4f in method_callbacks_run ../src/libsystemd/sd-bus/bus-objects.c:406
    #7 0x7fc0944e7854 in object_find_and_run ../src/libsystemd/sd-bus/bus-objects.c:1319
    #8 0x7fc0944e8f03 in bus_process_object ../src/libsystemd/sd-bus/bus-objects.c:1439
    #9 0x7fc09454ad78 in process_message ../src/libsystemd/sd-bus/sd-bus.c:3011
    #10 0x7fc09454b302 in process_running ../src/libsystemd/sd-bus/sd-bus.c:3053
    #11 0x7fc09454e158 in bus_process_internal ../src/libsystemd/sd-bus/sd-bus.c:3273
    #12 0x7fc09454e2f2 in sd_bus_process ../src/libsystemd/sd-bus/sd-bus.c:3300
    #13 0x7fc094551a59 in io_callback ../src/libsystemd/sd-bus/sd-bus.c:3642
    #14 0x7fc094727830 in source_dispatch ../src/libsystemd/sd-event/sd-event.c:4187
    #15 0x7fc094731009 in sd_event_dispatch ../src/libsystemd/sd-event/sd-event.c:4808
    #16 0x7fc094732124 in sd_event_run ../src/libsystemd/sd-event/sd-event.c:4869
    #17 0x7fc095f7af9f in manager_loop ../src/core/manager.c:3242
    #18 0x41cc7c in invoke_main_loop ../src/core/main.c:1937
    #19 0x4252e0 in main ../src/core/main.c:3072
    #20 0x7fc092a4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)

SUMMARY: AddressSanitizer: 17 byte(s) leaked in 1 allocation(s).
2023-06-01 22:14:59 +02:00
Frantisek Sumsal b86ed7f710 dbus-util: let's take it down a notch when converting file mode to string
I'm definitely a fan of precision, but in this case it's a bit too much:

    $ systemd-run --unit=test --socket-property=ListenFIFO=/tmp/foo --socket-property=SocketMode=0644 true
    $ systemctl cat test.socket
    # /run/systemd/transient/test.socket
    # This is a transient unit file, created programmatically via the systemd API. Do not edit.
    [Unit]
    Description=/usr/bin/true

    [Socket]
    ListenFIFO=/tmp/foo
    SocketMode=0000000000000000000000000000000000000644
2023-06-01 20:33:17 +02:00
Lennart Poettering 45e3406e23 veritysetup: remove double escaping of data device + hash device spec
generator_write_veritysetup_service_section() already escapes the
parameters internally, doing so in the caller means double escaping,
which is a bug. Fix it.
2023-06-01 19:15:10 +02:00
Lennart Poettering deb60ef92e veritysetup: minor renaming of functions
create_device() and create_disk() so far did very similar things, but
the name didn't give a hint what the difference was.

Hence let's rename them to create_special_device() and
create_veritytab_device() to make this more understandabe, as one
creates /proc/cmdline specified roothash=/usrhash= devices, and the
other one devices for items listed in /etc/veritytab.

No code changes besides renaming.
2023-06-01 19:06:20 +02:00
Lennart Poettering ffe0da297d {crypt|verity}setup: mention volume name in some error messages 2023-06-01 18:49:43 +02:00
Lennart Poettering ce49a479d2 {crypt|verity}setup: replace dep on systemd-tmpfiles-setup-dev.service by modprobe@loop.service
Both should have the same effect: the /dev/loop-control devices should
become available. systemd-tmpfiles-setup-dev.service creates the device
node "dry" based on modalias data, while modprobe@loop.service creates
it fully, because the module backing it is loaded properly. This should
shorten the deps chain a bit, simplify things and allows us to focus on
the stuff we actually need (i.e. the loopback infra) instead of all
entrypoints anyone might possibly need (i.e. the device nodes)
2023-06-01 18:49:43 +02:00
Lennart Poettering 5dd0214707 veritysetup-generator: only generate one set of deps on systemd-tmpfiles-setup-dev.service
If both the data and the hash device are a regular file we might create
two sets of deps on s-t-s-d.s, which is of course redundant. Shorten the
code to only generate this once.

No change in behaviour.
2023-06-01 18:49:43 +02:00
Lennart Poettering bf1484c70a veritysetup-generator: imply x-initrd.attach for "usr" and "root" volumes
Similar to the previous commit, just vor Verity rather than LUKS.
2023-06-01 18:49:43 +02:00
Lennart Poettering 8ce02b87ce cryptsetup-generator: imply x-initrd.attach for "usr" and "root" volumes
Let's imply "x-initrd.attach" for "usr" and "root" volumes, so that
we do not attempt to umount them anymore during shutdown.

The names of these volumes have been mandated by the Discoverable
Partition Spec:

https://uapi-group.org/specifications/specs/discoverable_partitions_specification/#suggested-mode-of-operation

Hence it appears reasonably safe to special case these volume names.

Note that a similar logic is implemented in fstab-generator and in fact
PID 1 to treat the root mount and /usr/ mount specially too, to avoid
trying to umount it at shutdown. (This is what fstab_is_extrinsic()
checks).

This should ensure that if /usr/ or / is for some reason a LUKS medium
we won't try to detach it during runtime, which likely fails, since we
run off it.

Note this also moves an ordering dep towards umount.target under the
x-initrd.attach check, becasue that's where the crucial conflicts dep is
placed too.
2023-06-01 18:49:43 +02:00
Lennart Poettering 953006dcb0 veritysetup-generator: use generic veritysetup writers at one more place
Let's use the common generator_write_veritysetup_unit_section(),
ggenerator_write_veritysetup_service_section(), generator_add_symlink()
implementation we already have at one more place.

This mostly generates the same unit, but for the first time hooks up
blockdev@dev-mapper-*.device for the device, which means things like
growfs on usr+root volumes will actually work now. (I mean, growfs
won#t, because verity devices are immutable after all, but things *like*
it that want to run between the device popping up and being mounted.)
2023-06-01 18:49:43 +02:00
Lennart Poettering 6747d9a13f cryptsetup: fix whitespace issue 2023-06-01 18:49:16 +02:00
Lennart Poettering d4ea4ebc39 fstab-util: drop redundant check
fstab_test_option() checks this as first thing anyway, hence let's drop
the redundant check.
2023-06-01 17:17:42 +02:00
Yu Watanabe 45a6a2aace sd-journal: fix assignment of tail entry offset
Fixes a bug introduced by 206f0f397e.
2023-06-01 17:04:10 +02:00
Yu Watanabe 17bd68ca74 Merge pull request #27874 from keszybz/test-bus-server-shortening
Simplify the code in test-bus-server
2023-06-01 21:10:55 +09:00
Lennart Poettering 614ac89d30 test-sizeof: let's be a tiny bit more careful when using glibc internal types
One can argue that internal glibc types (i.e. those starting with __)
are not really part of the glibc API, hence let's at least ifdef them.
2023-06-01 21:10:04 +09:00
Zbigniew Jędrzejewski-Szmek fcc54d1dfe Merge pull request #27856 from arianvp/fix-bootctl-status
bootctl: Print version number of detected binaries again
2023-06-01 10:25:30 +02:00
Zbigniew Jędrzejewski-Szmek 70b1676578 test-bus-server: simplify return value handling
Follow-up for f7794e423a.
2023-06-01 09:57:23 +02:00
Zbigniew Jędrzejewski-Szmek fa18faf1c0 various: remove typo/unusual spelling
Wikitionary says that "noone" is known, but not preferred by a large margin.
(It's also an obsolete spelling of "noon".)
2023-06-01 09:56:14 +02:00
Yu Watanabe 041d8ad857 Merge pull request #27796 from yuwata/memstream-util
util: introduce memstream-util
2023-06-01 12:07:17 +09:00
Rene Hollander 930133d5df networkd/dhcpserver: Save and expose the client hostname sent when requesting a DHCP lease.
DHCP clients often send their own hostname in option 12. It can be useful
to store it with the lease so it can be shown to a human to easily identify
which lease belongs to which device.

RFC: https://www.rfc-editor.org/rfc/rfc2132#section-3.14
2023-06-01 06:51:45 +09:00
Yu Watanabe 2485b7e2b8 tree-wide: use memstream-util 2023-06-01 06:48:47 +09:00
Yu Watanabe abe72100cf util: introduce memstream-util
There is many pitfalls in using memstream.
Let's introduce a wrapper to make us safely use it.
2023-06-01 06:48:43 +09:00
Yu Watanabe 24b0c6c2c9 calendarspec: rename arguments 2023-06-01 06:47:48 +09:00
Yu Watanabe a694747d45 elf-util: rename stack_context_destroy() -> stack_context_done() 2023-06-01 06:47:48 +09:00
Yu Watanabe 3256e2027b sd-bus: rename introspect_free() -> introspect_done 2023-06-01 06:47:48 +09:00
Yu Watanabe 5d2a48da12 tree-wide: use _cleanup_set_free_ and friends
Instead of _cleanup_(set_freep) or so.
2023-06-01 06:47:48 +09:00
Yu Watanabe 64377c6089 oomd: drop unused key 2023-06-01 06:47:48 +09:00
Yu Watanabe cc4d38b14b core/cgroup: fix setting SocketBindAllow=/SocketBindDeny= through DBus 2023-06-01 06:47:48 +09:00
Michal Sekletar 89e9df12b3 core/transaction: drop job that has unfulfilled required (Requires, BindsTo) dependencies
Resolves: #11338
2023-06-01 06:45:51 +09:00
Yu Watanabe 322bda8241 Merge pull request #27826 from yuwata/network-link-ready-without-ndisc-when-has-static-address
network: do not request dynamic addressing protocols finished when at…
2023-06-01 06:29:55 +09:00
Daan De Meyer 7d52bf16e7 Merge pull request #27628 from ddstreet/tpm2_header_cleanup
Tpm2 header cleanup
2023-05-31 23:06:14 +02:00
Daan De Meyer c4b7e0f812 Merge pull request #27844 from DaanDeMeyer/repart-arch
repart: Add --architecture option
2023-05-31 23:00:19 +02:00
Yu Watanabe 2f96a29c2c wait-online: request that at least one managed online interface exists
Fixes a regression caused by ab3aed4a03.

I thought the commit does not cause any severe regression. However,
drivers for network interfaces may be loaded later. So, we should wait
if no network interface is found.

Fixes #27822.
2023-05-31 22:12:03 +02:00
Lennart Poettering 38c86ce329 Merge pull request #27861 from poettering/find-esp-tweaks
minor tweaks to find-esp.c
2023-05-31 15:42:05 +02:00
Daan De Meyer edabe6fc11 Merge pull request #27806 from DaanDeMeyer/fix-mkosi-check
mkosi: Use proper check to detect whether we're in a VM
2023-05-31 15:26:05 +02:00
Dan Streetman ba723ea260 tpm2: sort tpm2 symbol list
Only cosmetic, no functional change.
2023-05-31 09:23:22 -04:00
Dan Streetman b57a7b3d9b tpm2: remove all extern tpm2-tss symbols
These library syms should be restricted to use only in tpm2-util.c,
and all other code should use simpler functions exported in tpm2-util.h.

Also move the Esys_Freep() cleanup function into tpm-util.c, and make
tpm2-tss symbols static.
2023-05-31 09:23:22 -04:00
Dan Streetman 9944909e68 tpm: remove external calls to dlopen_tpm2()
The calls outside tpm2-util.c are redundant, as tpm2_context_new()
is always called immediately after, which then calls dlopen_tpm2().
2023-05-31 09:23:21 -04:00
Daan De Meyer 2533fdd0fb Merge pull request #27766 from rphibel/cleanup-cgroups-before-cleaning-units
Don't GC unit if it is in cgroup_empty_queue
2023-05-31 14:48:42 +02:00