Commit Graph

83141 Commits

Author SHA1 Message Date
Luca Boccassi
bef244392b stub: fix passing kernel cmdline when loading via shim
This was mistakenly dropped when the custom PE loader was added.
Add it back, otherwise no smbios/addon cmdline options are passed
through.

Fixes https://github.com/systemd/systemd/issues/38349

Follow-up for 40aabfae72
2025-07-27 22:44:05 +01:00
Yu Watanabe
4fb09adec4 Rework file system group magic lookups (#38340) 2025-07-28 03:39:34 +09:00
Yu Watanabe
7292d676d0 test: skip verification for racy test cases
FORMAT_LIFETIME() internally calls now(), hence we cannot provide any
reliable verifications for finite lifetime.
2025-07-28 03:37:31 +09:00
Zbigniew Jędrzejewski-Szmek
aca4353ab2 Rework file system group lookups
We want to check if the magic we got from statfs() is one of the magics listed
for one of the file systems in the given group. To do this, we'd iteratate over
the file system names, convert each name to an array of magics, and compare
those to the one we got. We were using gperf-generated lookup table for this,
so the string lookups were quick, but still this seems unnecessarily complex.
Let's just generate a simple lookup function, because we can:

$ src/basic/filesystem-sets.py fs-in-group
bool fs_in_group(const struct statfs *st, FilesystemGroups fs_group) {
        switch (fs_group) {
        case FILESYSTEM_SET_BASIC_API:
                return F_TYPE_EQUAL(st->f_type, CGROUP2_SUPER_MAGIC)
                    || F_TYPE_EQUAL(st->f_type, CGROUP_SUPER_MAGIC)
                    || F_TYPE_EQUAL(st->f_type, DEVPTS_SUPER_MAGIC)
                    || F_TYPE_EQUAL(st->f_type, MQUEUE_MAGIC)
                    || F_TYPE_EQUAL(st->f_type, PROC_SUPER_MAGIC)
                    || F_TYPE_EQUAL(st->f_type, SYSFS_MAGIC)
                    || F_TYPE_EQUAL(st->f_type, TMPFS_MAGIC);
        case FILESYSTEM_SET_ANONYMOUS:
                return F_TYPE_EQUAL(st->f_type, ANON_INODE_FS_MAGIC)
                    || F_TYPE_EQUAL(st->f_type, PIPEFS_MAGIC)
                    || F_TYPE_EQUAL(st->f_type, SOCKFS_MAGIC);
...

We flatten the nested lookup of group=>fs=>magic into a single level.
The compiler can work its magic here to make the lookup quick.
2025-07-27 13:14:05 +02:00
Zbigniew Jędrzejewski-Szmek
b0123576f4 meson: rework generation of file system lookup helpers
Previously, the gperf table was the main "source of truth", and additional
information (e.g. which file system names are obsolete) was scattered in
various files. We would then parse the gperf file, using python, awk, grep, and
bash, and use the results in various ways. This is hard to understand and
maintain. Let's replace all of this with a single python script that generates
the requested outputs as appropriate.

$ diff -u <(git show @{u}:src/basic/filesystems-gperf.gperf) \
          <(src/basic/filesystem-sets.py gperf)
shows that the outputs are the same except for comments.

Similarly, 'src/basic/filesystem-sets.py fs-type-to-string' and
'src/basic/filesystem-sets.py filesystem-sets' can be used to view
the generated code.

The check that the kernel doesn't define any new file system magics is
converted into a normal test. It doesn't seem necessary to fail the build
when that happens.
2025-07-27 13:13:54 +02:00
Zbigniew Jędrzejewski-Szmek
c136be3f04 basic/stat-util: avoid access syscall
I was looking at strace for systemd-getty-generator and noticed the call to
faccessat2(3</sys>, "", W_OK, AT_EMPTY_PATH), even though we already did
fstatfs(3</sys>), which should give us all the necessary information. Let's
only do this additional check when it's likely to yield something useful, i.e.
for network fses and otherwise skip the syscall.

The call to statvfs is replaced by statfs because that gives us the .f_type
field and allows is_network_fs() to be called.

I'm a bit worried that the is_network_fs() is somewhat costly. This will be
improved in later commits.
2025-07-27 13:13:43 +02:00
Jesse Guo
9e6f0d4bbd po: Translated using Weblate (Chinese (Simplified) (zh_CN))
Currently translated at 100.0% (264 of 264 strings)

po: Translated using Weblate (Chinese (Simplified) (zh_CN))

Currently translated at 100.0% (264 of 264 strings)

po: Translated using Weblate (Chinese (Simplified) (zh_CN))

Currently translated at 100.0% (264 of 264 strings)

Co-authored-by: Jesse Guo <jesseguotech@outlook.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/zh_CN/
Translation: systemd/main
2025-07-27 19:23:54 +09:00
Yu Watanabe
31f388ea15 sd-bus: escape invalid characters in error message
At many places, we pass arguments of dbus method calls to
sd_bus_error_setf(), and produces unprintable log messages.
Let's always escape the generated error message.

This fixes something like the following:
```
[ 1921.875668] systemd-logind[611]: Got message type=method_call sender=:1.46 destination=:1.6 path=/org/freedesktop/login1 interface=org.freedesktop.login1.Manager member=GetSeat  cookie=1344 reply_cookie=0 signature=s error-name=n/a error-message=n/a
[ 1921.875758] systemd-logind[611]: [725B blob data]
[ 1921.875777] systemd-logind[611]: [768B blob data]
```
2025-07-27 11:03:15 +01:00
Luca Boccassi
ef101750ca TEST-21-DFUZZER: improve stability of the test, and enable services to be tested (#37862)
Fixes #37834.
2025-07-27 10:33:12 +01:00
Yu Watanabe
5c68c51045 NEWS: announce legacy iptables/libiptc support will be dropped in v259
nftables is available since kernel 3.13 (released on 19 January 2014).
Major distributions have already provided nftables, and marked/called
iptables as deprecated or legacy.

Moreover, currently, iptables/libiptc backend does not support IPv6.

Hence, it is not necessary to keep iptables/libiptc backend anymore.
Let's drop it in the next release.

Note, fedora/centos have already disabled iptables/libiptc support since v249.
2025-07-27 09:15:28 +02:00
Valentin David
5e2ad03dd8 pcrlock: Return positive exit status
Follow-up for 89e83aada8.

`is-supported` expects to return a positive exit status.
To achieve that, verb_make_policy() needs to return 0 on success.

Finishes the fix for #38019.

Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
2025-07-27 01:03:13 +01:00
Yu Watanabe
7db7b75ab3 TEST-04-JOURNAL: add more test cases for LogFilterPatterns=
For issue #38361.
2025-07-27 01:00:38 +01:00
Yu Watanabe
a77506c75f test: several cleanups for TEST-74-AUX-UTILS.socket-activate.sh
- wait after kill,
- try --now only once,
- ignore error in reading /proc/$PID/comm when --now is set,
  as the process may be already died.

Follow-up for 9e0d0c3fdf.

Hopefully fixes #38352.
2025-07-27 00:59:52 +01:00
Yu Watanabe
0464222aed locale: escape invalid keymap on logging
The keymap string may come from dbus method and may contain invalid
characters.
2025-07-27 00:58:02 +01:00
Yu Watanabe
e9eaa66ed8 man/repart: fix the required btrfs-progs version
Follow-up for 12c29e5b3a.

Prompted by #38355.
2025-07-27 00:56:28 +01:00
Yu Watanabe
69865ca697 TEST-21-DFUZZER: suppress debugging logs from homed, nsresourced, and userdbd 2025-07-27 08:48:53 +09:00
Yu Watanabe
2487f72bdc TEST-21-DFUZZER: enable services to be tested
Since e19e17df57, timesyncd is disabled by
default, and fuzzing for timesyncd failed.

```
[  754.247451] TEST-21-DFUZZER.sh[658]: Bus: org.freedesktop.timesync1 (system)
[  754.247725] TEST-21-DFUZZER.sh[658]: + systemd-run --pipe --wait -- dfuzzer -b 10000 -n org.freedesktop.timesync1
[  754.282237] TEST-21-DFUZZER.sh[3236]: Running as unit: run-p3236-i3237.service
[  754.348983] TEST-21-DFUZZER.sh[3238]: [SESSION BUS]
[  754.350443] TEST-21-DFUZZER.sh[3238]: Bus not found.
[  754.350705] TEST-21-DFUZZER.sh[3238]: [SYSTEM BUS]
[  754.359249] TEST-21-DFUZZER.sh[3238]: Error while calling method 'GetConnectionUnixProcessID': GDBus.Error:org.freedesktop.DBus.Error.NameHasNoOwner: The connection does not exist
[  754.359520] TEST-21-DFUZZER.sh[3238]: Couldn't get the PID of the tested process
[  754.359764] TEST-21-DFUZZER.sh[3238]: Exit status: 4
[  754.386721] TEST-21-DFUZZER.sh[3236]:           Finished with result: exit-code
[  754.387331] TEST-21-DFUZZER.sh[3236]: Main processes terminated with: code=exited, status=4/NOPERMISSION
[  754.387537] TEST-21-DFUZZER.sh[3236]:                Service runtime: 74ms
[  754.387706] TEST-21-DFUZZER.sh[3236]:              CPU time consumed: 21ms
[  754.389210] TEST-21-DFUZZER.sh[3236]:                    Memory peak: 12.9M (swap: 0B)
```

Also, create dummy interface for networkd and resolved.

Fixes #37834.
2025-07-27 08:48:53 +09:00
Yu Watanabe
5e2b606e4e TEST-21-DFUZZER: first test session bus, then service bus, finally system bus 2025-07-27 08:48:53 +09:00
Yu Watanabe
951e313b9a TEST-21-DFUZZER: update the list of destructive methods 2025-07-27 08:48:53 +09:00
Jesse Guo
f37c473fc5 po: Translated using Weblate (Chinese (Simplified) (zh_CN))
Currently translated at 100.0% (264 of 264 strings)

po: Translated using Weblate (Chinese (Simplified) (zh_CN))

Currently translated at 100.0% (264 of 264 strings)

Co-authored-by: Jesse Guo <jesseguotech@outlook.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/zh_CN/
Translation: systemd/main
2025-07-27 07:28:56 +09:00
Jesse Guo
7c23e3bc31 po: Translated using Weblate (Chinese (Simplified) (zh_CN))
Currently translated at 100.0% (264 of 264 strings)

po: Translated using Weblate (Chinese (Simplified) (zh_CN))

Currently translated at 100.0% (264 of 264 strings)

Co-authored-by: Jesse Guo <jesseguotech@outlook.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/zh_CN/
Translation: systemd/main
2025-07-27 04:39:40 +09:00
Jesse Guo
40e48f74be po: Translated using Weblate (Chinese (Simplified) (zh_CN))
Currently translated at 99.6% (263 of 264 strings)

Co-authored-by: Jesse Guo <jesseguotech@outlook.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/zh_CN/
Translation: systemd/main
2025-07-27 04:12:29 +09:00
Jesse Guo
fb3efa1ad1 po: Translated using Weblate (Chinese (Simplified) (zh_CN))
Currently translated at 99.2% (262 of 264 strings)

Co-authored-by: Jesse Guo <jesseguotech@outlook.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/zh_CN/
Translation: systemd/main
2025-07-27 01:27:31 +09:00
Jesse Guo
0b22962be6 po: Translated using Weblate (Chinese (Simplified) (zh_CN))
Currently translated at 98.8% (261 of 264 strings)

Co-authored-by: Jesse Guo <jesseguotech@outlook.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/zh_CN/
Translation: systemd/main
2025-07-27 00:22:34 +09:00
Yu Watanabe
3ea86aa673 TEST-64-UDEV-STORAGE: wait for partition devices being created before calling udevadm trigger
For some reasons, kernel or sfdisk once remove the created partitions
and recreated them. And if 'udevadm trigger' triggers devices currently
being removed, the udevd does not receive the triggered events, and the
command stuck.

```
[   33.150452] TEST-64-UDEV-STORAGE.sh[546]: + sfdisk --wipe=always /dev/md/mdmirpar
[   33.478336] systemd-udevd[442]: md127: Device is queued (SEQNUM=2163, ACTION=change)
[   33.480153] kernel:  md127: p1 p2 p3
[   33.483772] systemd-udevd[442]: md127p1: Device is queued (SEQNUM=2164, ACTION=add)
[   33.483914] systemd-udevd[442]: md127p2: Device is queued (SEQNUM=2165, ACTION=add)
[   33.484999] systemd-udevd[442]: md127p3: Device is queued (SEQNUM=2166, ACTION=add)
[   33.485564] systemd-udevd[442]: md127: Received inotify event of watch handle 164.
[   33.503016] TEST-64-UDEV-STORAGE.sh[546]: + SYSTEMD_LOG_LEVEL=debug
[   33.503016] TEST-64-UDEV-STORAGE.sh[546]: + timeout 30 udevadm trigger --settle --parent-match /dev/md/mdmirpar
[   33.485905] systemd-udevd[442]: Successfully forked off '(udev-synth)' as PID 3208.
[   33.486067] systemd-udevd[442]: md127: Removing watch handle 164.
[   33.489035] systemd-udevd[442]: md127p1: Device is queued (SEQNUM=2167, ACTION=remove)
[   33.489048] systemd-udevd[442]: Received inotify event about removal of watch handle 164.
[   33.489507] systemd-udevd[442]: md127p2: Device is queued (SEQNUM=2168, ACTION=remove)
[   33.496298] systemd-udevd[442]: md127p3: Device is queued (SEQNUM=2169, ACTION=remove)
[   33.500628] systemd-udevd[442]: md127: Device is queued (SEQNUM=2170, ACTION=change)
[   33.502355] systemd-udevd[442]: md127p1: Device is queued (SEQNUM=2171, ACTION=add)
[   33.509371] TEST-64-UDEV-STORAGE.sh[3211]: md127: Triggered device with action 'change'.
[   33.509371] TEST-64-UDEV-STORAGE.sh[3211]: md127p1: Triggered device with action 'change'.
[   33.509371] TEST-64-UDEV-STORAGE.sh[3211]: md127p2: Triggered device with action 'change'.
[   33.512532] systemd-udevd[442]: md127: Device is queued (SEQNUM=2172, ACTION=change, UUID=a0b75692-08ad-428a-859b-9ef8772874d7)
[   33.512666] systemd-udevd[442]: md127p1: Device is queued (SEQNUM=2173, ACTION=change, UUID=4cd75a91-aa5b-4678-878c-0420b6c2e1e9)
[   33.512796] systemd-udevd[442]: md127p2: Device is queued (SEQNUM=2174, ACTION=add)
[   33.512910] systemd-udevd[442]: md127p3: Device is queued (SEQNUM=2175, ACTION=add)
[   33.531834] TEST-64-UDEV-STORAGE.sh[3211]: md127: Got uevent without UUID, ignoring: No such file or directory
[   33.553563] TEST-64-UDEV-STORAGE.sh[3211]: md127p1: Got uevent without UUID, ignoring: No such file or directory
[   33.561262] TEST-64-UDEV-STORAGE.sh[3211]: md127p2: Got uevent without UUID, ignoring: No such file or directory
[   33.562468] TEST-64-UDEV-STORAGE.sh[3211]: md127p2: Got uevent without UUID, ignoring: No such file or directory
[   33.563143] TEST-64-UDEV-STORAGE.sh[3211]: md127p3: Got uevent without UUID, ignoring: No such file or directory
[   33.564174] TEST-64-UDEV-STORAGE.sh[3211]: md127p1: Got uevent without UUID, ignoring: No such file or directory
[   33.567614] TEST-64-UDEV-STORAGE.sh[3211]: md127p3: Got uevent without UUID, ignoring: No such file or directory
[   33.597750] TEST-64-UDEV-STORAGE.sh[3211]: md127: Got uevent without UUID, ignoring: No such file or directory
[   33.623522] TEST-64-UDEV-STORAGE.sh[3211]: md127p1: Got uevent without UUID, ignoring: No such file or directory
[   33.676268] TEST-64-UDEV-STORAGE.sh[3211]: md127p3: Got uevent without UUID, ignoring: No such file or directory
[   33.686088] TEST-64-UDEV-STORAGE.sh[3211]: md127p2: Got uevent without UUID, ignoring: No such file or directory
```

Let's wait for partition devices being actually created, and wait for
all queued events being processed. Then, call 'udevadm trigger'.
2025-07-26 11:20:16 +01:00
Luca Boccassi
b5a7f13a42 tree-wide: bunch of fixlets raised by coverity (#38341) 2025-07-26 11:10:00 +01:00
김인수
7157c7c4a5 po: Translated using Weblate (Korean)
Currently translated at 100.0% (264 of 264 strings)

Co-authored-by: 김인수 <simmon@nplob.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/ko/
Translation: systemd/main
2025-07-26 18:34:15 +09:00
Yu Watanabe
08cf7c70b9 fs-util: avoid overflow in MODE_TO_PTR() with MODE_INVALID
Note, currently MODE_TO_PTR() and PTR_TO_MODE() are only used in
src/udev/udev-rules.c .

Fixes CID#1548060.
2025-07-26 05:00:02 +09:00
Yu Watanabe
c119eb0edc install: skip later first_word() calls if one of earlier calls passes
Prompted by CID#1587764, that is false-positive.
2025-07-26 05:00:02 +09:00
Yu Watanabe
635894a493 fuzz-efi-string: add missing OOM check
Fixes CID#1610113 and CID#1610114.
2025-07-26 05:00:02 +09:00
Yu Watanabe
fa43d54b55 delta: add missing error check
Follow-up for 59829bb37a.
Fixes CID#1611425.
2025-07-26 05:00:02 +09:00
Yu Watanabe
2c3b3e2fd9 ordered-set: avoid overflow
Previously, ordered_set_put_strdupv() and friends returns the number of
pushed entries, but that is potentially larger than INT_MAX (of course,
realistically, OOM is triggered in that case).

No caller uses the number of the new entries. Let's return 1 when at
least one element is added.

Fixes CID#1611523.
2025-07-26 05:00:02 +09:00
Yu Watanabe
6ce3b1fa33 test: add explicit test cases for cpu_set_add() and cpu_set_add_range()
cpu_set_add_range() is used in parse_cpu_set(), hence already tested.
But it is better to test these functions explicitly.

For CID#1611787 and CID#1611788, that should be false-positive.
2025-07-26 05:00:02 +09:00
Yu Watanabe
d54f1e4329 cpu-set-util: check if cpu set is already allocated
Prompted by CID#1611789, CID#1611790, and CID#1611791.
2025-07-26 04:59:58 +09:00
Luca Boccassi
bcc73cafdb bootctl: automatically set --graceful when running in chroot
Installing stuff in a chroot should not fail because efivars are
not available. When running in a container touching efivars is
completely disabled, but there are some cases (recovery) where
it is needed to touch them in a chroot, so don't disable them but
avoid failing the run instead.
2025-07-25 20:44:03 +01:00
Luca Boccassi
a3eb0e99d3 cgroup-util: enforce alignment of f_handle
The change in 4d2e61211d
broke armv7 where uintptr_t is 4 bytes:

/* test_id */
Assertion '((uintptr_t) _p) % alignof(uint64_t) == 0' failed at src/basic/cgroup-util.c:108, function cg_get_cgroupid_at(). Aborting.

(gdb) p (uintptr_t)fh.file_handle.f_handle % _Alignof(uint64_t)
$9 = 4

Enforce that the structure is aligned as expected

Follow-up for 4d2e61211d
2025-07-25 20:42:23 +01:00
Yu Watanabe
04a99c48d2 cpu-set-util: fix identical ternary expression
Follow-up for fe3ada076e.
Fixes CID#1611792.
2025-07-26 03:44:49 +09:00
Yu Watanabe
1f4e9f6d60 core/exec-invoke: check size of read size
Even though we do not use the read data, it is better to check the size
to prevent something spurious going.

Fixes CID#1612155.
2025-07-26 03:44:49 +09:00
Yu Watanabe
4d13e4dcbb resolved: use usec_add() at one more place
Follow-up for 8458b7fb91.
Fixes CID#1612580.
2025-07-26 03:44:49 +09:00
Luca Boccassi
d6a70c1523 syscalls table: add sh (#38338) 2025-07-25 19:23:00 +01:00
Luca Boccassi
a50c687b01 syscalls-table: add sh and regenerated table 2025-07-25 17:17:28 +01:00
Luca Boccassi
481e2ceaed Meson: clean up "finding" of helper scripts (#38335)
Simplify meson definitions and use `files()` instead of `find_program()`
for internal scripts to make build logs cleaner.
2025-07-25 17:10:27 +01:00
Zbigniew Jędrzejewski-Szmek
5e405f612e meson: add instructions for adding new arch to syscall.h 2025-07-25 17:53:48 +02:00
Zbigniew Jędrzejewski-Szmek
9154cc7e80 getty-generator: improve debugging messages
We generally log what happens, but we didn't log anything about checking credentials,
so add that.

The error message when we cannot acces /proc/1/environ was confusing.
2025-07-25 14:04:17 +02:00
Zbigniew Jędrzejewski-Szmek
4c4a63a876 meson: indent find_program() calls for readability 2025-07-25 14:04:17 +02:00
Zbigniew Jędrzejewski-Szmek
c5dcbd073e meson: use files() not find_program() for helper scripts
We went back and forth between 'prog.sh', files('prog.sh'), and
find_program('prog.sh'). We want to use files() or find_program() so that we
get a good error message if the file is missing. Behaviour of meson changed
over time, and in the past not all forms could be used in all places. For
example 0f4c4f3824 added find_program() in many
places to avoid repeated messages. But it seems that all recent meson versions
work fine with files().

find_program prints silly messages:
  Program tools/make-man-index.py found: YES
       (/home/zbyszek/src/systemd/tools/make-man-index.py)
  Program tools/meson-render-jinja2.py found: YES
       (/home/zbyszek/src/systemd/tools/meson-render-jinja2.py)
  ...
We know that those files will be found, they are part of the git checkout.
With files() this is gone and the meson output is easier to read.
2025-07-25 14:04:17 +02:00
Zbigniew Jędrzejewski-Szmek
8aedfd979f tools: make all .py program files executable
All those files are standalone programs that can be executed directly.
Some .py files were marked executable, others weren't, probably accidentally.
Mark them all as executable in preparation for subsequent changes.
2025-07-25 12:33:13 +02:00
Zbigniew Jędrzejewski-Szmek
0bf9bbecae tools: consistently use #!/usr/bin/env python3
It's ugly, but it's better to be consistently ugly.
2025-07-25 12:33:13 +02:00
Zbigniew Jędrzejewski-Szmek
0e371ebb12 man: consistently use #!/usr/bin/python
Some files were using that, others weren't. Since those are user-facing
docs, we should use the nice clean form, not the workaround for strange
systems that we use in other places.
2025-07-25 12:33:13 +02:00
Zbigniew Jędrzejewski-Szmek
0e031d5e0b meson: inline output file names
Before 7d247d3cb8, we needed the file name
twice. But now we only need it once, so no need to overcomplicate things
by defining a variable with a single use.

When a variable is used, it's also easier to make a mistake and e.g.
accidentally reuse the variable later.
2025-07-25 12:33:13 +02:00