Commit Graph
8040 Commits
Author SHA1 Message Date
Lennart Poettering 96fc8cab2a Merge pull request #30578 from bluca/polkit-varlink
varlink: add glue to allow authenticating varlink connections via polkit
2024-01-04 15:15:45 +01:00
Mike Yuan 2e6f012bf0 strv: rename strv_endswith to endswith_strv and dedup ENDSWITH_SET 2024-01-04 16:51:57 +08:00
Lennart Poettering 2a02a8db91 Merge pull request #26663 from poettering/vpick
add new "vpick" concept for automatically picking newest resource from .v/ dir containing versioned files
2024-01-03 22:17:32 +01:00
Yu Watanabe 82a1597778 Merge pull request #28797 from Werkov/eff_limits
Add MemoryMaxEffective=, MemoryHighEffective= and TasksMaxEff…  …ective= properties
2024-01-04 05:38:06 +09:00
Lennart Poettering a5ecdf7c6b discover-image: add support for vpick 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 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 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 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
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 2a1ffd3e3a bus-polkit: port polkit_registry to use value destructors in hash_ops 2024-01-03 11:53:52 +01:00
Lennart PoetteringandLuca Boccassi 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 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
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
Lennart Poettering 35793c71e4 varlink: add two helpers for delayed processing of method calls
When we want to do Polkit authentication we want to temporarily pause
handling of a method call until we have the Polkit reply, and then start
again. Let's add some glue to make that easy. This adds two helpers:

varlink_dispatch_again() allows to ask for redispatching of the
currently queued incoming message. Usecase is this: if we don't process
a methd right away, we can come back later, and ask it to be processed
again with this function, in which case our handlers will be called a
2nd time, exactly like on the first time.

varlink_get_current_message() provides access to the currently processed
method call.

With this the polkit logic can look into the current message, do its
thing, and then restart the method handling.
2024-01-02 17:57:35 +01:00
Lennart Poettering 0eccf7259e varlink: add new helper varlink_get_peer_pidref() for getting PidRef of peer 2024-01-02 17:57:35 +01:00
Lennart Poettering 03d808c9f6 efi-loader: when detecting if we are booted in UKI measured boot mode, imply a check for TPM2
We simply don't carry any userspace support for TPM1.2 in our tree, and
we shouldn't given it's too weak by today's standards. Hence, if we
check if we are booted in UKI measured boot mode, don't just check if we
are booted in EFI, but also check that we have a TPM2 chip (as opposed
to none or only a TPM1.2 chip).

This is an alternative to #30652 but more comprehensive (and simpler),
since it covers all invocations of efi_measured_uki().

Fixes: #30650
Replaces: #30652
2024-01-02 17:48:53 +01:00
Luca Boccassi 86b8b66675 Merge pull request #30591 from yuwata/device-util
device-util: introduce device_in_subsystem() and device_is_devtype() helper functions
2024-01-01 19:26:39 +01:00
Mike Yuan 22a8f00229 utmp-wtmp: check actual value of bool instead of pointer 2024-01-01 19:13:14 +01:00
Mike Yuan cbdb8732dd bus-wait-for-units: rearrange function 2024-01-01 18:42:24 +08:00
Mike Yuan 86dea48ddf bus-wait-for-units: correctly report state if disconnected from bus 2024-01-01 18:42:24 +08:00
Mike Yuan 0ffcc7539b bus-wait-for-units: rephrase error message 2024-01-01 18:42:24 +08:00
Mike Yuan a490aa5a2d bus-wait-for-units: use hashmap_remove_value where appropriate 2024-01-01 18:42:23 +08:00
Mike Yuan edba11cbd1 bus-wait-for-jobs: remove unneeded strna and refactor code a bit 2024-01-01 18:42:23 +08:00
Mike Yuan 6aac0ff01c bus-wait-for-jobs: a few modernizations 2024-01-01 18:16:54 +08:00
Mike Yuan e945d395e2 bus-wait-for-jobs: rephrase error message 2024-01-01 15:58:52 +08:00
Mike Yuan a8af9745e5 bus-wait-for-jobs: reorganize functions 2024-01-01 15:57:55 +08:00
Mike Yuan b8f4a205f7 bus-wait-for-jobs: sort includes 2024-01-01 15:45:05 +08:00
Mike Yuan da6c52c57c various: don't use close_nointr if retval is not checked anyway 2023-12-28 20:44:01 +08:00
Mike Yuan 3760416ee8 shared/async: use safe_close where appropriate 2023-12-28 18:26:52 +08:00
Mike Yuan 1cbd441b09 fdset: use FOREACH_ARRAY at one more place 2023-12-28 18:26:52 +08:00
Mike Yuan 6e819bd2bd hibernate-util: remove unused code
All callers of write_resume_config() pass non-NULL device.
2023-12-27 22:38:42 +08:00
Mike Yuan 66b9956082 hibernate-util: make sure we use blockdev path for HibernationDevice.path
Before this commit, this field could spuriously contain the path of the
swapfile.
2023-12-27 22:38:42 +08:00
Frantisek Sumsal 321e64dc67 tpm2-util: declare the cleanup attribute first
As we do everywhere else (apart from it being incosistent, the switched
order also makes Coccinelle unhappy).
2023-12-27 11:15:48 +01:00
Frantisek Sumsal c83f4220a1 tree-wide: use IN_SET() more 2023-12-27 11:15:48 +01:00
Yu Watanabe fe3fcb9492 Merge pull request #30633 from mrc0mmand/cocci-shenanigans
coccinelle: rework how we run the Coccinelle transformations
2023-12-26 05:45:58 +09:00
Frantisek Sumsal c490b6ddc2 tree-wide: use IOVEC_MAKE() in a couple more places 2023-12-25 18:26:59 +01:00
Frantisek Sumsal 6f7936cf57 killall: fix errno check 2023-12-25 18:26:59 +01:00
Frantisek Sumsal f51aec74c9 tree-wide: shorten a couple of ternary expressions 2023-12-25 18:26:59 +01:00
Mike Yuan 38617c516a various: use FOREACH_ARRAY more
Prompted by #30622
2023-12-25 20:17:48 +09:00
Yu Watanabe 287a5f1cff Merge pull request #30628 from YHNdnzj/format-table-improvement
Some improvements for format-table
2023-12-25 20:01:32 +09:00
Mike Yuan 0a0f49556f Merge pull request #30622 from yuwata/space
tree-wide: drop unnecessary space or insert missing space
2023-12-25 17:52:48 +08:00
Mike Yuan 8ba111463d core,format-table: use strna/ersatz for formatting fdstore dump
Currently, the code doesn't handle anonymous inodes correctly.
2023-12-25 17:47:18 +08:00
Mike Yuan 2413a0fab4 format-table: introduce table_isempty and use it where appropriate 2023-12-25 17:47:18 +08:00
Yu Watanabe c01a5c0527 siphash24: introduce siphash24_compress_typesafe() macro
To prevent copy-and-paste mistake.

This also introduce in_addr_hash_func().

No functional change, just refactoring.
2023-12-25 15:38:59 +09:00
Yu Watanabe 07e8c3055d tree-wide: drop several doubled space 2023-12-25 02:13:49 +09:00
Yu Watanabe b3a9d980f3 tree-wide: drop space between variable and an increment/decrement 2023-12-25 01:56:40 +09:00
Yu Watanabe 1d03d970a1 tree-wide: insert space after for and switch 2023-12-25 01:29:38 +09:00