Commit graph

71090 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek d53017292e timesyncd: reorder structs instead of useless bitfields
Because of alignment, those bitfields were not doing anything useful,
and were causing the generated code to be more complicated. But in this
case, at least potentially there might be a number of copies of those
structs (if we have a bunch of time servers configured), so let's actually
implement the intended space savings by reording the fields to reduce the
size of holes.
2024-02-20 10:41:09 +01:00
Zbigniew Jędrzejewski-Szmek 611a6d15cb systemctl: drop pointless bitfield 2024-02-20 10:41:09 +01:00
Zbigniew Jędrzejewski-Szmek 6e2be1d97a sysupdate: drop pointless bitfields
Again, even without considering how many copies of the struct there
can be, this bitfield is useless because of alignment.
2024-02-20 10:41:09 +01:00
Zbigniew Jędrzejewski-Szmek 0a35e7f6be core/kmod-setup: drop another pointless bitfield annotation
We have two bools followed by a func pointer, which is aligned to e.g. 8 bytes,
so whether the two bools take one bit, one byte, or even a full word, makes no
difference in storage size. But the code generated to service a bitfield is
more complicated.

Also switch to FOREACH_ARRAY().
2024-02-20 10:40:59 +01:00
Luca Boccassi 92d1419eb8
Merge pull request #31218 from CodethinkLabs/vmspawn/journal_forwarding
vmspawn: support journal forwarding
2024-02-16 12:09:52 +00:00
Tomáš Pecka 9f78da68ac varlink: fix varlink_collect_full not resetting state
The varlink_collect_full function did not set varlink client's state
when the reply was an error. The state was stuck in "collecting-reply".

I discovered that while hacking on network varlink interface (adding a
new varlink method). The debug logs shows the process of performing the
first query which replies with an error:

  varlink: Setting state idle-client
  network: Sending message: {"method":"io.systemd.Network.LLDPNeighbors","parameters":{"ifindex":1},"more":true}
  network: Changing state idle-client → collecting
  network: Received message: {"error":"org.varlink.service.MethodNotFound","parameters":{"method":"io.systemd.Network.LLDPNeighbors"}}
  network: Changing state collecting → collecting-reply

Now another varlink_collect call is being made, but

  network: Connection busy.
  Failed to execute varlink call: Device or resource busy

This was not caught by the tests because there were no varlink_collect
calls that resulted in error reply.
2024-02-16 12:08:31 +00:00
Luca Boccassi 5ea0da03d4
Merge pull request #31311 from yuwata/journal-user-corruption
journal: fix user journal corruption on rotation
2024-02-16 12:07:50 +00:00
Colin Geniet bd083fc2eb hwdb: Remove version check in CH Pro Pedals rule
CH Pedals are incorrectly reported as an accelerometer [1], because they
have no button.  This is fixed by a rule in 60-input-id.hwdb [2], but
the rule checks id/version="0100", while my pedals report id/version="0111".

So there are several versions of the pedals, presumably all affected
by the bug. Remove the version check in the rule to fix them all.

[1] https://bugs.freedesktop.org/show_bug.cgi?id=81889
[2] commit: 230ed4c4ba (hwdb: CH Pro Pedals not classified correctly due to no buttons, 2022-01-19)
    PR: https://github.com/systemd/systemd/pull/22184
2024-02-16 12:07:17 +00:00
Sam Leonard ec3d2f2e9d vmspawn: fix possible NULL dereference in discover_boot_entry 2024-02-16 12:45:08 +01:00
Lennart Poettering f03e8f19b7
Merge pull request #30263 from msizanoen1/fix-onboot-rotate-2
journal: Reset runtime seqnum data when flushing to system journal
2024-02-16 12:02:09 +01:00
Frantisek Sumsal 7bd41e63f7 test: properly preserve journal from sd-bsod tests
I (incorrectly) assumed that --relinquish-var does everything --flush
does, including moving already existing stuff from /var/log/journal/ to
/run/log/journal/, but that's not the case. To actually do that we need
to shuffle things manually, so let's do just that.

