Commit Graph
100 Commits
Author SHA1 Message Date
Yu Watanabe 27971114d5 factory: do not install nsswitch.conf when nss is disabled
When systemd is built with musl, nss modules are not supported,
hence the file is not necessary. Let's not install the file.
2025-11-25 10:48:31 +01:00
Yu Watanabe da22ccf48f openssl-util: introduce openssl_extract_public_key() helper function
This splits out common logic in keyutil and systemd-measure.

Note, previously d2i_PUBKEY_fp() was used, but now it is replaced with
d2i_PUBKEY(), as musl seems to not support reading from memstream.
2025-11-24 22:49:55 +09:00
Yu Watanabe 0cc96fc213 test: use log_tests_skipped_errno() at one more place
Follow-up for 12d2abe082.
2025-11-24 21:16:39 +09:00
Yu Watanabe f866ff3df8 tree-wide: replace tab with space, adjust missing or duplicated space 2025-11-24 12:45:06 +01:00
Yu Watanabe 332bce5bd7 oomd: move check if processes can be killed into oomd_cgroup_kill()
This also adds a debuuging log if the check failed.
Addresses https://github.com/systemd/systemd/pull/39773#discussion_r2549439336.

Follow-up for 38e9d40c80.
2025-11-24 12:40:13 +01:00
Yu Watanabe 19deb47ade firstboot: drop redundant and spurious errno check
Follow-up for 2319154a6b.
2025-11-23 22:36:50 +09:00
Yu Watanabe 2d82ebf600 core/selinux-setup: actually skip setup gracefully when libselinux is not available (#39859) 2025-11-23 09:11:32 +09:00
Yu Watanabe f53ac7742f clang-tidy: Enable misc-include-cleaner check (#39835)
The previous commit fixes all remaining violations of the check for
a very specific setup (Fedora Rawhide with as many dependencies as
possible installed). The linter job in CI runs that specific setup
so we enable the check in the clang-tidy config but do not yet enable
the clang-tidy test suite in meson by default as it will very likely
still fail in different setups than the one in CI.
2025-11-22 20:54:28 +09:00
Yu Watanabe 229e106a6e NEWS: drop one sentence
We have agreed the bump.
2025-11-22 10:43:17 +09:00
Yu Watanabe e6baa5ba0b Use SD_JSON_BUILD_PAIR_* macros if possible in shared/core/home (#39845) 2025-11-22 10:04:02 +09:00
Yu Watanabe 924081f793 pam-systemd-home: various logging cleanups 2025-11-22 09:42:41 +09:00
Yu Watanabe 447eb0a00c pam-systemd-loadkey: append full stop 2025-11-22 09:42:41 +09:00
Yu Watanabe 37d8d6623f pam-systemd: various fixlets for logging
- Do not use '%m' when errno is not set.
- Do not use pam_syslog_errno() when errno is not set.
- Use pam_debug_syslog_errno() rather than log_debug_errno().
- Use 0 rather than PAM_SUCCESS in the function that returns negative
  errno, though PAM_SUCCESS == 0, hence that does not change any
  behavior.
- Append missing full stop in the log message.
2025-11-22 09:42:41 +09:00
Yu Watanabe 7214aa9a2c pam-util: make pam_debug_syslog_errno() returns pam error
Currently, the result of pam_debug_syslog_errno() is unused, hence this
does not change anything and may be slightly redundant. But let's follow
our usual coding style.
2025-11-22 09:42:41 +09:00
Yu Watanabe 82f2eb73b1 pam-util: use correct errno
- pam_log_oom() passes ENOMEM rather than -ENOMEM, hence previously
  pam_log_oom() did not return PAM_BUF_ERR.
- We may (mistakenly) pass SYNTHETIC_ERRNO(). Let's gracefully handle that.
- Introduce errno_to_pam_error() helper function.
2025-11-22 09:42:41 +09:00
Yu Watanabe 7582679d0e apparmor: update log message
Follow-up for c3b3eea2e5.
Addresses https://github.com/systemd/systemd/pull/39826#discussion_r2547327325.
2025-11-22 09:42:41 +09:00
Yu Watanabe 6df082a039 pam_systemd: fix OSC write failure message appearing in error logs (#39791) 2025-11-20 23:07:00 +09:00
Yu Watanabe d2b8e42742 meson: exit earlier from the subdirectory when bash/zshcompletiondir is 'no' 2025-11-20 14:50:30 +09:00
Yu Watanabe c74dc8cf14 meson: sort shell completions 2025-11-20 14:48:33 +09:00
Yu Watanabe 70fa7d4ccc core: SMACK label to Unix socket path and FD (#39772)
Currently, when a socket unit specifies SmackLabel=,
the label is not applied to the underlying Unix socket file or its file
descriptor.

This change ensures that the SMACK label is applied both to the
Unix socket path on the filesystem and to all associated socket FDs
when the socket is created.

Testing:

- Tested on Fedora 43 with kernel 6.17.7 with SMACK enabled.
- Created a systemd socket unit:

    [Unit]
    Description=UNIX socket

    [Socket]
    ListenStream=/run/test.sock
    SmackLabel=label

    [Install]
    WantedBy=sockets.target

- Created a corresponding service:

    [Unit]
    Description=UNIX socket service
    Requires=test.socket

    [Service]
    ExecStart=/usr/bin/socat -v - -
    StandardInput=socket

    [Install]
    WantedBy=multi-user.target

- Verified SMACK labels using getfattr:

  - Without SmackLabel:
    ```
    # file: run/test.sock
    security.SMACK64="_"
    # file: proc/<pid>/fd/*
    security.SMACK64="*"
    ```
  - With SmackLabel=label:
    ```
    # file: run/test.sock
    security.SMACK64="label"
    # file: proc/<pid>/fd/*
    security.SMACK64="label"
    ```
2025-11-20 13:23:51 +09:00
Yu Watanabe 5de39570c8 Simplify source lists in meson config (#39811) 2025-11-20 13:20:41 +09:00
Yu Watanabe a7947d54db NEWS: fix typo 2025-11-20 10:08:38 +09:00
Yu Watanabe cb4b36928a socket-label: move prototype of socket_address_listen() and string table for SocketAddressBindIPv6Only
The function socket_address_listen() is declared at shared/socket-label.c,
however its prototype was in basic/socket-util.h. This moves the
prototype to shared/socket-label.h.

Also, enum SocketAddressBindIPv6Only is not used anymore in basic/*.[ch].
Let's move the definition and its string table to shared/socket-label.[ch].

Follow-up for b25a930f0e.
2025-11-20 09:58:53 +09:00
Yu Watanabe 5feb65c5b1 user-util: avoid double evaluation in STRERROR_USER/GROUP()
Follow-up for 6e6e96f628.
2025-11-20 09:07:57 +09:00
Yu Watanabe 459000e8c5 errno-util: avoid double evaluation in STRERROR_OR_EOF()
Follow-up for f69ae8585f.
2025-11-20 09:04:35 +09:00
Yu Watanabe 18f280a478 test: fix tested function name
The test tests STRERROR_OR_EOF(), but logged as STRERROR_OR_ELSE.
2025-11-20 08:58:37 +09:00
Yu Watanabe 3f91ffe0fe core: Verify inherited FDs are writable for stdout/stderr (#39674)
When inheriting file descriptors for stdout/stderr (either from stdin or
when making stderr inherit from stdout), we previously just assumed they
would be writable and dup'd them. This could lead to broken setups if
the inherited FD was actually opened read-only.

Before dup'ing any inherited FDs to stdout/stderr, verify they are
actually writable using the new fd_is_writable() helper. If not, fall
back to /dev/null (or reopen the terminal in the TTY case) with a
warning, rather than silently creating a broken setup where output
operations would fail.
2025-11-20 08:19:46 +09:00
Yu Watanabe f7df0eab8d core/socket: do not log failure in setting socket option with number
This also downgrade to the debug level when the option is simply not
supported.

Follow-up for b81a14b91e.
Fixes #39792.
2025-11-19 18:16:31 +01:00
Yu Watanabe 031963fb16 core/unit: unit_process_job() tweaks (#39753) 2025-11-18 08:32:59 +09:00
Yu Watanabe 92a224c9b4 musl: gracefully disable utmp support (#39775) 2025-11-18 03:29:34 +09:00
Yu Watanabe bd3fc5c539 Revert "musl: utmpx: add several missing definitions"
This reverts commit 3ae7d8fd87.

Now utmp support is always disabled when building with musl,
and all definitions are unused in that case. Let's remove it.
2025-11-18 03:06:02 +09:00
Yu Watanabe 1a2ba82421 musl: meson: gracefully disable utmp support
musl only provides fake utmp functions, and these are not usable.
Let's disable the feature when building with musl.
2025-11-18 02:54:20 +09:00
Yu Watanabe 0ecff59065 Revert "musl: meson: add libutmps support"
This reverts commit bf9bc5beb0.

libutmps does not support utmpxname(), the function always fails
with ENOSYS, and always uses their own file.
However, our code relies on the funtion needs to succeed.

Let's revert the change now, and revisit later when musl users
request to support libutmps.
2025-11-18 02:54:20 +09:00
Yu Watanabe 1b9f3473c1 NEWS: menton future removal of SysV support and requirement bump 2025-11-18 02:40:22 +09:00
Yu Watanabe 43a1690e45 Split out script for musl builds (#39758) 2025-11-18 02:17:05 +09:00
Yu Watanabe 07910c73b0 test: modernize test-log and add test cases for log_format_iovec() (#39750) 2025-11-18 01:31:02 +09:00
Yu Watanabe d42db35a7c Drop remaining CGroup v1 specific code (#38969) 2025-11-17 23:48:29 +09:00
Yu Watanabe 0bb71aea62 NEWS: insert hyphen 2025-11-17 23:37:19 +09:00
Yu Watanabe c1568778d1 repart: fix typo
Follow-up for cfb6c54324.
2025-11-17 23:34:42 +09:00
Yu Watanabe f10444319e test-log: add test cases for log_format_iovec() 2025-11-17 23:07:05 +09:00
Yu Watanabe c1792c2005 test-log: migrate to use ASSERT_OK() and friends 2025-11-17 23:07:05 +09:00
Yu Watanabe d753c0c658 log: replace format string in LOG_ITEM() to a dummy one when analyzed by Coverity
Hopefully silence many false-positives.
2025-11-17 23:06:53 +09:00
Yu Watanabe 1f546ab779 log: make each string generated in log_format_iovec() NUL terminated
Nowadays, we append an extra NUL for each data if possible for safety.
We already do the same for example at write_to_kmsg(), log_do_context(),
write_to_journal(), log_struct_iovec_internal(), and so on.
This does not change any behavior, as the iov_len field is unchanged.
2025-11-17 22:38:38 +09:00
Yu Watanabe d32ec01223 shell-completion: drop deprecated cgroup controller suggestion 2025-11-17 21:31:51 +09:00
Yu Watanabe 44440ea658 cgroup-util: drop outdated comments 2025-11-17 21:31:51 +09:00
Yu Watanabe 4434fd76f1 cgroup-util: drop unused SYSTEMD_CGROUP_CONTROLLER_{LEGACY,HYBRID} 2025-11-17 21:31:51 +09:00
Yu Watanabe b9e612e070 cgroup-util: do not check validity of controller in cg_split_spec()
Now the controller part is always ignored, hence let's skip check for
the controller part of the spec. This also make it acceppt unnormalized
path. Previously paths were checked by path_is_normalized(), but now
checked by path_is_safe(). Also, now this mapps an empty path to NULL.
2025-11-17 21:31:51 +09:00
Yu Watanabe 6a8ab5f062 cgroup-show: drop unnecessary call of cg_mangle_path()
As the caller already dropped controller part.
2025-11-17 21:31:51 +09:00
Yu Watanabe a8156588fa cgroup-util: drop 'controller' argument from cg_get_path()
The argument is not used anymore. Let's drop it.
2025-11-17 21:31:50 +09:00
Yu Watanabe 5d397dc7f4 cgroup-util: drop 'controller' argument from cg_get_keyed_attribute() and cg_is_empty()
The argument is completely unused. Let's drop it.
2025-11-17 21:31:50 +09:00
Yu Watanabe 3454b160e4 cgroup-util: drop unused cg_unified() and friends 2025-11-17 21:31:50 +09:00
Yu Watanabe 90ee92b073 cgls: drop cgroup v1 support and warn when cgroup v1 controller is specified 2025-11-17 21:31:44 +09:00
Yu Watanabe 2fe89e3b0f limits-util: drop cgroup v1 support from physical_memory() 2025-11-17 21:30:29 +09:00
Yu Watanabe 2d6dd692be cgroup-util: drop cgroup v1 support in cg_get_path()
We have dropped cgroup v1 support in v258. Let's assume we are running
on cgroup v2 and drop unused legacy code.
2025-11-17 21:30:29 +09:00
Yu Watanabe f5a48af34b cgroup-util: use cg_is_available() in cg_kill_supported() 2025-11-17 21:30:29 +09:00
Yu Watanabe 57c16d344b cgroup-util: drop cgroup v1 support from cg_mask_supported_subtree()
We have dropped cgroup v1 support in v258. Let's drop unused legacy code.
2025-11-17 21:30:29 +09:00
Yu Watanabe 0ab90015e0 tree-wide: replace cg_get_path_and_check() with cg_get_path()
We have dropped cgroup v1 support in v258. When running on cgroup v2,
cg_get_path_and_check() with SYSTEMD_CGROUP_CONTROLLER as controller is
equivalent with checking if we are running on cgroup v2 and then
cg_get_path(). As we can assume we are running on cgroup v2, then the
check is not necessary anymore, thus we can replace
cg_get_path_and_check() with cg_get_path().
2025-11-17 21:30:29 +09:00
Yu Watanabe b525a72f7b cgroup-util: drop cgroup v1 support from cg_pid_get_path()
We have dropped cgroup v1 support in v258. Let's drop legacy code.
Then, we can drop 'controller' argument from cg_pid_get_path() and
cg_pidref_get_path().
2025-11-17 21:30:29 +09:00
Yu Watanabe 6475926a59 cgroup-util: drop 'controller' argument from cg_path_open()
Nowadays it always takes SYSTEMD_CGROUP_CONTROLLER as controller.
Let's drop it.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Yu Watanabe 4dbf06bd85 cgroup-util: drop 'controller' argument from cg_set_attribute(), cg_get_attribute() and friends
Non-null controller arguments are always ignored when running on cgroup v2.
Let's drop the argument.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Yu Watanabe 4d1badbbc4 cgroup-util: drop 'controller' argument from cg_enumerate_subgroups()
Nowadays it always takes SYSTEMD_CGROUP_CONTROLLER as controller.
Let's drop it.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Yu Watanabe f8de2107a7 cgroup-util: drop 'controller' argument from cg_enumerate_processes()
Nowadays it always takes SYSTEMD_CGROUP_CONTROLLER as controller.
Let's drop it.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Yu Watanabe 5169b1c5a7 cgroup-show: drop 'controller' argument from show_cgroup() and show_cgroup_and_extra()
Nowadays these always take SYSTEMD_CGROUP_CONTROLLER as controller.
Let's drop it.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Yu Watanabe 4365351b93 cgroup-util: introduce cg_is_available() and check it in tests
Now most of our code does not support cgroup v1. Let's skip test cases
if we are running on cgroup v1.
2025-11-17 21:29:51 +09:00
Yu Watanabe f115763f19 musl: ci: add build test and unit tests 2025-11-17 12:19:22 +09:00
Yu Watanabe 07e437f569 musl: glob-util: filter out . and .. even if GLOB_ALTDIRFUNC is not supported
musl neither support GLOB_ALTDIRFUNC nor GLOB_BRACE.
Let's make safe_glob() work even when GLOB_ALTDIRFUNC is not supported.
Currently, GLOB_BRACE is simply ignored when it is not supported.
2025-11-17 12:19:22 +09:00
Yu Watanabe bf9bc5beb0 musl: meson: add libutmps support
musl only provides fake functions, hence even with -Dutmp=true,
utmp/wtmp functionalities do not work. Let's allow to build with
libutmps.
2025-11-17 12:18:44 +09:00
Yu Watanabe 3ae7d8fd87 musl: utmpx: add several missing definitions 2025-11-17 11:27:07 +09:00
Yu Watanabe ddc9677c4f test-network: several tweaks (#39752) 2025-11-17 06:39:45 +09:00
Yu Watanabe d7cf08b735 test-network: drop two overly verbose outputs
Follow-up for 7f9c0c31d2.
2025-11-16 22:15:44 +09:00
Yu Watanabe 3632d7322f test-network: set TimeoutStopFailureMode=abort when running with sanitizers
Hopefully this provides useful data for issue #39631.
2025-11-16 22:15:43 +09:00
Yu Watanabe c43585bc30 Revert "test-network: disable several more sandbox features when running with sanitizers"
This reverts commit 454ce42305.

Unfortunately, it does not work.
2025-11-16 22:15:43 +09:00
Yu Watanabe 4f9f6a8517 resolve: voidify one function call
Fixes CID#1643235.
2025-11-16 14:06:26 +09:00
Yu Watanabe a112c7646b tree-wide: swap arguments for streq()
We usually set a variable first, then constant.
2025-11-16 14:01:56 +09:00
Yu Watanabe 33b2dc77bd test-network: migrate to use ASSERT_OK() and friends 2025-11-16 14:01:39 +09:00
Yu Watanabe 5a943bae12 network-internal: do not save partially parsed values 2025-11-16 14:01:28 +09:00
Yu Watanabe 8c236eca78 resolve: fix typo
Follow-up for 8209f4adcd.
2025-11-16 11:13:56 +09:00
Yu Watanabe e7254f9f4e efivars: fix typo
Follow-up for ab69a04600.
2025-11-16 11:12:10 +09:00
Yu Watanabe af70b7521f sd-dhcp-lease: use the last hostname option when multiple hostname is specified 2025-11-16 10:50:34 +09:00
Yu Watanabe a6c61b4adc sd-dhcp-lease: drop ret_ prefixes from the parsers 2025-11-16 10:49:59 +09:00
Yu Watanabe f28bc48434 network: unify log messages 2025-11-16 10:44:37 +09:00
Yu Watanabe de8ea7e219 test: add missing assertion
Follow-up for 5a5cb6ba50.
Fixes CID#1643217.
2025-11-16 05:51:22 +09:00
Yu Watanabe 8e4ef4a18c sd-event: do not ignore result of callbacks
Follow-up for 4c8b6d636c and
6aff6d3ffc.
Fixes CID#1643218 and friends.
2025-11-16 05:44:35 +09:00
Yu Watanabe c9fc7eb87e nspawn: Prevent invalid UIDs propagating in bind mounts (#39729)
Commit 88fce09026 modified the
mount_bind() function, causing it to perform arithmetic on the uid_shift
parameter. However, it performs this arithmetic even when uid_shift was
UID_INVALID, which was not intended. This typically occurred when
mount_custom() was called for a simple bind mount without user
namespaces (and thus no rootidmap mount option).

This arithmetic (e.g., uid_shift + m->destination_uid) then wraps
around, resulting in the invalid ID 4294967295 ((uid_t)-1).

This bug manifests for users running systemd-nspawn with
--link-journal=host and --volatile=yes (but without --private-users),
causing systemd-tmpfiles to fail.

Make mount_bind() robust by checking if uid_shift is valid before using
it in arithmetic. If it is UID_INVALID, it defaults to a shift of 0 for
the ownership calculation, restoring correct behavior for plain bind
mounts while preserving the intended logic for ID-mapped mounts.

Fixes: #39714
2025-11-16 04:46:18 +09:00
Yu Watanabe fe9bccb2b7 Make new sd-path configuration search functionality generic (#39684)
Reverts systemd/systemd#38680

After taking a closer look I'm not convinced by the approach, see below.

First of all, all other SD_PATH_SEARCH_* are either somewhat generic,
i.e. encode the common prefix for configurations, binaries, etc., or are
subdirectories under systemd/ hence in our own "domain". The
tmpfiles/sysctl/binfmt we don't prefix with "systemd" precisely because
the concept is generic and there're actually other impls of them. A
specific SD_PATH_SEARCH_SYSCTL doesn't fit into our existing scheme.
Instead something along the lines of "SEARCH_SYSTEM_CONFIGURATION" shall
be introduced, and consumers will just suffix
sysctl.d/tmpfiles.d/binfmt.d for the final result.

And secondly, I don't grok why systemd-sysctl now unnecessarily calls
into sd-path to obtain the fixed search path. None of our other tools do
that.

-----------

An alternate approach, SD_PATH_SYSTEM_SEARCH_CONFIGURATION, which does
exactly above, will be introduced instead. It provides a universal
interface for querying any system config with our idiomatic
/etc/:/run/:/usr/local/lib/:/usr/lib/ hierarchy.
2025-11-15 10:09:19 +09:00
Yu Watanabe 6412e540bc path-util: add generic ignore extension to the hidden files (#39554) 2025-11-15 10:05:38 +09:00
Yu Watanabe c7b31a64ee fd-util: do not block O_TMPFILE with -EISDIR (#39736) 2025-11-15 10:01:19 +09:00
Yu Watanabe 384e88a238 musl: stdio: check if stream is writable earlier in fputs() and friends 2025-11-15 05:10:33 +09:00
Yu Watanabe 08d207ba73 musl: introduce two wrappers (#39700) 2025-11-15 04:18:48 +09:00
Yu Watanabe fd7d749494 core: add varlink Reload/Reexecute methods (#39561)
Same as the D-Bus ones
2025-11-15 04:17:01 +09:00
Yu Watanabe 1569b1e25f tree-wide: use SD_JSON_BUILD_PAIR_* macros if possible (#39732) 2025-11-15 04:02:51 +09:00
Yu Watanabe 46ea7c3e32 musl: make strtoll() accept strings start with dot
glibc accepts strings start with '.' and returns 0, but musl refuses
them. Let's accept them, as our code assumes the function accept such
strings.
2025-11-15 03:41:40 +09:00
Yu Watanabe bb7d5e52a2 musl: test-bus-error: drop ._need_free flag checks
Its value depends on how strerror_r() implemented, and the
implementations of the function in glibc and musl are actually
different. Let's drop the checks.
2025-11-15 03:39:35 +09:00
Yu Watanabe ebb422dd2b musl: introduce GNU specific version of strerror_r()
musl provides XSI compliant strerror_r(), and it is slightly different
from the one by glibc.
Let's introduce a tiny wrapper to convert XSI strerror_r() to GNU one.

The wrapper also patches musl's spurious catchall error message.
2025-11-15 03:37:30 +09:00
Yu Watanabe c83f3f0837 musl: add several missing symbols (#39701) 2025-11-14 07:49:16 +09:00
Yu Watanabe aeb5fb83ca Three follow-ups for recent changes (#39724) 2025-11-14 07:48:47 +09:00
Yu Watanabe 69dd6d9420 musl: add several missing statx macros
glibc's sys/stat.h includes linux/stat.h, and we have copy of it from
the latest kernel, hence all new flags are always defined.
However, musl's sys/stat.h does not include linux/stat.h, and moreover,
they conflict with each other, hence we cannot include both header
simultaneously. Let's define missing macros to support musl.
2025-11-14 04:59:03 +09:00
Yu Watanabe 8324ef4213 musl: replace netinet/if_ether.h with our own implementation
musl's netinet/if_ether.h conflicts with linux/if_ether.h.
The reimplementation is mostly equivalent with what glibc does.
2025-11-14 04:59:03 +09:00
Yu Watanabe 6400e8dbd9 musl: provide several missing definitions for prctl() 2025-11-14 04:59:03 +09:00
Yu Watanabe 03d0fa4e4f musl: introduce dummy function for gnu_get_libc_version()
As the header gnu/libc-version.h and gnu_get_libc_version() function
are glibc specific, and musl does not provide them.
2025-11-14 04:59:03 +09:00