Commit Graph
100 Commits
Author SHA1 Message Date
Ivan Kruglov d4d31c1859 test: exempt the broker from its start rate limit in TEST-95 2026-09-17 04:51:36 -07:00
Ivan Kruglov 621df84009 test: give the D-Bus reconnect checks their own integration test
Killing the broker is destructive well beyond the units under test: nothing
reconnects to the new one, so logind for instance keeps running with
org.freedesktop.login1 unowned for the rest of the boot. As a subtest of
TEST-23-UNIT-FILE that leaked into everything running after it, and
statedir.sh, the first one to start user@0.service, then spent 25s per logind
property in user-runtime-dir and, where pam_systemd can't use Varlink, blocked
in CreateSession() past user@.service's 90s TimeoutStartSec and failed — with
the failure pointing at a subtest that has nothing to do with the bus.

In its own test the damage dies with the machine.
2026-09-17 04:51:29 -07:00
Ivan Kruglov 2b42e4f0c9 man: document what a failure action returns without an exit status 2026-09-03 10:18:29 -07:00
Ivan Kruglov 369bb5862b test: add a test for issue #43645 2026-09-03 10:18:29 -07:00
Ivan Kruglov 566436f1c6 core: don't exit 0 when a failure action has nothing to propagate
FailureAction=exit propagates the exit status of the unit's main process. When
there is none, emergency_action() left m->return_value at its initial 0, so the
manager exited 0 for a unit that failed. Whoever supervises it, e.g. a container
manager, then can't tell this apart from an orderly shutdown.

There is no status to propagate whenever the unit type has no notion of a main
process (only .service has), or the unit failed before any of its processes ran,
say because its cgroup couldn't be created. StartLimitAction= and
JobTimeoutAction= never have one at all.

Fixes: https://github.com/systemd/systemd/issues/43645
2026-09-03 10:09:32 -07:00
Ivan Kruglov d4b6e74655 core: use EXIT_EXCEPTION instead of a bare 255
No functional change.
2026-09-03 10:09:02 -07:00
Ivan Kruglov ee138cb41e test: check that an orphaned swap unit isn't resurrected by a reload
Issue: https://github.com/systemd/systemd/issues/43442
2026-08-25 06:05:37 -07:00
Ivan Kruglov 7875de8d00 core/swap: refuse to run swapoff without a device
Issue: https://github.com/systemd/systemd/issues/43442
2026-08-25 06:05:37 -07:00
Ivan Kruglov 262b155a32 core/execute: don't assert on an unpatched exec context
Issue: https://github.com/systemd/systemd/issues/43442
2026-08-25 06:05:37 -07:00
Ivan Kruglov d3c93d1678 core/swap: don't adopt a swap unit that isn't backed by anything
systemd creates one .swap unit per udev device link of every device listed
in /proc/swaps. When such a device link disappears while the swap itself
stays on -- e.g. because the link is not unique and udev repoints it at
another partition -- /proc/swaps doesn't change, so nothing re-examines the
unit and it stays active.

The next daemon-reload then orphans it: all units are dropped and rebuilt,
the enumeration from /proc/swaps no longer produces this name, and only the
deserialization brings the unit back, i.e. by name and without a fragment
on disk. swap_coldplug() restored its active state regardless, leaving a
unit that is active, unloadable and has no device, and that is never
garbage collected because active units aren't.

Refuse to adopt such a unit: if neither /proc/swaps nor a fragment vouches
for it, it describes a swap that doesn't exist anymore. Units that still
have a control process around are left alone, so that the process is
re-adopted and the timeout re-armed; those end up dead once it exits, as
they aren't backed by /proc/swaps either.

Issue: https://github.com/systemd/systemd/issues/43442
2026-08-25 06:05:37 -07:00
Ivan Kruglov 46a91a1867 test: cover --json= for the blame and identify-tpm2 verbs
Both verbs render through arg_json_format_flags but --json= was rejected for
them until the previous commit, and nothing in TEST-65-ANALYZE exercised it.
Add coverage in line with the other JSON-capable verbs.

