Commit Graph

5980 Commits

Author SHA1 Message Date
Yu Watanabe
4df7d51cde networkd-test: stop varlink socket before setting up runtime directories
Follow-up for b0ea79c5b5.
2025-07-05 16:54:19 +09:00
ZIHCO
9a08000d18 systemd-analyze: added the verb unit-shell to spawn and attach shell 2025-07-04 16:09:07 +01:00
Yu Watanabe
c2f3bb742b Add systemd-analyze verb to list runtime unit properties (#37665) 2025-07-04 11:47:38 +09:00
Zbigniew Jędrzejewski-Szmek
a839c4b7b7 analyze: add transient-settings verb
Related to https://github.com/systemd/systemd/pull/37641.

The name "transient settings" was used in docs/TRANSIENT-SETTINGS.md.
Using "setting" helps distinguish this from D-Bus "properties", which are
a much larger set, partially overlapping.
2025-07-03 21:03:26 +02:00
Zbigniew Jędrzejewski-Szmek
9228d67dc8 test: drop ProtectHostnameEx, add one test for ProtectHostnameEx
This is a separate commit because the parent commit is supposed to be
backward compatible, i.e. the tests must pass with both the bogus ProtectHostnameEx
name and ProtectHostname.

A test is added for ProtectHostnameEx to verify that it is still accepted
for backward compat.
2025-07-03 19:35:33 +02:00
Daan De Meyer
67b2cb7769 test: Add tests for various varlink socket units
Let's make sure these socket units work as expected by stopping the
related services and making sure the services are started as expected
when a client connects to the corresponding socket.
2025-07-03 11:24:03 +02:00
Luca Boccassi
a63f0ea73d test: allow to run test-local-addresses with IPv6 disabled by default, and assume RTA_VIA is always supported (#38039) 2025-07-03 09:58:02 +01:00
Yu Watanabe
34af1513d0 fuzz: avoid assertion for ExecContext.private_var_tmp triggered
Follow-up for 6156bec7a4.

Fixes #38037 and oss-fuzz#429112745.
2025-07-03 09:55:58 +01:00
Zbigniew Jędrzejewski-Szmek
0b5b043733 TEST-54-CREDS: s/ImportCredentialEx/ImportCredential/ except for one place
This is a separate commit because the tests are supposed to pass with both
the old spelling and the new.
2025-07-03 10:37:34 +02:00
Yu Watanabe
3d38732179 test: assume RTA_VIA is supported
RTA_VIA support was added in kernel v5.2:
d15662682d

Our baseline on the kernel is v5.4. Hence, we can assume that the
attribute is supported.
2025-07-03 12:51:22 +09:00
Mike Yuan
c950bb3bd7 TEST-07-PID1: add test cases for DeferTrigger= 2025-06-30 13:10:43 +02:00
Nick Labich
a9e860f22e nspawn: Add --bind-user-shell= to control shells for --bind-user
Prior to this change, no user shell can be specified in the user
records passed into a container via --bind-user=. This new option
allows users to:

1. When false (the default), continue to specify no user shell for
   each bound user record, resulting in the use of the container's
   default shell for bound users.

2. When true, include each host user's shell in the corresponding
   user record passed into a container (via --bind-user=).

3. When an absolute path, set that path as the user shell for each
   user record passed into a container (via --bind-user=).

This does not change the existing behavior, but allows users to
opt-in to either copy the shells specified by the host user records
or override the shell explicitly by path.
2025-06-30 10:45:10 +02:00
Yu Watanabe
bb60dd27a6 TEST-17-UDEV: check the exit code at last
Otherwise, it is hard to debug when the test failed.
2025-06-30 05:35:13 +09:00
Yu Watanabe
b351ebdc97 Revert "tree-wide: use CONF_FILES_CHASE_BASENAME where root directory is specified"
This reverts commit 6b606f3586.

The commit was mistakenly merged without review, and has several issues.
Let's revert at least now.
2025-06-29 10:15:56 +09:00
Zbigniew Jędrzejewski-Szmek
7d247d3cb8 meson: drop explicit custom_target names
[1] says:
> Since 0.60.0 the name argument is optional and defaults to the basename of
> the first output
We specify >= 0.62 as the supported version, so drop the duplicate name in all cases
where it is the same as outputs[0], i.e. almost all cases.

[1] https://mesonbuild.com/Reference-manual_functions.html#custom_target
2025-06-28 17:14:50 +02:00
Yu Watanabe
6b606f3586 tree-wide: use CONF_FILES_CHASE_BASENAME where root directory is specified
Otherwise, the result may point to outside of the root directory.

This also sets CONF_FILES_REGULAR and CONF_FILES_FILTER_MASKED, as the
callers will call fopen() or friends for the result, thus the enumerated
results must be non-empty regular files.
2025-06-28 04:13:43 +09:00
Yu Watanabe
d63c8ce020 test-network: wait for all addresses and routes configured before start monitoring
Otherwise, kernel may announce configuration of an address or route
after 'ip monitor' is started.

This also makes the test check if the whole output of 'ip monitor' is
empty. Otherwise, if the test fails, it is hard to find what is wrong.

Follow-ups for 912a48572d and
bcb9e72b6b.

Fixes #37982.
2025-06-27 11:30:33 +01:00
Lennart Poettering
c343f0ee13 repart: respect minimum sector size for ESP/VFAT partitions
Fixes: #37801
2025-06-26 14:52:20 +02:00
Jan Čermák
a7bfb9f76b journal-gatewayd: fix handling of num_skip pointing beyond the last entry
When `num_skip` is supplied to the `Range` header, journal-gatewayd
always returns the very last record even though it should have been
skipped. This is because the `sd_journal_next_skip` always returns
non-zero value on the first call, leading to one iteration of the
`request_reader_entries` returning the last record.

To avoid this unexpected behavior, check that the number of lines we
have skipped by is not lower than the requested skip value. If it is,
then it means there are lines which should not be returned now -
decrement the n_skip counter then and return from the function, closing
the stream if follow flag is not set.

Fixes #37954
2025-06-26 02:44:59 +09:00
Luca Boccassi
a0dfb02456 test: escape '+' from uname -r before using in regex via '=~'
It will otherwise interpret characters such as '+' as if they
were regex, and break matching.

For example TEST-71-HOSTNAME started failing when
uname -r started including a '+':

FAIL: 'Kernel: Linux 6.12.33+deb13-amd64' not found in:
 Static hostname: host
       Icon name: computer-vm
         Chassis: vm 🖴
      Machine ID: e6471c1f95ab49098827498ed816cdf7
         Boot ID: 231da987f64d4af59f2076fbb638c611
  Virtualization: kvm
Operating System: Debian GNU/Linux 13 (trixie)
          Kernel: Linux 6.12.33+deb13-amd64
    Architecture: x86-64
2025-06-25 05:44:13 +09:00
Lennart Poettering
9422ce83c2 udev: reset loopback block device ownership and mode on detach
Loopback block devices are agressively reused, without being removed in
between. This means various inode attributes on their device nodes will
– so far – remain in effect between uses of the devices. Since there are
applications which change access mode/ownership of such devices after
attaching files to them, let's undo this again when we detect them to be
unused again.

Fixes: #37745
2025-06-24 13:10:11 +02:00
Valentin David
0dc39dffbd Use paths specified from environment variables for /etc configuration files
Some configuration files that need updates are directly under in /etc. To
update them atomically, we need write access to /etc. For Ubuntu Core this is
an issue as /etc is not writable. Only a selection of subdirectories can be
writable. The general solution is symlinks or bind mounts to writable places.
But for atomic writes in /etc, that does not work. So Ubuntu has had a patch
for that that did not age well.

Instead we would like to introduce some environment variables for alternate
paths.

 * SYSTEMD_ETC_HOSTNAME: /etc/hostname
 * SYSTEMD_ETC_MACHINE_INFO: /etc/machine-info
 * SYSTEMD_ETC_LOCALTIME: /etc/localtime
 * SYSTEMD_ETC_LOCALE_CONF: /etc/locale.conf
 * SYSTEMD_ETC_VCONSOLE_CONF: /etc/vconsole.conf
 * SYSTEMD_ETC_ADJTIME: /etc/adjtime

While it is for now expected that there is a symlink from the standard, we
still try to read them from that alternate path. This is important for
`/etc/localtime`, which is a symlink, so we cannot have an indirect symlink or
bind mount for it.

Since machine-id is typically written only once and not updated. This commit
does not cover it. An initrd can properly create it and bind mount it.
2025-06-23 15:32:11 +02:00
Lennart Poettering
222b0b05ce core: escape UTF-8 in mount unit Where field before sending to clients
Followup for: 4804da5853 #27541

Fixes: #36206
2025-06-21 02:22:28 +09:00
Jan Čermák
a2015ad126 journal-gatewayd: make num_entries in Range header optional again
Since 435c372ce5 added in v256,
num_entries part of the Range header is mandatory and error is returned
when it's not filled in. This makes using the "follow" argument clumsy,
because for an indefinite following of the logs, arbitrary high number
must be specified. This change makes it possible to omit it again and
documents this behavior in the man page.

Moreover, as the cursor part of the header was never mandatory, enclose
it in square brackets in the documentation as well and elaborate how
indexing works.

Following are some concrete examples of the Range header which are now
accepted:

 entries= (or entries=:)
  - everything starting from the first event

 entries=cursor
  - everything starting from `cursor`

 entries=:-9:10
  - last 10 events and close the connection

If the follow flag is set:

 entries=:-4:10
  - last 5 events, wait for 5 new and close connection

 entries=:-9:
  - last 10 events and keep streaming

Note that only the very last one is changing current behavior, but
reintroduces pre-v256 compatibility.

Fixes #37172
2025-06-21 02:08:03 +09:00
Lennart Poettering
576a2bc79b resolved: honour RefuseRecordTypes= also in proxy mode
Fixes: #36491
2025-06-19 18:02:54 +02:00
Matteo Croce
030b227cec test: add test for systemd upgrade
Add a basic test to check that systemd works after an upgrade
2025-06-18 09:51:21 +01:00
Yu Watanabe
e08fdfdd7d test-network: compare LLDP sender and receiver information 2025-06-18 01:51:19 +09:00
Lennart Poettering
f2a365b982 network/dhcp-server: improvements for saving/loading leases (#37835) 2025-06-17 14:31:22 +02:00
Arkadiusz Bokowy
998aa62a21 sd-bus: Preserve interfaces addition order
When adding a new interface to the object add it at the end of the list.
This way, when iterating over the list, e.g., during handling introspect
call, the order of returned interfaces will mach the order in which they
were added.
2025-06-17 17:28:35 +09:00
Luca Boccassi
d3a57a0853 fstab-generator: set mode=0755 with root=tmpfs
If mode= is not set in rootflags= add mode=0755 when a tmpfs
is used on the rootfs, otherwise it will be group/world writable
as that's the default mode for tmpfs filesystems.

Follow-up for 725ad3b062
2025-06-17 16:13:45 +09:00
Yu Watanabe
888e3f4357 TEST-75-RESOLVED: add test case for reloading DNSStubListenerExtra= 2025-06-16 22:04:52 +09:00
Yu Watanabe
312e3835ee test-network: add tests for tunnel mode 2025-06-16 17:01:37 +09:00
Mike Yuan
a14a6f1df6 socket-activate: add a --now option to instantly start service (#37620) 2025-06-16 02:08:57 +02:00
Daniel Foster
9e0d0c3fdf test: add simple tests for systemd-socket-activate tool 2025-06-15 16:34:16 +10:00
Yu Watanabe
ce5a54ed9b test-network: add test case for issue #37714
I cannot reproduce the issue with the current git HEAD.
Let's add a test case that is used by the reporter of the issue.
2025-06-15 09:33:23 +09:00
Yu Watanabe
009d64dddd test-network: add test case for PersistLeases=runtime 2025-06-14 03:42:24 +09:00
Avram Dorfman
fb9076b994 test-network: add test case for bootp
Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
2025-06-13 14:15:04 +09:00
Yu Watanabe
78f8d5ed71 network: also check ID_NET_MANAGED_BY property on reconfigure
Previously, the property was checked only when an uevent is received,
so even if an interface has ID_NET_MANAGED_BY property, the interface
will be configured by networkd when reconfiguration is triggered e.g.
when interface state is changed.

Follow-up for ba87a61d05.
Fixes #36997.
2025-06-12 14:24:50 +09:00
Yu Watanabe
c6aae2cd8a test-network: add test case for issue #32186
The reporter said that the issue is caused by BindCarrier=, but
I cannot reproduce it. Anyway, let's test it.
2025-06-11 17:32:46 +09:00
Yu Watanabe
8882519583 test-network: read the current link flags of bond interface
Follow-up for 2700d2c7dc.
2025-06-11 17:18:43 +09:00
Dan Streetman
db83bd7e36 test: update keyutil test to verify new pkcs7 --hash-algorithm param 2025-06-10 08:46:36 -04:00
Yu Watanabe
b5bd717fcd test: extend timeout and enable generating debugging logs
Not sure why the test failed, but maybe the test environment is too
slow? Even this does not fix the failure, by enabling debugging logs,
this hopefully provides more useful information for debugging.

For issue #37685.
2025-06-06 19:43:32 +01:00
Daan De Meyer
f8f67eab70 core: Make sure we handle DelegateSubgroup= in combo with cgroupns
Currently, if we use a cgroup namespace together with DelegateSubgroup=,
the subgroup becomes the root of the cgroup namespace because we move the
service process to the subgroup before we unshare the cgroup namespace, and
the current cgroup becomes the root of the cgroup namespace when we unshare
the cgroup namespace.

Let's fix the problem by not moving the service process to the subgroup until
we've unshared the cgroup namespace. Note that this doesn't break the primary use
case of CLONE_INTO_CGROUP since we still use it to immediately clone into the service
main cgroup, just not anymore into the subgroup, but this shouldn't matter in practice.

Additionally, we need special handling for control processes, as those *do*
need to get spawned into the subcgroup immediately if delegation is configured to
avoid violating the cgroupsv2 "no inner processes" rule.

Effectively, this leaves us with the following logic:
- In exec_spawn(), spawn into subgroup if we're spawning a control process
  that needs to be spawned into a subgroup immediately. Otherwise, spawn into
  main service cgroup.
- In exec_invoke(), move into subgroup early if we don't need a cgroup namespace.
  Otherwise, move into subgroup after we've unshared the cgroup namespace.
2025-06-05 12:37:02 +02:00
Yu Watanabe
356e9bc018 test-network: extend comments how to run the test 2025-06-04 16:46:41 +01:00
Yu Watanabe
d2b41bd69e TEST-17-UDEV: acquire SYS_UID_MAX/SYS_GID_MAX from userdbctl
Suse build systemd with -Dsystem-uid-max=499 -Dsystem-gid-max=499,
and seems to not provide /etc/login.defs file. See
2dc224ae5d/packages/s/systemd/systemd.spec
2025-06-04 21:54:32 +09:00
Lennart Poettering
ccd2bf48b2 pcrlock: add "is-supported" verb that checks if the local TPM supports the commands we need for pcrlock
systemd-pcrlock requires support for the PolicyAuthorizeNV command,
which is not implemented in the first TPM2 releases. We also strictly
require SHA-256 support. Hence add a tool for checking for both of
these.

This is a tighter version of "systemd-analyze has-tpm2", that checks for
the precise feature that systemd-pcrlock needs, on top of basic TPM2
functionality.

Fixes: #37607
2025-06-03 16:12:45 +02:00
Luca Boccassi
6cd1842e33 test: send monotonic timestamp rather than unix seconds for MONOTONIC_USEC= argument
Follow-up for 3998b30a04
2025-06-03 10:54:03 +09:00
Yu Watanabe
0436240dd2 udevadm: allow to specify device by device ID (#37636) 2025-06-02 18:02:36 +09:00
Christian Glombek
0af9937691 portable,sysext: match extension OS ID also against host ID_LIKE 2025-05-31 10:02:11 +09:00
Luca Boccassi
703fbb0bba test: wait for coredump to appear before parsing
A new core was added to the test, but the loop counter was not increased
to wait for it, so the test races against systemd-coredump's processing.

This failed at least once in debci:

8015s [   32.227813] TEST-87-AUX-UTILS-VM.sh[1038]: + coredumpctl info COREDUMP_TIMESTAMP=1679509902000000
8015s [   32.228684] TEST-87-AUX-UTILS-VM.sh[1723]: No coredumps found.

Follow-up for 0c49e0049b

Fixes https://github.com/systemd/systemd/issues/37666
2025-05-31 10:01:30 +09:00