Commit Graph
82406 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 0adbb11b4e tests: print numeric error value too on failure
The error message is not always meaningful. Also, sometimes we care about the
sign of the value, and we ignore the sign of the error in the printing machinery.

The messages for errno are changed to say "errno" instead of "error". The problem with
the previous formalation is that our errors are always negative and errnos are
positive, so when we print the numerical value, we cannot use the word for both.

Example output:
src/test/test-tests.c:15: Assertion failed: Expected "-1" to succeed, but got error: -1/Operation not permitted
src/test/test-tests.c:16: Assertion failed: Expected "-ENOANO" to succeed, but got error: -55/No anode
src/test/test-tests.c:61: Assertion failed: Expected "0" to fail with error -2/"No such file or directory", but it succeeded
src/test/test-tests.c:62: Assertion failed: Expected "RET_NERRNO(mkdir("/i/will/fail/with/enoent", 666))" to fail with error -55/"No anode", but got the following error: -2/No such file or directory
src/test/test-tests.c:68: Assertion failed: Expected "0" to fail with errno 2/"No such file or directory", but it succeeded
src/test/test-tests.c:70: Assertion failed: Expected "mkdir("/i/will/fail/with/enoent", 666)" to fail with errno 55/"No anode", but got the following errno: 2/No such file or directory
2025-07-01 17:51:49 +02:00
Zbigniew Jędrzejewski-Szmek 236f7ab07c tests: cast to intmax_t instead of printing to a temp buffer
We can do this for int types, i.e. the variants where we expect a
success/error code. The macros which do generating comparison operations
also support floats so we shouldn't use intmax_t there.

The code is shorter and calling printf once is certainly more efficient.
2025-07-01 17:51:49 +02:00
Zbigniew Jędrzejewski-Szmek a1296fa5e5 test-tests: move assert tests to new file
Those macros are defined in tests.[ch], so the tests should be in test-tests.c.
2025-07-01 17:51:46 +02:00
Zbigniew Jędrzejewski-Szmek 89181651e6 shared/tests: indent defines 2025-07-01 17:47:34 +02:00
Vitaly Kuznetsov 821b453170 man/systemd-sysext: list ephemeral/ephemeral-import in the list of options
ephemeral/ephemeral-import are described as possible '--mutable' options but
not present in the list. Note, "systemd-sysext --help" lists them correctly.
2025-06-30 18:03:07 +01:00
Daan De Meyer 86e780759d test-xml: Use ASSERT_OK() instead of ASSERT_GE()
Follow up for 7a58b45017
2025-06-30 15:49:11 +01:00
Jim Spentzos 3725e17408 po: Translated using Weblate (Greek)
Currently translated at 35.7% (92 of 257 strings)

Co-authored-by: Jim Spentzos <jimspentzos2000@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/el/
Translation: systemd/main
2025-06-30 20:05:44 +09: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
Michael Ferrari 381304a209 repart: add support for Format=empty
This is a new meta value for the `Format=` option, which is equivalent
as specifying `Label=_empty` and `NoAuto=1` for compatibility with
sd-sysupdate.

Closes: https://github.com/systemd/systemd/issues/34596
2025-06-30 10:11:16 +02:00
Nick Labich 878c2b28df vmspawn: Use host_device driver for --extra-drive block devices
Extra drives attached to VMs use the file driver for regular files and the
host_device driver for block devices.

Fixes https://github.com/systemd/systemd/issues/37986
2025-06-30 10:08:30 +02:00
Yu Watanabe 4f18ff2e29 tree-wide: include unistd.h where necessary
We use symbols provided by unistd.h without including it. E.g.
open(), close(), read(), write(), access(), symlink(), unlink(), rmdir(),
fsync(), syncfs(), lseek(), ftruncate(), fchown(), dup2(), pipe2(),
getuid(), getgid(), gettid(), getppid(), pipe2(), execv(), _exit(),
environ, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO, F_OK, and their
friends and variants, so on.