This should make issues like #31334 easier to debug, since with this
patch we now have a coredump in the test journal as well:

~# make -C test/TEST-04-JOURNAL/ clean setup run TEST_MATCH_SUBTEST=bsod BUILD_DIR=$PWD/build TEST_NO_NSPAWN=1
...
[   12.176089] testsuite-04.sh[712]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/testsuite-04.bsod.sh failed'
[   12.176089] testsuite-04.sh[712]: Subtest /usr/lib/systemd/tests/testdata/units/testsuite-04.bsod.sh failed
[   12.176089] testsuite-04.sh[712]: + return 1
[   12.177347] systemd[1]: testsuite-04.service: Failed with result 'exit-code'.
[   12.220580] systemd[1]: Failed to start testsuite-04.service.
Spawning getter /home/mrc0mmand/repos/@systemd/systemd/build/journalctl -o export -D /var/tmp/systemd-tests/systemd-test.Qtqmmr/root/var/log/journal...
Finishing after writing 7649 entries
TEST-04-JOURNAL: (failed; see logs)
-rw-r----- 1 root root 16777216 Feb 15 21:13 /var/tmp/systemd-tests/systemd-test.Qtqmmr/system.journal
...

~# coredumpctl --file /var/tmp/systemd-tests/systemd-test.Qtqmmr/system.journal
TIME                        PID UID GID SIG     COREFILE EXE                           SIZE
Thu 2024-02-15 21:13:38 CET 812   0   0 SIGABRT journal  /usr/lib/systemd/systemd-bsod    -
2024-02-16 10:37:37 +01:00
mooo 7ad0a7b2b6 po: Translated using Weblate (Lithuanian)
Currently translated at 69.6% (158 of 227 strings)

Co-authored-by: mooo <hazap@hotmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/lt/
Translation: systemd/main
2024-02-16 09:29:40 +01:00
Daan De Meyer 55c2350e85
Merge pull request #31320 from DaanDeMeyer/versioning
meson: Start adding devel and rc suffixes to the project version
2024-02-15 20:15:04 +01:00
Frantisek Sumsal 8cc42169f1 test: add test cases for journal corruption on btrfs
For issue #24150 and #31222.
2024-02-16 03:48:18 +09:00
Yu Watanabe 18d4e475c7 journal-file-util: use COPY_VERIFY_LINKED
As the main thread may call journal_directory_vacuum() ->
unlinkat_deallocate() while another thread is copying the file.

Fixes #24150 and #31222.
2024-02-16 03:48:18 +09:00
Yu Watanabe 72ef2a617f copy: introduce COPY_VERIFY_LINKED flag
If the flag is set, then copy_file() and friends check if the source
file still exists when the copy operation finished.
2024-02-16 03:48:18 +09:00
Yu Watanabe cb0d5f73e6 sd-journal: use stat_verify_linked() 2024-02-16 03:48:18 +09:00
Yu Watanabe a6d0cf939c stat-util: introduce {stat,fd}_verify_linked() 2024-02-16 03:48:18 +09:00
Yu Watanabe dd7fa015a6 stat-util: rebreak comment 2024-02-16 03:48:18 +09:00
Yu Watanabe f0455cec53 bsod: fix -c/--continuous support
Fixes a bug introduced by f7f062bf9f.

