Commit Graph

36187 Commits

Author SHA1 Message Date
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
Lennart Poettering
716bc20034 homework: when creating home dir also treat specified size as hint
The resize logic is now able to handle resize requests that cannot be
fulfilled in full gracefully. Let's do the same when allocating new home
directories.

This means "homectl create foo --disk-size=min" and "homectl create foo
--disk-size=max" may now be used to create the smallest or largest home
directory we support.
2021-11-23 10:02:35 +01:00
Andrew Stone
7c5cef2211 core/automount: Add ExtraOptions field 2021-11-23 09:44:35 +01:00
Lennart Poettering
d26cdde3d4 homework: upload home password into kernel keyring if needed
If we do automatic disk space rebalancing, we must be able to unlock the
encrypted volume for that in the background, thus we need to decryption
key around in userspace. Let's do this via the kernel keyring. This
allows us to do this in a relatively secure way, so that it sticks
around between homework invocations, but still is destroyed
automatically when homed goes down.
2021-11-23 08:07:21 +01:00
Lennart Poettering
2619100038 homework: add auto-shrink/auto-grow 2021-11-23 08:04:10 +01:00
Lennart Poettering
ab3b6fcb40 homectl: expose new autoResizeMode JSON user record property 2021-11-23 08:04:10 +01:00
Lennart Poettering
8bec643c8f user-record: add auto-resize property 2021-11-23 08:04:10 +01:00
Lennart Poettering
e1158539e7 resolved: lower connection timeout for DoT connections in opportunistic mode
Fixes: #20801
2021-11-22 22:33:40 +01:00
Lennart Poettering
e2ef1e9aea resolved: clean up manager_write_resolv_conf() a bit
Let's downgrade log messages which are not fatal for the service to
LOG_WARNING.

And let's simplify clean-up by using _cleanup_(unlink_and_freep).
2021-11-22 22:33:40 +01:00
Lennart Poettering
8cf9898a96 resolved: make sure we don't hit an assert when dealing with incomplete DNSSD service definitions
Fixes: #21142
2021-11-22 22:33:40 +01:00
Lennart Poettering
ae78529fc7 resolved: properly signal transient errors back to NSS stack
NSS mostly knows four error cases: SUCCESS, NOTFOUND, UNAVAIL, TRYAGAIN,
and they can all be used in nsswitch.conf to route requests.

So far nss-resolve would return SUCCESS + NOTFOUND + UNAVAIL. Let's also
return TRYAGAIN in some cases, specifically the ones where we are
currntly unable to resolve a request but likely could later. i.e.
errors caused by networking issues or such.

Fixes: #20786
2021-11-22 22:33:40 +01:00
Lennart Poettering
5a78106ad9 resolved: fix ResolveService() hostname handling
Let's eat up special returns of dns_query_process_cname_many() when
storing hostname resolution results.

The rest of the code assumes only == 0 means success and != 0 means
error, but so far > 0 also could mean success, let's fix that.

Fixes: #21365 #21140

(This was originally broken in 1db8e6d1db)
2021-11-22 22:33:40 +01:00
Lennart Poettering
fb9044cb6b nspawn: voidify expose_port_execute() calls 2021-11-22 22:33:40 +01:00
Lennart Poettering
a8d0906344 resolved: add "proxy-only" stub on 127.0.0.54
This beefs up the DNS stub logic to listen on two IP addresses:
127.0.0.53 (as before) + 127.0.0.54 (new). When the latter is contact
our stub will operate in "bypass" mode only, i.e we'll try to pass DNS
requests as unmodified upstream as we can (and not do mDNS/LLMNR and
such, also no DNSSEC validation – but we'll still do DNS-over-TLS
wrapping).

This is supposed to be useful for container environments or tethering:
this stub could be exposed (via NAT redirect) to clients of this system
and we'll try to stay out of the way with doing too much DNS magic
ourselves, but still expose whatever the current DNS server is from
upstream under a stable address/port.

How to use this:

  # iptables -t nat -I PREROUTING -p udp -i <interface> --dport 53 -j DNAT --to 127.0.0.54:53
  # echo 1 > /proc/sys/net/ipv4/conf/<interface>/route_localnet
