1
0
mirror of https://github.com/systemd/systemd synced 2025-10-04 19:24:44 +02:00

Compare commits

...

7 Commits

Author SHA1 Message Date
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
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 e19e17df579823093238edb60470b29a2c5e24a6, 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
3 changed files with 168 additions and 62 deletions

View File

@ -15,7 +15,7 @@ msgid ""
msgstr "" msgstr ""
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-07-23 15:38+0100\n" "POT-Creation-Date: 2025-07-23 15:38+0100\n"
"PO-Revision-Date: 2025-07-26 20:30+0000\n" "PO-Revision-Date: 2025-07-27 09:55+0000\n"
"Last-Translator: Jesse Guo <jesseguotech@outlook.com>\n" "Last-Translator: Jesse Guo <jesseguotech@outlook.com>\n"
"Language-Team: Chinese (Simplified) <https://translate.fedoraproject.org/" "Language-Team: Chinese (Simplified) <https://translate.fedoraproject.org/"
"projects/systemd/main/zh_CN/>\n" "projects/systemd/main/zh_CN/>\n"
@ -96,12 +96,12 @@ msgstr "移除用户家区域需要认证。"
#: src/home/org.freedesktop.home1.policy:33 #: src/home/org.freedesktop.home1.policy:33
msgid "Check credentials of a home area" msgid "Check credentials of a home area"
msgstr "检查家区域凭证" msgstr "核验家区域的凭证"
#: src/home/org.freedesktop.home1.policy:34 #: src/home/org.freedesktop.home1.policy:34
msgid "" msgid ""
"Authentication is required to check credentials against a user's home area." "Authentication is required to check credentials against a user's home area."
msgstr "根据用户家区域检查凭证需要认证。" msgstr "将凭据与用户家区域进行核验需要认证。"
#: src/home/org.freedesktop.home1.policy:43 #: src/home/org.freedesktop.home1.policy:43
msgid "Update a home area" msgid "Update a home area"
@ -140,7 +140,7 @@ msgstr "更改家区域的密码"
#: src/home/org.freedesktop.home1.policy:74 #: src/home/org.freedesktop.home1.policy:74
msgid "" msgid ""
"Authentication is required to change the password of a user's home area." "Authentication is required to change the password of a user's home area."
msgstr "更改家区域密码需要认证。" msgstr "更改用户的家区域密码需要认证。"
#: src/home/org.freedesktop.home1.policy:83 #: src/home/org.freedesktop.home1.policy:83
msgid "Activate a home area" msgid "Activate a home area"
@ -152,7 +152,7 @@ msgstr "激活用户的家区域需要认证。"
#: src/home/org.freedesktop.home1.policy:93 #: src/home/org.freedesktop.home1.policy:93
msgid "Manage Home Directory Signing Keys" msgid "Manage Home Directory Signing Keys"
msgstr "管理家目录签名密钥" msgstr "管理家目录签名密钥"
#: src/home/org.freedesktop.home1.policy:94 #: src/home/org.freedesktop.home1.policy:94
msgid "Authentication is required to manage signing keys for home directories." msgid "Authentication is required to manage signing keys for home directories."
@ -263,7 +263,7 @@ msgstr "用户 %s 的安全令牌 PIN 不正确(仅剩一次重试机会!)
#: src/home/pam_systemd_home.c:685 #: src/home/pam_systemd_home.c:685
#, c-format #, c-format
msgid "Home of user %s is currently not active, please log in locally first." msgid "Home of user %s is currently not active, please log in locally first."
msgstr "用户 %s 的家目录目前未启用,请先在本地登录。" msgstr "用户 %s 的家目录目前未激活,请先在本地登录。"
#: src/home/pam_systemd_home.c:687 #: src/home/pam_systemd_home.c:687
#, c-format #, c-format

View File

