92247 Commits
Author SHA1 Message Date
Jeffrey Sardina 5a69b56d2a update 2026-10-10 23:26:48 -07:00
Daan De Meyer 1773505f7e update-helper: connect to user managers through their private socket
The helper reaches a user manager with the uid@ machine transport. That
transport runs systemd-run, which opens a PAM login session for the user.
In that session, systemd-stdio-bridge connects to the user's D-Bus broker.
rpm runs the helper once per package scriptlet. A large transaction therefore
opens many login sessions for every logged-in user. The operations also fail
whenever the user's D-Bus broker is not running.

The user manager accepts connections from root on its private socket, and
systemctl --user uses the same socket. Connect to
/run/user/UID/systemd/private directly with bus_connect_user_systemd_by_uid().
The user owns /run/user/UID. The function therefore refuses a socket that the
user does not own or that a process of another user listens on. Otherwise a
user could point the helper at the private socket of the system manager.
2026-10-10 22:53:03 +02:00
Daan De Meyer 14b5ed54fa bus-util: add bus_connect_user_systemd_by_uid()
systemd-update-helper runs as root and needs to connect to the private socket
of each user manager. The user owns /run/user/UID, which contains that socket,
and can replace the socket with a symlink or a hardlink. The private socket of
a capsule is in a directory that the capsule user owns too.
bus_set_address_capsule() therefore refuses symlinks and pins the socket inode
before connecting.

Generalize pin_capsule_socket() to take a full path, and add
bus_connect_user_systemd_by_uid() on top of it. The function connects only to
a socket that the user owns, and only when a process that runs as the user
listens on it. The owner of a socket inode is not always the process that
listens on it. For example, PID 1 listens as root on the socket of a socket
unit with SocketUser= set to the user.

A process of the user passes both checks when it listens on the socket. That
process can send file descriptors until the file descriptor table of the
caller is full. The function therefore refuses file descriptors from the peer.
2026-10-10 22:53:03 +02:00
Daan De Meyer d390e23673 mmap-cache: return right away on a category window hit
Most lookups find the range in the window of their category. On such a
hit, mmap_cache_fd_get() still calls category_attach_window(), which
returns without doing anything because the window is attached already.
mmap_cache_fd_get() also gets the cache through mmap_cache_fd_cache(),
which is not inlined.

Set the flag and return directly on a hit. Reading 1M entries of a real
journal takes 1.3% fewer cycles.
2026-10-10 22:52:34 +02:00
venkatchalla06 c556722826 firstboot: fix use-after-free/double-free of the Varlink reply in process_hostname()
ret_parameters (and ret_error_id) returned by sd_varlink_call()/
sd_varlink_callbo() are borrowed from the connection, as documented in
sd-varlink.h, and must not be unreffed by the caller. process_hostname()
declared its reply as _cleanup_(sd_json_variant_unrefp), freeing memory
owned by the Varlink connection and leading to a use-after-free/
double-free (the same bug class and ownership mistake just fixed for
pcrextend_pcr_now()/pcrextend_nvpcr_now() in 76a6dc6d).
2026-10-11 04:34:37 +09:00
abdurrafay3 e6b62f2b3a shutdown: copy shutdown verb so shutdown scripts receive $1
The arg_verb was copying the pointer to the shutdown verb, but that
pointer was being overwritten. When the shutdown scripts run, the forked
child calls rename_process() which overwrites argv, so the scripts got
an empty $1 instead of reboot, poweroff, etc.

Make a copy of the verb with strdup() so it is not affected.

Fixes: #44087

Follow-up for: 4927588993
2026-10-11 04:23:42 +09:00
Lennart Poettering fd30937468 sysinstall: fix typo in varlink iface
This is strictly speaking an API break, but given this is output only
and the component so new, I think we should just fix this anyway.

Fix: #44088
2026-10-11 04:21:50 +09:00
Rihards Prieditis 4a5b41390a po: Translated using Weblate (Latvian)
Currently translated at 100.0% (286 of 286 strings)

