Commit Graph
975 Commits
Author SHA1 Message Date
Daan De Meyer 6350d2dbd9 meson: Extract objects instead of creating intermediate static libraries
Currently, when we want to add unit tests for code that is compiled into
an executable, we either compile the code at least twice (once for the
executable, and once for each test that uses it) or we create a static
library which is then used by both the executable and all the tests.

Both of these options are not ideal, compiling source files more than
once slows down the build for no reason and creating the intermediate
static libraries takes a lot of boilerplate.

Instead, let's use the extract_objects() method that meson exposes on
build targets. This allows us to extract the objects corresponding to
specific source files and use them in other executables. Because we
define all executables upfront into a dictionary, we integrate this into
the dictionary approach by adding two new fields:

- 'extract' takes a list of files for which objects should be extracted.
  The extracted objects are stored in a dict keyed by the executable name
  from which they were extracted.
- 'objects' takes the name of an executable from which the extracted
  objects should be added to the current executable.

One side effect of this approach is that we can't build test executables
anymore without building the main executable, so we stop building test
executables unless we're also building the main executable. This allows
us to switch to using subdir_done() in all of these subdirectories to skip
parsing them if the corresponding component is disabled.

These changes get me down from 2439 => 2403 ninja targets on a full rebuild
from scratch.
2025-05-12 13:35:50 +02:00
Daan De Meyer 76d62b63ef main-func: Reduce transitive includes
Let's move some logic from _DEFINE_MAIN_FUNCTION() and other places
in main-func.h into functions that we implement in main-func.c to
allow moving some included headers from the header to the .c file.
2025-05-06 10:07:27 +02:00
Daan De Meyer 792a8bfb8a daemon-util: Rename starting/stopping message constants
Currently, NOTIFY_READY from daemon-util.h conflicts with NOTIFY_READY
from NotifyState from service.h so let's rename the constants to avoid
the conflict.
2025-05-01 14:02:17 +02:00
Daan De Meyer 1cf40697e3 tree-wide: Sort includes
This was done by running a locally built clang-format with
https://github.com/llvm/llvm-project/pull/137617 and
https://github.com/llvm/llvm-project/pull/137840 applied on all .c
and .h files.
2025-04-30 09:30:51 +02:00
Yu Watanabe 3a03b97d6f tree-wide: drop unnecessary inclusion of tmpfile-util.h 2025-04-30 05:38:48 +09:00
Daan De Meyer ff43267ce7 machine: Remove circular header dependencies 2025-04-23 10:33:37 +02:00
Daan De Meyer 793e187718 basic: Remove circular dependency between process-util.h and pidref.h 2025-04-18 14:19:16 +02:00
Luca Boccassi bd9c55ebe2 import/export: add support for zstd 2025-04-15 12:21:30 +01:00
Yu Watanabe f501563ec3 machine: fix typo
Follow-up for a4019c75c2.
2025-04-07 16:49:43 +09:00
Luca Boccassi 5aee5bda1a tree-wide: introduce LOG_ITEM() macro for verifying format string (#36780)
This introduce `LOG_ITEM()` macro that checks format strings in
log_struct() and friends.

Hopefully, this silences false-positive warnings by Coverity.
2025-03-24 12:58:14 +00:00
Daan De Meyer 04a44e25b9 units: Add systemd-machined.socket 2025-03-19 09:28:12 +01:00
Yu Watanabe 3cf6a3a3d4 tree-wide: check more log message format in log_struct() and friends
This introduce LOG_ITEM() macro that checks arbitrary formats in
log_struct().
Then, drop _printf_ attribute from log_struct_internal(), as it does not
help so much, and compiler checked only the first format string.

Hopefully, this silences false-positive warnings by Coverity.
2025-03-19 01:56:48 +09:00
Lennart Poettering afdca6c6c2 nspawn,run,machinectl,socket-activate: propagate $COLORTERM + $NO_COLOR
When we pass information about our calling terminal on to some service
or command we invoke, propagate $COLORTERM + $NO_COLOR in addition to
$TERM, in order to always consider the triplet of the three env vars the
real deal.
2025-03-17 10:17:54 +01:00
Lennart Poettering 837849561b varlink: optionally create leading dirs when binding AF_UNIX socket
This is such a common case, let's make it easy to do this.
2025-03-04 18:07:17 +01:00
Yu Watanabe aa14f19398 basic/linux: import capability.h from kernel 6.14-rc4 2025-03-04 02:24:49 +09:00
Lennart Poettering ff03ac8730 machinectl: add OSC context support to login/shell commands 2025-02-27 15:09:25 +01:00
Lennart Poettering 8e0193aabf tree-wide: pass EBADF to fd params of namespace_fork() 2025-02-18 12:11:00 +01:00
Ivan Kruglov f6a7328e24 machine: introduce io.systemd.MachineImage.CleanPool 2025-02-04 03:03:00 -08:00
Ivan Kruglov 5a99c9d778 machine: use image_clean_pool_operation() in dbus 2025-02-04 03:03:00 -08:00
Ivan Kruglov a4019c75c2 machine: image_clean_pool_operation() 2025-02-04 03:03:00 -08:00
Ivan Kruglov 2694549ddf machine: rename machine_copy_from_to() -> machine_copy_from_to_operation()
This is done to make it clear that machine_copy_from_to() use and
returns an Operation object.
2025-02-04 02:58:48 -08:00
Yu Watanabe 4658651466 machine: revert type change of "leader" in io.systemd.Machine.Register method
The varlink method io.systemd.Machine.Register() is in v256, hence type
of "leader" cannot be changed.
Let's revert the change by 755cb018c9, and
introduce another field "leaderProcessId", which takes detailed information
of the process.

Fixes a regression caused by 755cb018c9.
Fixes #36155.
2025-01-27 10:18:25 +01:00
Yu Watanabe d7306348b2 tree-wide: insert a space at the end of comments 2025-01-25 05:24:23 +09:00
Lennart Poettering c8127075ae tree-wide: implement generic io.systemd.service Varlink interface in all long-running services
Given we have the generic interface, let's hook it up everywhere.

This doesnt bother with the Reload() call usually, since that's more
involved, but hooks up the other relevant functions where applicable.
2025-01-18 23:24:29 +01:00
Mike Yuan d693ba5f8e terminal-util: drop unused open_terminal_in_namespace()
With our baseline including TIOCGPTPEER we now systematically
open pty peer through ioctl(), i.e. this sits unused
since 1d522f1a86. Kill it!
2025-01-15 17:46:10 +01:00
Ivan Kruglov 8342390161 machine: introduce io.systemd.MachineImage.SetPoolLimit 2025-01-15 02:47:58 -08:00
Ivan Kruglov efe47f5895 machine: use image_set_pool_limit() in dbus 2025-01-15 02:47:58 -08:00
Lennart Poettering 1d522f1a86 terminal-util: drop support for pre-TIOCGPTPEER kernels
Our minimum baseline is now far beyond 4.13, hence let's drop these
fallback paths.
2025-01-15 10:39:04 +01:00
Mike Yuan ab33edb05b shared/bus-util: move bus_message_read_id128() to bus-message-util 2025-01-13 16:24:44 +01:00
Lennart Poettering 361327e929 convert more code to PidRef (#35895) 2025-01-11 23:14:33 +01:00
Lennart Poettering b25430deab terminal-util: pidref'ify two terminal related calls 2025-01-10 14:09:48 +01:00
Ivan Kruglov d423f231f7 machine: VARLINK_ERROR_MACHINE_IMAGE_* defines 2025-01-10 11:49:49 +01:00
Ivan Kruglov c85e837744 machine: VARLINK_ERROR_MACHINE_* defines 2025-01-10 11:49:49 +01:00
Ivan Kruglov 6b77efe47e machine: fix logging of errno in machine_open_root_directory() 2025-01-10 11:49:49 +01:00
Ivan Kruglov 04bf637e25 machine: set SD_VARLINK_SERVER_ALLOW_FD_PASSING_OUTPUT for varlink server 2025-01-09 10:51:18 +01:00
Ivan Kruglov 8633bf5836 machine: introduce io.systemd.Machine.OpenRootDirectory 2025-01-09 10:51:18 +01:00
Ivan Kruglov 307458a6f4 machine: use machine_open_root_directory() in dbus 2025-01-09 10:51:18 +01:00
Ivan Kruglov 65275cfbe5 machine: machine_open_root_directory() 2025-01-09 10:51:18 +01:00
Yu Watanabe 2bef5d187d machine: update log message and comments
Follow-up for 9af9d66184 and
453f2359ff.
2025-01-07 09:11:09 +01:00
Lennart Poettering 237aca5fbe machine: switch to using cleanup handling for child process cleanup 2025-01-06 23:37:45 +01:00
Lennart Poettering c0381ba6e8 machine: transition back to host mount ns before copying files from/to container
When copying files from or to a container we so far opened the host side
fd first, then entered the container (specifically, joined it's mount
namespace) in a forked off child process, and opened the other side
there, followed by the (potentially slow) copying from inside the
container mount namespace.

This commit changes this so that we rejoin the host mount namespace
before doing the copying routine. This is relevant, so that we can rely
on /proc/self/fd/… to work, which is not the case otherwise, as we'll
see /proc/ from a pidns that is not our own, in wich case
/proc/self/fd/… is refused. By moving back to the host mount namespace
our own pidns and the pidns the /proc/ mount belongs to will be in sync
again, and all is good.

This is in particular preparation for the next commit, that makes the
copy routine strictly depending on /proc/ being accessible and working.
2025-01-06 23:37:45 +01:00
Ivan Kruglov 453f2359ff machine: introduce io.system.Machine.{CopyFrom, CopyTo} methods 2025-01-06 14:51:57 +01:00
Ivan Kruglov 8632e7ae23 machine: use machine_copy_from_to() in dbus implementation 2025-01-06 14:51:57 +01:00
Ivan Kruglov 9af9d66184 machine: introduce machine_copy_from_to() helper 2025-01-06 14:51:57 +01:00
Ivan Kruglov 347a1105a4 machine: split operation initialization into two steps 2025-01-06 14:41:49 +01:00
Ivan Kruglov ee71079aba machine: adjust operation callback logic for varlink
This is to simplyfy varlink callback. There is no use of this logic atm.
So, no harm.
2025-01-06 14:41:49 +01:00
Daan De Meyer eaf0f79293 machine: several follow-ups for #35066 (#35868)
Addresses the post-merge review comments.
2025-01-06 11:59:55 +01:00
Yu Watanabe 8551ac2092 machine: use json_dispatch_const_path() where applicable
Follow-up for #35066 and 3866e9ce9d.
2025-01-06 17:09:43 +09:00
Mike Yuan 92b8e5e72f namespace-util: introduce pidref_in_same_namespace() 2025-01-04 17:08:01 +01:00
Mike Yuan 0577339d7d various: add missing include for namespace-util.h
Preparation for later commits for removing inclusion
of namespace-util from process-util.h
2025-01-04 17:08:00 +01:00