@ -7,6 +7,7 @@
#include "errno-list.h" #include "errno-list.h"
#include "errno-util.h" #include "errno-util.h"
#include "string-util.h" #include "string-util.h"
#include "utf8.h"
BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_standard_errors[] = { BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_standard_errors[] = {
SD_BUS_ERROR_MAP(SD_BUS_ERROR_FAILED, EACCES), SD_BUS_ERROR_MAP(SD_BUS_ERROR_FAILED, EACCES),
@ -246,7 +247,7 @@ _public_ int sd_bus_error_setfv(sd_bus_error *e, const char *name, const char *f
* this, since we at least managed to write the error name */ * this, since we at least managed to write the error name */
if (vasprintf(&mesg, format, ap) >= 0) if (vasprintf(&mesg, format, ap) >= 0)
e->message = TAKE_PTR(mesg); e->message = utf8_escape_non_printable(mesg);
} }
e->_need_free = 1; e->_need_free = 1;

View File

@ -43,61 +43,135 @@ trap at_exit EXIT
systemctl log-level info systemctl log-level info
# FIXME: systemd-run doesn't play well with daemon-reexec
# See: https://github.com/systemd/systemd/issues/27204
add_suppression "org.freedesktop.systemd1" "org.freedesktop.systemd1.Manager:Reexecute FIXME"
add_suppression "org.freedesktop.systemd1" "org.freedesktop.systemd1.Manager:SoftReboot destructive"
add_suppression "org.freedesktop.login1" "Sleep destructive"
# Skip calling start and stop methods on unit objects, as doing that is not only time consuming, but it also # Skip calling start and stop methods on unit objects, as doing that is not only time consuming, but it also
# starts/stops units that interfere with the machine state. The actual code paths should be covered (to some # starts/stops units that interfere with the machine state. The actual code paths should be covered (to some
# degree) by the respective method counterparts on the manager object. # degree) by the respective method counterparts on the manager object.
for method in Start Stop Restart ReloadOrRestart ReloadOrTryRestart Kill; do MANAGER_METHOD_FILTER=(
StartUnit
StartUnitWithFlags
StartUnitReplace
StopUnit
RestartUnit
TryRestartUnit
ReloadOrRestartUnit
ReloadOrTryRestartUnit
KillUnit
QueueSignalUnit
FreezeUnit
AttachProcessesToUnit
RemoveSubgroupFromUnit
AbandonScope
CancelJob
Exit
Reboot
SoftReboot
PowerOff
Halt
KExec
SwitchRoot
EnqueueMarkedJobs
)
UNIT_METHOD_FILTER=(
Start
Stop
Restart
TryRestart
ReloadOrRestart
ReloadOrTryRestart
Kill
QueueSignal
Freeze
)
SCOPE_METHOD_FILTER=(
Abandon
)
JOB_METHOD_FILTER=(
Cancel
)
LOGIN_METHOD_FILTER=(
FlushDevices # This triggers all devices and makes the system super heavy
PowerOff
PowerOffWithFlags
Reboot
RebootWithFlags
Halt
HaltWithFlags
Suspend
SuspendWithFlags
Hibernate
HibernateWithFlags
HybridSleep
HybridSleepWithFlags
SuspendThenHibernate
SuspendThenHibernateWithFlags
ScheduleShutdown
)
for method in "${MANAGER_METHOD_FILTER[@]}"; do
add_suppression "org.freedesktop.systemd1" "org.freedesktop.systemd1.Manager:$method"
done
for method in "${UNIT_METHOD_FILTER[@]}"; do
add_suppression "org.freedesktop.systemd1" "org.freedesktop.systemd1.Unit:$method" add_suppression "org.freedesktop.systemd1" "org.freedesktop.systemd1.Unit:$method"
done done
for method in "${SCOPE_METHOD_FILTER[@]}"; do
add_suppression "org.freedesktop.systemd1" "org.freedesktop.systemd1.Scope:$method"
done
for method in "${JOB_METHOD_FILTER[@]}"; do
add_suppression "org.freedesktop.systemd1" "org.freedesktop.systemd1.Job:$method"
done
for method in "${LOGIN_METHOD_FILTER[@]}"; do
add_suppression "org.freedesktop.login1" "org.freedesktop.login1.Manager:$method"
done
cat /etc/dfuzzer.conf cat /etc/dfuzzer.conf
# TODO # TODO
# * check for possibly newly introduced buses? # * check for possibly newly introduced buses?
BUS_LIST=( NAME_LIST=(
org.freedesktop.home1 home
org.freedesktop.hostname1 hostname
org.freedesktop.import1 import
org.freedesktop.locale1 locale
org.freedesktop.login1 login
org.freedesktop.machine1 machine
org.freedesktop.portable1 portable
org.freedesktop.resolve1 resolve
org.freedesktop.systemd1 timedate
org.freedesktop.timedate1
) )
# systemd-oomd requires PSI
if tail -n +1 /proc/pressure/{cpu,io,memory}; then
BUS_LIST+=(
org.freedesktop.oom1
)
fi
# Some services require specific conditions: # Some services require specific conditions:
# - systemd-oomd requires PSI
# - systemd-timesyncd can't run in a container # - systemd-timesyncd can't run in a container
# - systemd-networkd can run in a container if it has CAP_NET_ADMIN capability # - systemd-networkd can run in a container if it has CAP_NET_ADMIN capability
if ! systemd-detect-virt --container; then if tail -n +1 /proc/pressure/{cpu,io,memory}; then
BUS_LIST+=( NAME_LIST+=( oom )
org.freedesktop.network1
org.freedesktop.timesync1
)
elif busctl introspect org.freedesktop.network1 / &>/dev/null; then
BUS_LIST+=(
org.freedesktop.network1
)
fi fi
SESSION_BUS_LIST=( if ! systemd-detect-virt --container; then
org.freedesktop.systemd1 NAME_LIST+=( timesync )
) fi
if ip link add dummy-fuzz type dummy; then
# if a dummy interface is created, then let's also setup it for resolved
ip link set dummy-fuzz up
ip address add 192.0.2.1/24 dev dummy-fuzz
# When we can create a dummy interface, we definitely have CAP_NET_ADMIN
NAME_LIST+=( network )
# Create unit files for another dummy interface for networkd
mkdir -p /run/systemd/network
cat >/run/systemd/network/10-dummy-fuzz2.netdev <<EOF
[NetDev]
Kind=dummy
Name=dummy-fuzz2
EOF
cat >/run/systemd/network/10-dummy-fuzz2.network <<EOF
[Match]
Name=dummy-fuzz2
[Network]
Address=192.0.2.2/24
EOF
fi
# Maximum payload size generated by dfuzzer (in bytes) - default: 50K # Maximum payload size generated by dfuzzer (in bytes) - default: 50K
PAYLOAD_MAX=50000 PAYLOAD_MAX=50000
@ -107,33 +181,64 @@ if [[ -v ASAN_OPTIONS || -v UBSAN_OPTIONS ]]; then
PAYLOAD_MAX=10000 # 10K PAYLOAD_MAX=10000 # 10K
fi fi
# Disable debugging logs from systemd-homed, systemd-nsresourced, and systemd-userdbd.
# Otherwise, journal is filled with the debugging logs by them.
systemctl service-log-level systemd-homed.service info
for service in systemd-nsresourced.service systemd-userdbd.service; do
mkdir -p "/run/systemd/system/${service}.d"
cat >"/run/systemd/system/${service}.d/10-disable-debug.conf" <<EOF
[Service]
Environment=SYSTEMD_LOG_LEVEL=info
EOF
systemctl daemon-reload
systemctl restart "$service"
done
test_systemd() {
systemd-run "$@" --pipe --wait \
-- dfuzzer -b "$PAYLOAD_MAX" -n org.freedesktop.systemd1
# Let's reload the systemd user daemon to test (de)serialization as well
systemctl "$@" daemon-reload
# FIXME: explicitly trigger reexecute until systemd/systemd#27204 is resolved
systemctl "$@" daemon-reexec
}
# Let's first test the session bus before the system one, as it may be in a
# spurious state after fuzzing the system bus or login bus.
echo "Bus: org.freedesktop.systemd1 (session)"
test_systemd --machine 'testuser@.host' --user
# Overmount /var/lib/machines with a size-limited tmpfs, as fuzzing # Overmount /var/lib/machines with a size-limited tmpfs, as fuzzing
# the org.freedesktop.machine1 stuff makes quite a mess # the org.freedesktop.machine1 stuff makes quite a mess
mount -t tmpfs -o size=50M tmpfs /var/lib/machines mount -t tmpfs -o size=50M tmpfs /var/lib/machines
# Fuzz both the system and the session buses (where applicable) # Next, test the system service buses, as the services may be in a spurious
for bus in "${BUS_LIST[@]}"; do # state after fuzzing the system service manager bus.
echo "Bus: $bus (system)" for name in "${NAME_LIST[@]}"; do
bus="org.freedesktop.${name}1"
service="systemd-${name}d.service"
echo "Bus: $bus"
# Unmask and enable the service.
systemctl unmask "$service"
systemctl enable "$service"
# enable debugging logs
systemctl service-log-level "$service" debug || :
systemd-run --pipe --wait \ systemd-run --pipe --wait \
-- dfuzzer -b "$PAYLOAD_MAX" -n "$bus" -- dfuzzer -b "$PAYLOAD_MAX" -n "$bus"
# Let's reload the systemd daemon to test (de)serialization as well # disable debugging logs
systemctl daemon-reload systemctl service-log-level "$service" info || :
# FIXME: explicitly trigger reexecute until systemd/systemd#27204 is resolved
systemctl daemon-reexec
done done
umount /var/lib/machines umount /var/lib/machines
for bus in "${SESSION_BUS_LIST[@]}"; do # Finally, test the system bus.
echo "Bus: $bus (session)" echo "Bus: org.freedesktop.systemd1 (system)"
systemd-run --machine 'testuser@.host' --user --pipe --wait \ test_systemd
-- dfuzzer -b "$PAYLOAD_MAX" -n "$bus"
# Let's reload the systemd user daemon to test (de)serialization as well
systemctl --machine 'testuser@.host' --user daemon-reload
# FIXME: explicitly trigger reexecute until systemd/systemd#27204 is resolved
systemctl --machine 'testuser@.host' --user daemon-reexec
done
touch /testok touch /testok