Currently, unistd.h is indirectly included mainly in the following two paths:
- through missing_syscall.h, which is planned to covert to .c file.
- through signal.h -> bits/sigstksz.h, which is new since glibc-2.34.
  Note, signal.h is included by sd-eevent.h. So, many source files
  indirectly include unistd.h if newer glibc is used.

Currently, our baseline on glibc is 2.31. We need to support glibc older
than 2.34, but unfortunately, we do not have any CI environments with
such old glibc. CIFuzz uses glibc-2.31, but it builds only fuzzers, and
many files are even not compiled.
2025-06-30 09:19:15 +02:00
Yu Watanabe b9c344b5c0 conf-files: several follow-ups for #37972 (#37997)
The PR #37972 was merged without final review by mistake, and has
several issues.
This reverts some of the commits in the PR, and fix several issues.
2025-06-30 12:47:49 +09: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 9000db5f6e conf-files: fix an empty root handling in conf_files_list_strv()
Before 50c81130b6, the function used
chase(), hence if root is an empty string, each config directory made
prefixed with the current working directory if it is relative. See
implementation of chase().

With 50c81130b6, conf_files_list_strv()
internally uses chaseat(), hence each config directory is not prefixed
anymore even if it is relative.

To restore the previous behavior, this makes
- if root is an empty string, prefix each config directories with the
  current working directory if relative.
- if root is relative, make it absolute to make the prefixed results also
  absolute, and debugging logs show absolute paths.
- use chaseat_prefix_root() to prefix the results, for safety.

Follow-ups for 50c81130b6.
2025-06-30 05:35:03 +09:00
Yu Watanabe 8ce463639a path-util: move empty_or_root_to_null() from chase.c
And rename it to empty_or_root_harder_to_null(), as it also checks if
the input path effectively points to the root by calling path_is_root().
This also adds simple test cases for the function.
2025-06-30 03:45:29 +09:00
Yu Watanabe cdd3aba3df conf-files: fstatat() sets errno on failure
Follow-up for 50c81130b6.
2025-06-29 10:15:56 +09:00
Yu Watanabe 07c2fadbed Revert "conf-files: introduce CONF_FILES_CHASE_BASENAME flag"
This reverts commit 49653adef3.

The commit was merged without review, and has several issues.
Let's revert the change now, and address the issue pointed out by
the commit later in another way.
2025-06-29 10:15:56 +09:00
Yu Watanabe c43223ff9f conf-files: drop use of CONF_FILES_CHASE_BASENAME in conf_files_list_with_replacement()
The flag has several potential issues, and will be dropped in the next
commit.

Follow-up for 41fb58595a.
2025-06-29 10:15:56 +09:00
Yu Watanabe 2d0ec7f900 Revert "pretty-print: also chase symlinks in the last component"
This reverts commit 2f2977cab8.

