Commit Graph
4166 Commits
Author SHA1 Message Date
Arkadiusz Bokowy 998aa62a21 sd-bus: Preserve interfaces addition order
When adding a new interface to the object add it at the end of the list.
This way, when iterating over the list, e.g., during handling introspect
call, the order of returned interfaces will mach the order in which they
were added.
2025-06-17 17:28:35 +09:00
Mike Yuan 6fdb6c73ae sd-bus: port to machine_spec_valid() 2025-06-17 01:39:57 +02:00
Yu Watanabe 169d270e81 meson: update generating lists
- config.h is not necessary when generating lists, hence drop it.
- linux/audit.h and libaudit.h are included by missing_audit.h,
  hence not necessary to include them explicitly.
2025-06-09 16:29:49 +01:00
Luca Boccassi f245fa0058 test: do not fail when lacking privs to create sysfs directory
4109s /* test_mdio_bus */
4109s src/libsystemd/sd-device/test-sd-device.c:55: Assertion failed: Expected "mkdir_p(syspath, 0755)" to succeed, but got error: Permission denied
4109s (mdio_bus) terminated by signal ABRT.
4109s src/libsystemd/sd-device/test-sd-device.c:37: Assertion failed: Expected "r = safe_fork("(mdio_bus)", FORK_CLOSE_ALL_FDS|FORK_DEATHSIG_SIGTERM|FORK_REOPEN_LOG|FORK_LOG|FORK_WAIT|FORK_NEW_MOUNTNS|FORK_MOUNTNS_SLAVE, NULL)" to succeed, but got error: Protocol error

