Commit Graph

5691 Commits

Author SHA1 Message Date
Yu Watanabe
9fff6bf59e nspawn: create /dev/net/tun only when it is accessible
Follow-up for 985ea98e7f.

When DevicePolicy= is enabled, but DeviceAllow= for /dev/net/tun is not
specified, bind-mounting the device node from the host system is
meaningless, as it cannot be used in the container anyway.

Let's check the device node is accessible before creating or
bind-mounting.
2025-02-18 23:24:20 +09:00
Luca Boccassi
21d36ef770 mkosi: Fix mkosi.clangd (#36387)
- Add missing '--' delimiter
- Use the new BuildSubdirectory JSON field to figure out the build
  subdirectory.
- Remove the /usr/include path mapping for now. This means we can't
  jump into system headers anymore if they don't exist on the host,
  we can find a way to add this back later if it turns out to be
  crucial.
2025-02-14 20:02:45 +00:00
Daan De Meyer
487ec6aa3f mkosi: Update to latest 2025-02-14 17:13:08 +01:00
Yu Watanabe
03d8b9dfab TEST-75-RESOLVED: skip a testcase when running on sanitizer 2025-02-14 11:54:56 +00:00
Yu Watanabe
2c9d6986d8 TEST-75-RESOLVED: keep IPv6 stack enabled
To make the issue #36351 easily reproduced.
2025-02-14 11:54:56 +00:00
Yu Watanabe
39da9b894f TEST-75-RESOLVED: assume knot 3.0 or newer is installed
And make the test failed if knot is installed but older than 3.0.
2025-02-14 11:54:56 +00:00
Muhammad Nuzaihan Bin Kamal Luddin
e644b332d0 resolve: clear previous assignments of RefuseRecordTypes= on reload
Follow-up for 81ae2237c1.
2025-02-14 11:54:56 +00:00
Yu Watanabe
4053af87bb core/mount: rework GracefulOptions= as x-systemd.graceful-option= (#36356)
Prompted by #36337
2025-02-14 13:01:14 +09:00
Daan De Meyer
ebcd568aa3 mkosi: Update to latest 2025-02-14 02:05:03 +00:00
Daan De Meyer
1e6514d6d0 fmf: Don't fail if we can't modify sysctl values
If the script is running unprivileged we might not be able to modify
these so let's skip in that case.
2025-02-13 20:35:56 +00:00
Daan De Meyer
b000e16798 ptyfwd: Forward various signals to forked process
We want systemd-pty-forward to be something that can be dropped in
somewhere without too much thought. To enable this, let's make sure
we forward various signals to the forked process. This makes sure that
any signals are delivered to the actual child process regardless of whether
it's running within systemd-pty-forward or not.
2025-02-13 10:21:00 +01:00
Daan De Meyer
b429f82eaf mkosi: Update to latest
In https://github.com/systemd/mkosi/pull/3497, mkosi has started parsing
options passed after the verb as regular mkosi options instead of options
for the invoked command. We adapt to this change by adding '--' as a delimiter
everywhere where required.
2025-02-12 21:39:27 +01:00
Mike Yuan
0d76f1c423 core/mount: rework GracefulOptions= to be just x-systemd.graceful-option=
09fbff57fc introduced new knob
for such functionality. However, that seems unnecessary.

The mount option string is ubiquitous in that all of fstab,
kernel cmdline, credentials, systemd-mount, ... speak it.
And we already have x-systemd.device-bound= that's parsed
by pid1 instead of fstab-generator. It feels hence more natural
for graceful options to be an extension of that, rather than
its own property.

There's also one nice side effect that the setting itself
is now more graceful for systemd versions not supporting
such feature.
2025-02-12 18:16:44 +01:00
Muhammad Nuzaihan Bin Kamal Luddin
81ae2237c1 resolve: add an option to explicitly disable query AAAA, SRV, MX, etc... (#34165)
Based on this patch i had submitted to RedHat
(https://issues.redhat.com/browse/RHEL-56280), i am submitting this
patch to this upstream systemd.

There is no way to explicitly enable/disable IPv6 AAAA queries.

Problem was that i am using RHEL9 and some applications does not use a
newer glibc that supports `no-aaaa` option in `/etc/resolv.conf`. So
some applications will still resolve IPv6 AAAA even with `no-aaaa`
option and it is inconsistent across the system where some work and some
don't.

So this systemd-resolved patch catch-all queries and disable IPv6 AAAA
queries for all applications in the OS by having an option
`RefuseRecordTypes=AAAA` to disable IPv6 AAAA queries.

Although https://github.com/systemd/systemd/pull/28136 tries to fix this
automatically but it still does not work with
`net.ipv6.conf.all.disable_ipv6 = 1`. Also tried with explicitly
removing the conditional and force set `family = AF_INET` and still
resolves AAAA records.

The issue is that i want to explicitly disable IPv6 AAAA queries instead
of systemd-resolved to figure out itself which address family it is
using, which always have problems.
2025-02-11 18:29:39 +09:00
Yu Watanabe
869b0dfe6e core: remove path to transient unit file from unit name maps on stop (#36186)
Fixes #35190.
2025-02-10 00:48:01 +09:00
Yu Watanabe
52e9bc2deb journal-remote,journal-upload: added compression support (#34822) 2025-02-09 13:33:33 +09:00
Yu Watanabe
ed8063d143 udevadm-test: show result in json format (#36284)
This adds `--json=MODE` command line option to `udevadm test`.
This may be useful for parsing e.g. network interface name or device
node symlinks.

Closes #23661.
2025-02-08 15:50:04 +09:00
Luca Boccassi
382e8a03ca network: allow to configure routing policy rule even if requesting interface is not activated yet (#36257)
Fixes a regression caused by 4f8b153d90
(v257).
Fixes #36244.
2025-02-07 22:56:36 +00:00
Yu Watanabe
ac722389a7 udevadm-test: allow to dump result in json format
This adds --json=MODE option for 'udevadm test' command.
When specified, all messages, except for the final result, will be
written to stderr, and the final result is shown in JSON format to
stdout. It may be useful for parsing the test result.
2025-02-08 01:39:35 +09:00
Andrii Chubatiuk
cfaf78001c journal-remote: added compression, compression-level and content-encoding negotiation 2025-02-07 07:05:02 +02:00
Lennart Poettering
8954a2a833 test: add some basic area tests 2025-02-06 09:23:49 +01:00
Yu Watanabe
570cd55783 udevadm: several cleanups for command line option parsers (#36241) 2025-02-06 09:39:03 +09:00
Luca Boccassi
2ee81b556f network/route: improve Gateway=_dhcp4 handling (#36183)
- Also configures route to the gateway and prefix route in the specified
table, if necessary.
- Also set preferred source address of the route.

Closes #36168.
2025-02-05 12:19:01 +00:00
Daan De Meyer
ea086b0877 network/routing-policy-rule: fix compare function (#36268)
Fixes a regression caused by fc58350aa4
(v257).
Fixes #35874.
2025-02-05 09:50:59 +01:00
Yu Watanabe
052ab05caf Two test readme improvements (#36265) 2025-02-05 10:08:00 +09:00
Yu Watanabe
a10172b035 test-network: add test case for issue #35874 2025-02-05 09:40:31 +09:00
Daan De Meyer
f017a55213 test: Move external packages section down and reword a little
This is advanced level stuff that regular contributors don't care
about in the slightest, so move it further down. Also reword the
section a little while we're at it.
2025-02-04 20:46:11 +01:00
Daan De Meyer
728a88e549 test: Move NO_BUILD instructions to a separate section
This isn't relevant for regular development, so let's move it to a
separate section.
2025-02-04 20:24:17 +01:00
Daan De Meyer
284a56ff60 test: Drop -Dremote=enabled instructions from readme
The test commands now use mkosi sandbox which always makes sure the
required dependencies for systemd-journal-remote are enabled so no
need to reconfigure meson explicitly anymore.
2025-02-04 20:21:36 +01:00
Ivan Kruglov
ea9b72ad35 machine: tests for io.systemd.MachineImage.CleanPool 2025-02-04 03:03:00 -08:00
Yu Watanabe
f7ae28fcec test-network: add test case for requesting routing policy rules by multiple interfaces
For issue #36244.
2025-02-04 12:28:59 +09:00
Yu Watanabe
295741c0d1 udevadm-verify: document '--resolve-names=late' and accept 'never' as is
When '--resolve-names=late', systemd-udevd resolves user/group names
during each event being processed, and does not verify names on parse.
When '--resolve-names=never', systemd-udevd refuses any user/group names
on parse. Hence, the parser of udev rules behaves diffrently. Let's not
convert 'never' -> 'late' silently, and use the specified option as is.

This also updates man page and shell completion for --resolve-names
option.
2025-02-02 15:55:01 +09:00
Lennart Poettering
4b840414be cryptenroll/repart/creds: no longer default to binding against literal PCR 7
PCR 7 covers the SecureBoot policy, in particular "dbx", i.e. the
denylist of bad actors. That list is pretty much as frequently updated
as firmware these days (as fwupd took over automatic updating). This
means literal PCR 7 policies are problematic: they likely break soon,
and are as brittle as any other literal PCR policies.

hence, pick safer defaults, i.e. exclude PCR 7 from the default mask.
This means the mask is now empty.

Generally, people should really switch to signed PCR policies covering
PCR 11, in combination with systemd-pcrlock for the other PCRs.
2025-01-30 10:32:26 +01:00
Yu Watanabe
448e99251a TEST-07-PID1: add reprudcer for issue #35190 2025-01-29 04:58:24 +09:00
Yu Watanabe
d90c01d02c network: bridge: add support for configuring locked ports (#36150)
"Recently" (as of 5.18) the Linux kernel gained the ability of locking
bridge ports to restrict network access to authenticated hosts only.

This is implemented by disabling automated learning and dropping
incoming traffic from unknown hosts. User space is then expected to add
fdb entries for authenticated hosts. Once a fdb entry exist, traffic for
that host will be forwarded as expected.

This was later extended with "Mac Authentication Bypass", where the
locking was extended to fdb entries. In this mode the kernel adds fdb
entries again automatically, but they are locked by default.

To properly configure this, add two network options and one netdev
option:

* `LinkLocalLearning=` to prevent the kernel from creating unlocked
entries based on link-local traffic, which would bypass any
authentication. Needed when enabling learning on a locked port.
* `Locked=` to allow setting a bridge port to locked.
* `MACAuthenticationBypass=` to allow enabling Mac Authentication
 Bypass on a port. Requires learning to be enabled on the port as well
 (and consequently `LinkLocalLearning` disabled on the bridge).

An authenticator (e.g. hostapd) is still needed to do the actual
authentication, the kernel only provides the access control.
2025-01-29 04:16:20 +09:00
Nick Rosbrook
d6608da1e6 networkd-test: add basic tests for systemd-networkd-wait-online --dns 2025-01-28 08:49:49 -05:00
Nick Rosbrook
5ee20919a2 test: add test for resolved SubscribeDNSConfiguration API 2025-01-28 08:49:49 -05:00
Nick Rosbrook
266cfdfc77 test: cleanup after testcase_12_resolvectl2 2025-01-28 08:49:49 -05:00
Jonas Gorski
08a26ecc47 network: bridge: add support for IFLA_BRPORT_MAB
Since linux commit a35ec8e38cdd1766f29924ca391a01de20163931 ("bridge:
Add MAC Authentication Bypass (MAB) support"), included since v6.2, it
is possible to enable MAC Authentication Bypass for bridge ports. In
this mode the locked port learns again, but the learned fdb entries are
locked, allowing user space to unlock hosts based seen MAC addresses.

This requires learning to be enabled on the port, and link-local
learning disabled for the bridge.

Add support to systemd-network for setting the new attribute for bridge
ports.
2025-01-28 12:22:26 +01:00
Jonas Gorski
a434de6056 network: bridge: add support for IFLA_BRPORT_LOCKED
Since linux commit a21d9a670d81103db7f788de1a4a4a6e4b891a0b ("net:
bridge: Add support for bridge port in locked mode"), included since
v5.18,  it is possible to set bridge ports to locked.

Locked ports do not learn automatically, and discard any traffic from
unknown source MACs. To allow traffic, the userspace authenticator is
expected to create fdb entries for authenticated hosts.

Add support to systemd-network for setting the new attribute for bridge
ports.
2025-01-28 10:38:01 +01:00
Jonas Gorski
d7de242ce7 network: bridge: add support for NO_LL_LEARN
When using locked ports on a bridge link-local learning needs to be
disabled to prevent the kernel from learning and automatically unlocking
hosts based on link-local traffic.

So add support for enabling NO_LL_LEARN for bridges.
2025-01-28 10:38:01 +01:00
Yu Watanabe
2ea15435fd test-network: add test case for Gateway=_dhcp4 with Table= 2025-01-27 08:39:09 +09:00
Yu Watanabe
ba0266b376 network: fix offset of preference in backward compat option
Fixes a bug introduced by a10d6e0124.

Fixes oss-fuzz#391916479 (https://issues.oss-fuzz.com/issues/391916479).
Fixes #36172.
2025-01-26 11:09:04 +09:00
Lennart Poettering
d6b008b01e Enforce per-user quota on /tmp/ and /dev/shm/ as user logs in (#36010)
There's finally quota on tmpfs, hence let's use it to make it harder for
users to DoS the system by consuming all disk space in /tmp/ and
/dev/shm/.

This enforces a default limit of 80% quota of the backing fs for these
two dirs for users, but this can be overriden in the user record, if
desired.

This also adds two other interesting features:

1. mount units gain GracefulOptions= which takes optional mount options
that are added only if supported by the kernel. (this is used to enable
usrquota on /tmp/, if available.)
2. The PAM logic in service management now supports reading passwords
from service credentials and via the askpw logic. This used for make
testing easy (so that we can run0 into a homed user which strictly
requires a password).
2025-01-24 12:52:27 +01:00
Luca Boccassi
3f9539a97f test: split VM-only subtests from TEST-74-AUX-UTILS to new VM-only test
TEST-74-AUX-UTILS covers many subtests, as it's a catch-all job, and a few
need a VM to run. The job is thus marked VM-only. But that means in settings
where we can't run VM tests (no KVM available), the entire thing is skipped,
losing tons of coverage that doesn't need skipping.

Move the VM-only subtests to TEST-87-AUX-UTILS-VM that is configured to only
run in VMs under both runners. This way we keep the existing tests as-is, and
we can add new VM-only tests without worrying. This is how the rest of the
tests are organized.

Follow-up for f4faac2073
2025-01-24 08:37:51 +01:00
Lennart Poettering
d58d449fc6 test: add test case for tmpfs quota logic + PAMName= ask-password logic 2025-01-23 22:36:39 +01:00
Lennart Poettering
db5c4a4503 test: test comprehensive tests for new (and old) nspawn userns modes 2025-01-23 21:48:02 +01:00
Yu Watanabe
02ec3dd4ef test: add test cases for OWNER=/GROUP= with non-system user/group 2025-01-24 02:33:18 +09:00
Yu Watanabe
7f2175eabb udevadm: introduce cat command
This introduces 'udevadm cat' command, that shows udev rules files or
udev.conf, which may be useful for debugging.

Closes #35818.
2025-01-23 22:23:45 +09:00
Yu Watanabe
7cb4508c5a udevadm-verify: chase specified paths
Also, when a filename is specified, also search udev rules file in
udev/rules.d directories.

This also refuses non-existing files, and file neither nor a regular
nor a directory, e.g. /dev/null.
2025-01-23 22:23:45 +09:00