1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-09 01:18:19 +03:00
Commit Graph

68401 Commits

Author SHA1 Message Date
Lennart Poettering
1761066b13 storagetm: add new systemd-storagetm component
This implements a "storage target mode", similar to what MacOS provides
since a long time as "Target Disk Mode":

        https://en.wikipedia.org/wiki/Target_Disk_Mode

This implementation is relatively simple:

1. a new generic target "storage-target-mode.target" is added, which
   when booted into defines the target mode.

2. a small tool and service "systemd-storagetm.service" is added which
   exposes a specific device or all devices as NVMe-TCP devices over the
   network.  NVMe-TCP appears to be hot shit right now how to expose
   block devices over the network. And it's really simple to set up via
   configs, hence our code is relatively short and neat.

The idea is that systemd-storagetm.target can be extended sooner or
later, for example to expose block devices also as USB mass storage
devices and similar, in case the system has "dual mode" USB controller
that can also work as device, not just as host. (And people could also
plug in sharing as NBD, iSCSI, whatever they want.)

How to use this? Boot into your system with a kernel cmdline of
"rd.systemd.unit=storage-target-mode.target ip=link-local", and you'll see on
screen the precise "nvme connect" command line to make the relevant
block devices available locally on some other machine. This all requires
that the target mode stuff is included in the initrd of course. And the
system will the stay in the initrd forever.

Why bother? Primarily three use-cases:

1. Debug a broken system: with very few dependencies during boot get
   access to the raw block device of a broken machine.

2. Migrate from system to another system, by dd'ing the old to the new
   directly.

3. Installing an OS remotely on some device (for example via Thunderbolt
   networking)

