Commit Graph

53494 Commits

Author SHA1 Message Date
Yu Watanabe
00575cfd69 hwdb-util: drop unused value assignment
The values assigned to 'r' were never used, and overwritten by the next
call of read_line_full().

Fixes CID#1548043 and CID#1548064.
2025-03-04 05:18:15 +09:00
Yu Watanabe
6529ab0b06 pe-binary: fix array overrun
This is a kind of paranoia, as memeqzero() does not read anyting if
length is zero. But, strictly speaking C language does not allow such,
and Coverity warn about that.

Fixes CID#1561177.
2025-03-04 05:18:15 +09:00
Yu Watanabe
2bf5d698d6 pe-binary: trivial coding style fixlets 2025-03-04 05:18:15 +09:00
Yu Watanabe
3428c4b818 generator: insert parentheses to make the code clearer
Silence CID#1563781.
2025-03-04 05:18:15 +09:00
Yu Watanabe
42f6a96e6c fileio: move call of label_ops_post() before error handling of creating files
Fixes CID#1563946.
2025-03-04 05:18:15 +09:00
Yu Watanabe
b0e5cde687 async: voidify call of fsync()
Fixes CID#1564787.
2025-03-04 05:18:15 +09:00
Daan De Meyer
9fd25fd3ce network: Use RTNH_COMPARE_MASK in route_can_update() (#36585)
Let's only compare flags that can be set by userspace and not all flags.

Fixes a bug introduced by 7027cdbd79 (v256).
Fixes #36544
2025-03-04 05:00:33 +09:00
Lennart Poettering
047a4111df mount-tool: various tweaks (#36584)
Split out from #36337
2025-03-03 13:57:27 +01:00
Lennart Poettering
1965d2b222 io-util: fix ppoll_usec() bypass
If a non-zero timeout is specified we should not bypass ppoll() even if
no fds are specified, since it will still act as a time based sleep in
that case.
2025-03-03 10:47:09 +01:00
Lennart Poettering
789f4f7ee0 tty-askpw-agent: react to SIGTERM while waiting for console
I noticed that systemd-tty-password-agent would time out when asked to
stop via SIGTERM, and eventually be killed, under some circumstances.
It took me a while but i figured out what was going on:

systemd-ask-pw-agent blocks SIGTERM because it wants async notifications
on SIGTERM via signalfd() to listen on. That mostly works great: except
for one case: if we actually get a pw query request, and hence need to
acquire the terminal: we issue open_terminal() in that case, but if the
terminal is used otherwsie we'll hang, and because SIGTERM is blocked
we'll hang and cannot exit cleanly.

Address that: optionally, in acquire_terminal() look for SIGTERM by
unblcking the signal mask via ppoll() while we wait.
2025-03-03 10:47:09 +01:00
Mike Yuan
bb12d57cd5 mount-tool: never bind to device on explicit x-systemd.device-bound=no 2025-03-03 10:45:57 +01:00
Mike Yuan
0a7295b388 mount-tool: correct arg_bind_device check 2025-03-03 10:45:56 +01:00
Mike Yuan
36d4437c5b mount-tool: accept fstab-style identifiers for remote what too
fstab-style identifiers have stable translation to absolute paths
in the file system, hence it makes no sense to reject them
even for remote mounts.
2025-03-03 10:45:56 +01:00
Mike Yuan
70b1f3e0a2 mount-tool: some modernizations and log message tweaks 2025-03-03 10:45:56 +01:00
Steve Ramage
241a0f6e0a core: DelegateNamespaces= does not depend on seccomp (#36580) 2025-03-03 14:34:31 +09:00
Lennart Poettering
f2e38b01e0 sd-id128: gracefully handle systems where kernel keyring access is blocked
In various scenarios we invoke containers with access to the kernel
keyring blocked. Let's make sure we can handle this properly: when the
invocation ID is stored in in the kernel keyring and we try to read it
and get EPERM we should handle it gracefully, like EOPNOTSUPP.
2025-03-03 14:30:41 +09:00
Lennart Poettering
c179f03911 osc-context: several follow-ups (#36579) 2025-03-02 22:00:09 +01:00
Jörg Behrmann
369655330d vmspawn: switch from -drive to -blockdev option 2025-03-02 21:54:30 +01:00
Mike Yuan
14a40a6d1c core/main: don't write shutdown OSC context outside of pid1
Follow-up for 98c283131c
2025-03-02 16:22:40 +01:00
Mike Yuan
20a7802852 run: send out TERM= only if actually set
Follow-up for 4d6eb6441a
2025-03-02 16:22:00 +01:00
Mike Yuan
02fc6c55e5 run: log about osc_context_open_chpriv() failure
Follow-up for 575922c914
2025-03-02 16:21:59 +01:00
Mike Yuan
cada508fd8 osc-context: drop unneeded temporary variable 2025-03-02 16:21:59 +01:00
Mike Yuan
ffabfef921 login/pam_systemd: use isatty_safe()
Follow-up for d8069b8add
2025-03-02 16:21:59 +01:00
Lennart Poettering
f2b1de6f5b Revert "sd-json: add new sd_json_variant_unset_field() call"
This reverts commit b6a2df6307.

The functionality is entirely redundant, we already have
sd_json_variant_filter() which does the same, and is in fact even more
powerful, since it takes a list instead of a single field to remove.
2025-03-02 11:04:15 +00:00
Daan De Meyer
daa2547e31 Add a few more bypass environment variables
When we're building ParticleOS images, we don't want the package
manager (or mkosi) to run systemd-sysusers, systemd-tmpfiles or
systemctl preset so let's add a few more bypass environment
variables that we can set to have execution of these skipped like
we already have $SYSTEMD_HWDB_UPDATE_BYPASS and $KERNEL_INSTALL_BYPASS.
2025-03-01 16:22:53 +01:00
Daan De Meyer
38701809a8 core: Add DelegateNamespaces= (#36532) 2025-03-01 15:18:45 +01:00
Daan De Meyer
8234cd9989 core: Add DelegateNamespaces=
This delegates one or more namespaces to the service. Concretely,
this setting influences in which order we unshare namespaces. Delegated
namespaces are unshared *after* the user namespace is unshared. Other
namespaces are unshared *before* the user namespace is unshared.

Fixes #35369
2025-03-01 13:54:58 +01:00
Yu Watanabe
aaa5065d8f bump minimum required version of glibc to 2.31, and drop many fallback logic around statx() (#36558)
glibc-2.31 was released on 2020-02-01, which is more than 5 years ago.
Let's also bump the baseline of glibc.
2025-03-01 04:18:17 +09:00
Daan De Meyer
54ae0edc4a dissect: Skip partitions with _empty label 2025-02-28 17:00:50 +01:00
Lennart Poettering
8a69330e54 homed: port to notify_recv() + convert to PidRef (#36557)
Just some refactoring/modernization
2025-02-28 17:00:31 +01:00
Yu Watanabe
ee739ea692 mountpoint-util: make statx() failure critical
Two error conditions are unreachable, as now both glibc and kernel
support statx(). In other many places, failure in statx() are handled as
critical, even if it is filtered by seccomp or so. Let's follow the same
way here.
2025-03-01 00:40:22 +09:00
Yu Watanabe
d5ddc0e0d3 stat-util: drop statx_fallback()
Now both our required baseline of glibc and kernel support statx.
2025-03-01 00:33:32 +09:00
Yu Watanabe
998e6394ea test-stat-util: check if linux/stat.h is actually included from sys/stat.h 2025-03-01 00:33:32 +09:00
Yu Watanabe
4424e6c811 tree-wide: drop workarounds for statx()
struct statx in glibc header was introduced in glibc-2.28
(fd70af45528d59a00eb3190ef6706cb299488fcd), but at that time,
sys/stat.h conflicts with linux/stat.h. Since glibc-2.30
(5dad6ffbb2b76215cfcd38c3001778536ada8e8a), sys/stat.h includes
linux/stat.h if exists.

Since now our baseline of glibc is 2.31. Hence, we can drop workarounds
for struct statx by importing linux/stat.h from newer kernel (v6.14-rc4).
2025-03-01 00:33:28 +09:00
Yu Watanabe
a3d0471b03 basic/linux: update kernel headers from v6.14-rc4 2025-02-28 23:38:45 +09:00
Yu Watanabe
914d1ec171 tmpfiles: fix output value assignment
Fixes a bug in 7eeda1da90 (v256).
2025-02-28 23:38:02 +09:00
Yu Watanabe
91421f8379 recurse-dir: fix wrong assertion and error code in log
Fixes a bug in b5a07e524e (v250).
2025-02-28 23:37:52 +09:00
Lennart Poettering
3b0103aaa5 homed: port worker management to PidRef 2025-02-28 14:18:23 +01:00
Lennart Poettering
09b3390529 pidref: take more fields into account in pidref_compare_func() 2025-02-28 14:18:20 +01:00
Lennart Poettering
2ad187fb68 pidref: export hash funcs
That way we can use them for definition of additional hash_ops that map
pidrefs to arbitrary other resources.
2025-02-28 14:18:07 +01:00
Lennart Poettering
a147e72add homed: port to notify_recv_with_fds()
Found another implementation of the sd_notify() reception. Modernize it.
2025-02-28 14:18:04 +01:00
Lennart Poettering
19ade24464 notify-recv: add notify_recv() flavour that returns a split up strv instead of he message text as string
This is useful at various places, since we split up the message as first
thing there anyway.
2025-02-28 14:17:52 +01:00
Yu Watanabe
3694397994 osc-context: fix typo
Follow-up for 91aa93ec8d.
2025-02-28 15:51:07 +09:00
Dan McGregor
113c159ba9 machine-id-setup: bhyve also provides a uuid
When using UEFI with bhyve it behaves similarly to qemu, and provides
a product_uuid. Use it if found, just like with qemu.
2025-02-28 13:15:35 +09:00
Lennart Poettering
46bd501faa Issue OSC ANSI sequence whenever we change "context" of a TTY, i.e. acquire privs, enter container or VM or similar (#35224)
This is mostly a strawman to get a discussion going regarding how to
communicate to terminal emulators such as ptyxis about run0 (and nspawn,
and vmspawn, and moe) and what it does.

It's hierarchical and I think still relatively simple.

/cc @chergert
2025-02-27 22:12:54 +01:00
Yu Watanabe
78f2c17454 parse-util: extend the maximum length of nftable identifiers
Since kernel v4.14, more specifically, after the following four commits,
e46abbcc05
b7263e071a
387454901b
6150957521
the maximum length of nftable identifiers are extended to 255.

Now, our kernel baseline is 5.4, hence we can freely use the extended
name length.

This also modernizes code a bit, and adds test cases.

Closes #36542.
2025-02-28 04:57:00 +09:00
Yu Watanabe
b8358967e6 sbsign: trivial coding style cleanups
Follow-ups for 8c0098d486.
2025-02-28 04:04:18 +09:00
Martin Wilck
505c2f2137 libfido2-util: accept cached pin in fido2_generate_hmac_hash()
fido2_generate_hmac_hash() sets req->keyring to "fido2-pin" when
calling ask_password_auto(), suggesting that a key by this name
can be read from the kernel keyring. But the keyring is never
opened because the ASK_PASSWORD_ACCEPT_CACHED flag is not set.

Set ASK_PASSWORD_ACCEPT_CACHED to allow automated / scripted
setup of encrypted volumes with FIDO2. If the PIN turns out to
be invalid, clear ASK_PASSWORD_ACCEPT_CACHED to avoid retrying
and possible lockout.
2025-02-27 17:35:47 +01:00
Lennart Poettering
bbdad5c025 core: also issue OSC 3008 from service context
(Note: we also change TEST-13-NSPAWN.machined.sh minimally here, because
it checks for byte precise output of a pty allocated for a service
invocation - which it's not going to get if it claims that the pty is an
all-powerful one. After all this PR ensures that we'll generate the new
OSC sequence on non-dumb terminals associated with services. Hence, set
TERM=dumb explicitly to ensure no ANSI sequences are generated, ever.
Which is a nice test btw that TERM=dumb really does its thing here.)
2025-02-27 15:17:34 +01:00
Lennart Poettering
5b3eaf9e68 terminal-util: change conditioning in terminal_reset_defensive()
So far we conditioned the logic that issues ansi sequences for resetting
the TTY based on whether something is a pty is not (under the assumption
we need no reset on ptys, since they are shortlived).

This is simply wrong though. The pty that a container getty is invoked
on is generally long-lived: as long as the container is up, and it will
be reused between getty instances/sessions all the time. In such a case
we really should reset properly.

Let's instead make the logic dependent on whether TERM is set to
anything other than "dumb". The previous commit made sure we always set
TERM in a sensible way in systemd-run, hence this
*explicit* logic sounds like a much better choice now, as it mea
2025-02-27 15:17:34 +01:00