Fixes #31334.
2024-02-16 02:21:11 +09:00
Yu Watanabe 3900255ac1
Merge pull request #31331 from yuwata/xopenat
tree-wide: several cleanups related to xopenat()
2024-02-16 01:32:21 +09:00
Yu Watanabe f73ad0a9fb journal-file-util: use the file descriptor of journal file on copy
No effective functionality changed, just refactoring.
2024-02-16 00:25:37 +09:00
Yu Watanabe 0f938a024e test: add test for copying symlink with copy_tree_at() 2024-02-16 00:25:37 +09:00
Yu Watanabe d1553bfd20 copy: use xopenat() to make 'from' argument optional 2024-02-16 00:25:37 +09:00
Yu Watanabe e40b11be04 fs-util: rename xopenat() -> xopanat_full() 2024-02-16 00:25:37 +09:00
Yu Watanabe 6383abd62c loop-util: fix error handling
Follow-up for 972c8db589.
2024-02-16 00:25:37 +09:00
Yu Watanabe 59a4e17249 chattr-util: fix error code
Follow-up for cf91b9155c.
2024-02-16 00:25:37 +09:00
Yu Watanabe bec1383623 chase: do not wrap xopenat() with RET_NERRNO()
Follow-up for 47f0e1b5e0.
2024-02-16 00:25:37 +09:00
Yu Watanabe e4c094c055 fs-util: readlinkat() supports an empty string
From readlinkat(2):
Since Linux 2.6.39, pathname can be an empty string, in which case the
call operates on the symbolic link referred to by dirfd (which should
have been obtained using open(2) with the O_PATH and O_NOFOLLOW flags).
2024-02-16 00:25:37 +09:00
Luca Boccassi 55d37de121
Merge pull request #30910 from YHNdnzj/logind-followup
logind-user: switch tracking logic to user-runtime-dir@.service
2024-02-15 14:32:48 +00:00
Michael Biebl 50b68cff54 systemctl: drop chain invocation of telinit
This functionality relied on telinit being available in a different path
then the compat symlink shipped by systemd itself. This is no longer the
case for any known distro, so remove that code.

Fixes: #31220
Replaces: #31249
2024-02-15 14:29:20 +00:00
Luca Boccassi e07e7017bb man: enchance sd_bus_set_watch_bind() example to handle one more failure
In case the D-Bus policy is not set up correctly the example just
loops forever. Check the return of sd_bus_request_name_async() in
a callback and exit if the error is not temporary.

Follow-up for 34bbda18a5
2024-02-15 14:19:39 +00:00
Sam Leonard 258d26940f
vmspawn: add --forward-journal= 2024-02-15 14:08:21 +00:00
Sam Leonard b4d4ebe850
journal-remote: allow AF_VSOCK and AF_UNIX for --listen-raw
This allows log messages forwarded over an AF_UNIX or AF_VSOCK socket by
journald to be received by systemd-journal-remote.
2024-02-15 14:08:20 +00:00
Sam Leonard f31cff849d
journald: implement socket forwarding
This commit adds a new way of forwarding journal messages - forwarding
over a socket.

The socket can be any of AF_INET, AF_INET6, AF_UNIUX or AF_VSOCK.

The address to connect to is retrieved from the "journald.forward_address" credential.

It can also be specified in systemd-journald's unit file with ForwardAddress=
2024-02-15 14:08:20 +00:00
Sam Leonard 6813be2eba
journald: Add assertions to config_parse_compress 2024-02-15 14:08:20 +00:00
Mike Yuan 0ba24952f5
core/manager: don't propagate manager session env to children
Follow-up for 4cb4e6cf6d

Fixes #31287
2024-02-15 19:23:53 +08:00
Mike Yuan 9128fd553c
env-util: minor modernization 2024-02-15 19:23:52 +08:00
Mike Yuan 52bcc872b5
logind-session: use Requires= for user{,-runtime-dir}@.service
Since we do require these basic user services, let's make
the dependency stronger. Note that logind should enqueue
start jobs for these already in user_start(), so mostly
just paranoia.
2024-02-15 19:23:52 +08:00
Mike Yuan e2a42c0c43
logind-user: track user started/stopping state through user-runtime-dir@.service
Before #30884, the user state is tied to user@.service (user service
manager). However, #30884 introduced sessions that need no manager,
and we can no longer rely on that.

Consider the following situation:

1. A 'background-light' session '1' is created (i.e. no user service manager
   is needed)