Co-authored-by: Rihards Prieditis <rprieditis@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/lv/
Translation: systemd/main
2026-10-11 04:21:07 +09:00
Lennart Poettering c673d9985d sd-event: fix floating inotify event (#44117) 2026-10-10 11:54:39 +02:00
Lennart Poettering e6cad5c43e report: add some basic journald and logind counter metrics (#44076) 2026-10-10 11:47:43 +02:00
Sergey Tiraspolsky 0490b976b9 hwdb: map Google Pixelbook (Eve) top row keys
Like other pre-Vivaldi Chromebooks, the Pixelbook's top row sends the
standard F1-F10 scancodes and Chrome OS translates them to actions in
userspace, so elsewhere the keys come through as F1-F10 even though
they are labelled Back, Refresh, Fullscreen, Overview, brightness down
and up, play/pause, mute and volume down and up. Map them to the
printed functions. Also map the menu key next to volume up (scancode
0x5d, F13 by default) to KEY_CONTROLPANEL and the Assistant key
(scancode 0xd8, which atkbd reports as unknown) to KEY_ASSISTANT, as
Chrome OS's own Eve hwdb does.

XKB_FIXED_MODEL=chromebook, used for Falco and Peppy, does not fit:
that model follows the original Chromebook top row (F2 Forward, F3
Refresh, brightness on F6/F7), while the Eve has Refresh on F2,
brightness on F5/F6, Play/Pause on F7 and no Forward key.

Tested on a Pixelbook with the DMI modalias
dmi:bvncoreboot:bvrGoogle_Eve.9584.230.0:...:svnGoogle:pnEve:...
2026-10-10 11:12:51 +02:00
Sergey Tiraspolsky 32e38ebd76 hwdb: add Google Pixelbook (Eve) chassis quirk
The 2017 Google Pixelbook (Eve) is a 2-in-1 with a 360° hinge, but its
firmware reports SMBIOS chassis type 3 (Desktop), so hostnamed reports
"desktop". Override it to "convertible". The ACPI power profile also
says "desktop", so nothing else corrects it.

Tested on a Pixelbook with the DMI modalias
dmi:bvncoreboot:bvrGoogle_Eve.9584.230.0:...:svnGoogle:pnEve:...
2026-10-10 11:12:11 +02:00
Lennart Poettering 910c508022 Update TODO 2026-10-10 10:40:03 +02:00
Lennart Poettering 8c64c6ad90 test: cover logind metrics 2026-10-10 10:40:03 +02:00
Lennart Poettering 5d7cb3878c logind: expose session and suspend metrics
logind now implements io.systemd.Metrics on
/run/systemd/report/io.systemd.Login, via the new
systemd-logind-metrics.socket, and reports:

- io.systemd.Login.SessionsStarted: counter of sessions started since
  boot, by session class (field class=)
- io.systemd.Login.CurrentSessions: gauge of current sessions, including
  those in closing state, by session class (field class=)
- io.systemd.Login.SuspendCounter: counter of suspend cycles, as reported
  by the kernel in /sys/power/suspend_stats/ (field result=success|fail)
2026-10-10 10:40:03 +02:00
Lennart Poettering 8242f08ecb logind: count started sessions per class in a memory mapped file in /run/
logind now counts started sessions by session class in
/run/systemd/login-counters, which it keeps mapped for its whole
runtime. The counters are monotonic (i.e. are not decreased on logout),
survive restarts of logind, but are reset on reboot.

Sessions are counted where they are created (via D-Bus or Varlink), not
in session_start(), since the latter is also called for sessions
restored after a restart of logind.

The counters are an array indexed by SessionClass (minus SESSION_NONE,
which is never registered with logind), hence the enum now carries a
note that its order determines the file layout.
2026-10-10 10:40:03 +02:00
Lennart Poettering 202a1ea32d test: cover journald message counter metrics 2026-10-10 10:40:03 +02:00
Lennart Poettering f0f2bf15b8 journald: expose message counters as metrics
journald now implements io.systemd.Metrics on
/run/systemd/report/io.systemd.JournalDaemon, via the new
systemd-journald-metrics.socket, and reports the message counters as
io.systemd.JournalDaemon.MessagesByPriority (field priority=) and
io.systemd.JournalDaemon.MessagesByTransport (field transport=).

Metrics requests are processed at a lower event loop priority than
incoming log messages. For now only the main journald instance provides
metrics, not the namespace instances.

Like the audit socket, the metrics socket is not listed in Sockets= of
the service, so that it can be disabled.
2026-10-10 10:38:15 +02:00
Lennart Poettering 141033a2fd journald: maintain message counters in a memory mapped file in /run/
journald now counts received log messages by priority and by transport
in $RUNTIME_DIRECTORY/counters, which it keeps mapped for its whole
runtime. The counters hence survive restarts of journald, but are reset
on reboot.

Messages are counted in each transport right after their priority is
known, i.e. before any filtering (LogLevelMax=, LogFilterPatterns=,
MaxLevelStore=, Storage=none) or rate limiting is applied. Kernel
messages are only counted after the kernel seqnum check, so that
messages seen before a restart are not counted twice. journald's own
messages are not counted.

This introduces a JournalTransport enum for the transports we receive
messages on, whose string names match the _TRANSPORT= field.
2026-10-10 10:38:15 +02:00
Lennart Poettering 91b1051642 shared: add helper for memory mapped counter files
This adds a small helper that creates (if needed) and maps a file in
/run/ that contains a 64-bit version field followed by raw 64-bit
counters. If the file has a different size or version than expected it
is reset. This is intended for daemons that want to maintain monotonic
counters that survive restarts of the daemon, but not reboots.
2026-10-10 10:38:15 +02:00
Lennart Poettering f75cb0a04b memory-util: introduce munmap_safe() and make use of it everywhere
This new wrapper for munmap() asserts on a bunch of unexpected
conditions:

1. if we try to unmap a valid pointer with a zero size
2. if we try to unmap a valid pointer with a size of SIZE_MAX (this
   is supposed to catch PAGE_SIZE() overflows, which is often used in
   combination)
3. munmap() failing

It also turns invocations with a NULL or MAP_FAILED pointer into NOPs.
That's useful to simplify error clean-up paths in case mmap() failed.

Finaly it returns a NULL pointer to the input type, so that we can
write:

p = mummap_safe(p, sz);

to invalidate both memory and the pointer p in one go.
2026-10-10 10:38:15 +02:00
Lennart Poettering b8ac543706 pretty-print: some more gcc appeasement 2026-10-10 10:38:15 +02:00
Yu Watanabe 570c46894b NEWS: networkd and networkctl is merged after v262
Hence, moved the entry to v263.

Follow-up for 4fb4d66d4b.
2026-10-10 04:48:54 +09:00
Yu Watanabe c33c5f91db sd-event: coding style fix 2026-10-10 04:30:17 +09:00
Yu Watanabe e1514ac3b9 test: add test case for sd_event_add_inotify() with floating event source 2026-10-10 04:30:17 +09:00
Yu Watanabe 0582f7cba9 sd-event: make inotify event source floating if ret is NULL
Otherwise, if sd_event_add_inotify() is called with NULL for ret,
the event source is disabled and never triggered.

Fixes a bug introduced by e67d738a87.
2026-10-10 04:28:59 +09:00
Egor Ignatov 04567a3b5e resolve: get the current DNS server before passing the server lists
manager_get_dns_server() may re-read /etc/resolv.conf and replace
m->dns_servers and m->search_domains, but it was passed as an argument
to dns_configuration_json_append() together with those lists, and the
order of evaluation of the arguments is unspecified. gcc with LTO reads
the list heads first, so after a foreign /etc/resolv.conf has changed
the freed lists are walked. Typically the serialization then fails with
EUCLEAN, which makes the SubscribeDNSConfiguration method of
io.systemd.Resolve.Monitor and in turn systemd-networkd-wait-online
--dns fail.

Call manager_get_dns_server() first and store the result in a local
variable.
2026-10-09 15:10:25 -04:00
Lennart Poettering 13bf80491b test-parse-helpers: use ASSERT_STREQ()/ASSERT_EQ() in test_path_simplify_and_warn_one()
Tests exist to test stuff, hence we should not use plain assert(), but
the ASSERT_XYZ() macros, which are never compiled out and print useful
information on failure.
2026-10-09 20:19:44 +02:00
Lennart Poettering a510e920af tests: some more fixes (#44099)
Addresses some issues seen in CI failures
2026-10-09 18:41:45 +02:00
Lennart Poettering da4052d003 bus-message-util: initialize variables to make gcc happy
gcc 13 on armhf complains with -Wmaybe-uninitialized about family, port
and server_name in bus_message_read_dns_array(), even though they are
always set when bus_message_read_dns_one() returns > 0.
2026-10-09 18:17:45 +02:00
Lennart Poettering e1577aaed6 test-resolved-packet: use assert_se() for the string comparison
With assert() the comparison is compiled out in NDEBUG builds, leaving
twilio_reply_string unused, which breaks the build with -Werror.
2026-10-09 18:17:45 +02:00
Lennart Poettering 5ad26e0080 tests: some minor CI fixes (#44097)
Some fixes for flakiness seen on CI
2026-10-09 18:17:25 +02:00
Daan De Meyer 25428cd656 journal-file: look up the window of an object only once
journal_file_move_to_object() maps the object header, reads the object
size from it, and then looks up the window again for the whole object.
That second lookup finds the same window nearly every time, since
windows are 8 MiB and most objects are small.

Have mmap_cache_fd_get() return how many bytes the window has after the
offset, and skip the second lookup when the object fits in the window
and in the file. Reading 1M entries of a real journal takes 10.7% fewer
cycles.
2026-10-09 14:03:41 +02:00
Zbigniew Jędrzejewski-Szmek f992bce2c1 Allow marking options as experimental (#44065) 2026-10-09 11:29:17 +02:00
nikstur b6ba95e0b1 meson: add extra-exec-search-path option
Alows to add more paths to the default paths that are used to search for
binaries.
2026-10-09 11:22:20 +02:00
Eric BoucherandZbigniew Jędrzejewski-Szmek 34127b7c4c cgtop: make root row default to cgroup with '/' to toggle
The root row in systemd-cgtop previously displayed whole-system RAM
usage read from /proc/meminfo (MemTotal - MemAvailable), not a cgroup
sum. This is a pragmatic fallback — the kernel intentionally does not
expose memory.current on the v2 root cgroup (see the existing
is_root_cgroup() comment about avoiding 'multiple truth about system
state'), so cgtop picked /proc/meminfo to fill the gap.

Nevertheless, that caued the '/' row to provide different information
than every other row in the table:
- All child rows: 'what is this cgroup charged for?' (anon + file
  + sock + shmem attributable to the cgroup).
- Root row: 'what is the whole system using?' (includes kernel
  slab, vmalloc, pagetables, zram mem_used, and anything not
  attributable to any cgroup).

On a typical desktop the root row can read ~10 GB while the sum of
direct children is ~5 GB, with no explanation visible in the tool
itself.

This commit:
  1. Introduces --root-memory= command line option.
  2. Flips the default for the root row to the sum of memory.current
     over its direct children.
  3. Adds a '/' interactive key that toggles between the two modes.
  4. Updates the interactive help string ('?' / 'h'), the man page,
     and the bash completion for the new option.

Inside a container (detect_container() > 0), is_root_cgroup() already
returns false, so none of this applies — the container's '/' still
reads memory.current from the namespaced cgroup as before.

Co-authored-by: Zbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
2026-10-09 11:19:05 +02:00
Rihards Prieditis 326a4ec3d3 po: Added translation using Weblate (Latvian)
Co-authored-by: Rihards Prieditis <rprieditis@gmail.com>
2026-10-09 11:16:49 +02:00
Lennart Poettering 189136a128 report: add metrics sources for network counters (#44081) 2026-10-09 09:43:12 +02:00
Lennart Poettering e42ad4c3b6 test: silence SC2329 for trap-invoked cleanup() in TEST-17-UDEV.sanity-check
cleanup() is only called via 'trap cleanup EXIT', which newer shellcheck
versions report as SC2329 rather than SC2317. Disable both, like the other
test scripts do.
2026-10-09 09:41:22 +02:00
Lennart Poettering b43136ffcd test-sd-device: tolerate devices disappearing during enumeration test
On CI (Azure runners) the accelerated networking PCI VF behind the
Hyper-V vmbus PCI bridge may be hot-unplugged while the test runs,
causing sd_device_new_from_syspath() to fail with ENODEV for a device we
just enumerated:

  test_sd_device_one(/sys/devices/LNXSYSTM:00/.../pci7870:00/7870:00:00.0)
  Assertion failed: Expected "sd_device_new_from_syspath(&dev, syspath)"
  to succeed, but got error: -19/ENODEV

Skip devices whose syspath vanished since enumeration rather than
failing.
2026-10-09 09:41:22 +02:00
Lennart Poettering 7898deeebc update TODO 2026-10-09 07:55:32 +02:00
Lennart Poettering 0c2366a159 report: Add network statistics metrics generator
One of the fundamental counters we need to cover in metrics are
packet/byte counters on network interfaces. Let's add this.

We do this separately from networkd, to not unnecessarily affect
networkd operations.
2026-10-09 07:55:32 +02:00
Lennart Poettering fc38a61894 metrics: lift restrictions on fields types
These checks stem from a rework from strv to a proper varlink object,
but the whole rework's point was to allow more expressive field types,
hence drop the unnecessary verification of the string type.
2026-10-09 07:50:47 +02:00
Lennart Poettering 3d367b352b report: add nonce concept
While systemd-report is conceptually designed to provide freshness
guarantees without nonces (for example via TPM clock, TSA or generation
counters), it sometimes is useful to provide a nonce, when talking
directly and synchronously to a node, instead of asynchronously.

Hence, let's just extend the Generate Varlink calls with a nonce
argument.
2026-10-09 07:11:34 +02:00
Lennart Poettering ed775d5f91 report: expose CLOCK_MONOTONIC/CLOCK_BOOTTIME as metrics, as a way to… (#44077)
… determine system uptime

And while we are at it, let's also expose CLOCK_REALTIME, all in nsec
accuracy.

(The realtime clock is also included in the report header, but in
calendar format with second granularity.)
2026-10-09 07:06:04 +02:00
Lennart Poettering 743754e083 report: expose file system birth time of /var/ as DeploymentTimestampNSec
The birth time of the root inode of the file system backing /var/ is a
good approximation of when the system was deployed, i.e. when its
persistent file system was created. If /var/ is not a mount point of its
own, use the root file system instead.

The metric is skipped if the file system does not record birth times.
2026-10-08 21:23:51 +02:00
Lennart Poettering 076f689180 report: expose CLOCK_MONOTONIC/CLOCK_BOOTTIME as metrics, as a way to determine system uptime
And while we are at it, let's also expose CLOCK_REALTIME, all in nsec
accuracy.

(The realtime clock is also included in the report header, but in
calendar format with second granularity.)
2026-10-08 20:55:16 +02:00
Daan De Meyer bde980af1e process-util: skip the atomic exchange for a cached PID
getpid_cached() runs a compare-and-exchange on every call, also when
the PID is cached already. On x86 that is a locked read-modify-write
even when the comparison fails. sd-journal calls getpid_cached() in
every public function to detect use after fork(). Reading the entries
of a journal hence calls it once per entry and field.

Load the cached value first, and only fall back to the exchange if it
is not set. Reading 1M entries of a real journal takes about 2% fewer
cycles.
2026-10-08 19:52:29 +02:00
Lennart Poettering 4da00a0432 report: suppress some metrics of hw owned by the host on containers 2026-10-08 17:30:21 +02:00
Amogh Gurudatta 1fedf6810b hwdb: add force-release volume key quirk for Lenovo ThinkBook 16 G7 ARP (21MW)
The Embedded Controller (EC) on the Lenovo ThinkBook 16 G7 (Product
Name: 21MW) fails to transmit PS/2 break codes (E0 B0) for Volume Down
(ae) and Volume Up (b0) upon physical key release after auto-repeat
(long press). This causes the volume keys to become logically stuck
down in the Linux input subsystem. Adding the '!' force-release flag
instructs udev/evdev to automatically synthesize a release event
immediately upon receiving the keypress.
2026-10-08 17:28:56 +02:00