identify-tpm2 is only invoked when has-tpm2 reports full support, as it
fails with EOPNOTSUPP when built without TPM2 support.
2026-08-12 03:54:33 -07:00
Ivan Kruglov b3f76af401 shell-completion: offer --json= for the standalone verbs that support it
Several verbs in the STANDALONE bucket accept --json=, but that bucket only
offers --help --version --system --user --global --no-pager, so completion
never suggested the option for them.

Split those verbs out into a new STANDALONE_JSON bucket that additionally
offers --json=off/pretty/short. The verbs are moved rather than copied, as
${VERBS[*]} is used to complete the verb list itself.
2026-08-12 03:54:10 -07:00
Ivan Kruglov 9b16161f34 analyze: allow --json= for the chid, blame and identify-tpm2 verbs
verb_chid(), verb_blame() and verb_identify_tpm2() all render their output
via table_print_with_pager() with arg_json_format_flags, so JSON output has
been implemented for them since they were introduced. However, none of them
was ever added to the verb allowlist that gates --json=, so e.g.
"systemd-analyze chid --json=pretty" failed with:

Option --json= is only supported for security, inspect-elf, ...

Add them to the allowlist (and the error message) so the option is accepted.
These are the only remaining verbs that render through arg_json_format_flags
but were not allowlisted.

Note that has-tpm2 is deliberately not included: verb_has_tpm2() defers to
verb_has_tpm2_generic(), which writes plain text via printf() and has no JSON
support, so accepting --json= there would silently ignore it.

This went unnoticed for chid because the TEST-65-ANALYZE coverage for it is
guarded behind a check for SMBIOS board_vendor and a non-container
environment, so it only runs on bare-metal/VM runners.
2026-08-12 03:53:42 -07:00
Ivan Kruglov d080ef9ebd test-tpm2: add tests for tpm2_pcr_bank_from_efi_active()
Cover the full preference order (SHA256 > SHA384 > SHA512 > SHA1), the
single-bank cases and the -EOPNOTSUPP path. Also test the _legacy()
variant: a set with SHA384/SHA512 active but no SHA256 must resolve to
SHA1, not SHA384, pinning down the backwards-compatibility behavior that
keeps legacy sealed secrets unsealable.

Co-developed-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 03:18:15 -07:00
Ivan Kruglov 2acfa5b294 tpm2: consider SHA384 and SHA512 PCR banks in tpm2_get_best_pcr_bank()
tpm2_get_best_pcr_bank() only ever considered SHA256 and SHA1, both in
the firmware-reported LoaderTpm2ActivePcrBanks path and in the
capability-based guesswork. On a TPM whose only active bank is SHA384 it
returned -EOPNOTSUPP, which for units ordered before sysinit.target
(systemd-pcrextend/systemd-pcrproduct.service) propagates and hangs the
boot, even with --graceful (that only covers "no TPM present").

Introduce a preference table (SHA256 > SHA384 > SHA512 > SHA1) and select
from it. SHA256 stays top for backwards compatibility; SHA384 is
preferred over SHA512 as it produces a shorter digest and so uses less of
the bounded TPM event log; SHA1 is the last resort. SM3/SHA3 are excluded
as we cannot compute those digests in software.

The legacy unseal path in tpm2_unseal() re-derives the bank for old
enrollments that did not record one (pcr_bank == UINT16_MAX). Those were
sealed by code that only picked SHA256 or SHA1, so the wider preference
could now re-derive a stronger bank the secret was never bound to and
silently fail to unseal. To stay compatible, the selection takes the
preference list as a parameter, and a _legacy() variant restricted to
{SHA256, SHA1} is used for that path; fresh-sealing callers keep the full
preference.

Co-developed-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 03:18:15 -07:00
Ivan Kruglov c925e405f3 pcrextend: skip measurement gracefully when the TPM can't be used
So far --graceful only short-circuited when no TPM was present at all (the
!tpm2_is_mostly_supported() check). If a TPM is present but can't actually be
used for the measurement we want, the measurement still failed hard. For
systemd-pcrextend instances ordered before sysinit.target this pushes the
system to degraded and blocks boot, which defeats the purpose of --graceful.