(And there might be more, for example the ability to boot from a
laptop's disk on another system)

Limitations:

1. There's no authentication/encryption. Hence: use this on local links
   only.

2. NVMe target mode on Linux supports r/w operation only. Ideally, we'd
   have a read-only mode, for security reasons, and default to it.

Future love:

1. We should have another mode, where we simply expose the homed LUKS
   home dirs like that.

2. Some lightweight hookup with plymouth, to display a (shortened)
   version of the info we write to the console.

To test all this, just run:

    mkosi --kernel-command-line-extra="rd.systemd.unit=storage-target-mode.target" qemu
2023-11-02 14:19:32 +01:00
Lennart Poettering
3b516db71d glyph-util: add computer disk + world emoji 2023-11-02 14:19:32 +01:00
Lennart Poettering
0adb58c3f1 sd-netlink: add call to query sd_event object an sd_netlink object is attached to
This mimics a similar call sd_bus_get_event() that already exists for
sd-bus.
2023-11-02 14:19:32 +01:00
Lennart Poettering
50ab93eb0e blockdev-util: export block_device_get_originating() 2023-11-02 14:19:32 +01:00
Lennart Poettering
de7e033286 udevadm-lock: switch things over to lock_generic_with_timeout()
This replaces the local implementation of a timeout file lock with our
new generic one.

Note that a comment in the old code claimed we couldn't use alarm()-like timeouts,
but htat's not entirely true: we can if we use SIGKILL, and thus know
for sure that the process will be dead in case the timer is hit before
we actually enter the file lock syscall. But we also know it will be
delivered if we hit after.
2023-11-02 14:19:32 +01:00
Lennart Poettering
e5f1e8b894 lock-util: add a new lock_generic_with_timeout() helper
This is just like lock_generic(), but applies the lock with a timeout.
This requires jumping through some hoops by executing things in a child
process, so that we can abort if necessary via a timer. Linux after all
has no native way to take file locks with a timeout.
2023-11-02 14:19:32 +01:00
Lennart Poettering
e9ccae3135 process-util: add new FORK_DEATHSIG_SIGKILL flag, rename FORK_DEATHSIG → FORK_DEATHSIG_SIGTERM
Sometimes it makes sense to hard kill a client if we die. Let's hence
add a third FORK_DEATHSIG flag for this purpose: FORK_DEATHSIG_SIGKILL.

To make things less confusing this also renames FORK_DEATHSIG to
FORK_DEATHSIG_SIGTERM to make clear it sends SIGTERM. We already had
FORK_DEATHSIG_SIGINT, hence this makes things nicely symmetric.

A bunch of users are switched over for FORK_DEATHSIG_SIGKILL where we
know it's safe to abort things abruptly. This should make some kernel
cases more robust, since we cannot get confused by signal masks or such.

While we are at it, also fix a bunch of bugs where we didn't take
FORK_DEATHSIG_SIGINT into account in safe_fork()
2023-11-02 14:09:23 +01:00
Lennart Poettering
61c062f896 fd-util: add new FORMAT_PROC_PID_FD_PATH() helper
This is just like FORMAT_PROC_FD_PATH() but goes via the PID number
rather than the "self" symlink.

This is useful whenever we want to generate a path that is useful
outside of our local scope.
2023-11-02 14:09:23 +01:00
Luca Boccassi
c13e6c720d mkosi: explicitly disable KVM in GHA runs
mkosi detects whether /dev/kvm is available and uses it if it is. But
some GHA hosts have it, but it's broken and not supported, so we need
to explicitly disable it.
2023-11-02 12:16:11 +00:00
Yu Watanabe
c57ff6230e NEWS: several updates for networking 2023-11-02 15:36:29 +09:00
Lennart Poettering
f1b622a00c varlink,json: introduce new varlink_dispatch() helper
varlink_dispatch() is a simple wrapper around json_dispatch() that
returns clean, standards-compliant InvalidParameter error back to
clients, if the specified JSON cannot be parsed properly.

For this json_dispatch() is extended to return the offending field's
name. Because it already has quite a few parameters, I then renamed
json_dispatch() to json_dispatch_full() and made json_dispatch() a
wrapper around it that passes the new argument as NULL. While doing so I
figured we should also get rid of the bad= argument in the short
wrapper, since it's only used in the OCI code.

To simplify the OCI code this adds a second wrapper oci_dispatch()
around json_dispatch_full(), that fills in bad= the way we want.

Net result: instead of one json_dispatch() call there are now:

1. json_dispatch_full() for the fully feature mother of all dispathers.
2. json_dispatch() for the simpler version that you want to use most of
   the time.
3. varlink_dispatch() that generates nice Varlink errors
4. oci_dispatch() that does the OCI specific error handling

And that's all there is.
2023-11-02 01:19:21 +00:00
Frantisek Sumsal
d0404391e5 fuzz: limit the size of the input
To avoid timeouts in oss-fuzz. The timeout reported in #29736 happened
with a ~500K test case, so with a conservative 128K limit we should
still be well within a range for any reasonable-ish generated input to
get through, while avoiding timeouts.

Resolves: #29736
2023-11-01 23:08:19 +00:00
Joerg Behrmann
43fe529e0f NEWS: more typo fixes 2023-11-02 05:55:40 +09:00
Luca Boccassi
79e1f7091f
Merge pull request #29816 from bluca/rel
Busywork for RC1
2023-11-01 20:14:11 +00:00
Frantisek Sumsal
68a5300f79 NEWS: fix a couple of typos and inconsistencies
And drop one duplicated paragraph.
2023-11-01 20:08:37 +00:00
Yu Watanabe
f5a0831c32
Merge pull request #29817 from YHNdnzj/fchmodat2
Add support for fchmodat2 and use it where appropriate
2023-11-02 04:56:29 +09:00
Lennart Poettering
b71a721fbc parse-util: add parse_tristate() and use it everywhere
We parse tristates all the time, let's add an explicit parser for them.
2023-11-02 04:52:16 +09:00
dependabot[bot]
6a4d0efa00 build(deps): bump meson from 1.2.2 to 1.2.3 in /.github/workflows
Bumps [meson](https://github.com/mesonbuild/meson) from 1.2.2 to 1.2.3.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/1.2.2...1.2.3)

---
updated-dependencies:
- dependency-name: meson
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-01 19:28:19 +00:00
dependabot[bot]
ca4d726205 build(deps): bump ninja from 1.11.1 to 1.11.1.1 in /.github/workflows
Bumps [ninja](https://github.com/ninja-build/ninja) from 1.11.1 to 1.11.1.1.
- [Release notes](https://github.com/ninja-build/ninja/releases)
- [Commits](https://github.com/ninja-build/ninja/commits)

---
updated-dependencies:
- dependency-name: ninja
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-01 17:30:30 +00:00
Lennart Poettering
423e2400af sort-util: make bsearch_safe() actually typesafe, by returning the right type 2023-11-01 17:18:15 +00:00
Arseny Maslennikov
30462563b1
nspawn-patch-uid: try fchmodat2() to restore mode of symlink
Prior to this commit, if the target had been a symlink, we did nothing
with it. Let's try with fchmodat2() and skip gracefully if not supported.

Co-authored-by: Mike Yuan <me@yhndnzj.com>
2023-11-02 00:29:09 +08:00
Arseny Maslennikov
adecfb3bc0
basic/fs-util: prefer fchmodat2 in fchmod_opath
Co-authored-by: Mike Yuan <me@yhndnzj.com>
2023-11-02 00:26:22 +08:00
Arseny Maslennikov
c21566d90b
basic/missing_syscall: add missing_fchmodat2()
Follow-up for 8b45281daa
and preparation for later commits.

Since libcs are more interested in the POSIX `fchmodat(3)`, they are
unlikely to provide a direct wrapper for this syscall. Thus, the headers
we examine to set `HAVE_*` are picked somewhat arbitrarily.

Also, hook up `try_fchmodat2()` in `test-seccomp.c`. (Also, correct that
function's prototype, despite the fact that mistake would not matter in
practice)

Co-authored-by: Mike Yuan <me@yhndnzj.com>
2023-11-02 00:23:12 +08:00
Lukas Nykryn
2b5b25f123 udev: add new builtin net_driver
Currently the ID_NET_DRIVER is set in net_setup_link builtin.
But this is called pretty late in the udev processing chain.

Right now in some custom rules it was workarounded by calling ethtool
binary directly, which is ugly.

So let's split this code to a separate builtin.
2023-11-01 16:00:19 +00:00
Lennart Poettering
c2ba2625d7 man: run ninja update-man-rules again
Apparently this has been forgotten a couple of times.
2023-11-01 16:02:05 +01:00
Lennart Poettering
9c21cfdd7d chase: fix corner case when using CHASE_PARENT with a path ending in ".."
If we use CHASE_PARENT on a path ending in ".." then things are a bit
weird, because we the last path we look at is actually the *parent* and not
the *child* of the preceeding path. Hence we cannot just return the 2nd
to last fd we look at. We have to correct it, by going *two* levels up,
to get to the actual parent, and make sure CHASE_PARENT does what it
should.

Example: for the path /a/b/c chase() with CHASE_PARENT will return
/a/b/c as path, and the fd returned points to /a/b. All good.  But now,
for the path /a/b/c/.. chase() with CHASE_PARENT would previously return
/a/b as path (which is OK) but the fd would point to /a/b/c, which is
*not* the parent of /a/b, after all! To get to the actual parent of
/a/b we have to go *two* levels up to get to /a.

Very confusing. But that's what we here for, no?

@mrc0mmand ran into this in https://github.com/systemd/systemd/pull/28891#issuecomment-1782833722
2023-11-01 14:43:24 +00:00
Luca Boccassi
7c2fd96dba
Merge pull request #29764 from dtardon/varlink-io.systemd.service
Add varlink interface io.systemd.service
2023-11-01 14:41:58 +00:00
Luca Boccassi
df594373a4
Merge pull request #29691 from yuwata/dissect
udev: update devlink with the newer device node even when priority is equivalent
2023-11-01 14:36:28 +00:00
Lennart Poettering
ac110243a8 bsod,loop-util: fix fd validity check 2023-11-01 15:21:20 +01:00
Lennart Poettering
943aca96f7 proc-cmdline: use read_virtual_file() for /proc/cmdline 2023-11-01 15:20:54 +01:00
Lennart Poettering
5c2597ab07
Merge pull request #29788 from poettering/nspawn-barrier-fix
nspawn: fix barriers when wiping fully visible procfs/sysfs
2023-11-01 15:20:15 +01:00
Lennart Poettering
a3b46c6bf6 cryptenroll: use erase_and_free() at two more places 2023-11-01 15:19:10 +01:00
Luca Boccassi
e37f3a12b2 meson: bump versions for v255-rc1 2023-11-01 14:07:54 +00:00
Luca Boccassi
6636cc54e5 Update syscalls table 2023-11-01 14:07:54 +00:00
Luca Boccassi
4561c679bc tools: syscall tables moved to a subdirectory 2023-11-01 14:07:54 +00:00
Luca Boccassi
73b2d48558 Update hwdb autosuspend rules 2023-11-01 14:07:54 +00:00
Luca Boccassi
f54ca611ea Update hwdb 2023-11-01 14:07:54 +00:00
Luca Boccassi
68ef4c570c NEWS: add contributors list 2023-11-01 14:07:54 +00:00
Yu Watanabe
4314abf6d4 sd-netlink: res_id is 16bit but serial is 32bit
The explicit value here is not so important.
Let's chop off the higher bits.

Fixes the issue reported at
https://github.com/systemd/systemd/pull/29802#issuecomment-1788637950.
2023-11-01 14:02:49 +00:00
Luca Boccassi
070243ecda
Merge pull request #29803 from poettering/coredump-message-tweaks
coredump: tweaks to log message & more
2023-11-01 13:20:11 +00:00
Yu Watanabe
498a6de596 dhcp6: enterprise ID is 32bit
Follow-up for 6b44099b3b.

Fixes #29800.
2023-11-01 13:19:59 +00:00
dependabot[bot]
094632a0ef build(deps): bump actions/checkout from 4.1.0 to 4.1.1
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](8ade135a41...b4ffde65f4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-01 12:32:55 +00:00
dependabot[bot]
ac60a3a41e build(deps): bump redhat-plumbers-in-action/differential-shellcheck
Bumps [redhat-plumbers-in-action/differential-shellcheck](https://github.com/redhat-plumbers-in-action/differential-shellcheck) from 4.2.2 to 5.0.1.
- [Release notes](https://github.com/redhat-plumbers-in-action/differential-shellcheck/releases)
- [Changelog](https://github.com/redhat-plumbers-in-action/differential-shellcheck/blob/main/docs/CHANGELOG.md)
- [Commits](ac4483d8c6...aa647ec446)

---
updated-dependencies:
- dependency-name: redhat-plumbers-in-action/differential-shellcheck
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-01 12:30:41 +00:00
dependabot[bot]
f211277934 build(deps): bump ossf/scorecard-action from 2.2.0 to 2.3.1
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.2.0 to 2.3.1.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](08b4669551...0864cf1902)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-01 12:26:57 +00:00
David Tardon
1263055121 varlink: add generic impl. of io.systemd.service.SetLogLevel() 2023-11-01 12:50:52 +01:00
Yu Watanabe
4ef83d9c88 udev: revert workarounds for issues caused by the devlink creation optimization
This reverts the following two commits:
- "udev: decrease devlink priority for encrypted partitions"
  c4521fc17b.
- "udev: decrease devlink priority for iso disks"
  df1dccd255.

These commits are workarounds for issues caused by
331aa7aa15.
With the previous commit, these workarounds are not necessary anymore,
as partitions are always processed later than their whole disk, and
a decrypted volume is also processed later than its backing volume.
2023-11-01 19:47:00 +09:00
Yu Watanabe
7ec5ce5673 udev: update devlink with the newer device node even when priority is equivalent
Several udev rules depends on the previous behavior, i.e. that udev
replaces the devlink with the newer device node when the priority is
equivalent. Let's relax the optimization done by
331aa7aa15.

Follow-up for 331aa7aa15.

Note, the offending commit drops O(N) of file reads per uevent, and this
commit does not change the computational order. So, hopefully the
performance impact of this change is small enough.

Fixes #28141.
2023-11-01 19:46:03 +09:00
André Paiusco
d397191b6d man: Improve text for SystemMaxFileSize when not set
If one sets the SystemMaxUse=64G by the current documentation would expect that each files size would be around 1/8 of this value (8G), althought if the SystemMaxFileSize is not explicit set, it has a max of 128M per file.
2023-11-01 10:41:24 +00:00
Peter Hutterer
4f7a629e6c analyze: handle CAP_BPF support 2023-11-01 10:25:59 +00:00
Lennart Poettering
bebf6fcf22 man: explicitly mention that environment.d/ cannot be used to set the service manager's own env block
Fixes: #29414
2023-11-01 10:25:02 +00:00