100 Commits
Author SHA1 Message Date
Mike Yuan 5306dca35f iovec-util: enclose macro arg in ()
Follow-up for 56f3ae9292
2026-07-26 19:58:08 +09:00
Mike Yuan c2624fe9a7 various: attach errno to structured logs, even if not used in msg 2026-07-25 19:37:47 +09:00
Mike Yuan 8c98dac0dc imds-generator: do not enable IMDS logic if detect_container() failed 2026-07-25 19:37:47 +09:00
Mike Yuan 37f760f787 imds-generator: use read_full_virtual_file() 2026-07-25 19:37:47 +09:00
Mike Yuan 8fa8e29656 imdsd: use free_many_charp() where appropriate 2026-07-25 19:37:47 +09:00
Mike Yuan d5d76ddd80 Revert "basic/allow-util: make free_many non-inline"
This reverts commit 3abe1e53f6.

I remain unconvinced. The function is very short, and
by making it inline the assert()s can be optimized away.
2026-07-25 19:37:47 +09:00
Mike Yuan 89d48b71ae efi-loader: move $SYSTEMD_FORCE_MEASURE override to efi_measured_os()
Follow-up for cd911bec6e

The (debug) envvar should have highest priority, hence move it
to the new entrypoint function and give it precedence over
systemd.tpm2_measured_os=.
2026-07-25 19:37:47 +09:00
Mike Yuan b82e739cb5 efi-loader: shorten the code a bit 2026-07-25 19:37:47 +09:00
Mike Yuan a9e5f5116e sd-daemon: escape notification msg using shell_escape()
Follow-up for f9e0a62392

xescape() would unconditionally emit hex escapes, rendering
\n unreadable.
2026-06-13 17:11:11 +02:00
Mike Yuan cd13dc16c3 core/execute-serialize: fix error handling 2026-06-13 17:11:11 +02:00
Mike Yuan 6f0731cf34 core/unit: refuse PrivatePIDs= + PAMName=
Fixes #40928
2026-06-13 17:11:11 +02:00
Mike Yuan 9be5a6f665 core/manager: add missing assertion on stop_notify_queue being empty
Follow-up for 1b4ab5a209
2026-06-13 17:11:10 +02:00
Mike Yuan a53d9a5794 namespace-util: add missing half of the assertion in is_our_namespace() 2026-06-13 17:11:10 +02:00
Mike Yuan 08eff23a2d mount-util: restore compat for kernels without MOUNT_ATTR_NOSYMFOLLOW (< 5.14)
Follow-up for 6753bd8a2f

Replaces #41341
2026-04-02 12:33:21 +01:00
Mike Yuan 771800a403 machine: never ever allow non-root-owned host machine
We really should lock this down _hard_, as evidenced by recent
security fallouts.
2026-03-27 11:47:42 +01:00
Mike Yuan 90cc5b0159 machine: introduce MACHINE_CLASS_CAN_REGISTER
Follow-up for 6df5f80bd3

