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

70154 Commits

Author SHA1 Message Date
Lennart Poettering
d768856819 dissect: port to vpick for selecting image 2024-01-03 18:38:46 +01:00
Lennart Poettering
300a03bec3 nspawn: hook up --image=/--directory=/--template= with vpick logic 2024-01-03 18:38:46 +01:00
Lennart Poettering
9e61ed1115 vpick: add new tool "systemd-vpick" which exposes vpick on the command line
Usecase:

    $ du $(systemd-vpick /srv/myimages.v/foo___.raw)

In order to determine size of newest image in /srv/myimages.v/
2024-01-03 18:38:46 +01:00
Lennart Poettering
76511c1bd3 shared: add new "vpick" concept for ".v/" directories that contain versioned resources
This adds a new concept for handling paths. At appropriate places, if a
path such as /foo/bar/baz.v/ is specified, we'll
automatically enumerate all entries in /foo/bar/baz.v/baz* and then
do a version sort and pick the newest file.

A slightly more complex syntax is available, too:

/foo/bar/baz.v/quux___waldo

if that's used, then we'll look for all files matching
/foo/bar/baz.v/quux*waldo, and split out the middle, and version sort
it, and pick the nwest.

The ___ wildcard indicates both a version string, and if needed an
architecture ID, in case per-arch entries shall be supported.

This is a very simple way to maintain versioned resources in a dir, and
make systemd's components automatically pick the newest. Example:

    /srv/myimages.v/foobar_1.32.65_x86-64.raw
    /srv/myimages.v/foobar_1.33.45_x86-64.raw
    /srv/myimages.v/foobar_1.31.5_x86-64.raw
    /srv/myimages.v/foobar_1.31.5_arm64.raw

If now nspawn is invoked like this:

    systemd-nspawn --image=/srv/myimages.v/foobar___.raw

Then it will automatically pick
/srv/myimages.v/foobar_1.33.45_x86-64.raw as the version to boot on
x86-64, and /srv/myimages.v/foobar_1.31.5_arm64.raw on arm64.

This commit only adds the basic implementation for picking files from a
dir, but no hook-up anywhere.
2024-01-03 18:38:46 +01:00
Lennart Poettering
cc03788086 stat-util: add inode_type_from_string() helper 2024-01-03 18:38:46 +01:00
Lennart Poettering
63566c6b6f string-util: add strrstr() helper 2024-01-03 18:38:46 +01:00
Lennart Poettering
cb599f881a strv: add new strv_endswith() helper 2024-01-03 18:38:46 +01:00
Lennart Poettering
de84484e7b
Merge pull request #29940 from poettering/stub-confext-pickup
stub/sysext: pick up confexts from ESP, too
2024-01-03 17:40:36 +01:00
Lennart Poettering
5f1fddbd31
Merge pull request #30194 from poettering/tpm-target
units: add a tpm2.target synchronization point and small generator that pulls in
2024-01-03 17:40:17 +01:00
Mike Yuan
41935c0c3a
logind-session: use RET_GATHER more 2024-01-03 23:22:58 +08:00
Mike Yuan
8ccba83fd8
logind-session-device: trivial modernizations 2024-01-03 23:22:57 +08:00
Mike Yuan
42e6ad1684 labeler: add matches for login and logind 2024-01-03 15:00:36 +00:00
Lennart Poettering
56f20e3a46
Merge pull request #30704 from yuwata/sd-dhcp-server-lease
dhcp-server: use sd_dhcp_client_id and split out lease handling to sd-dhcp-server-lease.[ch]
2024-01-03 13:58:30 +01:00
Lennart Poettering
52be84f52c
Merge pull request #30697 from yuwata/network-address-remove-and-cancel
network/address: several cleanups for address removal
2024-01-03 13:55:26 +01:00
Lennart Poettering
ae17fcb61a tpm2-util: handle TPMs gracefully that do not support ECC and return TPM2_RC_VALUES
If a TPM doesn't do ECC it could either return zero curves when asked
for it, or it could simply fail with TPM2_RC_VALUES because it doesn't
recognize the capability at all.

