Commit Graph
8191 Commits
Author SHA1 Message Date
Gabríel Arthúr Pétursson 47b425de0c shared: Move cryptsetup-tpm2.[ch] from systemd-cryptsetup 2024-02-01 11:57:52 +00:00
Lennart Poettering 116ce3f391 Merge pull request #31039 from AdrianVovk/slice-freeze-thaw
Rework slice recursive freeze/thaw
2024-01-31 09:48:05 +01:00
Lennart Poettering b45f47aaad Merge pull request #30968 from poettering/per-user-creds
per-user encrypted credentials
2024-01-31 09:47:12 +01:00
Adrian Vovk 4cb2e6af8d core: Fail to start/stop/reload unit if frozen
Previously, unit_{start,stop,reload} would call the low-level cgroup
unfreeze function whenever a unit was started, stopped, or reloaded. It
did so with no error checking. This call would ultimately recurse up the
cgroup tree, and unfreeze all the parent cgroups of the unit, unless an
error occurred (in which case I have no idea what would happen...)

After the freeze/thaw rework in a previous commit, this can no longer
work. If we recursively thaw the parent cgroups of the unit, there may
be sibling units marked as PARENT_FROZEN which will no longer actually
have frozen parents. Fixing this is a lot more complicated than simply
disallowing start/stop/reload on a frozen unit

Fixes https://github.com/systemd/systemd/issues/15849
2024-01-30 11:18:16 -05:00
Lennart Poettering f65d44d1f6 Merge pull request #31124 from keszybz/various-small-tweaks
Various small tweaks
2024-01-30 17:08:21 +01:00
Lennart Poettering 19f16c9935 creds: go via IPC service when unprivileged and trying to access services
Fixes: #30191
2024-01-30 17:07:47 +01:00
Lennart Poettering 2c3cbc5c01 creds-util: add IPC client wrapper for new varlink apis 2024-01-30 17:07:47 +01:00
Lennart Poettering 8464f7cbd6 creds: allow Varlink clients to encrypt/decrypt their own credentials without polkit authentication
Now that we have the concept of scoped credentials, we can allow
unprivileged clients to encrypt/decrypt them as longed as they are
scoped to them.
2024-01-30 17:07:47 +01:00
Lennart Poettering 48d67957d5 creds-util: add a concept of "user-scoped" credentials
So far credentials are a concept for system services only: to encrypt or
decrypt credential you must be privileged, as only then you can access
the TPM and the host key.

Let's break this up a bit: let's add a "user-scoped" credential, that
are specific to users. Internally this works by adding another step to
the acquisition of the symmetric encryption key for the credential: if a
"user-scoped" credential is used we'll generate an symmetric encryption
key K as usual, but then we'll use it to calculate

    K' = HMAC(K, flags || uid || machine-id || username)

and then use the resulting K' as encryption key instead. This basically
includes the (public) user's identity in the encryption key, ensuring
that only if the right user credentials are specified the correct key
can be acquired.
2024-01-30 17:07:47 +01:00
Yu Watanabe 613d953988 varlink: add short comment that the log message is checked in test
Follow-up for 038e455462.
2024-01-30 15:41:52 +00:00
Antonio Alvarez Feijoo 0fa25bd5f4 conf-parser: fix OOM check 2024-01-30 12:46:24 +00:00
Zbigniew Jędrzejewski-Szmek 2673d6fae0 shared/pretty-print: inline one more variable declaration 2024-01-30 10:11:30 +01:00
Zbigniew Jędrzejewski-Szmek f3663c0ec9 shared/pretty-print: use normal else-if cascade
This is not a hot path, but it seems silly to evalute subsequent branches,
which can never match once one has matched. Also, it makes the code harder to
read, because the reader has to first figure out that only one branch can
match.
2024-01-30 10:11:30 +01:00
Lennart Poettering 1b78be0bb5 bus-util: add helper for getting PidRef structs from bus
This adds two helpers: one for extracting a PidRef from an sd_bus_creds
object, and one from doing this from and sd_bus_message object.
2024-01-29 14:42:42 +01:00
Luca Boccassi 343e35b36d core: add SYSTEMD_VERITY_SHARING env var for local development
When running an image that cannot be mounted (e.g.: key missing intentionally
for development purposes), there's a retry loop that takes some time
and slows development down. Add an env var to disable it.
2024-01-26 10:14:15 +00:00
Daan De Meyer 329288613c Merge pull request #31048 from YHNdnzj/fstab-modernization
fstab-util/generator: a few cleanups/improvements
2024-01-26 09:01:19 +01:00
Lennart Poettering b68f4cade4 dissect: add --make-archive option to convert DDI to tarball 2024-01-25 18:47:39 +01:00
Mike Yuan 5d19388349 fstab-util: clean up fstab_filter_options
Let's get rid of the confusing goto so that the flow is more
straightforward. Note that the behavior is slightly changed:
previously, ret_filtered would be an empty string even if
the original opts passed in is NULL, but after this commit
it returns NULL too. But this shouldn't matter, as all our
code handles NULL opts gracefully.
2024-01-26 01:06:40 +08:00
Lennart Poettering 368b2bccd3 Merge pull request #31089 from keszybz/drop-syscall-filtering-and-new-syscalls
Drop syscall filtering and add new syscalls
2024-01-25 17:12:13 +01:00
Franck Bui 7ba1816dfe loop-util: drop unused .uevent_seqnum_not_before and .timestamp_not_before fields 2024-01-25 16:10:36 +01:00
Zbigniew Jędrzejewski-Szmek 58fcc6b013 meson: drop arch filtering in syscall list
I added the filtering in 752fedbea7 as a way
to reduce the number of items in the tables. I thought it's "obvious", but
it might not be so.

