Commit Graph
36268 Commits
Author SHA1 Message Date
Daan De Meyer bc6b326d48 journal: Don't allow creating invalid objects
Let's not allow creating empty entry or data objects. Let's also
not allow creating data objects from data without an embedded '='
character.
2021-11-24 22:14:36 +01:00
Lennart Poettering f7e910733c Merge pull request #21502 from keszybz/os-release-debugging
Additional debugging info to make release-extension easier to introspect
2021-11-24 22:00:02 +01:00
Dominique Martinet 3da361064b unit_is_bound_by_inactive: fix return pointer check
*ret_culprit should be set if ret_culprit has been passed a non-null value,
checking the previous *ret_culprit value does not make sense.

This would cause the culprit to not properly be assigned, leading to
pid1 crash when a unit could not be stopped.

Fixes: #21476
2021-11-24 18:42:37 +01:00
Lennart Poettering 6c68d5ad73 homework: add debug log message whenever we applied a uidmap to a mount 2021-11-24 18:42:08 +01:00
Lennart Poettering b05f4495bd homework: fix a bad error propagation 2021-11-24 18:42:08 +01:00
Lennart Poettering a8be098403 homework: also apply uid shifting when changing passwords/resizing/updating home areas
This adds uidmap shifting also when resizing/updating/changing
passwords. Prviously I thought we didn't have to, because the user is
not going to access the uidmap if we only quickly activate the home
area. But this thinking is wrong, because the three operations will
result in an update ~/.identity fie to be written, and we should do that
with uidmap applied, so that its ownership maps down to nobody below as
intended.

Fixes: #21441
2021-11-24 18:41:54 +01:00
Lennart Poettering 6f2c813667 homework: don't try to shift uidmap for already activated home areas
When we want to operate on an already activated home area we so far
tried to reapply the uidmapping logic. We shouldn't do that, it's
already applied after all.

We only want to apply this for newly activated home areas. Hence check
for the right HomeSetupFlags flag for it HOME_SETUP_ALREADY_ACTIVATED.

The patch is actually in theory a two-liner. Except that so far we don#t
pass the HomeSetupFlags flags down all necessary functions where the
uidmap stuff will eventually run. Hence this larger than intended
commit.
2021-11-24 18:31:51 +01:00
Lennart Poettering eae3a68144 homework: fix message typo 2021-11-24 18:29:52 +01:00
Lennart Poettering 6b356f4498 homectl: also acquire "cheap" passwords for homectl update/passwd
In 57bb9bcba5 support was added to read
"cheap" passwords from env vars and stuff before issuing the first
operation, instead of waiting for it until the first operation failed.

This was added for most verbs of "homectl", but two were left out:
update + passwd. Add it there too.
2021-11-24 18:26:28 +01:00
Zbigniew Jędrzejewski-Szmek f6048e5e56 dissect-image: always say "file of image" when reporting about the image
We give a path, but the path is only meaningful inside of the image.
Some messages made it clear that it's a path in the image, let's make
them all do that.
2021-11-24 17:43:01 +01:00
Zbigniew Jędrzejewski-Szmek ed15f8bceb Add debug logs of extension-release scanning 2021-11-24 17:43:01 +01:00
Zbigniew Jędrzejewski-Szmek 48084df6ed dissect-image: provide a more useful message when ENOMEDIUM is returned 2021-11-24 17:43:01 +01:00
Zbigniew Jędrzejewski-Szmek 2284750820 dissect-image: do not enable "verification" when trying to acquire metadata
The whole point of acquiring metadata is quite often to figure out why the
image does not pass verification. Refusing to provide metadata is just being
hostile to the user.

When called from other places (e.g. image_read_metadata()), verification is
still performed.
2021-11-24 17:42:19 +01:00
Lennart Poettering 543497fa34 test: add test for ioprio normalization 2021-11-24 16:12:15 +01:00
Lennart Poettering 8b330d7d75 core: normalize ioprio values we acquire from kernel
Linux 5.15 broke API in ioprio_get(): instead of returning
IOPRIO_CLASS_NONE when that's set it now returns IOPRIO_CLASS_BE, which
is what this actually is (the former is just an alias for the latter
with a priority value of 4).

Let's hide the differences between old and new kernels here, and always
normalize to what the new kernels do.
2021-11-24 16:12:15 +01:00
Lennart Poettering ba7772fee4 ioprio: normalize io priority values in configuration
Let's always say IOPRIO_CLASS_BE when IOPRIO_CALSS_NONE is set.
2021-11-24 16:12:15 +01:00
Lennart Poettering 0692548c73 ioprio-util: add macro for default ioprio settings
IOPRIO_CLASS_NONE with any priority value actually is an alias for
IOPRIO_CLASS_BE with priority value 4 – which is the default ioprio for
all processes.

