Commit Graph

53937 Commits

Author SHA1 Message Date
Yu Watanabe
34ae6b682b user-runtime-dir: correct quota size calculation (#36884) 2025-04-02 00:59:09 +09:00
Yu Watanabe
c5855d9640 notify-recv: several follow-ups for notify_socket_prepare()
Follow-ups for 2351bc991e.
Addresses post-merge review:
https://github.com/systemd/systemd/pull/36911#pullrequestreview-2732136658
2025-04-01 22:22:10 +09:00
Zbigniew Jędrzejewski-Szmek
cb6b161162 test-display-quota: add a little helper binary to show quota on tmpfs
quota from quota project fails:
$ quota
quota: Cannot stat() mounted device tmpfs: No such file or directory
quota: Cannot stat() mounted device tmpfs: No such file or directory

Having this helper helped me understand what is going on with the quotas when
the tests failed. I think it'd be useful to keep it around for now, even though
it is not actually connected in the tests.
2025-04-01 14:16:40 +02:00
Yu Watanabe
cdd2dd2d58 udev-spawn: manage spawned processes by PidRef 2025-04-01 18:25:29 +09:00
Yu Watanabe
b15c676b6e udev: trivial cleanups (#36916) 2025-04-01 18:24:34 +09:00
Yu Watanabe
5f8e8186e0 introduce notify_socket_prepare() and use it where applicable (#36911)
This introduces notify_socket_prepare(), which creates an autobind
notify socket and IO event source for the socket. Then, use it where we
send notification messages from worker processes to their manager
process.
2025-04-01 18:20:47 +09:00
Yu Watanabe
6941bf6b77 udev: update log messages 2025-04-01 15:55:52 +09:00
Yu Watanabe
cff85857c7 udev: disable timer event source for cleaning up idle workers when no worker exists
No functional change, as the timer event does nothing when there are no
workers.
2025-04-01 15:55:52 +09:00
Mike Yuan
6790db81d6 user-runtime-dir: correct quota size calculation
Follow-up for b1c95fb2e9

Fixes #36245
2025-03-31 22:46:04 +02:00
Yu Watanabe
451277707d validatefs: several follow-ups (#36910) 2025-04-01 05:35:21 +09:00
Yu Watanabe
4c42fc6aa8 sysupdated: use notify_socket_prepare()
This also make it use autobind notify socket.
2025-04-01 03:58:38 +09:00
Yu Watanabe
0ffddd23f4 sysupdate-transfer: use notify_socket_prepare() 2025-04-01 03:58:38 +09:00
Yu Watanabe
66936ba5fa sysupdate-transfer: fix potential memleak 2025-04-01 03:58:38 +09:00
Yu Watanabe
6228924d6e notify: use notify_socket_prepare() 2025-04-01 03:58:38 +09:00
Yu Watanabe
adfd9fe14c import: use notify_socket_prepare()
This also make it use autobind notify socket.
2025-04-01 03:58:38 +09:00
Yu Watanabe
0f627f9b35 homed: use notify_socket_prepare()
This also make it use autobind notify socket.
2025-04-01 03:58:34 +09:00
Yu Watanabe
2f973db276 udev-manager: coding style cleanups 2025-04-01 03:34:41 +09:00
Yu Watanabe
f594f32c3d udev-manager: use notify_start() and notify_on_cleanup()
No functional change. Just refactoring.
2025-04-01 03:34:41 +09:00
Yu Watanabe
2351bc991e notify-recv: introduce notify_socket_prepare() 2025-04-01 03:26:22 +09:00
Yu Watanabe
a6344afbc1 ac-power: follow-up for recent change
Follow-ups for 72586a971b.

- drop 'Options' sections,
- drop underlining for link,
- fix indentation.

Prompted by https://github.com/systemd/systemd/pull/36850#discussion_r2020594171
> the underline stuff we only use for long --help texts that have sections,
> for the section headers. systemctl --help does that for example. This one
> here is not that long, hence doesn't really need section headers, and
> hence no underlining. The clickable links don't need to be explicitly
> underlined, the terminal emulators that supper hyperlinks will underline
> them on their own (for example gnome-terminal uses a dotted line).

Addresses https://github.com/systemd/systemd/pull/36873#discussion_r2017578611
2025-04-01 02:55:28 +09:00
Yu Watanabe
9441880d83 socket-util: introduce socket_autobind() helper (#36893)
Prompted by https://github.com/systemd/systemd/pull/36858#discussion_r2017719305
and #36833.
2025-04-01 02:55:04 +09:00
Mike Yuan
f361fad245 validatefs: use fgetxattr_malloc() where appropriate 2025-03-31 19:23:50 +02:00
Mike Yuan
8950f7651e validatefs: do not use EXIT_* in run()
The plain DEFINE_MAIN_FUNCTION is used, i.e. all >= 0 retvals
are treated as success. No need for EXIT_* annotations.
2025-03-31 19:23:50 +02:00
Mike Yuan
7b8d6fc836 validatefs: insert empty line after short description in help() text
As per our usual coding style.
2025-03-31 19:23:50 +02:00
Mike Yuan
05587cece5 xattr-util: add missing assertions
Follow-up for ed024abac6
and 9fbe26cfa8

Also, let's not get too tangled up in the style of defining variables
in between. The functions are short enough, and vars involved are still
effectively at the beginning... Put differently, the separation from
'int r' is too deliberate and brings no actual value in my eyes.
2025-03-31 19:23:49 +02:00
Yu Watanabe
30252c0ca4 introduce systemd-validatefs@.service that ensures file systems can only be used in the way they were intended (#36714)
If we have multiple trusted fs (i.e. luks or dm-verity) we generate via
repart at boot, we must make sure they cannot be "misappropriated", i.e.
used for a different mount they were intended for.

Hence, let's introduce "mount constraint" data (encoded in xattrs on the
root inode of the fs) that tells us where a file system has to be
mounted, and what the gpt partition metadata has to be for the fs to be
valid.

Inspired by this thread:
https://lists.freedesktop.org/archives/systemd-devel/2025-March/051244.html
2025-04-01 01:14:33 +09:00
Mike Yuan
1eeb4f9f47 socket-util: introduce socket_autobind() helper
Prompted by https://github.com/systemd/systemd/pull/36858#discussion_r2017719305
and #36833
2025-03-31 18:11:37 +02:00
Mike Yuan
ddbbc98bd5 socket-util: drop SO_BINDTODEVICE fallback in socket_bind_to_ifindex()
Our baseline is v5.4 now.
2025-03-31 18:00:09 +02:00
Yu Watanabe
c7464843ad tree-wide: extend the comment about the issue in __convert_scm_timestamps() 2025-03-31 23:22:38 +09:00
Yu Watanabe
566b8f4d46 core/manager: update comment 2025-03-31 23:22:38 +09:00
Yu Watanabe
4216018807 missing_socket: drop unnecessary definitions and update comments
- SO_PEERGROUPS is since kernel v4.13
  (28b5ba2aa0f55d80adb2624564ed2b170c19519e),
- SO_BINDTOIFINDEX is since kernel v5.1
  (f5dd3d0c9638a9d9a02b5964c4ad636f06cf7e2c).
2025-03-31 23:22:12 +09:00
Lennart Poettering
85afe4760b repart: automatically generate validatefs xattrs
Let's automatically generate validatefs xattrs by default, that encode
the intended use of partitions.

This defaults to on, since the structure of repart definition files
tells us enough on use for this to be safe. There's an option however,
to turn this off.
2025-03-31 15:14:45 +02:00
Lennart Poettering
f872373a26 generators: hook in validatefs on gpt-auto and fstab generator mounts
Let's turn on validatefs automatically for all auto-discovered
partitions.

Let's add an x-systemd.validatefs option to optionally turn this on for
fstab listed file systems.
2025-03-31 15:14:28 +02:00
Lennart Poettering
0bdd5ccc81 validatefs: add new tool that enforces mount constraints
This new tool looks for a three xattr on the root inode of a file system
that encode mount constraints of the file system. The tool is supposed
to be hooke into the mount logic and is supposed to protect against
misappropriating trusted file systems in unintended ways.

Consider the following scenario: we boot up on first boot and create a
tpm-locked pair of /var/ and /srv/ partitions via systemd-repart. An
attacker then offline modifies the partition table, exchanging the
metadata of the /var/ and /srv/ partition. So far we'd happily accept
that, honour the modified metadata and boot up. This could be used to
revert changes to /var/ or similar. And all that even though both
partitions are encrypted and locked to TPM!

With this new mechanism we can encode in the protected contents of the
file systems the ways it can be used: the partition type uuid, the
partition label and the intended mount point can be stored in xattrs,
and we can check them automatically on mount, and take action on
mismatch. (action would typically be immediate reboot).
2025-03-31 15:14:13 +02:00
Lennart Poettering
9fbe26cfa8 xattr-util: add trivial xsetxattr_strv() wrapper 2025-03-31 15:13:55 +02:00
Lennart Poettering
ed024abac6 xattr-util: add trivial getxattr_at_strv() helper 2025-03-31 15:13:28 +02:00
Yu Watanabe
072ebe3ece watchdog: fix typo
Follow-up for ab596e4cde.
2025-03-31 21:27:00 +09:00
Yu Watanabe
b457af42e5 Log message improvements (#35237)
Various improvements to log messages. Inspired by
https://bugzilla.redhat.com/show_bug.cgi?id=2327296.
2025-03-31 21:23:23 +09:00
Yu Watanabe
5578f8e974 homed: move things over to quotactl_fd() (#36902)
Let's use quotactl_fd() wherever we can, it's 2025. quotactl() is such a
mess after all.
2025-03-31 21:15:03 +09:00
Busayo Dada
1220625a81 socket-proxy: add syntax highlighting to help output 2025-03-31 21:09:14 +09:00
Lennart Poettering
521b6bb117 homed: don't log error we don't have 2025-03-31 11:51:38 +02:00
Lennart Poettering
5daca30b0f homed: always use quotactl_fd() if its available
Let's always prefer quotactl_fd() when it's available and use quotactl()
only as as a fallback on old kernels.

This way we can operate on the fds we typically already have open, or if
needed we can open a new one, and use for multiple fs operation.

In the long run we should really focus on operating exclusively by fd
instead of by path, by device nor or otherwise. This gets us a step
closer to that.
2025-03-31 11:51:15 +02:00
Mike Yuan
6b4a05519b sd-bus/bus-common-errors: add missing error map entries 2025-03-29 19:51:13 +01:00
Luca Boccassi
d95818f522 meson: add feature flag for nspawn build
Other tools have it, nspawn doesn't, add one
2025-03-28 10:34:02 +00:00
Daan De Meyer
e213ecd484 test: Make it possible to run the integration tests standalone (#36868)
Currently, to run the integration tests, it's still necessary to
install various other build tools besides meson: A compiler, gperf,
libcap, ... which we want to avoid in CI systems where we receive
prebuilt systemd packages and only want to test them. Examples are
Debian's autopkgtest CI and Fedora CI. Let's make it possible for
these systems to run the integration tests without having to install
any other build dependency besides meson by extracting the logic
required to run the integration tests with meson into a separate
subdirectory and adding a standalone top-level meson.build file which
can be used to configure a meson tree with as its only purpose running
the integration tests.

Practically, we do the following:
- all the integration test directories and integration-test-wrapper.py
  are moved from test/ to test/integration-tests/.
- All the installation logic is kept out of test/integration-tests/ or
  any of its subdirectories and moved into test/meson.build instead.
- We add test/integration-tests/standalone/meson.build to run the
  integration tests standalone. This meson file includes
  test/integration-tests via a cute symlink hack to trick meson into
  including a parent directory with subdir().
- Documentation is included on how to use the new standalone mode.
2025-03-27 21:38:00 +01:00
Zbigniew Jędrzejewski-Szmek
bcc1eebd8f gpt-auto-generator: improve log message
We said "exiting", but then the program continues to do other operations
and log additional messages.
2025-03-27 12:04:47 +01:00
Zbigniew Jędrzejewski-Szmek
6bb9caa256 shared/exec-util: fix logging of the args of an executed program
The debug logs has lots of "About to execute /some/path (null)". This
occurs when the args array is empty. Instead, only print "(null)" if
we failed with oom.

Having strv_skip() return NULL makes this pleasant to write without repeating
strv_isempty() a few times.
2025-03-27 12:04:43 +01:00
Zbigniew Jędrzejewski-Szmek
d193cb77c7 test-execve: minor simplification 2025-03-27 12:04:40 +01:00
Zbigniew Jędrzejewski-Szmek
fdfa9fd8ab various: handle the positive condition after strv_skip() first 2025-03-27 12:04:37 +01:00
Zbigniew Jędrzejewski-Szmek
129446ddec busctl: use RET_GATHER 2025-03-27 12:04:33 +01:00