One immediate problem is that the filter is broken, because on arm64,
os.uname().machine returns "aarch64", so we incorrectly filter out the arm
syscalls (there is just one: arm_fadvise64_64). Of course we could fix the
filter, but I think it's better to nuke it altogether. The filter on applies to
1 arm syscall and 5 s390 syscalls, and we have 500+ other syscalls, so this
"optimization" doesn't really matter. OTOH, if we get the filter wrong,
the result is bad. And also, the existence of the filter at all creates
problems for cross-builds.

I wanted to get rid of 'generate-syscall-list.py', but we need to generate a
backslash in the output. https://github.com/mesonbuild/meson/issues/1564 makes
this very very hard, since any attempt to put a backslash an inline argument
results in the backslash being replaces by a forward slash, which doesn't quite
have the same meaning. So let's use a standalone script until
https://github.com/mesonbuild/meson/issues/1564 is resolved.
2024-01-25 13:51:21 +01:00
Zbigniew Jędrzejewski-Szmek 04a7790f23 meson: use a single line for one-item file lists
That file was mixing two styles, which looks ugly. Let's not make
the file unnecessarily long.
2024-01-25 13:50:09 +01:00
Mike Yuan 2d70878162 tree-wide: replace FOREACH_POINTER with FOREACH_ARGUMENT
The latter is more generic and while being compatible with
the former.
2024-01-24 21:29:11 +08:00
Lennart Poettering ed4498a193 Merge pull request #31067 from RA-Kooi/xen-uuid
machine-id-setup: Generate stable machine IDs on Xen virtual machines.
2024-01-24 09:35:30 +01:00
Ivan Shapovalov a97476c8ac hostname-setup: read hostname from system.hostname credential
`system.hostname` credential is treated similarly to the pre-existing
`system.machine_id` credential. It is considered after /etc/hostname,
but prior to the kernel defaults or os-release defaults.

Fixes #30667.

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
2024-01-23 22:03:06 +00:00
Luca Boccassi f70daee8f2 Merge pull request #30130 from poettering/pcrlock-root
pcrlock: add support for unlocking a root fs with a pcrlock file
2024-01-23 21:41:02 +00:00
Rafaël Kooi 98d550baa9 machine-id-setup: Generate stable machine IDs based on Xen hypervisor UUID 2024-01-23 18:55:15 +01:00
Lennart Poettering 3ef072ee26 pretty-print: split out color tinting into a helper of its own 2024-01-23 16:45:37 +01:00
Lennart Poettering f9bc96f657 color-util: make return values of rgb_to_hsv() optional
When we want to tint the bg color we don't care about the hue, we want
to set it ourself after all, hence make the arguments optional, so that
we don't even have to ask for it.
2024-01-23 16:45:37 +01:00
Lennart Poettering 03a83186be varlink: make sure varlink_server_detach_event() doesn't leave invalid pointer around 2024-01-23 14:17:43 +01:00
Lennart Poettering 0db917f759 Merge pull request #31019 from poettering/hostnamed-full-os-release
hostnamed: expose full /etc/os-release data in hostnamectl's --json= output
2024-01-23 12:28:41 +01:00
Yu Watanabe fc5edc91cb Merge pull request #31015 from yuwata/local-addresses
local-addresses: several cleanups and fixes, add test cases
2024-01-23 10:25:35 +09:00
Lennart Poettering 75673cd8ae user-util: add get{pw,gr}{uid,gid,name}_malloc() helpers
These are wrappers around getpwuid_r() and friends, and will allocate the
right-sized buffer for this call.