2. Session '1' scope unit pulls in user-runtime-dir@.service
3. Session '1' exits. A stop job is enqueued for user-runtime-dir@.service
   due to StopWhenUnneeded=yes
4. At the same time, another session '2' which requires user manager is started.
   However, session scope units have JobMode=fail, therefore the start job
   for user-runtime-dir@.service that was pulled in by session '2' scope job
   is deleted as it conflicts with the stop job.

We want session scope units to continue using JobMode=fail, but we still need
the dependencies to be started correctly, i.e. explicitly requested by logind
beforehand. Therefore, let's stop using StopWhenUnneeded=yes for
user-runtime-dir@.service, and track users' `started` and `stopping` state
based on that when user@.service is not needed. Then, for every invocation
of user_start(), we'll recheck if we need the service manager and start it
if so.

Also, the dependency type on user-runtime-dir@.service from user@.service
is upgraded to `BindsTo=`, in order to ensure that when logind stops the
former, the latter is stopped as well.
2024-02-15 19:23:44 +08:00
Mike Yuan 5518b72ba8
login/logind-session-dbus: some follow-ups for 'user-incomplete' (#30226)
We don't usually say ", refusing" in bus error messages.
Also, make use of unref_and_replace_full.
2024-02-15 19:23:44 +08:00
Adrian Vovk d0aef638ac keyring-util: Use reported key size to resize buf
According to keyctl(2), the return value for KEYCTL_READ is:

    The amount of data that is available in the key,
    irrespective of the provided buffer size

So, we could pass in a NULL buffer to query the size, then allocate the
exact right amount of space, then call keyctl again to get the key data.
However, we must still keep the for loop to avoid TOCTOU issues: the key
might have been replaced with something bigger while we're busy
allocating the buffer to store it.

Thus, we can actually save a syscall by picking some reasonable default
buffer size and skipping the NULL call to keyctl. If our default is big
enough, we're done and have saved a syscall! If not, then the first call
behaves essentially the same as the NULL call, and we use the size it
returns to reallocate the buffer appropriately.
2024-02-15 11:13:34 +00:00
Benjamin Franzke 614d09a37d nspawn: add support for owneridmap bind option
owneridmap bind option will map the target directory owner from inside the
container to the owner of the directory bound from the host filesystem.
This will ensure files and directories created in the container will be owned
by the directory owner of the host filesystem. All other users will remain
unmapped. Files to be written as other users in the container will not be
allowed.

Resolves: #27037
2024-02-15 11:49:54 +01:00
Yu Watanabe 4dcfdd210c log: reorder arguments of internal macro
To make the order matches with log_internal().

No functional change. Hopefully silence coverity issues like
CID#1534478, CID#1534479, CID#1534480, CID#1534482.
2024-02-15 18:16:33 +09:00
Yu Watanabe 7774a7ca79 test: fix cleanup function
Follow-up for 8349bbdfd8.
2024-02-15 09:37:10 +01:00
Adrian Vovk 058a84d113 homed: Pass in username and uid as Polkit details
This lets the Javascript polkit policies to decide whether to
allow/deny/authenticate based on the user that's being operated on.
2024-02-15 09:12:37 +01:00
Yu Watanabe 8c3f988880 vmspawn: fix alignment of merged initrd
Follow-up for 811ad9e6b2.

Fixes CID#1534481.
2024-02-15 09:11:55 +01:00
Daan De Meyer 9a07df3bcd
Merge pull request #31330 from yuwata/sd-journal-trivial-cleanups
sd-journal: trivial cleanups
2024-02-15 08:56:56 +01:00
Yu Watanabe 0984c3d021 copy: rebreak comment and fix typo 2024-02-15 10:19:02 +09:00
Yu Watanabe a9c2e0f426 sd-journal: fix potential memory leak
Though, hopefully, the memory leak is hypothetical, as we always close
journal file with the timer by journal_file_offline_close().
2024-02-15 09:50:18 +09:00