2021-11-22 22:33:24 +01:00
Lennart Poettering
c1b91f06b9 socket-util: add helper for generically initializing sockaddr_union from in_addr_union 2021-11-22 22:18:34 +01:00
Lennart Poettering
f96b500ece resolved: include IP address info in debug output for incoming datagrams 2021-11-22 22:18:34 +01:00
Lennart Poettering
ded152134e resolved: use RET_NERRNO() where it makes sense 2021-11-22 18:36:03 +01:00
Jan Janssen
f7c0dacc9a Remove own copyright line 2021-11-22 16:08:37 +01:00
Luca Boccassi
d837adb0a8 Merge pull request #21357 from mbd98/usr-verity-auto
veritysetup-generator, fstab-generator: Setup and mount usr verity device when 'usrhash' (and optionally systemd.verity_usr_*) is present as kernel command line parameter
2021-11-22 13:09:38 +00:00
Daan De Meyer
f910926715 Merge pull request #21452 from vcaputo/mmap-cache-fd
mmap-cache: simplify MMapFileDescriptor-centric function signatures
2021-11-22 10:35:34 +01:00
Lennart Poettering
494876ce38 Merge pull request #21425 from keszybz/ppc64-fixes
Add base-filesystem defines for arm64/ppc64el/riscv64 and make build quiet again
2021-11-22 10:10:05 +01:00
Zbigniew Jędrzejewski-Szmek
0895e87348 analyze: fix printing config when there is no main config file
Since 8b8024f1c2 and the follow-up commits, the
main config file may be located in /usr or in other paths. But the code in
analyze.c was still assuming that it must be in /etc. Things mostly worked for
our own config files because we usually install a comments-only file in /etc,
but was not correct in the general case.

This fixes in particular 'systemd-analyze cat-config systemd/zram-generator.conf'.
In Fedora we distribute a config file in zram-generator-defaults.rpm that is in
/usr/lib, and 'cat-config' would refuse to show it because
/etc/systemd/zram-generator.conf does not exist.

The main config file is optional, but let's print an informative message
because this is a slightly unusual case.

The file paths that we printed were missing the root prefix.
2021-11-21 12:10:51 +00:00
Luca Boccassi
289a42304d Merge pull request #21432 from DaanDeMeyer/journal-trivial-fixes
Journal trivial fixes
2021-11-20 18:00:35 +00:00
Luca Boccassi
26bae8109d Merge pull request #21431 from DaanDeMeyer/issue-19799
journal: Limit the number of audit fields we add to a message
2021-11-20 17:58:51 +00:00
Lennart Poettering
a50966416e nspawn: use FOREACH_STRING() more 2021-11-20 17:54:53 +00:00
Christian Göttsche
7e570d575f core: prefix functions to avoid identical static function names
The function name `method_reload` is used both in dbus-unit.c and
dbus-manager.c for static functions.
With the previous addition of adding the function name to the audit
information on SELinux denials, rename the one (and its relatives) in
dbus-unit.c as most of the functions in src/core/dbus-unit.c are already
prefixed with `bus_unit_`.
2021-11-20 16:38:03 +00:00
Christian Göttsche
963438a027 selinux: name mac_selinux_generic_access_check as internal function
`mac_selinux_generic_access_check()` should not be called directly, only
via the wrapper macros `mac_selinux_access_check` and
`mac_selinux_unit_access_check`.
2021-11-20 16:38:03 +00:00
Christian Göttsche
6fbb33f631 selinux: improve debug log format
path might be NULL when checking against the system permissions, so wrap
with strna().

The command line might not be available over D-Bus and thus cl might be
empty. Print "n/a" instead of the empty string.
2021-11-20 16:38:03 +00:00
Christian Göttsche
f0804759cf selinux: add function name to audit data
Include the systemd C function name in the audit message to improve the
debug ability on denials.
Similar like kernel denial messages include the syscall name.
2021-11-20 16:38:03 +00:00
Vito Caputo
c3bd54bf4f mmap-cache: s/mmap_cache/mmap_cache_fd_/ where apropos
Mostly mechanical renaming of mmap-cache functions that now
operate exclusively on the MMapFileDescriptor.
2021-11-19 13:43:00 -08:00
Vito Caputo
1da2c4ceeb mmap-cache: simplify API around MMapFileDescriptor
MMapFileDescriptor carries a reference to its originating
MMapCache, there's no value in supplying the
MMapFileDescriptor-centric functions a separate MMapCache.

A future commit will rename these functions to consistently use
an mmap_cache_fd_* prefix for improved clarity.
2021-11-19 13:39:00 -08:00
Mark Boudreau
c1b9e3dffe fstab-generator: use 'usr' mapper device when 'usrhash' is present
If 'usrhash' is present as a kernel command line parameter, use the usr
mapper device for usr mount
2021-11-19 15:53:40 -05:00