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

68430 Commits

Author SHA1 Message Date
Lennart Poettering
a434270139 pcrlock: add new pcrlock tool 2023-11-03 11:23:54 +01:00
Lennart Poettering
b52e950598 tpm2-util: add common array for TPM2 hash algorithms
This is useful to enumerate all hash algorithms we want to predict
measurements for.
2023-11-03 11:23:34 +01:00
Lennart Poettering
40ce73214a tpm2-util: make various marshalling/unmarshalling calls static, as we only use them internally in tpm2-util.c
Note, some of these were just added in this same PR. We only exported
them initially to make sure gcc doesn't complained about unused local
symbols.
2023-11-03 11:23:14 +01:00
Lennart Poettering
ce80da02b8 tpm2-util: add generic helpers for sealing/unsealing data
These helpers tpm2_seal_data()/tpm2_unseal_data() are useful for
sealing/unsealing data without any further semantics around them. This
is different from the existing tpm2_seal()/tpm2_unseal() which seal with
a specific policy and serialize in a specific way, as we use it for disk
encryption.

These new helpers are more generic, they do not serialize in a specific
way or imply policy, they are just the core of the sealing/unsealing.

(We should look into porting tpm2_seal()/tpm2_unseal() onto these new
helpers, but this isn#t trivial, since the classic serialization we use
uses a merged marshalling of private/public key, which we'd have to
change in one way or another)
2023-11-03 11:22:55 +01:00
Lennart Poettering
48d060564a tpm2-util: add helper for creating/removing/updating NV index with stored policy
This is the primary core of what pcrlock is supposed to do eventually:
maintain a TPM2 policy hash inside an NV index which we then can
reference via a PolicyAuthorizeNV expression to lock other objects
against it.
2023-11-03 11:22:35 +01:00
Lennart Poettering
2cd8f75316 tpm2-util: add calls for calculating/submitting PolicyAuthorizeNV + PolicyOR TPM2 policies 2023-11-03 11:22:16 +01:00
Lennart Poettering
34657b1f0b tpm2-util: add helper that calculates name of NV index 2023-11-03 11:21:55 +01:00
Lennart Poettering
f7be7a245e tpm2-util: add helper for setting TPM2B_AUTH in binary 2023-11-03 11:21:35 +01:00
Lennart Poettering
360062095d tpm2-util: add helpers for marshalling NV index public areas 2023-11-03 11:21:16 +01:00
Lennart Poettering
9fe3b63672 tpm2-util: add helpers for marshalling public/private keys
Note: we export these new symbols for now. A later commit in this PR
will make them static again. The only reason they are exported here is
to make sure gcc doesn't complain about unused static symbols, and I
really wanted to commit them in a separate commit.
2023-11-03 11:20:56 +01:00
Lennart Poettering
8f3f9c2bf5 tpm2-util: export a couple of functions we'd like to use for pcrlock 2023-11-03 11:20:36 +01:00
Lennart Poettering
199d758879 tpm2-util: pick up a few new symbols from tpm2-tss 2023-11-03 11:20:30 +01:00
Lennart Poettering
f88f929470 tpm2-util: add helper for returning path to EFI event log blob 2023-11-03 11:20:11 +01:00
Lennart Poettering
a63b260166 tpm2-util: add various uefi event log definitions 2023-11-03 11:19:46 +01:00
Lennart Poettering
981f76278f efivars: add UEFI 'database' variable uuid 2023-11-03 11:19:19 +01:00
Yu Watanabe
45a7ef454e man: mention DHCPv4 Router option is ignored when Classless Static Routes option is received
For #29564.
2023-11-03 10:14:59 +00:00
Frantisek Sumsal
69d17e23db varlink: limit the maximum nesting depth
Let's limit the maximum nesting depth for structure definitions to 64 to
avoid stack overflows with very deep definitions.

Resolves: #29589
2023-11-02 20:43:38 +00:00
Luca Boccassi
d2e99d288e
Merge pull request #29792 from poettering/resolved-monitor-packet
resolved: make sure "resolvectl monitor" can properly deal with stub …
2023-11-02 20:43:19 +00:00
Lennart Poettering
0631eac96d crytsetup: allow overriding the token .so library path via an env var
I tried to get something similar upstream:

https://gitlab.com/cryptsetup/cryptsetup/-/issues/846

But no luck, it was suggested I use ELF interposition instead. Hence,
let's do so (but not via ugly LD_PRELOAD, but simply by overriding the
relevant symbol natively in our own code).

This makes debugging tokens a ton easier.
2023-11-02 18:18:00 +00:00
Lennart Poettering
2bdd7a8ac9 meson: make sure we never actually link to libxenctrl
We don't make use of any of its symbols, we just want the headers, hence
make sure we never try to link against it.
2023-11-02 17:27:07 +00:00
Lennart Poettering
707de94cbf tree-wide: never link directly against p11kit
We go via dlopen() at most places, but forgot some. Cover the missing
cases too.
2023-11-02 17:26:46 +00:00
Luca Boccassi
918ef2eeeb
Merge pull request #29748 from poettering/tgtmode
Storage target mode, inspired by "target disk mode" á la MacOS, but with NVMe-TCP
2023-11-02 17:26:05 +00:00
Frantisek Sumsal
a0e000076a test: check that resolvectl monitor --json generates valid JSON
Provides coverage for #29580.
2023-11-02 18:08:30 +01:00
Luca Boccassi
6d5202ccaa mount-util: call CLEANUP_ARRAY after allocating array
Coverity gets confused if it is called before.

CID#1523757
2023-11-02 15:34:10 +00:00
Lennart Poettering
d2c5b50ae3 update TODO 2023-11-02 14:19:32 +01:00
Lennart Poettering
08b939a6a9 update NEWS 2023-11-02 14:19:32 +01:00
Lennart Poettering
565b7c90eb test: add integration test for systemd-storagetm 2023-11-02 14:19:32 +01:00
Lennart Poettering
eae4943afa man: add docs for new storagetm service 2023-11-02 14:19:32 +01:00
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
Lennart Poettering
ae55c9c0ae resolved: make sure "resolvectl monitor" can properly deal with stub queries
If we receive a query via the two stubs we store the original packet
instead of just the question object. Hence when we send monitor info to
subscribed clients we need to extract its question and also include it
in the returned data.

Fixes: #29580
2023-11-01 23:00:45 +01: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