Handle both cases the same way.

Fixes: #30679
2024-01-03 13:54:20 +01:00
Michal Sekletar
fd7fd59b6d tests: add test for StartAuxiliaryScope() 2024-01-03 13:50:46 +01:00
Michal Sekletar
84c01612de core/manager: add dbus API to create auxiliary scope from running service
This commit introduces new D-Bus API, StartAuxiliaryScope(). It may be
used by services as part of the restart procedure. Service sends an
array of PID file descriptors corresponding to processes that are part
of the service and must continue running also after service restarts,
i.e. they haven't finished the job why they were spawned in the first
place (e.g. long running video transcoding job). Systemd creates new
scope unit for these processes and migrates them into it. Cgroup
properties of scope are copied from the service so it retains same
cgroup settings and limits as service had.
2024-01-03 13:50:41 +01:00
Lennart Poettering
7bf4b5605e update TODO 2024-01-03 13:50:06 +01:00
Lennart Poettering
4e1f0037b8 units: add a tpm2.target synchronization point and small generator that pulls in
Distributions apparently only compile a subset of TPM2 drivers into the
kernel. For those not compiled it but provided as kmod we need a
synchronization point: we must wait before the first TPM2 interaction
until the driver is available and accessible.

This adds a tpm2.target unit as such a synchronization point. It's
ordered after /dev/tpmrm0, and is pulled in by a generator whenever we
detect that the kernel reported a TPM2 to exist but we have no device
for it yet.

This should solve the issue, but might create problems: if there are TPM
devices supported by firmware that we don't have Linux drivers for we'll
hang for a bit. Hence let's add a kernel cmdline switch to disable (or
alternatively force) this logic.