Follow-up for 687a92a1b6
2025-06-09 15:11:30 +09:00
Yu Watanabe 6c2558a2fc tree-wide: allow building with -Wgnu-variable-sized-type-not-at-end option for clang (#37499)
Follow-up for #36993.
Closes #37497.
2025-06-07 01:02:38 +09:00
Yu Watanabe 687a92a1b6 sd-device: replace '!' with '/' before calling sd_device_new_from_subsystem_sysname()
Device ID uses device directory name as is, hence may contain '!', but
sd_device_new_from_subsystem_sysname() expects that the input is sysname.
So, we need to replace '!' with '/'.

Follow-up for 1393c5a2a4.
Fixes #37711.
2025-06-06 23:59:02 +09:00
A. Wilcox 6b783209a8 tree-wide: basename -> path_extract_filename 2025-06-06 19:06:48 +09:00
Lennart Poettering 5ee8b3edb3 journal: replace a bunch of assert() with friendlier checks
We should not rely that data stored in the journal files remains
entirely untouched at all times. Because we unallocate files, data might
go away any time. Hence, never assert() on any expectations on what the
file contains. Instead, handle it more gracefully as a corruption issue,
and return EBADMSG.

Fixes: #35229 #32436
2025-06-05 22:31:41 +02:00
Lennart Poettering 813facd3ba journal: add 'const' at one more place 2025-06-05 22:31:40 +02:00
Lennart Poettering b16cb30edd journal: determine compression once, not twice
This is just paranoia: let's determine the compression to use once,
instead of twice, after all te data is in journal files which might be
corrupted any time, and it would be weird if we came to different
results here each time.
2025-06-05 22:31:39 +02:00
Lennart Poettering 7d52a60843 journal: use EBADMSG for invalid data in file mmap
We must assume that any data in the mmap can change anytime because the
file is deallocated or similar. Let's strictly use EBADMSG for reporting
invalid file contents though (as opposed to using EINVAL if our own code
passes a wrong parameter somwhere).
2025-06-05 22:31:21 +02:00
Lennart Poettering a589e1bd9e varlink-util: format system errors via %m in varlink_call_and_log()
This kinda does what bee59ab901 did for
varlinkctl also for the generic varlink_call_and_log() handler.
2025-06-05 14:28:14 +02:00
Lennart Poettering 79226d797d sd-bus: treat '@' as equivalent to '@.host'
We allow omission of the part before and the part after the @. But so
far we didn't allow omitting both. There's no real reason for
disallowing that, hence be systematic and allow it.
2025-06-05 12:49:42 +02:00
Lennart Poettering 2ae32e9d8f sd-bus: port to split_user_at_host() 2025-06-05 12:49:35 +02:00
Mike Yuan 46b0844743 sd-daemon: add sd_pidfd_get_inode_id()
We nowadays expose pidfdid at various places, e.g. envvars
and dbus properties. Also the sd_notify() MAINPID= message
has been complemented with MAINPIDFDID=. But acquiring
pidfdid is actually non-trivial especially considering
the 32-bit case, hence let's introduce a public helper
in sd-daemon specifically for that purpose.
2025-06-05 01:35:08 +02:00
Mike Yuan 68db777ae2 sd-login: reject invalid pidfd with -EBADF consistently
We got it mostly right except for one function, fix it.
2025-06-05 00:28:00 +02:00
Lennart Poettering 4f4113ee33 sd-login: various modernizations (#37728) 2025-06-04 22:24:57 +02:00
Lennart Poettering 9151a60a4e journal-file: let's make journal_file_copy_entry() robust against concurrent writing of the source
As usual, we need to protect ourselves against concurrent modification
of journal files. We a pretty good at that these days when reading
journal files. But journal_file_copy_entry() so far wasn't too good with
that. journal_file_append_data() so far returned EINVAL when you pass
invalid data to it. Since we pass the source data as-is in there, it's
going to fail if the journal source file is slightly invalid due to a
concurrent update.

Hence, we need to validate data gracefully here that we think comes from
a safe place, because actually it doesn't, it's directly copied from an
unsafe journal file.

Hence, let's introduce a clear error code here, and look for it in
journal_file_copy_entry(), and handle it gracefully.

Pretty sure this fixes #33372, but it's a race, so I don't know for
sure. If this remains reproducible we need to look at this again.

Fixes: #33372
2025-06-04 18:05:58 +02:00
Lennart Poettering eb78010898 sd-login: port sd_peer_get_cgroup() to SO_PEERPIDFD 2025-06-04 17:58:44 +02:00
Lennart Poettering e2af482f0a sd-login: place inner part of sd_login_monitor_new() by a table 2025-06-04 17:58:43 +02:00
Lennart Poettering eac4a028df sd-login: modernize return parameter handling
Let's rename the return parameters as "ret_xyz" systematically in
sd-login.

Also, let's make the return parameters systematically optional, like we
typically do these days. So far some where optional, other's weren't.
Let's clean this up.
2025-06-04 17:58:42 +02:00
Jelle van der Waa 095031683f treewide: correct argument comments for sd_netlink_call 2025-06-04 13:32:24 +02:00
Jelle van der Waa edffcc84f2 sd-varlink: correct argument comment 2025-06-04 10:52:59 +02:00
Yu Watanabe dbef4dd4f2 sd-event: move flex array in struct inotify_data to the end 2025-06-04 13:13:14 +09:00
Yu Watanabe ddfe2afbd3 sd-journal: drop unnecessary use of dummy_t
Then, make flex arrays to zero-length arrays, as union cannot have
flex arrays, even though flex and zero-length arrays are effectively
equivalent.
2025-06-04 13:13:14 +09:00
Yu Watanabe 545814714c sd-journal: replace sizeof(ObjectHeader) with offsetof(ObjectHeader, payload)
Note, the preceding fields have size that is a multiple of 8 bytes,
so the end of `.size` is aligned, thus
`offsetof(ObjectHeader, payload) == sizeof(ObjectHeader)`.
2025-06-04 13:13:14 +09:00
Yu Watanabe 462d287bc9 sd-journal: variable sized array cannot be used in ObjectHeader
The struct ObjectHeader is embedded in real object structs.
Hence, the existence of the flex array in ObjectHeader violates the
requirement that flex array must be at the end of struct.
2025-06-04 13:13:14 +09:00
Jelle van der Waa 2bfa3185aa sd-journal: rename sd_journal_get_monotonic_usec ret argument
Rename ret to ret_monotonic to distinguish from ret_boot_id and
according to existing argument comments.
2025-06-02 17:39:44 +02:00
Zbigniew Jędrzejewski-Szmek 9e2befbf4b sd-device: do not include file name directly in error messages
$ diff -u <(strings -n 10 build/libsystemd.so.0.40.0.0 | sort) <(strings -n 10 build/libsystemd.so.0.40.0 | sort)
--- /proc/self/fd/11    2025-05-31 15:17:16.968761963 +0200
+++ /proc/self/fd/12    2025-05-31 15:17:16.970159823 +0200
@@ -3860,11 +3860,6 @@
 Failed to fstat() journal file '%s', ignoring: %m
 Failed to fstat %s: %m
 Failed to get basic: %m
-Failed to get device "ACTION" property, ignoring: %m
-Failed to get device "DEVNUM" property, ignoring: %m
-Failed to get device "DISKSEQ" property, ignoring: %m
-Failed to get device "IFINDEX" property, ignoring: %m
-Failed to get device "SEQNUM" property, ignoring: %m
 Failed to get device "%s" property, ignoring: %m
 Failed to get inode number of pidfd for pid %i: %m
 Failed to get peer's socket address, ignoring: %m

$ ls -l build/libsystemd.so.0.40.0{,.0}
-rwxr-xr-x 1 zbyszek zbyszek 7631640 May 31 15:16 build/libsystemd.so.0.40.0
-rwxr-xr-x 1 zbyszek zbyszek 7635736 May 31 15:16 build/libsystemd.so.0.40.0.0

$ size build/libsystemd.so.0.40.0{,.0}
   text    data     bss     dec     hex filename
1241382   56185    3554 1301121  13da81 build/libsystemd.so.0.40.0
1241606   56185    3554 1301345  13db61 build/libsystemd.so.0.40.0.0

So the savings are ~4kB, which is more than I expected.
2025-05-31 15:35:02 +02:00
Yu Watanabe d117687ab3 sd-bus: rename internal structs and enums
This renames e.g. struct bus_body_part -> BusMessageBodyPart to
follow our usual coding style. Also, several struct and enum
declarations are moved to relevant headers.
Also, this introduces bus-forward.h.
2025-05-28 09:52:28 +02:00
Daan De Meyer 4793dbc56e core: introduce io.systemd.Unit.List (first PR) (#37432) 2025-05-27 12:42:11 +02:00
Lennart Poettering 5c5934c62d mountfsd: add ability to create dir owned by foreign UID range in unpriv $HOME (#37616) 2025-05-27 12:20:05 +02:00
Lennart Poettering cb062410ec sd-json: add json_dispatch_const_filename()
json_dispatch_const_filename() is to json_dispatch_filename() what json_dispatch_const_path() is to json_dispatch_path().
2025-05-27 10:37:11 +02:00
Lennart Poettering 4b9c918431 machine: use the correct escaping calls for machine metadata 2025-05-27 10:23:36 +02:00
Ivan Kruglov 643622f850 json: json_dispatch_const_unit_name() 2025-05-27 01:16:56 -07:00
Daan De Meyer a6f4a9c07b netlink-internal: Make message_get_serial() static inline again
There was no need to move this function to the implementation file,
so let's make it static inline again.

Follow up for #37591.
2025-05-24 20:44:32 +02:00
Daan De Meyer 4cfd024e73 forward: Move ChaseFlags forward declaration to forward.h 2025-05-24 20:44:12 +02:00
Daan De Meyer 5cdf13c70c libsystemd: Clean up includes
For libsystemd's headers, the changes made depend on whether the
header is installed or not. For installed headers, the only change
made is that commonly included headers were moved to _sd-common.h.
For these headers, there should be no noticeable change in behavior
when including them. For non-installed headers, includes were replaced
with forward declarations where possible as usual.

Split out of #37344.
2025-05-25 03:40:24 +09:00
Daan De Meyer b416ac0e15 basic: Move ratelimit logging functions to log-ratelimit.h 2025-05-25 03:28:50 +09:00
Jelle van der Waa 6217935422 sd-bus: prefix return arguments with 'ret_' for sd_bus_message_peek_type 2025-05-24 16:58:55 +02:00
Daan De Meyer 69a283c5f2 shared: Clean up includes
Split out of #37344.
2025-05-24 14:00:44 +02:00
Daan De Meyer 1e35e81b2c tree-wide: Clean up includes
Preparation for cleaning up includes in src/shared.
2025-05-22 21:10:15 +02:00
Daan De Meyer 5ea01af240 meson: Use .inc for generated code meant to be included in other files
These files use the .h extension but are not standalone so let's not
make it appear like they are proper headers and instead use the .inc
extension.
2025-05-22 11:25:29 +02:00
Jelle van der Waa 26b5eea47f sd-login: rename sd_seat_get_active arguments
Follow the argument comment naming.
2025-05-21 10:50:48 +02:00
Jelle van der Waa c670f828f1 sd-bus: rename cookie to ret_cookie
Follow the argument comment naming.
2025-05-21 10:50:25 +02:00
Jelle van der Waa 00299a80f7 sd-event: rename 's' -> 'ret' 2025-05-21 10:50:25 +02:00
Lennart Poettering 7928c0e0a1 resolved: add concept of delegating lookups below certain domains to specific DNS servers
This permits configuration of additional "delegates" which ensure that
lookups for certain DNS zones are routed to specific sets of DNS
servers, in addition to the routes we create for each network interface.

For now, this allows only static configuration, but eventually we should
open this up to IPC.

Fixes: #5573 #14159 #20485 #21260 #24532 #32022

(Fixes #32022, because now redundant)
2025-05-20 23:00:03 +02:00
Daan De Meyer d86fead481 meson: Rework clang-tidy integration to be done via unit tests
Instead of using run-clang-tidy.py with its own scheduling, let's
just gather a list of source files ourselves and then use that to
add a unit test for each source file that runs clang-tidy on the
source file.

We also add a bit of logic to run clang-tidy on most header files
as well for extra coverage. This uncovered various header files that
were not standalone so this commit also includes fixes to make sure
the clang-tidy tests are all green.

We can also use this in a later commit to run clang-include-cleaner
on each source file in the same way.
2025-05-20 10:29:59 +02:00
Daan De Meyer d94c24e9cc sd-varlink: Expose sd_varlink_idl_parse()
We're planning to do code generation based on the systemd varlink
APIs. To simplify this, let's expose the IDL parser, so we can use
it to do code generation instead of having to write our own IDL
parser.
2025-05-19 15:19:24 +02:00
Daan De Meyer 34f714349b sd-varlink: Fix argument names of sd_varlink_idl_parse() 2025-05-19 15:08:16 +02:00