We so far had multiple implementations of a buffer allocation loop
around getpwuid_r() and friends, and they all suck in some way. Let's
clean this up and add a common implementation, and use it everywhere.

Also, be more careful with error numbers, in particular systematically
turn ENOENT into ENOSRCH (the former is what is returned if /etc/passwd
is absent, which we want to consider identical to user not existing,
which is ENOSRCH). We so far did this at some invocations, but not all.

There are some invocations of getpwuid() left in the codebase. We really
should fix those too, and have a single unified implementation of the
logic, but those are not as trivial to convert, so left for another
time.
2024-01-22 17:55:07 +01:00
Lennart Poettering d37c312b87 pcrlock: when unlocking try to pick up pcrlock policy from system credentials 2024-01-22 15:20:22 +01:00
Lennart Poettering db21c2ec70 hostnamed: expose /etc/os-release and /etc/machine-info data in full
There's some appetite to have the full os-release/machine-info data
exposed by hostnamed.

let's do so in the Describe() method and via Varlink. It's trivial after
all.

Inspired by: #18649
2024-01-22 14:39:22 +01:00
nl6720 934288757c tree-wide: link to docs.kernel.org for kernel documentation
https://www.kernel.org/ links to https://docs.kernel.org/ for the documentation.
These URLs are shorter and nicer looking.
2024-01-22 10:50:33 +00:00
Mike Yuan 696f5da420 Merge pull request #31004 from AdrianVovk/misc-cleanups
Misc cleanups
2024-01-20 16:43:20 +08:00
Yu Watanabe e5ee645344 local-addresses: introduce has_local_address() helper function
It will be used later.
2024-01-20 16:07:19 +09:00
Yu Watanabe 16d95d6ff8 local-addresses: introduce own parser for RTA_MULTIPATH 2024-01-20 16:07:19 +09:00
Yu Watanabe eb1f9ed6a0 local-addresses: also save weight of multipath routes 2024-01-20 16:07:19 +09:00
Yu Watanabe 0b2c0c3159 local-addresses: introduce generic setter add_local_addresses_full() 2024-01-20 16:07:19 +09:00
Yu Watanabe 1305fe4ecf local-addresses: RTA_OIF and RTA_MULTIPATH are exclusive 2024-01-20 16:07:19 +09:00
Yu Watanabe 4019bec852 local-addresses: fix memleak of 'multipath_routes'
Also reduces scopes of some variables.
2024-01-20 16:07:19 +09:00
Yu Watanabe a64f60416c local-addresses: always sort and dedup even if addresses are not requested
Otherwise, the return value may different when ret is NULL or not.
2024-01-20 16:07:19 +09:00
Yu Watanabe e90863f231 local-addresses: ignore tentative addresses
As tentative addresses may be dropped soon if DAD failed.
2024-01-20 16:07:19 +09:00
Yu Watanabe 5cb56068d0 local-addresses: check family more
Just for safety. No functional change, unless the kernel sends broken
messages.
2024-01-20 16:07:19 +09:00
Yu Watanabe 37359b1c81 local-addresses: rename metric -> priority
To make it consistent with the netlink attribute RTA_PRIORITY.
2024-01-20 16:07:19 +09:00
Lennart Poettering e4924fb0d1 ptyfwd: when leaving a session with tinted background, clear to end of screen
So if we tint the background of a ptyfwd session with a color and the
session ends, then so far we reset the bg color and clear till the end
of line.

Let's instead clear till the end of the screen. This is nicer since it
means that any follow-up output will not be affected by the changed
background color anymore.
2024-01-20 01:11:48 +00:00
Yu Watanabe a3df693799 udev-util: introduce reset_cached_udev_availability() 2024-01-19 15:06:08 +09:00
Yu Watanabe d2881ef96e tree-wide: add short comments for namespace_open() and namespace_enter()
Also use -EBADF when unspecified.
2024-01-19 15:06:08 +09:00