Similar to SESSION_CAN_* macros in logind-session.h
2026-03-27 11:47:42 +01:00
Mike Yuan be176c0c91 Make imds networking unlocked by default (#41359) 2026-03-26 20:08:17 +01:00
Mike Yuan de68e23ff1 creds: minor cleanups for --newline= handling (#41329)
Prompted by #41325

Fixes #41348
2026-03-26 18:36:51 +01:00
Mike Yuan e153cf36b0 core: address review feedback from Mike (#41354)
This commit addresses the review feedback from @YHNdnzj (many thanks)

Closes: https://github.com/systemd/systemd/issues/41324
2026-03-26 18:18:01 +01:00
Mike Yuan 734af2908a creds: minor tweak for fputc() error handling
Let's do not assume errno is set for return values other than
EOF, following what we do in fileio.c.
2026-03-26 16:01:35 +01:00
Mike Yuan 64d1c102ad creds: if newline is explicitly requested, skip tty check
Before this commit, the > 0 state of arg_newline tristate is
simply ignored.

Yes, this is a minor compat break, but I'd argue the previous
behavior was not useful as "yes" is treated the same as "auto".
An issue also reported that it was quite surprising.

Fixes #41348
2026-03-26 16:00:42 +01:00
Mike Yuan 1060f82611 creds: use parse_tristate_argument_with_auto() where appropriate 2026-03-26 15:55:50 +01:00
Mike Yuan 82bfcc37e2 cleanup-util: include assert-fundamental.h instead of -util
The split was initially done to reduce transitive includes,
and for assert() only the former is needed.
2026-03-26 15:55:50 +01:00
Mike Yuan aa71035a20 meson: detect availability of attributes using cc.has_function_attribute()
Alternative to fabc22f599

As suggested in https://github.com/systemd/systemd/pull/41174#discussion_r2966411375
2026-03-25 21:54:21 +01:00
Mike Yuan f3d385da2a memory-util: avoid passing invalid pointer to memcmp() when length == 16
If length is exactly 16, the loop would finish with length == 0,
but we'd carry on to the memcmp() check, where the 'p + 16' passed
would be invalid memory. memcmp() demands valid pointers even if
size is specified to 0, hence let's catch this ourselves.
2026-03-25 21:49:04 +01:00
Mike Yuan a7f1670f62 user-record: extract user_record_image_is_blockdev() common helper 2026-03-06 22:50:48 +01:00
Mike Yuan e65a6e26ad core/varlink-unit: distinguish PIDREF_AUTOMATIC from unset
Follow-up for ab73333c43

Methods that take numeric pid values use 0 to denote the peer,
hence let's log about 0 on PIDREF_AUTOMATIC, -1 if truly unset.
2026-03-06 04:05:28 +09:00
Mike Yuan ae4c3904af boot/pe: remove unneeded parens
Follow-up for f8ed94ea99
2026-03-06 04:05:28 +09:00
Mike Yuan df51a04a75 path-util: drop unused paths_check_timestamp() 2026-03-06 02:39:39 +09:00
Mike Yuan 909108163f tree-wide: various Coccinelle-suggested tweaks and related fixes (#40950) 2026-03-05 17:07:39 +01:00
Mike Yuan ab7d40ff0c machine-varlink: reference the right struct in VARLINK_DISPATCH_MACHINE_LOOKUP_FIELDS
This practically shouldn't matter, as the layout for name
and pidref fields are identical for all the structs. But
let's get things right.
2026-03-05 08:56:34 +01:00
Mike Yuan c8f764e40d hwdb/60-tpm2: correct prefix in comment (tpm -> tpm2)
Follow-up for f2eed3fa25
2026-03-05 01:03:47 +01:00
Mike Yuan 568dbbd5a9 journalctl-filter: drop doubled newline
Follow-up for d8302c2fd9
2026-03-05 01:01:33 +01:00
Mike Yuan e209570844 clang-tidy fixes (#40947) 2026-03-04 16:27:51 +01:00
Mike Yuan e8c542981b machine-dbus: do not check for overlapping condition
Follow-up for c5e48e3a66

This also makes things in line with the varlink method.
2026-03-04 14:32:46 +01:00
Mike Yuan f1f38e2fc1 sd-journal/catalog: make catalog_file_dirs static 2026-03-04 14:32:17 +01:00
Mike Yuan ae558ebd42 bpf-dlopen: mark bpf_get_error() as static
Any use of this function should go via bpf_get_error_translated().
2026-03-04 14:32:17 +01:00
Mike Yuan 2853e4cb1c shared/password-quality-util-*: make dl functions static 2026-03-04 14:32:16 +01:00
Mike Yuan a521abbf27 machined: move declaration of manager_object to machined-dbus.h 2026-03-04 14:32:16 +01:00
Mike Yuan 08e4cf491a various: make bus objects static 2026-03-04 14:32:16 +01:00
Mike Yuan 5aeda638bb core/varlink-metrics: make metric_family_table static 2026-03-04 14:32:16 +01:00
Mike Yuan a0ea74092e shared/varlink-*: normalize includes 2026-03-04 14:32:16 +01:00
Mike Yuan 769b0bf746 various: mark arg_* as static 2026-03-04 14:32:15 +01:00
Mike Yuan 192954ac68 bootctl: declare missing arg_* in header
Follow-up for 90cf998875
2026-03-04 14:32:15 +01:00
Mike Yuan 18d1f2dced tree-wide: make private hash ops static 2026-03-04 14:32:15 +01:00
Mike Yuan 11f06ab768 shared/acpi-fpdt: set _packed_ attr properly
We were declaring a variable named _packed...
2026-03-04 14:32:15 +01:00
Mike Yuan 36d30330f7 ansi-color: in 256 mode, always set the fallback color first
Linux console is very weird when it comes to ANSI color sequences.
Not only that it isn't aware of ':' separator (c.f.
https://github.com/systemd/systemd/pull/40878#issuecomment-3979826739),
it even skips the whole CSI-m sequence if it contains parts it cannot
parse. Hence when color mode is set to 256 (i.e. default when no
extra info is available) let's always emit two distinct CSI-m sequences,
and set the fallback 16 color first in case the terminal doesn't have
complete support for the 256 one.

Replaces #40905
2026-03-03 23:56:05 +01:00
Mike Yuan 085f92730a tree-wide: use ALPHANUMERICAL where appropriate
Prompted by 43116c5662
2026-03-04 07:36:10 +09:00
Mike Yuan 38a527b0c6 systemctl-start-unit: enclose command in single quotes 2026-03-03 17:51:43 +01:00
Mike Yuan 93d768e0f3 systemd/sd-varlink-idl.h: fix ABI breakage
Follow-up for 2e51ed7fcb
2026-03-02 10:49:52 +01:00
Mike Yuan 452c576927 core/varlink-unit: use VARLINK_ERROR_UNIT_NO_SUCH_UNIT macro
Follow-up for 1fc868ac6b
2026-03-02 10:49:51 +01:00
Mike Yuan a12a4bdc9a pidref: do not tamper with pidref_acquire_pidfd_id() retval
If a pidfd id is passed to us, it must have originated from
somewhere, i.e. pidfs should be supported on the system.
Hence let's be honest about -EOPNOTSUPP, which might indicate
some bigger problems under the hood, rather than allowing
it to be turned into mild -ESRCH.
2026-03-02 15:25:53 +09:00
Mike Yuan eb8df25a37 core/exec-invoke: make fd array sizing less error-prone
History has clearly shown that we're terrible at keeping
the size of the dont_close array up-to-date. Hence let's
step away from a hardcoded max size for that, instead
always collect all fds in the array initializer and
let compiler figure it out, taking advantage of the fact
that close_all_fds() gracefully handles invalid fds in
the 'except' array.
2026-03-01 13:55:39 +01:00
Mike Yuan f2e7ba1074 core/exec-invoke: drop duplicate addition of handoff_timestamp_fd to dont_close array
Follow-up for 12001b1bf0

It is part of the keep_fds array already, which is intended
for fds that need to survive until the very end of executor
runtime, i.e. across the second close_all_fds() call.
2026-03-01 13:55:39 +01:00
Mike Yuan 0aa70bef5e core/exec-invoke: correct size for dont_close array in close_remaining_fds()
Follow-up for 79dd24cf14
2026-03-01 13:55:39 +01:00
Mike Yuan ec93edc4ca core/exec-invoke: fix potential double close of socket/bpffs fds on failure
The owned fds should be closed before close_all_fds() along the lines
of exec_params/runtime_close(), otherwise they would be left dangling
afterwards.
2026-03-01 13:55:39 +01:00
Mike Yuan b702bbc31c core/execute: drop redundant close of root_directory_fd
exec_params_shallow_clear() will take care of it.
2026-03-01 13:55:30 +01:00
Mike Yuan abffc0ef43 process-util: leave actual log fd closing to close_all_fds() if the latter will be done anyways 2026-03-01 13:18:19 +01:00
Mike Yuan 8df624bfdd sd-varlink: add missing space 2026-02-28 12:01:06 +01:00
Mike Yuan 7982acff82 shared/pager: do not wait for process again after FORK_WAIT
Follow-up for fbd276cb86

Fixes #40873
2026-02-28 12:00:52 +01:00
Mike Yuan 04b3c2d199 tmpfiles: minor logging fixes (#40875) 2026-02-28 11:48:43 +01:00
Mike Yuan 476d0d7643 tmpfiles: downgrade log level for non-existent symlink target
I'm seeing a *lot* of noise induced by missing varlink sockets
under /run/host/ after 3363693935.
2026-02-27 17:11:41 +01:00
Mike Yuan b1c6bcf949 tmpfiles: fix doubled "/" in root + path logging 2026-02-27 17:07:43 +01:00
Mike Yuan 0dbd116351 shared/dropin: use set_contains() where appropriate 2026-02-27 08:50:37 +01:00
Mike Yuan efa6ba2ab6 core: validate input cgroup path more prudently 2026-02-26 14:23:25 +01:00
Mike Yuan 42aee39107 core/cgroup: avoid one unnecessary strjoina() 2026-02-26 14:23:23 +01:00
Mike Yuan 679e738bf4 core/dbus-unit: query sender uid only once, validate unit uid early
Follow-up for 05f5156ad1
2026-02-26 14:23:23 +01:00
Mike Yuan 4e6e3b8707 sd-json: fix off-by-one issue when updating parent for array elements
Follow-up for 8525bb369a
2026-02-26 14:23:12 +01:00
Mike Yuan 2b67122cdf core/namespace: clean up append_private_tmp() a bit
With the previous changes the modes for /tmp/ and /var/tmp/
may come in arbitrary directions, i.e. we may downgrade one
and upgrade another. Hence let's refactor the setup logic
a bit so they're truly independent.
2026-02-25 12:38:12 +01:00
Mike Yuan 9984a35d65 core/execute: stop looking at ExecSharedRuntime to determine PrivateTmp= state
The only reason why ExecSharedRuntime.(var_)tmp_dir might
be suppressed is when (/var)/tmp/ is listed in InaccessiblePaths=,
in which case mount namespace is needed anyways. Moreover,
the current logic imposes a chicken-and-egg problem:
at various places in pid1 we'd need to check whether
the unit runs in a mountns, but the ExecSharedRuntime
may not be allocated for it just yet.
2026-02-25 12:38:11 +01:00
Mike Yuan 0d10a125f6 core/execute: make exec_shared_runtime_make() handle distinct PrivateTmp= modes properly 2026-02-25 12:38:11 +01:00
Mike Yuan e438e5923d core/namespace: two fixes for namespace_cleanup_tmpdir()
* Make sure we're not passing NULL to rmdir()
* Remove the inner "tmp" subdir as well, so that callers
  can handle this transparently (e.g. exec_shared_runtime_make()
  is not aware of the nested rmdir() requirements)

While at it, remove unneeded PROTECT_ERRNO.
2026-02-25 12:38:11 +01:00
Mike Yuan a45fb074fe core/namespace: rename() might return ENOTEMPTY if target dir exists 2026-02-25 12:36:45 +01:00
Mike Yuan 2e71d0a2bd core/unit: refuse UserNamespacePath= + PrivateUsers=
Such setup makes zero sense, as if we unshare userns ourselves
we'd immediately lose CAP_SYS_ADMIN over the userns specified.
2026-02-25 12:36:44 +01:00
Mike Yuan 457bd2345c core/execute: do not suppress ExecSharedRuntime if userns path is specified
Follow-up for 79dd24cf14
2026-02-25 12:36:44 +01:00
Mike Yuan 3c47dc76be systemctl-start-unit: drop redundant check for enqueue-marked-jobs --wait
Follow-up for c008f88ded

The check at the beginning of the function already covers this.
2026-02-25 05:09:38 +09:00
Mike Yuan 21fd534ae8 systemctl: introduce enqueue-marked-jobs verb (#40810) 2026-02-24 18:08:22 +01:00
Mike Yuan 81f31dccb8 man/systemctl: deprecate --marked 2026-02-24 16:00:05 +01:00
Mike Yuan c008f88ded systemctl: introduce enqueue-marked-jobs verb, stop lumping it with distinct verbs 2026-02-24 16:00:05 +01:00
Mike Yuan a8ceed0000 Revert "systemctl: allow --marker with start/stop too"
This reverts commit 351b4dd123.

I'm pretty sure we should not create more of these multiplexer
interfaces, which in this specific also leads to a fair bit of
confusion: start/stop/reload-or-restart --marked all enqueue
all job types.

Instead, a dedicated verb will be introduced in later commits.
2026-02-24 15:48:53 +01:00
Mike Yuan d39b103719 core: Introduce ConditionPathIsSocket= (#40791) 2026-02-23 17:07:28 +01:00
Mike Yuan d8302c2fd9 journalctl-vl-server: allow querying units for specific uid in system scope
This also moves journal_add_unit_matches() back to
journalctl-filter.[ch], as I see more appropriate.
2026-02-23 10:43:00 +01:00
Mike Yuan bd994b2f81 journalctl-vl-server: do not output in reverse order
While at it, do not log from varlink method callback,
as per our usual style.
2026-02-23 10:21:57 +01:00
Mike Yuan 9d193c8f13 journalctl-vl-server: 'entry' is never NULL 2026-02-23 10:21:57 +01:00
Mike Yuan ffe69b3fa1 journalctl-vl-server: use SD_JSON_BUILD_PAIR_VARIANT 2026-02-23 10:21:57 +01:00
Mike Yuan fd0b6187be journalctl-vl-server: return proper error if unit pattern has no match
Note that SD_VARLINK_ERROR_INVALID_PARAMETERS requires
the invalid param name to be specified, hence we would
otherwise have reported an invalid INVALID_PARAMETERS
error ;)
2026-02-23 10:21:56 +01:00
Mike Yuan 4ed5e84bea logs-show: clean up journal_entry_to_json() a bit
* Make sure ret is initialized on success return
* Drop unneeded 'object' variable
* No need to ref/unref json objects when constructing
  intermediary array
2026-02-23 10:21:56 +01:00
Mike Yuan eaeceb5fb6 units/user/systemd-journalctl.socket: drop MaxConnectionsPerSource=
For AF_UNIX sockets connection sources are accounted for
based on UID, hence in user scope this effectively
limits total number of connections, which is not really
desirable.
2026-02-23 10:21:56 +01:00
Mike Yuan 2afe8e28f8 units/systemd-journalctl@.service: run with DynamicUser=yes
Follow-up for a109189fab

This follows the existing practice for
systemd-journal-{upload,gatewayd}.service,
as I think allocating a full-blown user
specifically for this purpose is an overkill.
And with DynamicUser=yes we can also take
advantage of implied sandboxing.
2026-02-23 10:21:56 +01:00
Mike Yuan 2619656950 units/systemd-journalctl@.service: require mount for /var/log/journal/ 2026-02-23 10:21:56 +01:00
Mike Yuan 5c247bbd57 units/systemd-pcrlock.socket: drop [Install] section
The socket is statically enabled.
2026-02-23 10:21:55 +01:00
Mike Yuan c71aa4047b TODO: drop completed entry 2026-02-23 10:21:55 +01:00
Mike Yuan bd7ba0a645 parse-argument: make parse_tristate_argument() do something useful (#40652)
Alternative to #37751
2026-02-21 03:10:00 +01:00
Mike Yuan f04023d35f vmspawn: clean up OVMF secure boot support check a bit
find_ovmf_config() would do filtering based on arg_secure_boot
already, hence the mismatch can only occur if we're using
user-specified firmware. So be explicit about this in log.
2026-02-20 21:21:01 +01:00
Mike Yuan 39a5b957e1 vmspawn: use parse_tristate_argument_with_auto() 2026-02-20 21:21:01 +01:00
Mike Yuan 577e5e9a5e parse-argument: make parse_tristate_argument() do something useful
I expressed the issue I have with parse_tristate_argument()
in #37751: it doesn't add any value to direct use of parse_tristate();
on the contrary, it doesn't support means to reset the arg to "auto"/-1 state.
The mere reason it existed is that we need a int type ret param.

Since the previous attempt to address this mess failed, let's
try to make the function more useful by making it accept "auto".
I figure this is useful on its own.

As requested in
https://github.com/systemd/systemd/pull/40652#discussion_r2831833996,
the function name is suffixed with _with_auto() to establish
that "auto" is handled internally.
2026-02-20 21:20:45 +01:00
Mike Yuan 1f0749c5f3 NEWS: correct descriptions for bootctl/networkd's varlink interfaces 2026-02-17 16:27:06 +01:00
Mike Yuan 888b385c54 NEWS: two additions for pid1 2026-02-17 16:26:36 +01:00
Mike Yuan b52a202b61 sd-json: fix doubled space 2026-02-17 16:26:36 +01:00
Mike Yuan 603a899720 resolved-dns-scope: fix typo 2026-02-17 16:26:36 +01:00