Make the two extend helpers report every "TPM is present-or-absent but cannot
be used for this measurement" condition with a single errno, -EOPNOTSUPP: no
usable PCR bank, no TPM device, missing crypto (e.g. AES-128-CFB), no NvPCR
support, and OpenSSL-less builds. tpm2_context_new_or_warn() reports a missing
device as -ENOENT, so each helper translates that to -EOPNOTSUPP at the call
site, keeping every errno single-meaning.

Co-developed-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 15:39:32 +02:00
Ivan Kruglov bf867054e9 test: add integration tests for io.systemd.Job varlink methods
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-19 11:05:55 +02:00
Ivan Kruglov e86b49473f test: wait systemd to finish reexec in TEST-74-AUX-UTILS.varlinkctl.sh 2026-05-19 11:05:55 +02:00
Ivan Kruglov f287d85a0a test: split TEST-74-AUX-UTILS.varlinkctl.sh into per-interface subtests
Split the monolithic varlinkctl test script into separate files per varlink interface for better organization and easier maintenance:
- varlinkctl.sh: core varlinkctl tool tests (CLI, transports, socket discovery, upgrade/serve) and io.systemd.Manager
- varlinkctl-network.sh: io.systemd.Network
- varlinkctl-unit.sh: io.systemd.Unit (system + user manager)
- varlinkctl-metrics.sh: io.systemd.Metrics

No functional changes — the test content is moved as-is.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-19 11:05:55 +02:00
Ivan Kruglov 3941dff8b4 core: introduce io.systemd.Job interface with List, Cancel, and ClearAll methods
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-19 11:05:55 +02:00
Ivan Kruglov 7416bdf8f1 shared: extend Job varlink type with Unit and ActivationDetails fields
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-19 11:05:55 +02:00
Ivan Kruglov 6080d1cc42 errno-util: include -ENOENT in ERRNO_IS_XATTR_ABSENT()
The getxattr(2) man page only enumerates xattr-specific errors (ENODATA,
ENOTSUP, ERANGE, E2BIG, ...) in its own ERRORS section, but at the
bottom of that section notes that "the errors documented in stat(2) can
also be returned." stat(2) returns -ENOENT when a component of the path
does not exist, so any xattr lookup against a path can fail with -ENOENT
exactly the same way as -ENODATA — both mean "there is nothing here for
me to read." The previous definition of ERRNO_IS_NEG_XATTR_ABSENT()
reflected only the directly-enumerated errors and missed -ENOENT, so
callers that should semantically swallow "the xattr is absent" instead
bubbled -ENOENT up as a hard error.

The most visible consequence on real fleets has been systemd-journald
spamming dmesg with one line per dispatched log message whenever a
unit's cgroup directory cannot be found at the time
client_context_read_log_filter_patterns() is called — typically inside
containers whose journald observes clients whose unit cgroup is no
longer present in its view (cgroup-namespace boundary, unit teardown
race, transient sub-scope already collapsed back to its unit cgroup,
etc.). The same bug pattern lurks at every other cgroup-xattr callsite:
systemd-oomd reading user.oomd_avoid / user.oomd_omit / user.oomd_ooms
on cgroups it is concurrently killing; killall reading
user.survive_final_kill_signal during shutdown; cg_is_delegated() /
cg_has_coredump_receive() / cgroup_get_managed_oom_kill_last(); etc. For
these, "path is gone" is by construction the same answer as "xattr is
not set" — there is no way for the user to have attached an xattr to a
path that does not exist.

A quick survey of non-cgroup callers (src/portable/portable.c,
src/home/{homework-luks,user-record-util}.c,
src/random-seed/random-seed-tool.c, src/basic/os-util.c) confirms they
all operate on fds or on paths whose absence is already the desired
silent-skip outcome, so widening the macro to also fold in -ENOENT does
not change observable behavior at any other site.

