Commit Graph
90783 Commits
Author SHA1 Message Date
dongshengyuan eb4abd2d14 hostnamectl: document JSON status object output
status with --static, --pretty, or --transient prints only the
selected hostname in regular output. JSON status output is built from
hostnamed's Describe data and remains a full status object.

Document this distinction so callers do not expect the name type
switches to turn JSON status into a single scalar value.

Follow-up for: ac8a4f6b78
2026-07-23 12:19:48 +09:00
Luca Boccassi 765dc96746 homed: verify privileged worker changes
Workers may return a newer embedded identity while processing
an owner update. Accept self-modifiable changes, but require
privileged changes to carry a trusted signature.

Follow-up for 70a5db5822
2026-07-22 17:11:08 +02:00
Luca Boccassi b9ef5951f8 rm-rf: downgrade root check log when directory doesn't exist
When a unit is stopped we try to destroy the credential mount point,
which might not exist. This logs at error level, which is noisy and
pointless. Downgrade to debug level on ENOENT.

systemd[1]: Failed to determine whether '/run/credentials/run-p119516-i119816.service' is the root file system: No such file or directory

Follow-up for 9dd2dab37e
2026-07-22 15:09:36 +02:00
Liu Zheng 3ac01c2512 man: document that ExitType=cgroup is rejected for Type=oneshot
The ExitType= documentation stated that ExitType=main "cannot be used
with Type=oneshot", which is incorrect: ExitType=main is the default
and works fine with Type=oneshot. The restriction actually enforced by
the code is that ExitType=cgroup is refused for Type=oneshot services
(see service_verify() in src/core/service.c).

Move the "cannot be used with Type=oneshot" note from the ExitType=main
bullet to the ExitType=cgroup bullet where it belongs.

Fixes #42327