We got this right at one place, but wrong at three others (where we
assumed the default value was 0, not 4). Let's add a
macro that encodes this properly, and use it everywhere.
2021-11-24 16:12:15 +01:00
Lennart Poettering 032b3afbf4 shared: split out ioprio related stuff into ioprio-util.[ch]
No actual code changes, just some splitting out.
2021-11-24 16:12:15 +01:00
Zbigniew Jędrzejewski-Szmek 03ae68f419 dissect-image: reuse common exit path 2021-11-24 15:55:58 +01:00
Zbigniew Jędrzejewski-Szmek 73c2c5255d shared/format-table: drop unnecessary _cleanup_ 2021-11-24 15:55:58 +01:00
Zbigniew Jędrzejewski-Szmek 9fa94e0753 test-pretty-print: spelling nitpick
The antonym of "nay" is usually spelled as "yea" (and pronouced as yā, so it
rhymes with "nay"), see e.g. https://www.cop.senate.gov/general/Features/votes.htm
2021-11-24 15:55:58 +01:00
Daan De Meyer 49ae9d91f9 shared: Add support for non-native architectures to dissect_image()
To allow dissecting images of architectures other than the native
(or secondary) one, we add a third designator 'OTHER' to represent
architectures other than the native or secondary one.

If no partitions of the native or secondary arch are available, we
check if a root partition of any other arch is available and use that
instead if we found one.
2021-11-24 15:06:38 +01:00
Daan De Meyer 6ddd80ae18 gpt: Store the partition type in GptPartitionType
This replaces the _GPT_ALL_ARCHES macro.
2021-11-24 14:47:57 +01:00
Daan De Meyer 51d1c8f2fe gpt: Store the architecture in GptPartitionType
We also add a function gpt_partition_type_uuid_to_arch() to get the
architecture of a partition type uuid.
2021-11-24 14:47:21 +01:00
Daan De Meyer 3c58ae1313 basic: Rename SECONDARY_ARCHITECTURE to ARCHITECTURE_SECONDARY
For easier integration with the _GPT_ALL_ARCHES macro in a future
commit.
2021-11-24 12:00:41 +01:00
Daan De Meyer 6d4c80ddbb gpt: Rename PPC64LE TO PPC64_LE
For consistency with ARCHITECTURE_PPC64_LE
2021-11-24 12:00:41 +01:00
Daan De Meyer b998ff21e1 basic: Give architecure enum a name 2021-11-24 12:00:41 +01:00
Zbigniew Jędrzejewski-Szmek 91ee7c5ebd basic/architectures: sort by name and remove duplicates
C.f. 086df29f35.
2021-11-24 10:05:28 +01:00
Julia Kartseva 7ab3c86d63 bpf: fix memleak in restrict_fs_bpf
Memory allocated in bpf skeleton is not freed. Wrap ptr in _cleanup_.

Fixes: #21471
2021-11-24 09:37:33 +01:00
Lennart Poettering e18dadca24 Merge pull request #21448 from poettering/disk-image-purpose
encode disk image purpose in extension-release.d + os-release
2021-11-24 09:37:04 +01:00
Lennart Poettering aa3cc58a9f recurse-dir: give callers of recurse_dir_at() control over path prefix
One of the niceties of recurse_dir()/recurse_dir_at() is that the path
argument is decoration, it's not used for actually accessing the fs in
anyway. That's very handy in environments where chroots and relative
paths are used, as we can path in any path we like and the recursion
function will suffix with whatever it discovers but will not try to make
sense of the prefix you pass.

This works great, except that the recurse_dir_at() wrapper broke that:
it adjusted the path if NULL to "." simply for the sake of making
openat() on the top work. Let's make this adjustment more local and do
it only for the openat() itself, and otherwise pass the path through the
way we got it. This means: if a caller really wants the paths that are
concatenated to start with a "." it can just pass that. This way the
caller gets full control back of the path prefix. Win!

Note that all current users of recurse_dir_at() don't pass NULL as
second arg, hence this check is without any real effect for now. It's
preparation for future uses however.
2021-11-24 09:34:10 +01:00
Lennart Poettering 994c9c70a1 dissect: show intended purpose of images in dissection output
With this the tool will show whether an image is intended to be a
bootable OS image, a system extension, or a portable service image.
Example output with this patch:

<snip>
      Name: image_53.raw
      Size: 3.2G

Machine ID: bb9f2921198040feb7c82270bf66e4b8
OS Release: NAME=Fedora
            VERSION=34 (Thirty Four)
            …
            PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy
            IMAGE_VERSION=53

    Use As: ✓ bootable system for UEFI
            ✓ bootable system for container
            ✗ portable service
            ✗ extension for system
            ✗ extension for initrd
            ✗ extension for portable service

RW DESIGNATOR PARTITION UUID                       PARTITION LABEL      FSTYPE ARCHITECTURE VERITY GROWFS NODE         PARTNO
rw root       d56af2b4-35eb-2e40-8f08-2d3b7012b0fc Root Partition       btrfs  x86-64       no         no /dev/loop1p2 2
rw esp        e3d11339-05c1-a74a-ae77-aae76812c134 ESP System Partition vfat   -            -          no /dev/loop1p1 1
…
</snip>
2021-11-23 22:55:49 +01:00
Lennart Poettering 8a129c808a os-release: add new PORTABLE_PREFIXES= field for declaring valid portable service match prefixes 2021-11-23 22:55:11 +01:00
Lennart Poettering 60c5f7002b extension-release.d/: add a new field SYSEXT_SCOPE= for clarifying what a system extension is for
This should make things a bit more robust since it ensures system
extension can only applied to the right environments. Right now three
different "scopes" are defined:

1. "system" (for regular OS systems, after the initrd transition)
2. "initrd" (for sysext images that apply to the initrd environment)
3. "portable" (for sysext images that apply to portable images)

If not specified we imply a default of "system portable", i.e. any image
where the field is not specified is implicitly OK for application to OS
images and for portable services – but not for initrds.
2021-11-23 22:55:11 +01:00
Lennart Poettering a4e0d61713 dissect-image: when extracting metadata from image also check if it contains init system
It's good to know whether we can boot the image.
2021-11-23 22:55:11 +01:00
Lennart Poettering 8570b98b12 dissect: add helper call for unifying three loops 2021-11-23 22:55:11 +01:00
Lennart Poettering ae54abe7fe bootctl: use new red/green check/cross mark helpers at two places 2021-11-23 22:40:15 +01:00
Lennart Poettering 3131c24bd6 pretty-print: add helper for quickly outputting red/green cross/check marks
Compound constructors FTW!
2021-11-23 22:40:15 +01:00
Miika Karanki 98503c6d0c sd-bus: Fix standard method argument names
The argument names of methods under org.freedesktop.DBus.Properties and
org.freedesktop.DBus.Introspectable interfaces are specifies in D-Bus
specification[1]. They are:

  org.freedesktop.DBus.Introspectable.Introspect (out STRING xml_data)
  org.freedesktop.DBus.Properties.Get (in STRING interface_name,
                                       in STRING property_name,
                                       out VARIANT value);
  org.freedesktop.DBus.Properties.Set (in STRING interface_name,
                                       in STRING property_name,
                                       in VARIANT value);
  org.freedesktop.DBus.Properties.GetAll (in STRING interface_name,
                                          out DICT<STRING,VARIANT> props);

sd-bus is using different argument names in the introspection document.
Usually this is not a problem but in case something tries to map the
argument names based on the introspection document to the position of
the arguments in the method call, then using names different than the
ones specified in the D-Bus specification is confusing.

So fix the names to match the D-Bus specification.

[1] https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-introspectable
2021-11-23 19:46:56 +01:00
Lennart Poettering 383c6f41e8 Merge pull request #21479 from keszybz/cosmetic-initialization-adjustments
Cosmetic initialization adjustments
2021-11-23 18:42:45 +01:00
Lennart Poettering ed90de9fbc process-util: add missing NULL initialization for _cleanup_ variable
This is will otherwise trigger a bad memory access in the error path
2021-11-23 18:42:22 +01:00
Lennart Poettering 5c682b7881 Merge pull request #21440 from poettering/homed-initial-fs-size
homed: also support minimizing/maximizing home dirs when creating them
2021-11-23 16:44:26 +01:00
Zbigniew Jędrzejewski-Szmek fc44acc0d2 resolved: add _unused_ annotations to appease clang 2021-11-23 16:20:14 +01:00
Zbigniew Jędrzejewski-Szmek b2d781ec86 shared/format-table: add cosmetic initialization
p is unconditionally initialized below, but our coding style says that
initialization should be added anyway.
2021-11-23 16:20:14 +01:00
Zbigniew Jędrzejewski-Szmek 64ea42e975 resolved: inline declarations of iterator variables 2021-11-23 16:20:14 +01:00
Zbigniew Jędrzejewski-Szmek 0c4f37f0fb resolved: move packet rewinder initalization inline
There is no functional change, but this reduces the risk that
in some future refactoring we'll forget the do the initialization in all
execution paths.
2021-11-23 16:20:14 +01:00
Boqun Feng 76eec06499 virt: Fix the detection for Hyper-V VMs
Use product_version instead of product_name in DMI table and the string
"Hyper-V" to avoid misdetection.

Fixes: #21468

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
2021-11-23 13:23:33 +01:00
Lennart Poettering 244cab4a65 Merge pull request #21443 from poettering/homed-grow-shrink-on-login-logout
homed: add ability to auto-grow home dir in login and auto-shrink on logout (if luks2+btrfs is used)
2021-11-23 13:13:06 +01:00
Zbigniew Jędrzejewski-Szmek a33bc79b99 udev/cdrom_id: use a macro to initialize context
c was initialized unconditionally, but one has to look at the function
body to understand this. Let's make the whole thing shorter and more
direct.
2021-11-23 12:31:20 +01:00
Lennart Poettering 31ea1bfec1 homework: correct initial minimal fs size calculations by LUKS2/GPT overhead
So far we assumed we ignore the LUKS2/GPT header overhead when
determining what the lower bound for images sizes is. Let's correct
this.
2021-11-23 10:02:56 +01:00