Extend test-xattr-util's getxattr_at_malloc test with an explicit
non-existent-path lookup that asserts ERRNO_IS_NEG_XATTR_ABSENT() now
matches, alongside the pre-existing non-existent-xattr (-ENODATA) check.
2026-05-19 01:45:54 +09:00
Ivan Kruglov e4b5bdb9b3 json-util: add JSON_BUILD_PAIR_ENUM_NON_EMPTY macro
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-18 00:33:52 -07:00
Ivan Kruglov 2d4f2441f5 json-util: add json_dispatch_job_id() dispatcher for job IDs
Job IDs are uint32_t values that are always >= 1 (the manager's ID counter starts at 1 and wraps from UINT32_MAX back to 1, never assigning 0). Add a dedicated dispatch function that validates this constraint, rejecting 0 and treating null as "unset" (0).

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-18 00:33:47 -07:00
Ivan Kruglov 3fcb483bca test: add ServiceContext/Runtime enum and integration tests
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-15 00:02:01 -07:00
Ivan Kruglov 69b5c5db10 core: expand ServiceContext and add ServiceRuntime for io.systemd.Unit.List
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-15 00:02:01 -07:00
Ivan Kruglov 5305da009a shared: add exec_command_status_build_json() and ExecCommandStatus varlink type to common
Add exec_command_status_build_json() and exec_command_status_list_build_json() to varlink-common, alongside exec_command_build_json() and exec_command_list_build_json(). The status list function is the runtime counterpart of the command list function — the two arrays are positionally aligned so index N in the status array corresponds to index N in the command array. Commands that have not yet run produce null entries to preserve alignment.

Add the ExecCommandStatus varlink struct type to varlink-idl-common next to ExecCommand. It contains PID, timestamps, and mutually exclusive ExitStatus (int, for normal exit) / ExitSignal (string, for signal kill).
2026-05-15 00:02:01 -07:00
Ivan Kruglov 59203dca3a core: move service_context_build_json() to varlink-service.c
Move the existing (partial) service context builder from varlink-unit.c into its own varlink-service.c file, following the pattern established by other unit type context builders (varlink-path.c, varlink-scope.c, etc.). No functional change.
2026-05-14 09:53:03 -07:00
Ivan Kruglov cf6e46c863 test: add SocketContext/Runtime enum and integration tests
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-12 08:55:38 -07:00
Ivan Kruglov cce0a82c10 core: implement SocketContext/Runtime for io.systemd.Unit.List
Add varlink context and runtime builders for .socket units:

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-12 08:55:33 -07:00
Ivan Kruglov c5406d3e1e core: use JSON_BUILD_PAIR_FINITE_USEC_NON_ZERO() for "disabled when zero" usec fields
Scope: RuntimeMaxUSec, RuntimeRandomizedExtraUSec — zero means no limit
Timer: RandomizedDelayUSec, RandomizedOffsetUSec — zero means no delay
2026-05-12 08:51:26 -07:00
Ivan Kruglov 5f1c10e7bc json: add JSON_BUILD_PAIR_FINITE_USEC_NON_ZERO()
Like JSON_BUILD_PAIR_FINITE_USEC() but also suppresses zero values. Useful for usec_t fields where zero means "disabled" or "not configured" (e.g. KeepAliveTimeUSec, DeferAcceptUSec, RandomizedDelayUSec) as opposed to timeout fields where zero would be unusual and worth showing.
2026-05-12 08:51:26 -07:00
Ivan Kruglov 8c0464b7b9 shared: move exec_command_list_build_json() to varlink-common
exec_command_list_build_json() serializes a linked list of ExecCommand into a JSON array. It was static in varlink-unit.c (used by service_context_build_json) but is also needed by the upcoming socket context builder. Move it next to exec_command_build_json() in varlink-common where it can be shared.
2026-05-12 08:10:55 -07:00
Ivan Kruglov cb3a1a1b2f test: use jq // empty instead of grep -v null in Unit.List tests
Replace `grep -v null` with jq's `// empty` alternative operator when filtering unit IDs. With `set -o pipefail`, `grep` returns 1 when no lines match, which aborts the script before conditional guards can run. The `// empty` operator suppresses null output directly in jq without risking a pipeline failure.
2026-05-11 04:32:14 -07:00
Ivan Kruglov ae619b1224 core: implement TimerContext/Runtime for io.systemd.Unit.List + tests
Add varlink context and runtime builders for .timer units:

TimerContext: MonotonicTimers (with MonotonicTimerBase enum), CalendarTimers, Unit, OnClockChange, OnTimezoneChange, AccuracyUSec, RandomizedDelayUSec, RandomizedOffsetUSec, FixedRandomDelay, Persistent, WakeSystem, RemainAfterElapse, DeferReactivation
TimerRuntime: Result (TimerResult enum), NextElapseUSecRealtime, NextElapseUSecMonotonic, LastTriggerUSec

MonotonicTimerSpec and CalendarTimerSpec are separate types since they have different value types (int vs string). MonotonicTimerBase and TimerResult are proper varlink enum types.

Compared to the old io-systemd-Unit-List branch, this adds RandomizedOffsetUSec and DeferReactivation (both present in D-Bus but previously missing), and adds full runtime fields.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-11 04:32:14 -07:00
Ivan Kruglov ed4740a0dc core: implement SwapContext/Runtime for io.systemd.Unit.List + tests
Add varlink context and runtime builders for .swap units:

SwapContext: What, Priority, Options, TimeoutUSec, ExecActivate, ExecDeactivate
SwapRuntime: ControlPID, Result, CleanResult, UID, GID (SwapResult enum)

SwapResult is exposed as a proper varlink enum type. Runtime follows the same pattern as MountRuntime (ControlPID, Result, CleanResult, ref UID/GID).

The integration test is conditional since swap units may not be present on all systems.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-11 04:32:14 -07:00
Ivan Kruglov 412b2d3101 core: implement ScopeContext/Runtime for io.systemd.Unit.List + tests
Add varlink context and runtime builders for .scope units:

ScopeContext: OOMPolicy (enum), RuntimeMaxUSec, RuntimeRandomizedExtraUSec, TimeoutStopUSec
ScopeRuntime: Result (ScopeResult enum)

Both OOMPolicy and ScopeResult are exposed as proper varlink enum types.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-11 04:32:03 -07:00
Ivan Kruglov e11867ebdd shared: move OOMPolicy varlink enum to varlink-idl-common
OOMPolicy is used by both io.systemd.Manager (DefaultOOMPolicy) and io.systemd.Unit (ScopeContext.OOMPolicy), so it belongs in the shared common types alongside ManagedOOMMode and EmergencyAction.
2026-05-11 03:03:32 -07:00
Ivan Kruglov 8787415123 core: implement PathContext/Runtime for io.systemd.Unit.List + tests
Add varlink context and runtime builders for .path units:

PathContext: Paths (array of PathType enum + path specs), Unit, MakeDirectory, DirectoryMode, TriggerLimit
PathRuntime: Result (PathResult enum)

Both PathType and PathResult are exposed as proper varlink enum types.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-11 03:03:32 -07:00
Ivan Kruglov d0c912899a test: add missing varlink IDL enum tests for Job and ServiceType
PR #41583 (io.systemd.Unit.StartTransient) introduced several new varlink IDL enum types without corresponding enum consistency tests:

- JobType, JobState, JobResult in the new io.systemd.Job interface
- ServiceType in the Unit interface's ServiceContext

Add a new test-varlink-idl-job test file covering all three Job enums, and add ServiceType coverage to the existing test-varlink-idl-unit test. Export vl_type_ServiceType (was static) so it can be referenced from the test.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-08 17:22:04 +02:00
Ivan Kruglov bcdf4d0c70 core: implement MountContext/Runtime for io.systemd.Unit.List + tests 2026-04-16 02:15:52 -07:00
Ivan Kruglov 1e3f41e73b core: implement AutomountContext/Runtime for io.systemd.Unit.List + tests 2026-04-16 02:15:52 -07:00
Ivan Kruglov 2136f32c76 core: implement KillContext for io.systemd.Unit.List + tests 2026-04-15 23:37:55 -07:00
Ivan Kruglov bdbbb9cf91 shared: exec_command_build_json() 2026-04-15 23:37:55 -07:00
Ivan Kruglov 01f6d9e39f basic: resurrect unit_type_to_capitalized_string() 2026-04-14 05:37:49 -07:00
Ivan Kruglov 3dd09ccea2 docs: clarify when to use varlink enum types vs plain strings
Add guidance on when a field should use a proper varlink enum type
versus remaining a plain string: user-controlled/API fields should be
enums, engine-internal state fields may stay as strings.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-14 13:37:02 +02:00
Ivan Kruglov 6518bcf872 varlink: add ManagedOOMMode enum type to io.systemd.oom
Convert the mode field in ControlGroup from plain string to the
ManagedOOMMode enum type from varlink-idl-common. Register
ManagedOOMMode in both io.systemd.oom and io.systemd.ManagedOOM
interfaces since both use the ControlGroup struct.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-14 02:10:52 -07:00
Ivan Kruglov 5d0ac2c23c varlink: add enum types for class and whom fields in io.systemd.Machine
Convert the class field (Register input, List output) from plain string
to MachineClass enum type, and the whom field (Kill input) to KillWhom
enum type.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-14 02:10:52 -07:00
Ivan Kruglov 2fda0fb4c7 varlink: add enum types for scheduling and mount settings in io.systemd.Unit
Convert CPUSchedulingPolicy, IOSchedulingClass, NUMAPolicy and MountFlags
fields from plain strings to proper varlink enum types in the io.systemd.Unit
interface. Update the corresponding serialization code to use
json_underscorify() for correct enum value formatting.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-14 02:10:52 -07:00
Ivan Kruglov b5aa7635ce varlink: add enum types for configuration settings in io.systemd.Manager
Convert 8 string fields in the io.systemd.Manager varlink interface to
proper enum types:

- LogTarget: new enum (console, console_prefixed, kmsg, journal, ...)
- DefaultStandardOutput/Error: reuse ExecOutputType from common
- DefaultMemory/CPU/IOPressureWatch: reuse CGroupPressureWatch from common
- DefaultOOMPolicy: new enum (continue, stop, kill)
- CtrlAltDelBurstAction: reuse EmergencyAction from common

Output serialization updated to use JSON_BUILD_PAIR_ENUM for automatic
underscorification of dash-containing values.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-14 02:10:52 -07:00
Ivan Kruglov 29c00e0295 varlink: move shared enum types to varlink-idl-common
Move ExecOutputType, CGroupPressureWatch, EmergencyAction and
ManagedOOMMode enum type definitions from varlink-io.systemd.Unit to
varlink-idl-common, as these types are shared across multiple varlink
interfaces.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 05:37:08 -07:00
Ivan Kruglov 23f0c9070b news: new record about strings vs enums in varlink 2026-04-10 08:37:04 -07:00
Ivan Kruglov 99fe3283c5 test: add core-specific varlink enum sync test
Add test-varlink-idl-unit that validates all varlink enum types in
io.systemd.Unit match their corresponding C string tables. This
catches drift between varlink IDL enum definitions and internal
enum values.

Uses core_test_template since it links against libcore for access
to the string table lookup functions.

ExecOutput uses TEST_IDL_ENUM_TO_STRING only because the '+' in
'kmsg+console' doesn't survive the underscorify/dashify round-trip.
2026-04-10 08:37:04 -07:00
Ivan Kruglov 1912b3585d varlink: add enum types for configuration settings in io.systemd.Unit
Define proper varlink enum types for unit configuration settings that
are part of the user-facing API (values users/clients can select).
This replaces SD_VARLINK_STRING with SD_VARLINK_DEFINE_FIELD_BY_TYPE
for these fields, giving them strong type semantics in the IDL.

Enum types added for ExecContext (ExecInputType, ExecOutputType,
ExecUtmpMode, ExecPreserveMode, ExecKeyringMode, MemoryTHP,
ProtectProc, ProcSubset, ProtectSystem, ProtectHome, PrivateTmp,
PrivateUsers, ProtectHostname, ProtectControlGroups, PrivatePIDs,
PrivateBPF), CGroupContext (CGroupDevicePolicy, ManagedOOMMode,
ManagedOOMPreference, CGroupPressureWatch, NFTSetSource, NFProto,
BPFCGroupAttachType, CGroupController), and UnitContext (CollectMode,
EmergencyAction, JobMode).

Engine-reported runtime state fields (Type, LoadState, ActiveState,
FreezerState, SubState, UnitFileState) remain as strings since only
the engine selects those values.
2026-04-10 07:05:36 -07:00
Ivan Kruglov 3649c6b3d9 test: extract varlink IDL test helpers into shared header
Move the TEST_IDL_ENUM_TO_STRING, TEST_IDL_ENUM_FROM_STRING, and
TEST_IDL_ENUM macros along with test_enum_to_string_name() from
test-varlink-idl.c into test-varlink-idl-util.h so they can be
reused by other test files.
2026-04-10 05:56:13 -07:00
Ivan Kruglov 6eab41c813 test: use --nogpgcheck instead of --no-gpgchecks in TEST-88-UPGRADE
--no-gpgchecks was introduced in 9204838724 but is only available in
dnf5. Use --nogpgcheck instead, which is supported by both dnf4 and
dnf5 (where it is an alias for --no-gpgchecks).

Fixes test failure on distros still using dnf4 (e.g. CentOS/RHEL 9).

Co-developed-by: Claude <claude@anthropic.com>
2026-03-12 13:40:05 +00:00
Ivan Kruglov cc14f78c02 report: validate metric name by socket 2026-02-16 05:46:24 -08:00
Ivan Kruglov b465e848f3 report: rearrange handling connection drop when skipping metrics 2026-02-16 02:34:11 -08:00
Ivan Kruglov b8ef90d6fd docs: initial version of varlink guideline 2025-11-14 17:54:20 +01:00
Ivan Kruglov 959a8e49f4 core: enable SELinux checks in io.systemd.Unit.List 2025-10-20 03:58:55 -07:00
Ivan Kruglov 8b1f7f13f0 test: lookup a unit by cgroup and invocationID in TEST-74-AUX-UTILS.varlinkctl 2025-10-20 03:58:55 -07:00
Ivan Kruglov 6c2c2e0598 core: io.systemd.Unit.List can lookup by InvocationID 2025-10-20 03:58:53 -07:00
Ivan Kruglov 6b78d931cd core: io.systemd.Unit.List can lookup unit by CGroup 2025-10-20 03:58:39 -07:00
Ivan Kruglov 4ddd3fe1fb core: make name/pid lookup params use AND logic in io.systemd.Unit.List 2025-10-20 02:10:57 -07:00
Ivan Kruglov 366f57bff4 basic: pidref_is_set_or_automatic() 2025-10-20 02:10:00 -07:00
Ivan Kruglov 55eccf3b0d core: add comments in varlink-io.systemd.Unit.c 2025-10-16 03:52:08 -07:00
Ivan Kruglov fdb2c0dd6f core: ExecContext for io.systemd.Unit.List method 2025-10-16 03:52:08 -07:00
Ivan Kruglov 3064c04473 core: exec_log_level_max_with_exec_params() 2025-10-16 03:52:08 -07:00
Ivan Kruglov fbfc439438 core: move cpuset_build_json() to varlink-common 2025-10-16 03:52:02 -07:00
Ivan Kruglov 3de607b48b basic: secure_bits_to_strv() 2025-10-16 03:29:14 -07:00
Ivan Kruglov 115083886a nsflags: namespace_flags_to_strv() 2025-10-16 03:26:39 -07:00
Ivan Kruglov 0033d937c7 json: helper macro JSON_BUILD_PAIR_YES_NO() 2025-10-15 09:14:10 -07:00
Ivan Kruglov aacfa999dd json: helper macros JSON_BUILD_PAIR_CONDITION_*() 2025-10-15 09:14:10 -07:00
Ivan Kruglov c5df8c2323 core: merging errno usage in access_init() 2025-07-30 08:25:58 +09:00
Ivan Kruglov ce6bdb7969 core: more use of log_selinux_enforcing_errno() in selinux-access.c 2025-07-29 07:22:16 -07:00
Ivan Kruglov 98b9f1c519 core: fix mac_selinux_unit_access_check_varlink() macro 2025-07-29 06:36:58 -07:00
Ivan Kruglov d8135125f8 core: leave comments in varlink-unit.c and varlink-cgroup.c about runtime/context split 2025-07-11 06:56:17 -07:00
Ivan Kruglov 08cd319664 core: move Slice from runtime to context in io.systemd.Unit.List 2025-07-11 06:56:17 -07:00
Ivan Kruglov aa352ece0d core: move DebugInvocation from runtime to context in io.systemd.Unit.List 2025-07-11 06:48:41 -07:00
Ivan Kruglov d5f4bd3700 selinux: mac_selinux_unit_access_check_varlink macros 2025-07-10 21:16:32 +02:00
Ivan Kruglov e3fef210c8 selinux: mac_selinux_access_check_varlink_internal() 2025-07-10 21:16:32 +02:00
Ivan Kruglov fe3f2ac073 selinux: check_access() 2025-07-10 21:16:32 +02:00
Ivan Kruglov 5dc3096efb core: leave a comment about context/runtime split 2025-07-10 21:08:11 +02:00
Ivan Kruglov 79eec46dfd core: move ControlGroup move runtime to context 2025-07-10 21:08:11 +02:00
Ivan Kruglov 89701e02ac core: move ConfirmSpawn from runtime to context 2025-07-10 21:08:11 +02:00
Ivan Kruglov 303d1b6b57 core: move ShowStatus/Log* from runtime to context 2025-07-10 21:08:11 +02:00
Ivan Kruglov 712f763036 core: move WatchdogDevice from runtime to context 2025-07-10 21:08:11 +02:00
Ivan Kruglov 545fde151a core: move RuntimeWatchdog* + RebootWatchdog + KExecWatchdog from runtime to spec 2025-07-10 21:08:11 +02:00
Ivan Kruglov afa9992429 core: fix double Environment present in both context and runtime 2025-07-10 21:08:11 +02:00
Ivan Kruglov a5d8520f86 core: move Version/Arch/Features/Taints/UnitPath from context to runtime 2025-07-10 21:08:11 +02:00
Ivan Kruglov 84c05ec632 selinux: get_our_contexts() 2025-07-10 21:06:51 +02:00
Ivan Kruglov 3484af2800 selinux: rename mac_selinux_access_check_internal() -> mac_selinux_access_check_bus_internal() 2025-07-10 21:06:51 +02:00
Ivan Kruglov 5a1cb174f8 selinux-utils: rename and expose log_selinux_enforcing_errno() 2025-07-10 21:06:51 +02:00
Ivan Kruglov 204e3cb6c8 selinux-util: mac_selinux_get_peer_label() 2025-07-10 21:06:51 +02:00
Ivan Kruglov 8006ab9047 core: adding CGroup runtime for io.systemd.Unit.List 2025-06-05 04:05:05 -07:00
Ivan Kruglov dffde7708a core: adding CGroup context for io.systemd.Unit.List 2025-06-05 04:05:05 -07:00
Ivan Kruglov 27a10f4f2a core: *ret = NULL for early return in unit_mounts_for_build_json() 2025-06-05 03:59:36 -07:00
Ivan Kruglov e3fee4519f core: break line after sd_json_buildo( in varlink-manager.c 2025-05-27 01:16:56 -07:00
Ivan Kruglov dd14c3eab1 test: simple tests for io.systemd.Unit varlink interface 2025-05-27 01:16:56 -07:00
Ivan Kruglov 92fa38c99d test: quote entire path to socket in io.systemd.Manager tests 2025-05-27 01:16:56 -07:00