Signed-off-by: Liu Zheng <liuzheng@uniontech.com>
2026-07-22 12:24:15 +01:00
Armaan Sandhu eb03267070 escape: reject UTF-16 surrogates in \u escapes in cunescape_one() (#43079)
A `\u` escape in `cunescape_one()` was accepted for any 16-bit value
except NUL. That range `0x0000`-`0xFFFF` includes the UTF-16 surrogates
`0xD800`-`0xDFFF`, which are not valid Unicode scalar values and cannot
be encoded as valid UTF-8.
2026-07-21 23:40:26 +09:00
Yu Watanabe cc594a83f4 home: insert a space before '=' 2026-07-21 23:38:40 +09:00
Beniamino Galvani 9af2d7e4c8 man: update the sample glib/sd-event integration
The normal order of operations when iterating the GLib main loop is:

 - prepare()  -> sd_event_prepare()
 - poll the file descriptors
 - check()    -> sd_event_wait()
 - dispatch() -> sd_event_dispatch()

GLib does not guarantee that check() is always called between two
consecutive prepare() invocations. When another thread attaches or
removes a source with poll fds while the main thread is inside
poll(), g_main_context_check_unlocked() returns immediately without
calling any source's check() callback.

Since the sd_event GSource adapter maps prepare/check/dispatch to
sd_event_prepare/sd_event_wait/sd_event_dispatch, a skipped check()
leaves sd_event in ARMED state. The next prepare() then hits
assertion "e->state == SD_EVENT_INITIAL".

The following program reproduces the faulty scenario by creating a
thread that attaches a new fd during the poll phase:

  #include <stdio.h>
  #include <stdlib.h>
  #include <sys/socket.h>
  #include <glib.h>
  #include <systemd/sd-event.h>
  #include <unistd.h>

  /* from glib-event-glue.c */
  extern GSource *g_sd_event_create_source(sd_event *event);

  static gpointer thread_func(gpointer user_data) {
    GSource *source;
    GPollFD pollfd;
    int fd;

    g_usleep(G_USEC_PER_SEC / 10);

    fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
    if (fd < 0)
      abort();

    source = g_source_new(&(GSourceFuncs){0}, sizeof(GSource));
    pollfd.fd = fd;
    pollfd.events = G_IO_IN;
    pollfd.revents = 0;
    g_source_add_poll(source, &pollfd);
    g_source_attach(source, NULL);
    g_source_destroy(source);
    g_source_unref(source);

    close(fd);

    return NULL;
  }

  int main(int argc, char *argv[]) {
    sd_event *event = NULL;
    GSource *source;
    GThread *thread;
    int i, r;

    r = sd_event_default(&event);
    if (r < 0)
      return 1;

    source = g_sd_event_create_source(event);
    if (!source)
      return 1;

    g_source_attach(source, NULL);

    for (i = 0; i < 50; i++) {
      thread = g_thread_new("check-skip", thread_func, NULL);
      g_main_context_iteration(NULL, TRUE);
      g_thread_join(thread);
      g_main_context_iteration(NULL, FALSE);
    }

    g_source_destroy(source);
    g_source_unref(source);
    sd_event_unref(event);

    return 0;
  }

When the program uses the current glue code, it crashes with:

  Assertion 'e->state == SD_EVENT_INITIAL' failed at src/libsystemd/sd-event/sd-event.c:4560, function sd_event_prepare(). Aborting.

Fix the problem by skipping sd_event_prepare() if the event is
already ARMED: it was already prepared in a previous iteration and
it can be polled immediately.
2026-07-21 14:50:02 +01:00
Guillaume Kehren ac64b2dfa3 man: document unlocked as default IMDS network mode
The default IMDS network mode was changed to unlocked, but the
systemd-imdsd@.service documentation still described locked as the
default.

Fixes #42687
2026-07-21 11:43:52 +01:00
Yu Watanabe ab373b2cec Assorted cleanups for #42978 (#43051)
https://github.com/systemd/systemd/pull/42978
2026-07-21 14:03:49 +09:00
Yu Watanabe bda98358d2 tools: reject invalid inputs and align machine-readable output (#43040) 2026-07-21 12:23:00 +09:00
Yu Watanabe 8eede7122f sd-device: allow non-safe characters in uevent files
This partially reverts 13ce62caba.

Sometimes, the kernel passes non-safe characters in uevent files,
such as the UNIQ= property for USB serial devices.

Instead of rejecting the entire uevent file, let's only ignore the
specific key-value pairs that contain non-safe characters.

Fixes #43008.
2026-07-21 12:19:32 +09:00
Yu Watanabe 97653d10ff hwdb: strip the root from filenames when generating hwdb.bin (#43062)
The modern hwdb.bin format contains the filenames of the input data that
makes up the database. This is useful but in offline builds where --root
is used, the filenames are the full build paths including the specified
root. This introduces build paths and thus information leakage and
non-reproducible data.

Solve this by stripping the root prefix off the original path when
passing to import_file.
2026-07-21 12:19:00 +09:00
Julian Bouzas 3bc3b6c6e7 hwdb: classify PlayStation controller audio as controller form-factor
Add Sony PlayStation controller entries to 70-sound-card.hwdb so that their
ALSA sound devices are tagged with SOUND_FORM_FACTOR=controller:
 - DualSense (054c:0ce6)
 - DualSense Edge (054c:0df2)
 - DualShock 4 CUH-ZCT1x (054c:05c4)
 - DualShock 4 CUH-ZCT2x (054c:09cc)

These controllers expose USB audio but are neither headsets nor speakers.
Pinning them in the hwdb ensures they are identified correctly before any
fallback matching occurs.
2026-07-21 07:30:37 +09:00
Ross Burton ab9be70e94 hwdb: strip the root from filenames when generating hwdb.bin
The modern hwdb.bin format contains the filenames of the input data that
makes up the database.  This is useful but in offline builds where
--root is used, the filenames are the full build paths including the
specified root.  This introduces build paths and thus information
leakage and non-reproducible data.

Solve this by stripping the root prefix off the original path when
passing to import_file.

Add TEST-17-UDEV.hwdb.sh to verify that hwdb.bin files contain the
path inside the root, but not the path of the root.
2026-07-20 14:31:15 +01:00
Yu Watanabe 843bba839a po: update Japanese translation 2026-07-20 12:40:02 +01:00
Yu Watanabe e11f211326 man/network: fix default value for RequiredFamilyForOnline=
It was unexpectedly changed by c89efaf9e5.

Fixes #43074.
2026-07-20 12:39:18 +01:00
Luca Boccassi cab511f5f5 Fix typos reported by Fossies (#43084) 2026-07-20 12:38:47 +01:00
Luca Boccassi e304d559e8 udev: drop home-grown udev-ctrl socket (#40802)
Nowadays, varlink is used to control systemd-udevd. Let's drop the
legacy socket.

Note, the existence of /run/udev/control socket is widely used in both
our code and external projects. Also, the dependency to
systemd-udevd-control.socket is widely used in many projects. Hence, we
need to create a symlink to the socket file and .socket unit file.
2026-07-20 12:37:27 +01:00
Ross Burton d024c58b8e hwdb: add debug logging for the output filename
It's useful to see exactly what file was written to when updating the
HWDB.
2026-07-20 11:24:57 +01:00
Luca Boccassi 368eb65155 mkosi: update debian commit reference to 56402b2bde258999a8f01a8b04465fde9242d6a1
* 56402b2bde Drop symlink to systemd-udevd-control.socket
* 3afaaf4f89 Install new files for upstream build
2026-07-20 10:58:51 +01:00
Armaan Sandhu 79f25def86 hostname-util: strip all trailing separators in hostname_cleanup() (#43077)
Fixes #43054.
2026-07-20 16:35:12 +09:00
Yu Watanabe 38116b79ba sysinstall: fix typo
Follow-up for c17d0c7e85.
2026-07-20 16:23:04 +09:00
Yu Watanabe 38f9b660c3 tpm2-util: fix typo
Follow-up for 2348941b5d.
2026-07-20 16:23:04 +09:00
Yu Watanabe 9bbd947083 tpm2-util: fix typo
Follow-ups for 5a80137aa4.
2026-07-20 16:23:04 +09:00
Yu Watanabe 50f58d0e15 network: fix typo
Follow-up for d094067547.
2026-07-20 16:23:04 +09:00
Yu Watanabe 3fb89fc69e string-util: fix typo
Follow-up for 093cac3fe8.
2026-07-20 16:23:04 +09:00
Yu Watanabe 3fcd5cec3b report: fix typo
Follow-up for 3c2f7c6002.
2026-07-20 16:23:04 +09:00
Yu Watanabe 4476d35081 sysupdate: fix typo
Follow-up for d82e256bb9.
2026-07-20 16:22:40 +09:00
Yu Watanabe e10e1c4c5e TODO: fix typo
Follow-ups for f61e1e5cf4 and
3d0309ac0f.
2026-07-20 15:03:37 +09:00
Nandakumar Raghavan 13aec9fddf networkctl,networkd: add --no-reconfigure flag to networkctl reload
Add a new --no-reconfigure flag to 'networkctl reload' that reloads
.network and .netdev files from disk without reconfiguring any network
interfaces. This may be useful to avoid reconfiguring multiple interfaces
simultaneously when multiple .network files are updated, or when an updated
.network file is applied to multiple interfaces.

On the networkd side, manager_reload() gains a reconfigure_links parameter
that gates the per-link reconfiguration loop. A new io.systemd.Network.Reload
varlink method is added that exposes this as an optional reconfigureLinks
boolean (defaults to true). Both plain 'networkctl reload' and
'--no-reconfigure' now unconditionally call this method first. If an older
networkd returns MethodNotFound, plain reload falls back to
io.systemd.service.Reload for backward compatibility; '--no-reconfigure'
fails with a clear error in that case.
2026-07-20 14:35:04 +09:00
Sinity 1166f4472d core/dbus: do not block the manager on GetId during bus (re-)connection
bus_init_api() issued a synchronous GetId call on every API bus
(re-)connection to decide whether saved subscription state could be
coldplugged onto the new connection.

If the D-Bus socket unit is listening while the message bus daemon
behind it is gone, connect() succeeds against the socket backlog but
nothing answers the authentication handshake. The synchronous call
then blocks PID 1 for BUS_AUTH_TIMEOUT (90 seconds by default), and
queued bus operations can trigger repeated reconnection attempts.
This was observed during shutdown as roughly 15 minutes of teardown
progressing only in 90-second intervals.

Query the instance ID asynchronously on every connection. Defer API
setup until the reply is processed, so saved subscriptions are
validated and coldplugged before new subscription requests can arrive.
If the query cannot be queued or its reply is invalid, discard the
unvalidated state and expose the API without blocking the manager.

Reset the live bus ID on every connection and serialize pending bus ID
and subscription state across reload and reexec. During daemon-reload,
preserve state that was already awaiting the asynchronous reply while
discarding the duplicate state produced by the reload itself.

Also remove the now-unused synchronous bus_get_instance_id() helper.
2026-07-20 11:53:34 +09:00
Zbigniew Jędrzejewski-Szmek d751846043 Manage dlopen notes at beginning of execution, and downgrade priorities in shared libraries (#43060) 2026-07-19 21:23:47 +02:00
Zbigniew Jędrzejewski-Szmek 0f81431e35 portable: tighten image handling and command error reporting (#43033)
Let's further improve portable image handling and command error
reporting.
2026-07-19 21:09:24 +02:00
Zbigniew Jędrzejewski-Szmek 787853bd78 Improve sysinstall messages (#43050)
I was trying to use systemd-sysinstall and those are the fixes for
various ugly parts that are immediately obvious when it is used.
2026-07-19 20:16:06 +02:00
dongshengyuan 4368db3219 boot: cover BCD offsets past the buffer
Add a zero-length test for offset > max so the first bounds guard
is covered separately from the length overflow check.

Follow-up: 231857cfe8
2026-07-19 20:21:47 +09:00
Alexey Shabalin f9a9b6b4f5 password-quality-util-passwdqc: restore password-quality-util.h include
suggest_passwords() references the N_SUGGESTIONS macro, which is defined in
password-quality-util.h. Commit ff33c8f87d ("Extend test-dlopen-so to also
cover cases when built without support") introduced the per-backend split
headers: for the pwquality backend it added the new
password-quality-util-pwquality.h include while keeping password-quality-util.h,
but for the passwdqc backend it replaced password-quality-util.h with
password-quality-util-passwdqc.h (which only pulls in shared-forward.h). As a
result N_SUGGESTIONS is no longer declared in the passwdqc translation unit and
the build fails when the passwdqc backend is enabled.

The passwdqc backend is not exercised by the default CI, so this went
unnoticed. Add the include back, matching the pwquality backend.
2026-07-19 20:19:48 +09:00
Arian van Putten 78a8170a8a systemd-imds-generator: fix import docs
We only run import in the initrd by default. Clarify this.
2026-07-19 10:59:59 +01:00
Lennart Poettering 215ad044d3 run: split out polkit ops into separate .c file (#43047) 2026-07-18 11:03:36 +02:00
dongshengyuan 7a81ad4b6b creds: reject empty validity intervals
Reject credentials whose not-after timestamp is equal to the timestamp
at each encryption entry point.

Reproducer: systemd-creds --timestamp=TS --not-after=TS encrypt in out

Before: encryption succeeded, but decrypt refused the credential as not
in order.

Follow-up: 21bc0b6fa1
2026-07-18 15:53:00 +08:00
dongshengyuan dab2a82a30 dissect: include image size in JSON output
Use the image metadata size when building JSON output, matching the
value already shown by the text output.

Reproducer: systemd-dissect --json=short image.raw

Before: text output showed Size, but JSON omitted the top-level size
field.

Follow-up: be5bee2a13
2026-07-18 15:53:00 +08:00
dongshengyuan 928cc86772 sysupdate: keep JSON check-new exit status consistent
Return failure for --json check-new when no candidate is available.
Let sysupdated accept that exact JSON no-update result from workers.

Reproducer: systemd-sysupdate --verify=no --json=short check-new

Before: the command printed {"available":null} and exited successfully.

Follow-up: 42c0b689a8
2026-07-18 15:53:00 +08:00
dongshengyuan e7e68ec449 repart: skip generated files during dry runs
Skip generated fstab and crypttab output when --dry-run=yes is used,
after confirming there is eligible content to generate.

Reproducer: systemd-repart --dry-run=yes --generate-fstab=/tmp/root/etc/fstab -

Before: the command exited successfully and still wrote the requested
fstab file.

Follow-up: 1a0541d44c
2026-07-18 15:48:34 +08:00
dongshengyuan 50eaa51ce1 firstboot: validate root shell credentials
Validate passwd.shell.root after reading the credential so it uses
the same target-root shell checks as --root-shell= and prompted input.

Reproducer: CREDENTIALS_DIRECTORY=... systemd-firstboot --root=...
with passwd.shell.root=/bin/nonexistentshell

Before: /etc/passwd was written with the nonexistent root shell and
the command exited successfully.

Follow-up: 416f7b3a11
2026-07-18 15:48:34 +08:00
dongshengyuan 05b49871a2 sysusers: validate shell credentials
Validate passwd.shell.<user> credentials with the same login-shell
rules used for sysusers.d shell fields before writing passwd entries.

Reproducer: CREDENTIALS_DIRECTORY=... systemd-sysusers --root=...
with --inline 'u creduser 999 "Cred User" / -'

Before: relative-shell was written as the login shell and the command
exited successfully.

Follow-up: 99e9f896fb
2026-07-18 15:48:34 +08:00
Lennart Poettering 1f360f0abd run: simplify timer property handling
Let's make timer prop handling less special, and more like path/socket
handling. Let's move the checks for at least one OnXYZ= setting to a
common place at the end of parsing, instead of explicit checks for each
property.
2026-07-18 00:01:47 +02:00
Lennart Poettering 9793dde16e run: split out polkit ops into separate .c file
Let's shorten an already very long .c file, by splitting it apart a bit.

Splitting out the polkit code is relatively easy, since it does not
touch any of the arg_xyz variables.
2026-07-18 00:01:47 +02:00
Yu Watanabe 8e54afe8da mkosi/opensuse: do not try to package non-existent symlink to systemd-udevd-control.socket 2026-07-18 05:29:59 +09:00
Yu Watanabe 20ef89f646 NEWS: mention the removeal of legacy udev control socket 2026-07-18 05:29:59 +09:00
Yu Watanabe 17e911ffc8 udev: drop home-grown udev-ctrl socket
Nowadays, varlink is used to control systemd-udevd. Let's drop the
legacy socket.

Note, the existence of /run/udev/control socket is widely used in both
our code and external projects. Also, the dependency to
systemd-udevd-control.socket is widely used in many projects.
Hence, we need to create a symlink to the socket file and .socket unit
file.
2026-07-18 05:29:59 +09:00
Yu Watanabe 14f934df35 nspawn: do not try to connect udevd
nspawn itself does not require to control udevd process.

Only necessary points are
- udevd is available, and
- we are in the main network namespace.

Let's check them explicitly.

This also makes the check is skipped when we are talking to mountfsd, as
the check is pointless in that case.
2026-07-18 05:29:59 +09:00