Commit Graph
967 Commits
Author SHA1 Message Date
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
Daan De Meyer d0d647e084 Introduce systemd-pty-forward (#35761)
This allows running a command with tinted terminal background.
2025-01-03 19:34:42 +01:00
Daan De Meyer 9fbecf12fb tree-wide: Rename ret_slave to ret_peer 2025-01-03 09:28:13 +01:00
Ivan Kruglov d12b63f168 machine: introduce io.systemd.Machine.BindMount method 2025-01-02 16:58:16 +01:00
Yu Watanabe 51a0a3b049 machine: GC machine when no leader PID is set
After d8854ff1ac, if a serialized
leader PID of a machine is already dead when deserialized, then the
leader PID and PIDFD are unset for the machine, and subsequent
machine_start() -> machine_watch_pidfd() will trigger an assertion.
This makes a Machine object without leader PID GCed.

Fixes a bug introduced by the combination of
d8854ff1ac (v255) and
1762c2c045 (v257).

Fixes #35602.
2024-12-28 12:03:20 +00:00
Ivan Kruglov 544b7718b3 machine: add debugging info to trace #35115 2024-12-23 16:38:22 +00:00
Lennart Poettering 1c0ade2e1f discover-image: introduce per-user image directories
We nowadays support unprivileged invocation of systemd-nspawn +
systemd-vmspawn, but there was no support for discovering suitable disk
images (i.e. no per-user counterpart of /var/lib/machines). Add this
now, and hook it up everywhere.

Instead of hardcoding machined's, importd's, portabled's, sysupdated's
image discovery to RUNTIME_SCOPE_SYSTEM I introduced a field that make
the scope variable, even if this field is always initialized to
RUNTIME_SCOPE_SYSTEM for now. I think these four services should
eventually be updated to support a per-user concept too, this is
preparation for that, even though it doesn't outright add support for
this.

This is for the largest part not user visible, except for in nspawn,
vmspawn and the dissect tool. For the latter I added a pair of
--user/--system switches to select the discovery scope.
2024-12-20 18:04:01 +01:00
Yu Watanabe 64b504bde3 machinectl: explicitly assign PTY forwarder to sd_bus_slot
No functional change, just refactoring.
2024-12-18 20:28:28 +09:00
Yu Watanabe 12807b5a49 ptyfwd: always flush buffer and disconnect before exit
Then, it is not necessary to manually drain PTY forwarder by the user
side. Also, not necessary to free PTY forwarder earlier explicitly to
make it disconnected.
2024-12-18 20:28:07 +09:00