Commit Graph
100 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek ce04f8a331 updatectl: fix feature JSON parsing (#43617)
## Summary

`updatectl features` failed because it expected the old feature JSON
fields,
while `systemd-sysupdate` now returns `id`, `isEnabled`, and
`documentation`
as an array.

This change:

- Aligns `updatectl` with the current feature JSON schema.
- Unifies JSON output between `systemd-sysupdate`, D-Bus, and Varlink.
- Adds support for multiple `Documentation=` entries for Features and
  Components.
- Exposes and parses `appstream` and `suggested` metadata.
- Propagates condition-evaluation errors through `condition_test_list()`
and
  `feature_is_suggested()`.
- Reports suggestion-evaluation failures instead of silently treating
them as
  `false`.
- Improves JSON dump error handling.
- Expands `TEST-72-SYSUPDATE` coverage and fixes its unknown-field
assertion.
- Documents the `DescribeFeature()` JSON field transition in `NEWS`.
- Keeps the existing Component name list for `sysupdated` compatibility.

The `name`/`enabled` to `id`/`isEnabled` transition is intentional and
documented as a v262 payload change.

Fixes #43603
2026-09-08 16:08:11 +02:00
Zbigniew Jędrzejewski-Szmek a3f75ace9c Convert systemd-analyze to option and verb macros (#41945)
I thought that this would require some bigger changes, but it turns out
that the existing functionality is good enough with some minor
adjustments if used appropriately.

The behaviour of help_section() is changed to simplify all callers.
2026-05-05 13:47:17 +02:00
Zbigniew Jędrzejewski-Szmek b98d532a6c core: do not GC units that have FDs stored (#41435)
If a unit has FileDescriptorStorePreserve=yes we'll keep its FDs around
in case it starts again. But if there are no reverse dependencies
referencing it, we'll also GC it and lose all the FDs, which defeats the
point of the setting (which is opt-in).

Do not GC units that have FDs stored to avoid this.

Follow-up for b9c1883a9c
2026-04-03 14:30:07 +02:00
Zbigniew Jędrzejewski-Szmek a0adf78f4d Importd: skip fifos and sockets (#41090) 2026-03-13 23:52:44 +01:00
Zbigniew Jędrzejewski-SzmekandCopilot Autofix powered by AI e799263ff4 test-network: handle the case where dnsmasq is slow to start better
> read_dnsmasq_log_file() will raise FileNotFoundError if dnsmasq hasn’t created the
> log file yet (or if the file was just removed by stop_dnsmasq() before the restart).
> This would error the test instead of retrying.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-13 12:02:07 +01:00
Zbigniew Jędrzejewski-Szmek 0a17bb5c34 core: simplify requirements in unit_get_private_var_tmp() to just After=
As in the previous commit, checking for both requirements and ordering seems
unnecessary. In practical cases, the mount will be pulled in by the rest
of the transaction, so ordering is the part that matters. (The setup is
racy without the ordering.)  If we drop the second check, the admin can
just use After=tmp.mount to achieve the desired behaviour, without needing
to explicitly pull in the unit. This is easier to configure and more robust.

This changes the implementation introduced in
6156bec7a4.

Also actually describe the implemented behaviour in the man page.
2026-02-25 12:38:11 +01:00
Zbigniew Jędrzejewski-Szmek fa33eef344 core: upgrade /tmp when PrivateTmp=yes/DefaultDeps=no to disconnected
In https://github.com/systemd/systemd/issues/28515, multiple people report that
services that have PrivateTmp=yes and DefaultDependencies=no fail to create the
temporary directories under /tmp, when /tmp is e.g. a bind mount or some other
kind of mount that takes more time.

Before PrivateTmp=disconnected was added, we didn't have a nice solution:
DefaultDependencies=no is used to start services very early, so we wouldn't
want to add a dependency on /tmp automatically. With PrivateTmp=disconnected we
have a fairly nice solution. Let's "upgrade" to this mode automatically.
Strictly speaking, it is a small compat break, but in practice it's unlikely to
matter for early-boot services whether their /tmp is private or disconnected.

The dependency on /tmp that is checked is After. I think this is enough,
since any tmp.mount would be pulled in by local-fs.target and the rest of
the transaction anyway, so we don't need to check more than After.

The asserts are relaxed, because now the two settings can now diverge
in either way.

Resolves https://github.com/systemd/systemd/issues/28515.

[yhndnzj: fix unit_add_exec_dependencies() to handle the new
          combination; add a comment in exec_needs_sys_admin()]
2026-02-25 12:38:11 +01:00
Zbigniew Jędrzejewski-Szmek 92a0761d55 core/exec-invoke: add missing char in comment 2026-02-25 12:36:44 +01:00
Zbigniew Jędrzejewski-Szmek c46cc2630d man: make it clear that homectl -A/T/N do not take an argument
Just like in the --help strings, we need to avoid confusion between
short options which take an argument and those that don't.
2026-02-13 11:07:27 +01:00
Zbigniew Jędrzejewski-Szmek 952f3a5dbf homectl: drop --and-resize and --and-change-password
The two options are were not documented or ever used in the codebase.
Additionally, the parser expected an argumentless option, while the option
table declared a required argument. So I think this was added for debugging
and never excercised properly. Since there was no public documentation for
those, it's as if they never existed, so it should be fine to drop them.
2026-02-13 11:07:26 +01:00
Zbigniew Jędrzejewski-Szmek 097f130731 resolvectl: split out helper to parse stdin
No functional change, just splitting up of a lengthy function.
2026-02-13 11:07:25 +01:00
Zbigniew Jędrzejewski-Szmek b4df0a9ee6 nspawn: split out helper to parse --private-users
This is just to make parse_argv() slightly more managable.
2026-02-13 11:07:22 +01:00
Zbigniew Jędrzejewski-Szmek 26de1563d0 nspawn: simplify parsing of --hostname/--machine 2026-02-11 12:50:51 +01:00
Zbigniew Jędrzejewski-Szmek c1fcc80421 journal-upload: drop custom option error handling
The line to set opterr=0 was added in the initial commit in
3d090cc6f3. But afaict, this never worked as
intended, because ':' must be the first char in optstring given to
getopt_long() for it to return ':' for a missing option value. Since
this wasn't set, getopt_long() would return '?', and the missing value
would be handled as an unknown option:
  $ build/systemd-journal-upload --key
  Unknown option --key.
  $ build/systemd-journal-upload --asdf
  Unknown option --asdf.

Let's just do the standard thing:
  $ build/systemd-journal-upload --key
  build/systemd-journal-upload: option '--key' requires an argument
  $ build/systemd-journal-upload --asdf
  build/systemd-journal-upload: unrecognized option '--asdf'
2026-02-11 11:48:29 +01:00
Zbigniew Jędrzejewski-Szmek 7b6f1ea371 cryptenroll: simplification 2026-02-11 11:47:59 +01:00
Zbigniew Jędrzejewski-Szmek 4a991af017 cryptenroll: split out parser for --wipe-slot= 2026-02-11 11:47:52 +01:00
Zbigniew Jędrzejewski-Szmek ff12bcd4fb path: simplify run()
No functional change, just less indents.
2026-02-11 11:47:18 +01:00
Zbigniew Jędrzejewski-Szmek e4c6ee2ce5 mount-tool: fix confusion in --help
See grandparent commit for explanation.
2026-02-11 11:46:44 +01:00
Zbigniew Jędrzejewski-Szmek 84f6967558 importctl: fix confusion in --help
See parent commit for explanation.
2026-02-11 11:46:38 +01:00
Zbigniew Jędrzejewski-Szmek cb406988ac cgtop: fix confusion in --help
When we say '-n --iterations=N' in --help, this means that the program
can be invoked with '-n N' or '--iterations=N' or '--iterations N'.
(The short option is specified without the argument.)

Here we tried to use '-p --order=path' to mean that the program can be
invoked with '-p' or '--order=path', but that is incompatible with the
established convention.

Also, indicate that the arg to --cpu is optional.
2026-02-11 11:46:12 +01:00
Zbigniew Jędrzejewski-Szmek dffcb61f7f metrics/report: add log messages, do not hang if no metrics are found
If the directory existed but was empty, we'd hang in the event loop.
2026-02-04 18:20:11 +01:00
Zbigniew Jędrzejewski-Szmek ab4028c47a metrics/report: use _cleanup_, avoid goto 2026-02-04 17:57:24 +01:00
Zbigniew Jędrzejewski-Szmek 7a1e761070 pid1: shorten message about jobs skipped after failed condition checks
I was looking at some logs on a console, and because of the lengthy message,
the actually interesting part, i.e. what condition failed, didn't even fit
on the screen. Let's make the sentence legible but brief.
2026-02-04 16:33:26 +01:00
Zbigniew Jędrzejewski-Szmek e047394797 [metrics] Introduce metrics API (#39202)
See the [design
doc](https://github.com/systemd/systemd/issues/38023#issue-3192567450)
by @ikruglov

This PR introduces the metrics API framework, adds some basic system
wide/per unit/service metrics, and a basic CLI. The PR is broken into
two commits as described below.

### Deviations from the original design
- Introduced top level field "object" for ease of filtering. Instead of
having `fields: { unit: "foo", unit_type: "service" }`, we now have
`object: foo.service` as the top level field.


### First commit

The first commit includes:
- Metrics API definitions
- Code to set up the varlink server
- The describe method which shows all the metrics families
- The list method which lists all the metrics
- Type definitions related to MetricFamily
- Common code to build json objects

### Second commit
The second commit adds some basic metrics, a basic CLI (systemd-report)
which
lists the metrics, and integration tests.

**System wide metrics:**
- units_by_type_total
- units_by_state_total

**Two per unit metrics:**
- unit_active_state
- unit_load_state

**A service state metric:**
- nrestarts

### Sample outputs

**units_by_type_total**:

```
{
        "name" : "io.systemd.Manager.units_by_type_total",
        "value" : 52,
        "fields" : {
                "type" : "target"
        }
}
{
        "name" : "io.systemd.Manager.units_by_type_total",
        "value" : 82,
        "fields" : {
                "type" : "device"
        }
}
{
        "name" : "io.systemd.Manager.units_by_type_total",
        "value" : 2,
        "fields" : {
                "type" : "automount"
        }
}
```
**units_by_state_total**:
```
{
        "name" : "io.systemd.Manager.units_by_state_total",
        "value" : 216,
        "fields" : {
                "state" : "active"
        }
}
{
        "name" : "io.systemd.Manager.units_by_state_total",
        "value" : 0,
        "fields" : {
                "state" : "reloading"
        }
}
{
        "name" : "io.systemd.Manager.units_by_state_total",
        "value" : 120,
        "fields" : {
                "state" : "inactive"
        }
}
```
**unit_active_state**:
```
{
        "name" : "io.systemd.Manager.unit_active_state",
        "object" : "multi-user.target",
        "value" : "active"
}
{
        "name" : "io.systemd.Manager.unit_active_state",
        "object" : "systemd-sysusers.service",
        "value" : "inactive"
}
```
**unit_load_state**:
```
{
        "name" : "io.systemd.Manager.unit_load_state",
        "object" : "multi-user.target",
        "value" : "loaded"
}

```
**nrestarts**:
```
{
        "name" : "io.systemd.Manager.nrestarts",
        "object" : "user@0.service",
        "value" : 0
}
{
        "name" : "io.systemd.Manager.nrestarts",
        "object" : "user-runtime-dir@0.service",
        "value" : 0
}
```
2026-02-04 16:31:55 +01:00
Zbigniew Jędrzejewski-Szmek 65040d0876 Followups for the recent chagnes to stability statements (#40540) 2026-02-03 12:50:39 +01:00
Zbigniew Jędrzejewski-Szmek 2cbea2dd75 docs: update old man page links to the official location 2026-02-03 12:49:37 +01:00
Zbigniew Jędrzejewski-Szmek d905ac0da1 docs/INCOMPATIBILITIES: describe the new meson option 2026-02-03 12:49:37 +01:00
Zbigniew Jędrzejewski-Szmek 65f72f5dbb ask-password: remove files in /run when query is aborted
Because of the missing 'goto', if the query was aborted, we
would leave behind the ask.* ini file.
2026-02-02 15:16:23 +01:00
Zbigniew Jędrzejewski-Szmek f01c99c67e ask-password: reject control chars and quotes in query description
As reported in https://yeswehack.com/vulnerability-center/reports/705270,
YesWeHack issue #YWH-PGM9780-66, if a newline is injected into the message
field, it is passed through unmolested and lands in the .ini file. This
obviously would cause the parser to be confused.

Let's forbid any control characters or quotes in those fields. If we want
something more complicated in the future, we can add a custom validation
function and allow some escaping mechanism.
2026-02-02 15:16:23 +01:00
Zbigniew Jędrzejewski-Szmek fcff83a534 meson: conditionalize tmpfiles.d/legacy.conf
This is a compat interface, so let downstream like Arch drop it easily.
2026-02-01 09:40:10 +01:00
Zbigniew Jędrzejewski-Szmek 0acd1b4f35 units: restore runlevel[0-6].target aliases
This partially reverts commit e58ba80a40. Those
aliases were removed as part of the removal of sysvinit compat, but the removal
was immediately reported as a regression by users. In particular, users can
have one of those set as the default target, or use those names in Wants= or
Requires= dependencies. At least in Fedora, the removal was immediately
reverted.

When looking at our "portability and stability promise", I noticed that those
units are explicitly listed in the promise. Let's restore them upstream. They
are conditionalized under a new -Dcompat-sysv-interfaces=bool option, so that
downstreams like Arch that wasnt to strictly avoid legacy interfaces can easily
disable them. They are dropped from the docs, like we do for all deprecated
interfaces.
2026-02-01 09:40:10 +01:00
Zbigniew Jędrzejewski-Szmek f4dd927e5c docs/PORTABILITY_AND_STABILITY: update the policy
The kernel has a "don't break userspace" policy [1] which is very easy
to understand and like (even if the details are complicated). We had a
complicated policy statement, but the actual practice is that we'll
generally avoid changes that cause problems for users. So the whole
detailed table is more of a guideline than something that we can rely
on.

To improve public perception, and to align the docs with practice, let's
make a general promise to keep stability, and change the existing table
to a "guideline" that tells people which interfaces to use and which not
to use so that use and development of systemd don't conflict or create
pain.

The existing document was very long, and I think it'll have a bigger
impact if it shorter. In particular, the chart is dropped, because it
was of limited use and severly outdated, because we have added many new
interfaces and components without updating it. Adding the missing
elements (and then keeping it updated) would be a lot of effort. The
chart would be most useful to somebody trying to build a systemd
reimplementation, but there haven't been many attempts like this, so
let's save the work and drop it and make the document shorter.

I also dropped the mentions of Debian. Back in the day, we did indeed
adopt many Debian conventions for config files and such, but over the
years the scope of the project has grown quite a bit and that part
of systemd is a small fraction now. And we've adopted conventions
and ideas from many other places too, so we don't mention Debian
specifically.

[1] https://docs.kernel.org/admin-guide/reporting-regressions.html
2026-01-31 17:28:42 +01:00
Zbigniew Jędrzejewski-Szmek 0c40aef7ef emacs: drop obsolete emacs property
New emacs warns on every open about the old attribute. Let's assume that
everybody who uses emacs uses the latest version, so we can drop the compat.
2026-01-31 17:26:17 +01:00
Zbigniew Jędrzejewski-Szmek 248bc94fbf Rework error propagation in systemctl preset (#40504) 2026-01-29 16:41:31 +01:00
Zbigniew Jędrzejewski-Szmek 64eb78135c shared/install: rework error propagation again
The immediate impulse for this change is the fedora scriptlet which called:
  /usr/lib/systemd/systemd-update-helper install-system-units cryptsetup-pre.target cryptsetup.target getty@.service ... system-systemd\x2dcryptsetup.slice system-systemd\x2dveritysetup.slice ...
which called
  systemctl preset cryptsetup-pre.target cryptsetup.target getty@.service ... system-systemd\x2dcryptsetup.slice system-systemd\x2dveritysetup.slice ...
which threw an error that system-systemdx2dcryptsetup.slice does not exist
and did nothing at all. (The backslash is consumed by the shell.)
The obvious fix here is to figure out more levels of escaping… But we should
do something more robust in such cases.

If we fail in processing of a single unit, let preset all continue processing
units, report the failure through 'changes'. At the end, return failure. In
general, for operations which operate on a list of units specified by the user,
fail the whole operation if any of the individual operations failed. The only
operation where we don't do this is 'preset-all'.

$ SYSTEMD_LOG_LEVEL=debug build/systemctl --root=/ preset asdf1.servie asdf2.path; echo $?
Cannot find unit asdf1.servie.service.
Cannot find unit asdf2.path.
Failed to preset unit: Unit asdf1.servie.service does not exist
Failed to preset unit: Unit asdf2.path does not exist
1

While at it, fix double logging in the manager: dump_unit_changes() already
logs about errors, so the manager should only log on success.
2026-01-29 08:49:44 +01:00
Zbigniew Jędrzejewski-Szmek c67d64add6 shared/install: fix bogus error handling
This partially reverts a4f0e0da35. The
intent was good, we gather the errors, but we have no mechanism to
propagate the result, so the gathered result was ignored. In 'changes'
we can only report errors for specific units. If reading of the
directory fails, we might just as well report the error immediately.
This isn't great, but it's better then ignoring the errors. In practice,
failing halfway in this manner is unlikely, since it'd mean that the fs
is corrupted or something like that. We might as well return immediately
on such catastrophic errors.
2026-01-29 07:45:55 +01:00
Zbigniew Jędrzejewski-Szmek 69d130aac5 preparations for installer PR (#40446)
As suggested by @keszybz the generic preparatory work split out of
#38764
2026-01-27 15:04:47 +01:00
Zbigniew Jędrzejewski-Szmek 56b9c3ad40 sd-bus: allow receiving messages with MSG_CTRUNC set (#40089)
In the event that we can't receive all of the fds from the message
(which can happen for a number of reasons including LSM denials or
hitting the fd limit of the process) the kernel will set the MSG_CTRUNC
flag.  Through our use of recvmsg_safe() we've been treating this as a
fatal error, which will result in dropping the connection.

Let's dial that back a bit: we can receive the message, but when the
user attempts to access the missing fds via sd_bus_message_read_basic()
we can return the (existing) error code of -EBADMSG to indicate that the
fd is missing.

We can do this by using recvmsg() directly, and relaxing some of the
checks on message creation: when (and only when) we have received
MSG_CTRUNC we allow a smaller than expected (per the header) number of
fds to be present.  The error check in sd_bus_message_read_basic() was
already there so we don't need to do anything about that.

This puts the receiver of the message into a difficult situation: you
can call sd_bus_message_read_basic() as often as you want but as long as
it keeps returning -EBADMSG it won't progress through the message and
you won't be able to close whatever container you're in.  That means
that the user will probably need to abandon processing the message
anyway.  So why not just drop the message up front?  This approach is
more likely to yield a useful error message, which will be invaluable
for people trying to track down problems caused by LSM denials.

Fixes #34688
2026-01-27 12:07:33 +01:00
Zbigniew Jędrzejewski-Szmek 072e72424b units/getty@.service: use [Install]Alias= instead of static alias
In Fedora, kmsconvt@.service is starting to be used instead of getty@.service
to have nicer font handling. This means that we need the autovt@.service alias
point to the new unit. So far the alias was done through a static symlink
because there was little reason to change it. Let's use [Install] instead so
the decision which implementation to use can be made after installation.

https://bugzilla.redhat.com/show_bug.cgi?id=2429626
https://fedoraproject.org/wiki/Changes/UseKmsconVTConsole
2026-01-24 13:19:08 +01:00
Zbigniew Jędrzejewski-Szmek 3a5b37e162 Split up the giant switch statement in homectl's parse_argv (#40059)
This is in preparation for later changes. The 1500+ line switch statement was very
hard to work with and had quite a bit of duplicated code. This is a rework that
splits outs parts into functions. I split this up into a bunch of commits so that it
can be reasonably reviewed. When viewed as one giant commit, diff just shows
a giant block of removed code and a giant block of added code.

In some cases I wasn't sure why one or the other of the identity arrays is used…
I preserved existing behaviour in all cases.
2026-01-16 14:31:08 +01:00
Zbigniew Jędrzejewski-Szmek 311fddcd8d man/systemd.service: Expand docs on RestartSteps (#40309) 2026-01-15 11:41:17 +01:00
Zbigniew Jędrzejewski-Szmek f7047b8c1c mailmap: deduplicate some frequent contributors 2026-01-14 17:07:18 +01:00
Zbigniew Jędrzejewski-Szmek 6e78240e64 udev: silence notification failures (#40275)
Closes #39943.
2026-01-14 16:26:00 +01:00
Zbigniew Jędrzejewski-Szmek f2c3ef9678 homectl: add argument comments 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek edd2a2a006 homectl: let drop_from_identity take multiple args
The only functional change should be that we deduplicate arg_identity_filter.
2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 37ad119451 homectl: trivial simplification 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek ed646a8d47 homectl: split out helpers parse_uid_field
Yet another very similar function, but without generics it's hard to deduplicate
those.
2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 47f631fda5 homectl: split out helpers parse_{fido2_device,pkcs11_token_uri}_field
Both implement the 'list' verb.
2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek b078b7f055 homectl: split out helper parse_tmpfs_limit_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 3f9c133922 homectl: split out helper parse_capability_set_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 0c2199b4cc homectl: split out helper parse_rebalance_weight 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek a161867b00 homectl: split out helper parse_auto_resize_mode_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek ed93b1ed14 homectl: split out helpers parse_{time,timestamp}_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 316e9887f2 homectl: split out helper parse_group_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 65cf26c72d homectl: split out helper parse_weight_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 12771c0cc6 homectl: split out helpers parse_{disk,sector}_size_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 873d38eac9 homectl: split out helper parse_language_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 0126bebccb homectl: split out helper parse_environment_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 47749fa762 homectl: split out helper parse_rlimit_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 2ef165ba1c homectl: fix confusion between "FOO" and "RLIMIT_FOO" as json keys
We parse RLIMIT_FOO, FOO, and LimitFOO all the same. But the keys in the
JSON dict are supposed to be "RLIMIT_FOO". We were creating such keys,
but then filtering them using "FOO", i.e. the filtering was not effective.

Using strjoina since both strings are under our control.
2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 56c05601f4 homectl: split out helper parse_nice_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 5db63f9de8 homectl: split out helpers that extend parse_string_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 9f4c9a6cd9 homectl: split out helper parse_mode_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 2bcf520f31 homectl: split out helper parse_boolean_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek b1982aada6 homectl: split out helpers parse_{unsigned,u64,size}_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek d7a4dfb8b2 homectl: split out helper parse_string_field 2026-01-12 12:24:51 +01:00
Zbigniew Jędrzejewski-Szmek fbd7ca0ef0 homectl: split out parser parse_ssh_authorized_keys
The idea is to split out helpers to make parse_argv() itself more
manageable. If possible, the helpers will be reused in many places. But
even if not, as in this case, it seems good to split out the code for a
specific option. Always, the sd_json_variant** pointer or pointers that
are operated on are selected in the caller. This way it is easier to see
which of the identity variables is used and if two different ones are
used.
2026-01-12 12:24:34 +01:00
Zbigniew Jędrzejewski-Szmek 4a74a48c23 NEWS: fix typo 2026-01-05 22:15:29 +01:00
Zbigniew Jędrzejewski-Szmek 8a27100d06 shared/install: ignore aliasing failure when doing presets
In recent Fedora, preset-all fails:
[  155s] Failed to preset unit: File '/buildroot/etc/systemd/user/dbus.service'
         already exists and is a symlink to /usr/lib/systemd/user/dbus-broker.service
[  155s] ‣ "systemctl --root=/buildroot --global preset-all" returned non-zero exit code 1.

Strictly speaking, this is an error in configuration. The presets specify that
both dbus-broker.service and dbus-daemon.service shall be enabled and they both
claim the 'dbus.service' alias. But this kind of error is very easy to make.
Failing the preset operation is too harsh, since in most cases the system will
work fine without an alias and changes in unrelated components can cause the
conflict.

Let's reuse the same logic that was added in
ad5fdd3912: when enabling the unit through
'preset' or 'preset-all', print the message, but suppress the error. When
enabling through 'enable', fail the operation.
2026-01-05 03:06:37 +09:00
Zbigniew Jędrzejewski-Szmek 689391f8c8 TEST-46-HOMED: fix 2 minute timeout in cleanup
The test passes but for two minutes the cleanup function just logs:
Failed to inspect home: No home for user homedsshtest known
Failed to inspect home: No home for user homedsshtest known
Failed to inspect home: No home for user homedsshtest known
...

Do not wait for the user to become inactive or remove the user if 'homectl
inspect' doesn't find the user. This brings a successfull run from 176 s
to 58 s here.
2026-01-04 16:04:54 +01:00
Zbigniew Jędrzejewski-Szmek 4a4be1015b inhibit: fix borked double logging on error
Previously, if execution failed, we'd log at error level both from the
child and the parent, and we were using a bogus variable for the argument
name:
$ build/systemd-inhibit list
Failed to execute : No such file or directory
list failed with exit status 1.

In general, we can and should assume that the program the user is calling
is well behaved, so it'll log the error on its own if appropriate. So we
shouldn't log on "normal errors", but only if the child is terminated by
a signal.

And since the program name is controlled by the user, use quotes everywhere
to avoid ambiguity.

Now:
$ build/systemd-inhibit false
(nothing)
$ build/systemd-inhibit bash -c 'kill -SEGV $$'
src/basic/process-util.c:895: 'bash' terminated by signal SEGV.
2026-01-04 14:07:57 +01:00
Zbigniew Jędrzejewski-Szmek 22aa8c4879 basic/process-util: reduce scope of variables 2026-01-04 14:07:57 +01:00
Zbigniew Jędrzejewski-Szmek 1ee73c884e basic/process-util: use synthetic errno in two more places 2026-01-04 14:07:57 +01:00
Zbigniew Jędrzejewski-Szmek b30f77cd12 ssh-generator: reword error message
We have two error messages with exactly the same message.
Let's change one so that it is possible to distinguish them
in logs.
2026-01-04 14:07:57 +01:00
Zbigniew Jędrzejewski-Szmek 1d26e7c1d5 bootctl: round the timeout up
I think this is better: if I specify 0.5s, I'd be suprised if the
menu didn't show up at all.
2026-01-04 13:58:37 +01:00
Zbigniew Jędrzejewski-Szmek abd17aa3f4 bootctl: rework setting of menu timeout variables
menu-force and menu-hidden were added in 97f077df05,
menu-disable was added in 6efdd7fec5, a year later.
So we can assume that if the feature flag is set, the other string values are
supported too. The comment that there's no way check that was added later in
5b45fad4fc, but it was incorrect even at that
time.

Fixes https://github.com/systemd/systemd/issues/39167. As described in the
issue, we documented various string values in the BLI, but bootctl didn't use
the string values. At the time menu-force and menu-hidden were added, using
numerical values for compatibility made sense. But that stopped being needed
when a string value that didn't have a strictly equivalent numerical value and
a feature flag were added.

When converting a large number to menu-force, message is downgraded to debug,
since the severity of the issue is very minor. Debug messages are added in
other places when the requested setting is modified too.
2026-01-04 13:55:44 +01:00
Zbigniew Jędrzejewski-Szmek 736fc4b479 meson: avoid double compilation for standalone progs
So far we compiled the normal and standalone versions completely
independently. Let's use the 'extract' template pattern to avoid any
additional compilation and only require an single link to produce the
.standalone variants.

Unfortunately, as designed, the 'extract' framework only allows one set of
object files to be extracted. Since we need all the files for the
.standalone version, we cannot use 'extract' for other purposes. Thus, in
the two cases where 'extract' was used for the test binaries, this is now
changed to compile the files a second time. But the number of files in that
list is small, so this seems like a better option.

(If we weren't using the template system, we could easily extract just the
objects we need. But with the current system, at the point of the
definition, the binaries are not defined yet. We'd need to handle all of
this through sets of dictionaries, and that just seems like too much
trouble to avoid double compilation of a few small files.)
2025-12-19 13:15:49 +01:00
Zbigniew Jędrzejewski-Szmek b6c86e145a meson: drop now-unused -DSTANDALONE
If we ever want to add it back, it should be with -DSTANDALONE=0|1, so
that #if instead of #ifdef can be used. We generally converted our internal
defines to that form.
2025-12-19 13:15:49 +01:00
Zbigniew Jędrzejewski-Szmek 795e066d22 sysusers,tmpfiles: make standalone versions full-featured
This effectively reverts 3537577c37. Originally,
the #ifdefs were added because we didn't want to pull in the whole tree of
libmount and other dependencies in standalone versions. But dependencies are
now loaded through dlopen(), so this is not needed anymore. (And doesn't even
make much of a difference.)
2025-12-19 13:15:49 +01:00
Zbigniew Jędrzejewski-Szmek 54492552a1 meson: allow .standalone version to be always built
Allow .standalone version to be built on-demand, even if -Dstandalone=false
is configured. In other words, this changes the meson option from a hard
disablement to a soft "build is on/off by default".

The meson config was originally written in this way but we lost this feature
after the transition to templates. It is nice to build additional targets on
demand during development, so add this back.
2025-12-19 13:14:19 +01:00
Zbigniew Jędrzejewski-Szmek 9e104bd3aa meson: put src/import source lists directly in templates
The indirection through variables doesn't seem that useful here:
OTOH, the lists are short, and OTOH, there is a bunch of different
programs with similar names. Overall, it's all easier to follow if
the lists are inline.
2025-12-19 13:12:35 +01:00
Zbigniew Jędrzejewski-Szmek d91a184509 core: use terminal_get_size_by_csi18 to query terminal size
This allows us to query the window size without moving the cursor. We have
various reports about the cursor being in an unexpected position and/or state.

Closes https://github.com/systemd/systemd/issues/37526.
2025-12-18 10:47:19 +01:00
Zbigniew Jędrzejewski-Szmek 3cdd80d3e0 sd-boot: correct typos 2025-12-17 22:55:38 +01:00
Zbigniew Jędrzejewski-Szmek 221a33c412 TODO: remove resolved entry
Done in https://github.com/uapi-group/specifications/commit/677b722bb8b84625b68162ba201c8461497f9585.
2025-12-17 22:55:38 +01:00
Zbigniew Jędrzejewski-Szmek 755637b04a docs/BLI: add missing descriptions of feature bits
Follow up for 2553a5482c,
92bb46c464,
e15d18b4c6,
a67f22c4a7,
e1f1b5fc62.
2025-12-17 22:55:38 +01:00
Zbigniew Jędrzejewski-Szmek 3e2b026da3 man/systemd-boot: say that /EFI/systemd/drivers is for hardware
In aad0d11e7c we stopped supporting XBOOTLDR
with a different fs driver. This was the primary example that comes to mind
when we talk about loading filesystem drivers in the firmware. Since we don't
want people to do load such drivers, use a different example.
2025-12-17 22:55:38 +01:00
Zbigniew Jędrzejewski-Szmek 1228429908 docs/BOOT_LOADER_INTERFACE: use full variable names once
We said in the header that "all EFI variables use the vendor UUID
4a67b082-0a4c-41cf-b6c7-440b29bb8c4f", but people not familiar with
UEFI might not know that this is concatenated with the variable name.
Let's use the full form once — when introducing the variable — to
make it easier to grep and search for.

While at it, use sembreaks in the document. This makes subsequent
changes much easier to review. (It also shows that some sentences
are rather long and thus hard to understand.)
2025-12-17 22:55:23 +01:00
Zbigniew Jędrzejewski-Szmek 3310f979f8 Sync kernel headers and add GUEST_MEMFD_MAGIC (#40104) 2025-12-16 14:04:03 +01:00
Zbigniew Jędrzejewski-Szmek 0c8c70e2b3 Chores for RC3 (#40058) 2025-12-10 18:33:05 +01:00
Zbigniew Jędrzejewski-Szmek 13a74f350e tar-util: allow to build without acl support (#39965)
This adds minimal definitions provided by libacl to make tar-util built
without libacl support.
Fixes the following compile error:
```
../src/shared/tar-util.c:62:9: error: unknown type name 'acl_t'
   62 |         acl_t acl_access, acl_default;
      |         ^~~~~
```

Follow-up for 4ded7f7a43.
Fixes #39928.
Replaces #39954.
2025-12-10 09:42:50 +01:00
Zbigniew Jędrzejewski-Szmek 12391431c2 machined: add description to varlink server, unify error messages
manager_varlink_init_resolve_hook and manager_varlink_init_userdb are very
similar, but one didn't set a description and the other one had an error
message which didn't print the offending path.

Define constants for the paths, and also change other similar constants
to have slightly shorter names. (It's an "address" and "path", but we don't
need to have both parts in the name, esp. that it makes the name very long.)
2025-12-05 12:17:06 +01:00
Zbigniew Jędrzejewski-Szmek 9454927c76 sd-netlink: read error message for NFNL_MSG_BATCH_BEGIN (#39967)
Before:
```
$ unshare --user --map-users=0:$(id -u):1 --map-groups=0:$(id -g):1 build/test-firewall-util
/* test_v6 */
src/test/test-firewall-util.c:34: Assertion failed: "r = fw_nftables_add_masquerade(nfnl, true, AF_INET6, &u1, 128)" failed with unexpected error: -110/ETIMEDOUT
Aborted (core dumped)
```

After:
```
$ unshare --user --map-users=0:$(id -u):1 --map-groups=0:$(id -g):1 /var/build/test-firewall-util
/* test_v6 */
test-firewall-util: Failed to add IPv6 masquerade, skipping tests: Operation not permitted
/* test_v4 */
test-firewall-util: Failed to add IPv4 masquerade, skipping tests: Operation not permitted
```
2025-12-05 12:12:03 +01:00
Zbigniew Jędrzejewski-Szmek d9e894ef72 Fix systemctl start --verbose off-by-one logs (#39927) 2025-12-05 11:09:14 +01:00
Zbigniew Jędrzejewski-Szmek 322f6adbcd meson: add tools/meson.build
Previously, we looked for scripts in the tools/ directory ad hoc,
wherever they were needed. Let's do those checks in one place.
The main meson.build file is shrunk somewhat, which is always nice.
2025-12-01 16:18:11 +01:00
Zbigniew Jędrzejewski-Szmek 963bebd7b0 meson: add source dir to include_directories automatically
Quite often we need to specify include_directories('.'). Normally, meson
does this automatically, but we specify implicit_include_directories : false,
see 30d20907bd for an explanation.
Passing the include_directories argument through the template layers was rather
cumbersome. Let's simplify things by always including the directory of the
first source file. This makes the definitions simpler, at the cost of having an
unnecessary include directory in the list in some cases.

(Tests are excluded from this change, because they happen to not need this, but
also because some tests have source[0] which is a custom target, and we'd need
newer meson to support that.)
2025-12-01 15:35:22 +01:00
Zbigniew Jędrzejewski-Szmek 4c3c60c270 meson: reuse variable in one more place 2025-12-01 14:40:03 +01:00
Zbigniew Jędrzejewski-Szmek 21eb636aaa sd-notify: print a debug message when sd_notify() succeds
… and also when it fails, in the few cases where this wasn't done already.
When I was debugging https://github.com/systemd/systemd/issues/39048, it
was quite confusing that we print copious information about D-Bus messages
and all other steps we're undertaking, but nothing about the sd-notify
messages which are much more important. Add some debug messages for the
cases where we didn't print anything. (The case where $NOTIFY_SOCKET is
not set in left unchanged. The variable is often left unset and we don't
need to spam logs in that trivial case.)
2025-11-27 20:03:00 +01:00
Zbigniew Jędrzejewski-Szmek f943ab6efb systemctl: stop showing last message from previous run
--lines=1 means that we show the last message about the unit, whatever it is:

$ SYSTEMD_LOG_LEVEL=debug systemctl --verbose start demo2
...
Invoking 'journalctl -q --follow --no-pager --lines=1 --synchronize-on-exit=yes --unit=demo2.service' as child.
...
Directory /var/log/journal/7d16833bfa924410851e2a193bcfd4ba added.
Journal effective settings seal=no keyed_hash=yes compress=ZSTD compress_threshold_bytes=8B
...
Reiterating files to get inotify watches established.
Considering root directory '/run/log/journal'.
Considering root directory '/var/log/journal'.
Considering directory '/var/log/journal/7d16833bfa924410851e2a193bcfd4ba'.
Nov 26 17:24:35 rawhide systemd[1]: Finished demo2.service.
...
Executing dbus call org.freedesktop.systemd1.Manager StartUnit(demo2.service, replace)
...
Job for demo2.service finished.
Got result done/Success for job demo2.service.
journal: Sending message: {"method":"io.systemd.Journal.Synchronize","parameters":{"offline":false}}
Nov 27 13:05:30 rawhide systemd[1]: Starting demo2.service...
Nov 27 13:05:30 rawhide systemd[1]: demo2.service: Deactivated successfully.
Nov 27 13:05:30 rawhide systemd[1]: Finished demo2.service.
...

We obviously should only show _new_ messages, hence change to --lines=0.
This works properly after the fix in the previous commit.

Fixes #39048.
2025-11-27 20:03:00 +01:00
Zbigniew Jędrzejewski-Szmek ef90afd59e journal: send READY=1 also when --lines=0 is given
If --lines=0 is given, we'd skip the setup and not invoke sd_notify,
potentially blocking the caller. Change the condition for the callback
to also include that case. Since then the callback would always be
set, the 'if' statement is not necessary anymore.
2025-11-27 20:02:02 +01:00
Zbigniew Jędrzejewski-Szmek 1d26bac43f tree-wide: Fix constness issues with newer glibc (#39896)
Latest glibc uses _Generic to have strstr() and other functions return
const char* or char* based on whether the input is a const char* or a
char*. This causes build failures as we previously always expected a
char*.

Let's fix the compilation failures and add our own macros similar to
glibc's to have string functions that return a mutable or const pointer
depending on the input.
2025-11-26 00:32:54 +01:00