Commit Graph
4141 Commits
Author SHA1 Message Date
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
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
Lennart Poettering e7ce9e0954 sd-bus: drop a bunch of 'else'
With the new US taxes on bits and bytes let's reduce our footprint a
bit.
2025-05-17 00:18:24 +02:00
Daan De Meyer ef10d4b526 Bugprone argument comment - round 5 (#37481) 2025-05-15 20:33:50 +02:00
Jelle van der Waa ccf379b46e sd-varlink: fix argument comment
Follow-up for 52068c1e9c
2025-05-15 11:12:43 +02:00
Lennart Poettering 272017d32a socket-util: add trivial socket_get_cookie() helper 2025-05-15 09:45:19 +02:00
Daan De Meyer 08fd159db1 networkd-util: Avoid call to endswith()
Instead of recalculating the length of the string again after
reading it, let's make sd_netlink_message_read_string() return the
length of the string that we then use to check if the last character
is a dot or not.

This allows us to get rid of the string-util.h include in #37344.
2025-05-14 22:33:45 +02:00
Luca Boccassi 74acb358c5 test: fix assertion failure with CONFIG_UNIX_DIAG disabled
On OBS the build VM is heavily locked down, with network
disabled in various ways in the custom kernel, to isolate the
build, including disabling CONFIG_UNIX_DIAG.

[  456s] /* test_af_unix_get_qlen */
[  456s] src/test/test-socket-netlink.c:393: Assertion failed: Expected "af_unix_get_qlen(unix_fd, &q)" to succeed, but got error: No such file or directory

[  454s] /* test_sock_diag_unix */
[  454s] src/libsystemd/sd-netlink/test-netlink.c:727: Assertion failed: Expected "sd_netlink_call(nl, message, 0, &reply)" to succeed, but got error: No such file or directory

Follow-up for 89e546e927
Follow-up for 4a3bf440f2
2025-05-14 21:24:48 +01:00
Yu Watanabe 1ef6cee327 Bugprone argument comment - round 4 (#37380)
Follow up from https://github.com/systemd/systemd/pull/37356
2025-05-15 03:36:16 +09:00
Jelle van der Waa 2a1a6e5dd0 sd-device: fix argument comment chase_flags 2025-05-14 12:10:56 +02:00
Yu Watanabe 2012d6d74e device-util: introduce device_get_seat() helper function 2025-05-14 02:06:02 +09:00
Yu Watanabe ab1bd9daed device-util: introduce several more helper functions
This also makes device_in_subsystem() and device_is_devtype() return
negative error on critical error
2025-05-14 02:06:02 +09:00
Lennart Poettering 89e546e927 sd-netlink: add minimal support for sock_diag netlink sockets
This is just enough of the type info to determine AF_UNIX queue lengths
information.
2025-05-13 14:42:34 +02:00
Lennart Poettering 6e196011ca sd-netlink: allow configuration of flags parameter when creating message object
We soon want to add for sock_diag(7) netlink sockets. Those reuse the
same message type codes for request and response but with different
message formats. Hence we need to look at NLM_F_REQUEST to determine
which message policy to apply. Hence it is essential to know the flags
parameters right away when creating a message, since we cannot do early
validation otherwise.

This only adds support for setting the flags value right at the moment
of creation of the message object, it does not otherwise add
sock_diag(7) support, that is added in a later message.

This also corrects the flag for synthetic NLMSG_ERROR messages which
should not have the NLM_F_REQUEST flag set (since they are responses,
not requests).
2025-05-13 14:42:33 +02:00
Daan De Meyer 30d20907bd meson: Remove unneeded include directories
meson by default adds the current source and build directory as include
directories. Because we structure our meson code by gathering a giant dict
of everything we want to do and then doing all the actual target generation
in the top level meson.build, this behavior does not make sense at all because
we end up adding the top level repository directory as an include directory
which is never what we want.

At the same time, let's also make sure the top level directory of the build
directory is not an include directory, by moving the version.h generation
into the src/version subdirectory and then adding the src/version subdirectory
of the build directory as an include directory instead of the top level
repository directory.

Making this change means that language servers such as clangd can't get
confused when they automatically insert an #include line and insert
"#include "src/basic/fs-util.h" instead of "#include "fs-util.h".
2025-05-12 13:35:50 +02:00
Yu Watanabe e969ec1d51 sd-device: rename arguments
To make it consistent with its declaration and other function
prototypes.
2025-05-10 00:26:32 +09:00
Daan De Meyer 3b7d332047 macro: Reduce transitive includes 2025-05-09 11:33:31 +02:00
Daan De Meyer 3b58245624 basic: Override glibc's sys/param.h header with an empty file
Instead of unconditionally including sys/param.h in
macro-fundamental.h which itself includes a bunch of other unnecessary
headers, let's override it with an empty file to avoid it from overriding
our MAX() macro. We can't make including it an error as it's included (
for seemingly no good reason) by <resolv.h>.
2025-05-09 11:23:14 +02:00
anonymix007 907328749f sd-device: Introduce sd_device_get_sysattr_value_with_size() 2025-05-07 18:52:49 +03:00
Daan De Meyer e53d4f343d iovec-util: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer e548ca38b9 device-util: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer 6553db6063 strv: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer d9ccf6b349 path-util: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer fda652117e fs-util: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Zbigniew Jędrzejewski-Szmek 463c301fbb test-sd-login: add a "test" that just calls all sd_pid_get_* functions
As a test, it just increases our code coverage in a fake way.
When run manually, it can be used to conveniently print what logind
thinks about various processes:

$ build/test-sd-login
sd_pid_get_session(0) → No data available
sd_pid_get_unit(0) → user@1000.service
sd_pid_get_user_unit(0) → app-ghostty-transient-5088.scope
sd_pid_get_machine_name(0) → No such file or directory
sd_pid_get_slice(0) → user-1000.slice
sd_pid_get_user_slice(0) → app.slice
sd_pid_get_owner_uid(0) → 1000
sd_pid_get_cgroup(0) → /user.slice/user-1000.slice/user@1000.service/app.slice/app-ghostty-transient-5088.scope/surfaces/556FAF50BA40.scope

$ build/test-sd-login cgroup 1
sd_pid_get_cgroup(1) → /init.scope
2025-05-07 22:02:46 +09:00
Zbigniew Jędrzejewski-Szmek 8ae4cbb168 test-sd-device: drop chunk added by mistake
I initially wrote it this way, but then decided to implement a loop
limit, but forgot to drop the first approach in one place.
Fixup for 74cb65e45f.
2025-05-07 22:02:46 +09:00
Daan De Meyer 38c9ca5380 tree-wide: Remove strv_from_stdarg_alloca()
It's trivial to replace all uses of this function with STRV_MAKE()
and strv_new_ap() so let's get rid of this variant.
2025-05-06 17:40:01 +02:00