Fixes: #30164
2024-01-03 13:49:02 +01:00
Lennart Poettering
6018a27cb7 test-64: only look at plugged devices, not all of them 2024-01-03 13:47:57 +01:00
Michal Koutný
93f8e88d23 cgroup: Restrict effective limits with global resource provision
Global resource (whole system or root cg's (e.g. in a container)) is
also a well-defined limit for memory and tasks, take it into account
when calculating effective limits.
2024-01-03 13:43:04 +01:00
Michal Koutný
ce35bb95c7 test: Add effective cgroup limits testing 2024-01-03 13:37:58 +01:00
Michal Koutný
834ca54624 test: Convert rlimit test to subtest of generic limit testing
No functional change intended. Preparation for new tests.
2024-01-03 13:37:58 +01:00
Michal Koutný
4fb0d2dc14 cgroup: Add EffectiveMemoryMax=, EffectiveMemoryHigh= and EffectiveTasksMax= properties
Users become perplexed when they run their workload in a unit with no
explicit limits configured (moreover, listing the limit property would
even show it's infinity) but they experience unexpected resource
limitation.

The memory and pid limits come as the most visible, therefore add new
unit read-only properties:
- EffectiveMemoryMax=,
- EffectiveMemoryHigh=,
- EffectiveTasksMax=.

These properties represent the most stringent limit systemd is aware of
for the given unit -- and that is typically(*) the effective value.

Implement the properties by simply traversing all parents in the
leaf-slice tree and picking the minimum value. Note that effective
limits are thus defined even for units that don't enable explicit
accounting (because of the hierarchy).

(*) The evasive case is when systemd runs in a cgroupns and cannot
reason about outer setup. Complete solution would need kernel support.
2024-01-03 13:37:08 +01:00
Yu Watanabe
04d4086c22 resolve/mdns: do not append goodby packet entries to known answers section
When we receive a goodby packet about a host, and we have a cache entry about
the host, we do not immediately remove the cache entry, but update it with TTL 1.
See RFC 6762 section 10.1 and 3755027c2c.

If we receive a request soon after the goodby packet, previously the
entry was included in the known answers section of the reply. But such
information should not be appended.

Follow-up for 3755027c2c.
2024-01-03 13:16:43 +01:00
Luca Boccassi
2e3414660c varlink: avoid logging content of message if it contains sensitive data
This is important now that creds are sent via varlink

 systemd-creds[463]: varlink-3: Sending message: {"parameters":{"data":"Zm9vYmFyCg=="}}
 systemd-creds[462]: varlink-3: New incoming message: {"method":"io.systemd.Credentials.Encrypt","parameters":{"data":"Zm9vYmFyCg=="}}
2024-01-03 11:54:48 +01:00
Luca Boccassi
fa9a6db478 json: add JSON_FORMAT_REFUSE_SENSITIVE to json_variant_format()
Returns -EPERM if any node in the variant is marked as sensitive,
useful to avoid leaking data to log messages and so on
2024-01-03 11:54:48 +01:00
Lennart Poettering
caef0bc3dc creds: open up access to clients via Polkit
Use auth_admin_keep, so that users don't have to re-auth interactively
again and again when encrypting/decrypting batches of credentials.
2024-01-03 11:53:52 +01:00
Lennart Poettering
2a1ffd3e3a bus-polkit: port polkit_registry to use value destructors in hash_ops 2024-01-03 11:53:52 +01:00
Lennart Poettering
d04c1a1c8e bus-polkit: add support for authenticating varlink peers via polkit
This extends our current polkit logic, so that we can in a very similar
fashion as we already can authenticate dbus peers authenticate varlink
connection peers.

polkit natively speaks dbus and can authentication dbus peers. To get
the same level of support for varlink we'll use authentication by
pidfd+uid. This requires polkit v124, and if that's not available it
will fallback to authorizing root only as before.

Co-authored-by: Luca Boccassi <bluca@debian.org>
2024-01-03 11:53:29 +01:00
Mike Yuan
7c2e495c75
Merge pull request #30694 from yuwata/sd-netlink-move-macro-and-introduce-tos-getter
sd-netlink: two cleanups
2024-01-03 18:47:12 +08:00
Mike Yuan
f6ce1ad033
Merge pull request #30686 from poettering/uki-measured-check-imply-tpm2
efi-loader: when detecting if we are booted in UKI measured boot mode, imply a check for TPM2
2024-01-03 18:39:22 +08:00
Lennart Poettering
d4fee8941a confext: make sure we pick up configuration extensions passed to us from the stub
With fixes from Maanya Goenka.
2024-01-03 11:23:27 +01:00
Lennart Poettering
39e0c237f1 stub: pick up confexts from the ESP as well
This does what we do for system extension also for configuration
extension.

This is complicated by the fact that we previously looked for
<uki-binary>.d/*.raw for system extensions. We want to measure sysexts
and confexts to different PCRs (13 vs. 12) hence we must distinguish
them, but *.raw would match both kinds.

This commit solves this via the following mechanism: we'll load confexts
from *.confext.raw and sysexts from *.raw but will then enclude
*.confext.raw from the latter. This preserves compatibility but allows
us to somewhat reasonable distinguish both types of images.

The documentation is updated not going into this detail though, and
instead now claims that sysexts shall be *.sysext.raw and confexts
*.confext.raw even though we actually are more lenient than this. This
is simply to push people towards using the longer, more descriptive
suffixes.

I added an XML comment (<!-- … -->) about this to the docs, so that
whenever somebody notices the difference between code and docs
understands why and leaves it that way.
2024-01-03 10:38:34 +01:00
Yu Watanabe
dd8ab4a206 sd-dhcp-server: rename DHCPLease -> sd_dhcp_server_lease
Then, move basic functions for the object to sd-dhcp-server-lease.[ch].

No effective funcional changes.
2024-01-03 15:20:31 +09:00
Yu Watanabe
95c48613f4 sd-dhcp-server: use sd_dhcp_client_id 2024-01-03 15:20:31 +09:00
Rose
cb924b9b6a fundamental: prefer byte swap builtins over byte swapping manually
This builtin reduces complexity and GCC/Clang have supported these builtins for a long time.
2024-01-03 15:11:55 +09:00
Yu Watanabe
12fb1fc5dd
Merge pull request #30702 from yuwata/sd-dhcp-client-id
dhcp: introduce sd_dhcp_client_id and relevant functions
2024-01-03 15:10:46 +09:00
Yu Watanabe
778823fd52 backlight: supprt ID_LEDS_CLAMP udev property for leds subsystem devices
Closes #30507.
2024-01-03 09:30:41 +09:00
Yu Watanabe
e0feaedbd9 udev/dmi-memory-id: update table with latest SMBIOS specification
Closes #30699.
2024-01-03 08:43:17 +09:00
Yu Watanabe
7e08a337b2
Merge pull request #30700 from yuwata/storagetm-fixlets
storagetm: several trivial fixlets
2024-01-03 08:42:58 +09:00
Yu Watanabe
cb0a3b8c14 network/route: drop TTL propagate support for MPLS routes
This effectively reverts 9b88f20aba.

We do not support MPLS routes, only IPv4 or IPv6 routes are supported.
2024-01-03 08:41:53 +09:00
Yu Watanabe
6ba147485e network/queue: fix potential double-free on oom
Currently, link_queue_request_safe(), which is a wrapper of
request_new(), is called with a free function at
- link_request_stacked_netdev() at netdev/netdev.c,
- link_request_address() at networkd-address.c,
- link_request_nexthop() at networkd-nexthop.c,
- link_request_neighbor() at networkd-networkd.c.

For the netdev case, the reference counter of the passed object is increased
only when the function returns 1. So, on failure (with -ENOMEM)
previously we unexpectedly dropped the reference of the NetDev object.
Similarly, for Address and friends, the ownership of the object is moved to the
Request object only when the function returns 1. And on failure, previously
the object was freed twice.

Also, netdev_queue_request(), which is another wrapper of request_new()
potentially leaks memory when the same NetDev object is queued twice.
Fortunately, that should not happen as the function is called only once
per object.

This fixes the above issue, and now the ownership or the reference
counter of the object is changed only when it is succeeded with 1.
2024-01-03 08:41:36 +09:00
Yu Watanabe
ff49e703ff
Merge pull request #30691 from yuwata/resolve-ipv6
resolve: do not listen to IPv6 when disabled by sysctl
2024-01-03 08:41:14 +09:00
Frantisek Sumsal
995bf013a1 test: rewrite test-exec-deserialization.py
Rewrite the test in bash and make it part of our integration test suite,
so it's actually executed in all our upstream CI environments.

The original test is flaky in environments where daemon-reload might
occur during the test runtime (e.g. when running the test in parallel
with the systemd-networkd test suite). Also, it was run only in CentOS
CI in limited way (i.e. without sanitizers), since it tests the host's
systemd, instead of the just built one.

Resolves: #29943
2024-01-03 08:40:55 +09:00
Mike Yuan
0e3638380d various: unexport a few internal structs
We don't expose destructors for these internal structs already.
Let's make the struct itself implementation detail too.
2024-01-03 08:40:33 +09:00
Yu Watanabe
d59a2b3bf5 sd-dhcp-lease: use sd_dhcp_client_id 2024-01-03 06:06:39 +09:00
Yu Watanabe
1809132064 dhcp: move sd_dhcp_client_id_to_string() to sd-dhcp-client-id.[ch]
Then, this makes it take sd_dhcp_client_id object, and introduce
sd_dhcp_client_id_to_string_from_raw().
2024-01-03 06:06:36 +09:00
Yu Watanabe
6efa51f862 dhcp: introduce sd_dhcp_client_id and relevant functions
This splits out client ID handling from sd-dhcp-client.c to
sd-dhcp-client-id.[ch]. This will be used later in other places.
2024-01-03 06:06:34 +09:00
Mike Gilbert
049f178b80 storagetm: ensure we pass dev_t* to sd_device_get_devnum
On MIPS32 OABI, st_rdev is unsigned long, not dev_t. Use a temporary
variable to avoid an incompatible pointer.

Bug: https://bugs.gentoo.org/920576
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21278
Fixes: https://github.com/systemd/systemd/issues/30626
2024-01-03 05:37:25 +09:00