The commit was mistakenly merged without review. Also as pointed at
https://github.com/systemd/systemd/pull/37972#discussion_r2173234198
now the output is confusing. Let's revert at least now.
2025-06-29 10:15:56 +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
Yu Watanabe dbe13de11c meson: drop custom_target names (#38003) 2025-06-29 05:58:26 +09:00
Zbigniew Jędrzejewski-Szmek 13bdaad1d4 meson: adjust indentation 2025-06-28 17:18:35 +02: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
Zbigniew Jędrzejewski-Szmek e11041d30f man: drop inadvertently added -x, make shellcheck clean
aecb6eaed7 added -x most likely for debugging,
drop it. Also, adjust quoting to make the generated scripts liked by shellcheck.
2025-06-28 15:31:46 +02:00
Zbigniew Jędrzejewski-Szmek 0a580dee6b meson: quote paths in generated systemd-runtest.env
Looking at aecb6eaed7, it seems that we
want build paths with spaces to be supported. Let's use 'printf %q' here
to make that work. Also, use capture:true to make the command less complicated.
2025-06-28 15:10:00 +02:00
Yu Watanabe 90b14808f2 repart: fix typo
Follow-up for e7b4b2968e.
2025-06-28 04:32:45 +09:00
Yu Watanabe 591d113def test-conf-files: use ASSERT_OK() and friends 2025-06-28 04:13:43 +09: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 2f2977cab8 pretty-print: also chase symlinks in the last component
Otherwise, this may shows files outside of the specified root directory.
2025-06-28 04:13:43 +09:00
Yu Watanabe 41fb58595a conf-files: rework conf_files_list_with_replacement()
Previously, symlinks in the replacement was not chased, hence we may
inserted a path to outside of the root directory, or we may have wrong
judgement whether we should insert the replacement or not.

This makes the symlinks in the replacement also resolved.
Also, as the function is only used by tmpfiles and sysusers, this
enables CONF_FILES_REGULAR, CONF_FILES_CHASE_BASENAME, and
CONF_FILES_FILTER_MASKED_BY_SYMLINK flags.
2025-06-28 04:13:43 +09:00
Yu Watanabe 49653adef3 conf-files: introduce CONF_FILES_CHASE_BASENAME flag
Previously, when a root directory is specified to conf_files_list() and
friends, the last component of each result was not resolved, even though
they internally chases the last component. So the caller needs to chase
the path again when the file is used.

This introduce a new flag that makes the whole path of each result is
resolved, hence caller can use it as is.
2025-06-28 04:13:43 +09:00
Yu Watanabe 50c81130b6 conf-files: chase symlink files in conf directories
Previously, symlinks in paths to conf directories are chased, but
symlink files in conf directories were not.

This also makes symlink files in conf directories chased. And, any
unresolvable symlinks are dropped, even if no verification is requested.
2025-06-28 04:13:38 +09:00
Yu Watanabe d6570eafe3 userdb: fix enumeration of .membership files
The man page nss-systemd(8) says

> The contents of these files are currently not read, and the files
> should be created empty.

But previously we filtered out such files, as the CONF_FILES_FILTER_MASKED
flag checks if a file is empty (or symlink to null), thus any empty files
were ignored.

To accept empty .membership files, let's use CONF_FILES_FILTER_MASKED_BY_SYMLINK.

Fixes #37945.
2025-06-28 03:54:48 +09:00
Yu Watanabe e93d8c844c conf-files: split CONF_FILES_FILTER_MASKED flag into two 2025-06-28 03:54:48 +09:00
Yu Watanabe 9d0fed7b44 stat-util: split null_or_empty() into two 2025-06-28 03:54:48 +09:00
Yaping Li 7a58b45017 test-xml: migrate to new assertion macros (#37990)
We recently added a new set of assertion macros such as ASSERT_GE,
ASSERT_OK, ASSERT_EQ, ... which show not only the expression that failed
but also the values of the arguments of the expression. Let's use them.
2025-06-28 03:53:12 +09:00
Mike Yuan 77de0a0e26 basic/include: trivial cleanups for libc header wrapper (#37937) 2025-06-27 16:03:10 +02:00
Lennart Poettering 4b6dbd4ea5 resolved: don't wait for TLS close_notify replies unnecessarily
This is based on #35764 by Guruswamy Basavaiah, but covers further code
paths.

This ensures that when we initiate a TLS shutdown we'll write out our
own close_notify message, but not wait for the close_notify reply from
the server side anymore.

Replaces: #35764
2025-06-27 14:32:28 +01:00
Lennart Poettering 635b42edd9 resolved: when determining error to return, prefer "conclusive" over "inconclusive" errors
When asked to look something up, and all scopes we contact fail we need
to pick a suitable error code for the failure, and given that we look up
things on multiple scopes we might have multiple errors to choose from.
So far we simply picked the error from the last scope in the list, which
hence would be pretty arbitrary.

Let's tweak this a bit, and if we have multiple errors to choose from,
let's prefer "conclusive" failures over "inconclusive" ones. The
"inconclusive" ones in this sense are the ones where we didn't even issue
a request, but couldn't even do that because we had no server, no
network or things like that. The "conclusive" ones are the errors we got
from a server, that hence a "real" in a way.

This addresses the confusion described in #37969. For LLMNR lookups we
generally refuse looking up A addresses via IPv6 and AAAA via IPv4. This
generates a DNS_TRANSACTION_NO_SERVERS error, which we would then return
for one type of lookup but not for the other, because the IPv6 scope is
generally created after the IPv4 one, and hence so far won.

Fixes: #37969
2025-06-27 14:30:40 +01:00
Lennart Poettering 5584632f40 cpu-set-util: fix null pointer dereference and several cleanups (#37900)
Fixes CID#1611618.
2025-06-27 14:59:25 +02:00
Fleuria bed9d2587c timer: Do not recalculate monotonic elapse time on clock change
The only clock change that affects monotonic timers is suspend causing
CLOCK_MONOTONIC to fall behind CLOCK_BOOTTIME. However, monotonic timers
that use CLOCK_BOOTTIME are not intended to have their elapse time
changed after a suspend. Hence condition the calculation of monotonic
timers’ elapse times on the cause not being a clock change.

Fixes #29245
2025-06-27 14:45:02 +02: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
Andy Shevchenko 318c4f7b81 hwdb: Add accel orientation quirk for the Microtech e-tab Pro
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2025-06-27 11:21:03 +01:00
Lennart Poettering 7478fbb0af core: fixes for RandomizedOffsetSec= feature (#37981)
Fixes: #37870
Follow-up for: #36437
2025-06-26 22:58:22 +02:00
Luca Boccassi f00c2ac34a mkosi: update mkosi commit reference to 0d1143150835b21c1bfe64428df5f45b558280b1 (#37977)
* b2fe7ba6b1 Do not use return in finally
* b4f3088535 Ensure directories exist before running sync scripts
* e83e7036b0 mkosi-obs: also allow enrolling additional certs in KEK
* b6432fbc29 initrd: Copy /etc/pki/rpm-gpg into sandbox tree
* 44b96b93c8 Partially revert "resources: add systemd-boot-efi"
* 7a22260179 Check that keys are both in context.cli and history
* 6570b21a4b fix: Remove `erofs-utils` from initrd
* ff61c5022a mkosi-initrd: Add atkbd and i8042 modules to the default
initrd modules
* eaa37f7c6c Generate initrds outside of umask context manager
* de09209520 ci: Drop differential shellcheck
* d07c6b93c9 build(deps): bump github/codeql-action from 3.28.16 to
3.28.18
* 9a12fb1bef Check that commit exists in config_parse_minimum_version()
* 9e5b4f8932 kmod: factor out comparison and also count empty
directories as invalid
* 39ed5ef6c2 apt: support including additional configuration for
reprepro
2025-06-26 17:27:04 +01:00
Lennart Poettering c6bb846c04 shared: make sure RandomizedOffsetUSec can be set as transient prop
Fixes: #37870
Follow-up for: #36437
2025-06-26 17:31:00 +02:00
Lennart Poettering 99fd08224f man: add proper version info for RandomizedOffsetUSec
Follow-up for: #36437
Fixes: #37870
2025-06-26 17:28:49 +02:00
Lennart Poettering d14cfb6e82 repart: enforce minimum size on ESP based on sector size (#37899)
Fixes: #37801
2025-06-26 17:22:47 +02:00
Lennart Poettering 584e5222d2 fix docs for inhibitor logic (#37975)
Fixes: #34091

Sigh.
2025-06-26 17:22:08 +02:00
Luca Boccassi 4cce53b76a Small udpates to TPM2_PCR_MEASUREMENTS page (#37978) 2025-06-26 14:28:03 +01:00