]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 years agoukify: allow multiple initrds 25180/head
Zbigniew Jędrzejewski-Szmek [Sat, 26 Nov 2022 13:31:57 +0000 (14:31 +0100)] 
ukify: allow multiple initrds

If given, multiple initrds are concatenated into a temporary file which then
becomes the .initrd section.

It is also possible to give no initrd. After all, some machines boot without an
initrd, and it should be possible to use the stub without requiring an initrd.
(The stub might not like this, but this is something to fix there.)

2 years agoci: install pefile
Zbigniew Jędrzejewski-Szmek [Fri, 25 Nov 2022 18:14:42 +0000 (19:14 +0100)] 
ci: install pefile

2 years agoman: add man page for ukify
Zbigniew Jędrzejewski-Szmek [Fri, 25 Nov 2022 15:25:23 +0000 (16:25 +0100)] 
man: add man page for ukify

2 years agoukify: try to find the uname string in the linux image if not specified
Zbigniew Jędrzejewski-Szmek [Wed, 16 Nov 2022 16:44:28 +0000 (17:44 +0100)] 
ukify: try to find the uname string in the linux image if not specified

The approach is based on mkinicpio's autodetection.

This is hacky as hell. Some cases are actually fairly nice: ppc64el images have
a note that contains 'uname -r'. (The note is not uniquely labeled at all, and
only contains the release part instead of the full version-hostname-release
string, and we don't actually care about ppc, and it's very hard to read the
note from Python, but in general that'd be the approach I'd like.)

I opted to simply read and decompress the full linux binary in some cases.
Python doesn't make it easy to do streaming decompression with regexp matching,
and it doesn't seem to matter much: the image decompresses in a fraction of a
second.

2 years agotests: add pytest tests for ukify
Zbigniew Jędrzejewski-Szmek [Fri, 25 Nov 2022 16:21:40 +0000 (17:21 +0100)] 
tests: add pytest tests for ukify

Some gymnastics were needed to import ukify as a module. Before the file
was templated, this was trivial: insert the directory in sys.path, call import.
But it's a real pain to import the unsuffixed file after processing. Instead,
the untemplated file is imported, which works well enough for tests and is
very simple.

The tests can be called via pytest:
  PATH=build/:$PATH pytest -v src/ukify/test/test_ukify.py
or directly:
  PATH=build/:$PATH src/ukify/test/test_ukify.py
or via the meson test machinery output:
  meson test -C build test-ukify -v
or without verbose output:
  meson test -C build test-ukify

Zekret files are obfuscated using base64.

2 years agomeson,ukify: hook up ukify, add --version option
Zbigniew Jędrzejewski-Szmek [Wed, 16 Nov 2022 14:52:47 +0000 (15:52 +0100)] 
meson,ukify: hook up ukify, add --version option

The option is added because we have a similar one for kernel-install. This
program requires python, and some people might want to skip it because of this.

The tool is installed in /usr/lib/systemd for now, since the interface might
change.

A template file is used, but there is no .in suffix.
The problem is that we'll later want to import the file as a module
for tests, but recent Python versions make it annoyingly hard to import
a module from a file without a .py suffix. imp.load_sources() works, but it
is deprecated and throws warnings.
importlib.machinery.SourceFileLoader().load_module() works, but is also
deprecated. And the documented replacements are a maze of twisted little
callbacks that result in an empty module.
So let's take the easy way out, and skip the suffix which makes it easy
to import the template as a module after adding the directory to sys.path.

2 years agoukify: add helper to create UKIs
Zbigniew Jędrzejewski-Szmek [Sat, 29 Oct 2022 18:07:46 +0000 (20:07 +0200)] 
ukify: add helper to create UKIs

Features:
- adds sections .linux, .initrd, .uname, .osrel, .pcrpkey, .pcrsig, .cmdline, .splash
- multiple initrds can be concatenated
- section flags are set properly (READONLY, DATA or CODE)
- uses systemd-measure to precalculate pcr measurements and create a signed json policy
- the inner linux image will be signed automatically with sbsign if unsigned
- uses sbsign to sign the output image
- offsets are calculated so that sections are placed adjacent, with .linux last
- custom sections are possible
- multiple pcr signing keys can be specified and different boot phase paths can be
  signed with different keys
- most things can be overriden (path to tools, stub file, signing keys, pcr banks,
  boot phase paths, whether to sign things)
- superficial verification of slash bmp is done
- kernel uname "scraping" from the kernel if not specified (in a later patch)

TODO:
- change systemd-measure to not require a functional TPM2. W/o this, we'd need
  to support all banks in the build machine, which is hard to guarantee.
- load signing keys from /etc/kernel/
- supress exceptions, so if something external fails, the user will not see a traceback
- conversion to BMP from other formats

$ sudo /usr/lib/systemd/ukify \
  --tools=build/ \
  --measure \
  /lib/modules/6.0.5-300.fc37.x86_64/vmlinuz \
  /boot/08a5690a2eed47cf92ac0a5d2e3cf6b0/6.0.5-300.fc37.x86_64/initrd \
  --secureboot-private-key=server.key --secureboot-certificate=server.crt \
  --pcr-private-key=tpm2-pcr-private.pem --pcr-public-key=tpm2-pcr-public.pem \
  --cmdline='rw quiet' \
  --section test:TESTTESTTEST \
  --section test2:TESTTESTTEST2 \
  --pcr-banks=sha1 \
  --uname="$(uname -rv)"

Host arch 'x86_64', efi arch 'x64'
+ sbverify --list /lib/modules/6.0.5-300.fc37.x86_64/vmlinuz
+ build/systemd-measure calculate --linux=/lib/modules/6.0.5-300.fc37.x86_64/vmlinuz --osrel=/etc/os-release --cmdline=/tmp/tmpcmdline_5aufjir --pcrpkey=tpm2-pcr-public.pem --initrd=/boot/08a5690a2eed47cf92ac0a5d2e3cf6b0/6.0.5-300.fc37.x86_64/initrd --bank=sha1
11:sha1=03df5e5243bc002b959d52359fe04e266d0b5ebf
11:sha1=54949b82bae32e80343ff0f01eeeeb75f4c07d3f
11:sha1=0fc62be88aa9c5ad7282aa8adb504f451bcec9df
11:sha1=b71155e7fcd467f7c1696f675e37887032e2eafa
+ build/systemd-measure sign --linux=/lib/modules/6.0.5-300.fc37.x86_64/vmlinuz --osrel=/etc/os-release --cmdline=/tmp/tmpcmdline_5aufjir --pcrpkey=tpm2-pcr-public.pem --initrd=/boot/08a5690a2eed47cf92ac0a5d2e3cf6b0/6.0.5-300.fc37.x86_64/initrd --bank=sha1 --private-key=tpm2-pcr-private.pem --public-key=tpm2-pcr-public.pem
+ objcopy /usr/lib/systemd/boot/efi/linuxx64.efi.stub --add-section .osrel=/etc/os-release --change-section-vma .osrel=0x22000 --add-section .cmdline=/tmp/tmpcmdline_5aufjir --change-section-vma .cmdline=0x23000 --add-section .pcrpkey=tpm2-pcr-public.pem --change-section-vma .pcrpkey=0x24000 --add-section .initrd=/boot/08a5690a2eed47cf92ac0a5d2e3cf6b0/6.0.5-300.fc37.x86_64/initrd --change-section-vma .initrd=0x25000 --add-section .uname=/tmp/tmpuname0v3uzh5r --change-section-vma .uname=0x4009000 --add-section .test=/tmp/tmptestuxve59c8 --change-section-vma .test=0x400a000 --add-section .test2=/tmp/tmptest2_i143p9i --change-section-vma .test2=0x400b000 --add-section .pcrsig=/tmp/tmppcrsigdtcqxz_w --change-section-vma .pcrsig=0x400c000 --add-section .linux=/lib/modules/6.0.5-300.fc37.x86_64/vmlinuz --change-section-vma .linux=0x400d000 /tmp/uki4vsbf7y8
+ sbsign --key server.key --cert server.crt /tmp/uki4vsbf7y8 --output vmlinuz.efi
warning: data remaining[79849520 vs 79866644]: gaps between PE/COFF sections?
warning: data remaining[79849520 vs 79866648]: gaps between PE/COFF sections?
Signing Unsigned original image
Wrote signed vmlinuz.efi

2 years agobootctl: use output mode where "[]" is written instead for empty output
Zbigniew Jędrzejewski-Szmek [Thu, 17 Nov 2022 14:40:54 +0000 (15:40 +0100)] 
bootctl: use output mode where "[]" is written instead for empty output

It's easier for the caller if output is always a list, even if there are no
entries.

2 years agoshared/json: optimize appending objects to arrays
Zbigniew Jędrzejewski-Szmek [Thu, 17 Nov 2022 13:32:46 +0000 (14:32 +0100)] 
shared/json: optimize appending objects to arrays

When repeatedly appending an object to a growing array, we would create a new
array larger by one slot, insert all the old entries and the new element with
ref count bumps into the new array, and then unref the old array.

This would cause problems when building an array with more than a few thousand
elements. If userdbctl is modified to construct an array,
'userdbctl --json=pretty group >/dev/null' with 31k groups:
0.74s   (existing code)
102.17s (returning an array)
0.79s   (with this patch)

We append arrays in various places, so it seems nice to make this generally
fast.

2 years agoshared/json: make it possible to specify source name for strings too, add tests
Zbigniew Jędrzejewski-Szmek [Thu, 17 Nov 2022 13:15:48 +0000 (14:15 +0100)] 
shared/json: make it possible to specify source name for strings too, add tests

The source would be set implicitly when parsing from a named file. But
it's useful to specify the source also for cases where we're parsing a
ready string. I noticed the lack of this API when trying to write tests,
but it seems generally useful to be specify a source name when parsing
things.

2 years agotests: add a simple test that bootctl output is valid json
Zbigniew Jędrzejewski-Szmek [Wed, 16 Nov 2022 08:49:30 +0000 (09:49 +0100)] 
tests: add a simple test that bootctl output is valid json

python's json.tool module is used because it does validation. jq is more forgiving.
Also, json is in the stdlib, so it should be always available.

2 years agobootctl: make --json output normal json
Zbigniew Jędrzejewski-Szmek [Tue, 15 Nov 2022 14:00:57 +0000 (15:00 +0100)] 
bootctl: make --json output normal json

We would output a sequence of concatenated JSON strings. 'jq' accepts such
output without fuss, and can even automatically build an array with --slurp/-s.
Nevertheless, parsing this format is more effort for the reader, since it's not
"standard JSON". E.g. Python's json module cannot do this out-of-the-box, but
needs some loop with json.JSONDecoder.raw_decode() and then collecting the
objects into an array. Such streaming output make sense in case of logs, where
we stream the output and it has no predefined length. But here we expect at
most a few dozen entries, so it's nicer to write normal JSON that is trivial to
parse.

I'm treating this is a bugfix and not attempting to provide compatibility
backwards. I don't think the previous format was seeing much use, and it's
trivial to adapt to the new one.

2 years agoupdate TODO
Lennart Poettering [Fri, 25 Nov 2022 16:33:56 +0000 (17:33 +0100)] 
update TODO

2 years agomkfs-util: Drop batch (b) and n flags from mcopy
Daan De Meyer [Fri, 25 Nov 2022 11:54:33 +0000 (12:54 +0100)] 
mkfs-util: Drop batch (b) and n flags from mcopy

The batch flag is bugged on older versions of mcopy causing failures
such as:

```
Internal error, size too big
Streamcache allocation problem:: 5
```

It's also a little unclear what the batch flag actually does, so since
everything still works without it, it doesn't hurt to remove it.

The n flag only applies when copying from fat to unix which we don't do
so it doesn't make sense in this scenario.

2 years agoMerge pull request #25482 from DaanDeMeyer/repart-skip-partitions
Daan De Meyer [Fri, 25 Nov 2022 12:31:09 +0000 (13:31 +0100)] 
Merge pull request #25482 from DaanDeMeyer/repart-skip-partitions

repart: Add --skip-partitions=

2 years agorepart: Add --skip-partitions= 25482/head
Daan De Meyer [Tue, 22 Nov 2022 13:27:30 +0000 (14:27 +0100)] 
repart: Add --skip-partitions=

--include-partitions and --exclude-partitions now fully exclude
partitions from repart. Whenever a partition type is excluded, we
don't take any partitions of that type into account at all when
running systemd-repart.

--skip-partitions= is introduced to do what --exclude-partitions did
previously. Any skipped partitions are taken into acount when doing
size calculations, but are not yet populated.

Why do we need both concepts? Exclusion is needed so that we can
use shared repart definitions to generate bootable and non-bootable
images. When generating a non-bootable image, we use --exclude-partitions
to exclude the ESP partition. Skipping is needed so that we can
populate the root partition while skipping the ESP partition, get
the roothash of the root partition, use that to generate a UKI, and
finally populate the ESP partition with the UKI included.

2 years agoresolved: remove inappropriate assert()
Lennart Poettering [Thu, 24 Nov 2022 17:42:08 +0000 (18:42 +0100)] 
resolved: remove inappropriate assert()

A NULL Bitmap object is by all our code considered identical to an empty
bitmap. Hence let's remove the entirely unnecessary assert().

The assert() can be triggered if debug monitoring is used an an empty
NSEC or NSEC3 RR is included in an answer resolved returns.

it's not really a security issue since enabling debug monitoring is a
manual step requiring root privileges, that is off by default. Moreover,
it's a "clean" assert(), i.e. the worst that happens is tha a coredump
is generated and resolved restarted.

Fixes: #25449
2 years agoMerge pull request #25473 from yuwata/mount-tool-cleanups
Luca Boccassi [Thu, 24 Nov 2022 19:40:37 +0000 (20:40 +0100)] 
Merge pull request #25473 from yuwata/mount-tool-cleanups

mount-tool: several cleanups

2 years agounits: fix typo in Condition in systemd-boot-system-token
Luca Boccassi [Thu, 24 Nov 2022 10:01:59 +0000 (10:01 +0000)] 
units: fix typo in Condition in systemd-boot-system-token

/lib/systemd/system/systemd-boot-system-token.service:20: Unknown key name 'ConditionPathExists|' in section 'Unit', ignoring

Follow-up for 0a1d8ac77a21ae0741bdf4af08f3a71354805ff1

2 years agoMerge pull request #25500 from DaanDeMeyer/mcopy-skip-symlinks
Daan De Meyer [Thu, 24 Nov 2022 15:28:01 +0000 (16:28 +0100)] 
Merge pull request #25500 from DaanDeMeyer/mcopy-skip-symlinks

mkfs-util: Skip symlinks when calling mcopy

2 years agomkfs-util: Skip non files/directories when calling mcopy 25500/head
Daan De Meyer [Wed, 23 Nov 2022 13:12:38 +0000 (14:12 +0100)] 
mkfs-util: Skip non files/directories when calling mcopy

Only files and directories are supported by vfat. When we pass a
symlink to mcopy, it will try to dereference them and copy what the
symlink points at into the vfat partition instead. Let's avoid this
by skipping all unsupported file types when establishing the list of
top level targets that mcopy should copy.

We also use RECURSE_DIR_SORT everywhere when iterating directories
to make things more reproducible.

2 years agorecurse-dir: Handle RECURSE_DIR_ENSURE_TYPE in readdir_all()
Daan De Meyer [Thu, 24 Nov 2022 12:13:21 +0000 (13:13 +0100)] 
recurse-dir: Handle RECURSE_DIR_ENSURE_TYPE in readdir_all()

2 years agodirent-util: Expose dirent_ensure_type()
Daan De Meyer [Thu, 24 Nov 2022 12:13:05 +0000 (13:13 +0100)] 
dirent-util: Expose dirent_ensure_type()

2 years agomkfs-util: Check if mcopy is installed
Daan De Meyer [Wed, 23 Nov 2022 09:05:23 +0000 (10:05 +0100)] 
mkfs-util: Check if mcopy is installed

2 years agoMerge pull request #25509 from enr0n/oomd-unpriv-container-fix
Luca Boccassi [Thu, 24 Nov 2022 10:21:16 +0000 (11:21 +0100)] 
Merge pull request #25509 from enr0n/oomd-unpriv-container-fix

Fix `oomd_fetch_cgroup_oom_preference()` for unprivileged LXD containers

2 years agoshared: use move_pivot_root() for services
Christian Brauner [Wed, 23 Nov 2022 15:15:20 +0000 (16:15 +0100)] 
shared: use move_pivot_root() for services

Currently, services use mount_move_root() in order to setup the root
directory of services using a mount namespace. This relies on MS_MOVE
and chroot(). However, this has serious drawbacks even for relatively
simple mount propagation scenarios.

What systemd currently does is roughly equivalent to the following shell
code:

  unshare --mount --propagation=shared
  cd /
  mount --make-rslave /
  mkdir /new-root
  mount --rbind / /new-root
  cd /new-root
  mount --move /new-root /
  chroot .

This looks simple enough but has the consequence that two separate mount
trees exist for the lifetime of the service. The first one was created
when the mount namespace was created, and the second one when a new
mount for the rootfs was created. The first mount tree sticks around as
a shadow mount tree. Both mount trees are dependent mounts with the host
rootfs as their dominating mount.

Now, when mount propagation is triggered by the host by e.g.,

   mount --bind /opt /mnt

it means that two propagation events are generated. I'm skipping over
the exact kernel details as they aren't that important. The gist is that
for every propagation event that is generated a second one is generated
for the shadow mount tree. In other words, the kernel creates two copies
for each mount that is propagated instead of one.

This isn't necessary. We can simply change the sequence above to:

  unshare --mount --propagation=shared
  cd /
  mount --make-rslave /
  mkdir /new-root
  # stash fd to old rootfs
  # stash fd to new rootfs
  mount --rbind / /new-root
  mkdir /new-root
  cd /new-root
  pivot_root . .
  # new root is tucked under old root
  # chdir into old rootfs via stashed fd
  umount -l /old-root

The pivot_root allows us to get rid of the old mount tree that was
created when the mount namespace was created. So after this sequence
only one mount tree is alive. Plus, it's safer and nicer. Moving mounts
isn't pleasnt.

This patch doesn't convert nspawn yet as the requirements are more
tricky given that it wants to preserve the rootfs as a shared mount
which goes against pivot_root() requirements.

Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
2 years agomount: use device enumerator to find matching loopback block device 25473/head
Yu Watanabe [Tue, 22 Nov 2022 02:22:20 +0000 (11:22 +0900)] 
mount: use device enumerator to find matching loopback block device

No functional change, just refactoring.

2 years agomount: split umount_by_device() into two
Yu Watanabe [Tue, 22 Nov 2022 02:04:33 +0000 (11:04 +0900)] 
mount: split umount_by_device() into two

No functional change, just refactoring and preparation for later
commits.

2 years agomount: make acquire_mount_where_for_loop_dev() take sd-device object
Yu Watanabe [Tue, 22 Nov 2022 02:43:57 +0000 (11:43 +0900)] 
mount: make acquire_mount_where_for_loop_dev() take sd-device object

No functional change, just refactoring.

2 years agoMerge pull request #25483 from poettering/ppoll-usec-eintr
Yu Watanabe [Thu, 24 Nov 2022 00:42:48 +0000 (09:42 +0900)] 
Merge pull request #25483 from poettering/ppoll-usec-eintr

ppoll() + EINTR fixes

2 years agocore: add possibility to not track certain unit types
Michal Sekletar [Wed, 7 Sep 2022 15:37:34 +0000 (17:37 +0200)] 
core: add possibility to not track certain unit types

2 years agoportable: add a few more useful debug log messages
Luca Boccassi [Wed, 23 Nov 2022 16:06:48 +0000 (16:06 +0000)] 
portable: add a few more useful debug log messages

When attaching and /etc/systemd/system.attached can't be created or used
(eg: dead symlink) the logs are pretty much useless as even at debug
level there's no indication of what is going wrong.
Add some debug logs, and return a more specific error string over D-Bus.

2 years agooomd: fix unreachable test case in test-oomd-util 25509/head
Nick Rosbrook [Tue, 22 Nov 2022 16:30:03 +0000 (11:30 -0500)] 
oomd: fix unreachable test case in test-oomd-util

This conditional with !empty_or_root(ctx->path) always returns false
because the most recent oomd_cgroup_context_acquire() call was with the
root cgroup. Make sure this test case can be reached by checking cgroup
instead of ctx->path.

While here, use an unused uid (61183) instead of the nobody uid so the
test case does not fail in unprivileged LXD containers.

2 years agooomd: always allow root-owned cgroups to set ManagedOOMPreference
Nick Rosbrook [Tue, 22 Nov 2022 15:33:55 +0000 (10:33 -0500)] 
oomd: always allow root-owned cgroups to set ManagedOOMPreference

Commit 652a4efb66a ("oomd: loosen the restriction on ManagedOOMPreference")
made the change to allow ManagedOOMPreference on a cgroup candidate when
the monitored cgroup and cgroup candidate are owned by the same user.

The commit assumed that this check was sufficient to continue allowing
ManagedOOMPreference on all cgroups owned by root. However, it caused a
regression for unprivileged LXD containers where e.g. /sys/fs/cgroup is
owned by nobody (uid=65534).

Fix this by explicitly allowing the ManagedOOMPreference if uid == 0 in
oomd_fetch_cgroup_oom_preference().

2 years agoRevert "find-esp: Relax filesystem root directory check"
Daan De Meyer [Wed, 23 Nov 2022 12:28:57 +0000 (13:28 +0100)] 
Revert "find-esp: Relax filesystem root directory check"

This reverts commit d91a5f6481d35e28148fe46bc490bb4f34656947.

This is the wrong approach as we don't detect the UUID and devid
of valid ESP/XBOOTLDR partitions.

2 years agohwdb: remove fuzz and deadzone for Simucube wheel bases.
Bernd Steinhauser [Wed, 23 Nov 2022 14:07:25 +0000 (15:07 +0100)] 
hwdb: remove fuzz and deadzone for Simucube wheel bases.

For these devices the axes are setup via a special
configuration tool. udev should not apply additional
fuzz or deadzone.

Reference for the product IDs:
https://granitedevices.com/wiki/Simucube_product_USB_interface_documentation
This also indicates that there are a total of 8 axes.

2 years agoMerge pull request #25486 from keszybz/kernel-install-header
Lennart Poettering [Wed, 23 Nov 2022 16:36:44 +0000 (17:36 +0100)] 
Merge pull request #25486 from keszybz/kernel-install-header

Add "File created by …" header to BLS entries

2 years agoTODO: add item about mnt_fstype_is_netfs()
Zbigniew Jędrzejewski-Szmek [Wed, 23 Nov 2022 11:43:28 +0000 (12:43 +0100)] 
TODO: add item about mnt_fstype_is_netfs()

2 years agorepart: Make parse_filter_partitions() more generic
Daan De Meyer [Tue, 22 Nov 2022 13:03:54 +0000 (14:03 +0100)] 
repart: Make parse_filter_partitions() more generic

2 years agorepart: Rename arg_filter_partitions_size to arg_n_filter_partitions
Daan De Meyer [Tue, 22 Nov 2022 12:59:18 +0000 (13:59 +0100)] 
repart: Rename arg_filter_partitions_size to arg_n_filter_partitions

2 years agokernel-install: add header to generate entry files 25486/head
Zbigniew Jędrzejewski-Szmek [Tue, 22 Nov 2022 14:59:21 +0000 (15:59 +0100)] 
kernel-install: add header to generate entry files

I was looking at a bug in bugzilla about some boot loader issue, and it was
hard to say if the boot entry files were generated by our plugin or something
else. Add a header to make this clear.

kernel-install invokes the plugins via absolute path always, so $0 gives as
the full path the location where the plugin is installed. This is what we want:

  title      Fedora Linux 37 (Workstation Edition)
  # Boot Loader Specification type#1 entry
  # File created by /usr/lib/kernel/install.d/90-loaderentry.install (systemd 252-409-g5028904^)

2 years agofind-esp: Relax filesystem root directory check
Daan De Meyer [Mon, 21 Nov 2022 19:41:22 +0000 (20:41 +0100)] 
find-esp: Relax filesystem root directory check

When relaxed checks are requested, let's not require the efi/xbootldr
directory to be the root of the filesystem. When building images, image
builders might install all efi/xbootldr files to a regular directory
first before packing them up into a partition. To allow bootctl to be
used in such scenarios to install systemd-boot, we need to relax the
fsroot check.

2 years agorepart: respect --discard=no also for block devices
Luca Boccassi [Tue, 22 Nov 2022 16:24:54 +0000 (16:24 +0000)] 
repart: respect --discard=no also for block devices

It's only used to avoid BLKDISCARD on individual partitions at the moment.
It can take a lot of time to run on very slow devices, so avoid it for
them too.

2 years agoUpdate changelog with latest sd-boot, sd-stub, and bootctl changes
Jason A. Donenfeld [Wed, 23 Nov 2022 00:24:57 +0000 (01:24 +0100)] 
Update changelog with latest sd-boot, sd-stub, and bootctl changes

2 years agostub: handle random seed like sd-boot does
Jason A. Donenfeld [Fri, 18 Nov 2022 01:49:16 +0000 (02:49 +0100)] 
stub: handle random seed like sd-boot does

sd-stub has an opportunity to handle the seed the same way sd-boot does,
which would have benefits for UKIs when sd-boot is not in use. This
commit wires that up.

It refactors the XBOOTLDR partition discovery to also find the ESP
partition, so that it access the random seed there.

2 years agosd-event: reenable epoll_pwait2()
Lennart Poettering [Tue, 22 Nov 2022 14:38:52 +0000 (15:38 +0100)] 
sd-event: reenable epoll_pwait2()

This reenables epoll_pwait2() use, i.e. undoes the effect of
39f756d3ae4765b8bf017567a12b8a4b358eaaf5.

Instead of just reverting that, this PR will change things so that we
strictly rely on glibc's new epoll_pwait2() wrapper (which was added
earlier this year), and drop our own manual fallback syscall wrapper.
That should nicely side-step any issues with correct syscall wrapping
definitions (which on some arch seem not to be easy, given the sigset_t
size final argument), by making this a glibc problem, not ours.

Given that the only benefit this delivers are time-outs more granular
than msec, it shouldn't really matter that we'll miss out on support
for this on systems with older glibcs.

2 years agoMerge pull request #25485 from DaanDeMeyer/gpt-fix
Daan De Meyer [Tue, 22 Nov 2022 21:29:50 +0000 (22:29 +0100)] 
Merge pull request #25485 from DaanDeMeyer/gpt-fix

gpt: Specify designator array sizes explicitly

2 years agokernel-install: make 90-loadentry.install templated
Zbigniew Jędrzejewski-Szmek [Tue, 22 Nov 2022 14:59:21 +0000 (15:59 +0100)] 
kernel-install: make 90-loadentry.install templated

It's a bit annoying that this causes so much churn, but I don't see a different
way to do this.

2 years agogpt: Drop PARTITION_LINUX_GENERIC and PARTITION_USER_HOME 25485/head
Daan De Meyer [Tue, 22 Nov 2022 14:59:50 +0000 (15:59 +0100)] 
gpt: Drop PARTITION_LINUX_GENERIC and PARTITION_USER_HOME

These don't have an inherent purpose, and aren't used throughout
the codebase, so let's simplify things and remove these.

See https://github.com/systemd/systemd/pull/24803#discussion_r1028190421
for more information.

2 years agogpt: Specify designator array sizes explicitly
Daan De Meyer [Tue, 22 Nov 2022 14:53:02 +0000 (15:53 +0100)] 
gpt: Specify designator array sizes explicitly

Avoid users accidentally accessing uninitialized memory by always
making sure the array size covers all possible enum values.

2 years agoio-util: document EINTR situation a bit 25483/head
Lennart Poettering [Tue, 22 Nov 2022 14:23:34 +0000 (15:23 +0100)] 
io-util: document EINTR situation a bit

2 years agoMerge pull request #25477 from yuwata/network-wifi-reconfigure-on-connect
Luca Boccassi [Tue, 22 Nov 2022 12:37:15 +0000 (13:37 +0100)] 
Merge pull request #25477 from yuwata/network-wifi-reconfigure-on-connect

network: wifi: try to reconfigure when connected

2 years agoman/journalctl: mention systemd-cat, make the description more direct
Zbigniew Jędrzejewski-Szmek [Tue, 22 Nov 2022 11:00:17 +0000 (12:00 +0100)] 
man/journalctl: mention systemd-cat, make the description more direct

We said "query the journal". This is true but also very generic. Let's say
"print log entries from the journal" instead, so that users who are looking for
"logging" are more likely to figure out that the journalctl is the tool for
them.

Also, mention systemd-journal-remote.service which can write the journal too.
And give some hints how to figure out how to write *to* the journal.

2 years agoutmp-wtmp: handle EINTR gracefully when waiting to write to tty
Lennart Poettering [Tue, 22 Nov 2022 11:56:55 +0000 (12:56 +0100)] 
utmp-wtmp: handle EINTR gracefully when waiting to write to tty

2 years agoutmp-wtmp: fix error in case isatty() fails
Lennart Poettering [Tue, 22 Nov 2022 11:56:38 +0000 (12:56 +0100)] 
utmp-wtmp: fix error in case isatty() fails

2 years agohomed: handle EINTR gracefully when waiting for device node
Lennart Poettering [Tue, 22 Nov 2022 11:55:10 +0000 (12:55 +0100)] 
homed: handle EINTR gracefully when waiting for device node

2 years agoresolved: handle -EINTR returned from fd_wait_for_event() better
Lennart Poettering [Tue, 22 Nov 2022 11:28:19 +0000 (12:28 +0100)] 
resolved: handle -EINTR returned from fd_wait_for_event() better

We might get signals for various reasons (for example, somebody asking
us to reload caches via a signal), hence let's handle this gracefully.

2 years agosd-netlink: handle EINTR from poll() gracefully, as success
Lennart Poettering [Tue, 22 Nov 2022 12:00:48 +0000 (13:00 +0100)] 
sd-netlink: handle EINTR from poll() gracefully, as success

2 years agovarlink: also handle EINTR gracefully when waiting for EIO via ppoll()
Lennart Poettering [Tue, 22 Nov 2022 11:42:46 +0000 (12:42 +0100)] 
varlink: also handle EINTR gracefully when waiting for EIO via ppoll()

2 years agostdio-bridge: don't be bothered with EINTR
Lennart Poettering [Tue, 22 Nov 2022 11:18:07 +0000 (12:18 +0100)] 
stdio-bridge: don't be bothered with EINTR

We handle signals via signal handlers, hence no need to be concerned
about EINTR.

2 years agosd-bus: handle -EINTR return from bus_poll()
Lennart Poettering [Mon, 21 Nov 2022 16:42:04 +0000 (17:42 +0100)] 
sd-bus: handle -EINTR return from bus_poll()

In sd_bus_wait(), let's convert EINTR to a return code of 0, thus asking
the caller do loop again and enter sd_bus_process() again (which will
not find any queued events). This way we'll not return an error on
something that isn't really an error. This should typically make sure
things are properly handled by the caller, magically, without eating up
the event entirely, and still giving the caller time to run some code if
they want.

2 years agotree-wide: modernizations with RET_NERRNO()
Lennart Poettering [Tue, 22 Nov 2022 11:14:33 +0000 (12:14 +0100)] 
tree-wide: modernizations with RET_NERRNO()

2 years agoman: update docs for MemoryZSwapMax=
Anita Zhang [Tue, 22 Nov 2022 06:36:37 +0000 (22:36 -0800)] 
man: update docs for MemoryZSwapMax=

2 years agoresolved: Fix OpenSSL error messages
Benjamin Fogle [Thu, 17 Nov 2022 14:52:50 +0000 (09:52 -0500)] 
resolved: Fix OpenSSL error messages

2 years agonetwork: wifi: try to reconfigure when connected 25477/head
Yu Watanabe [Tue, 22 Nov 2022 05:24:32 +0000 (14:24 +0900)] 
network: wifi: try to reconfigure when connected

Sometimes, RTM_NEWLINK message with carrier is received earlier than
NL80211_CMD_CONNECT. To make SSID= or other WiFi related settings in
[Match] section work, let's try to reconfigure the interface.

Fixes a bug introduced by 96f5f9ef9a1ba5146d3357c1548fb675d3bd5b68.

Fixes #25384.

2 years agonetwork: drop unnecessary prototype
Yu Watanabe [Tue, 22 Nov 2022 05:31:31 +0000 (14:31 +0900)] 
network: drop unnecessary prototype

Follow-up for a39a9ac8065c29330207838b70fe388bde2bc254.

2 years agoMerge pull request #25470 from keszybz/strv-extendf-format
Yu Watanabe [Tue, 22 Nov 2022 03:27:37 +0000 (12:27 +0900)] 
Merge pull request #25470 from keszybz/strv-extendf-format

Improve check for strv_extendf() format string

2 years agosystemctl: edit: write override files as text files
наб [Tue, 8 Nov 2022 20:30:01 +0000 (21:30 +0100)] 
systemctl: edit: write override files as text files

Instead of stripping the newline off the final would-be line;
continue to reduce an empty-line-only file to an empty file, though

Closes #25303

2 years agobootctl: use grey-and-slash prefix for source in list too
Zbigniew Jędrzejewski-Szmek [Wed, 16 Nov 2022 11:55:35 +0000 (12:55 +0100)] 
bootctl: use grey-and-slash prefix for source in list too

Follow-up for 7851732262ec94f50598c4a289589a6ddb97ebfd. The source
field also shows a path relative to $BOOT, so it should be displayed
in the same fashion.

2 years agoudev: make sure auto-root logic also works in UKIs booted from XBOOTLDR
Lennart Poettering [Mon, 21 Nov 2022 14:32:22 +0000 (15:32 +0100)] 
udev: make sure auto-root logic also works in UKIs booted from XBOOTLDR

If no root= switch is specified on the kernel command line we'll use the
root disk on which the partition the LoaderDevicePartUUID efi var is
located – as long as that partition is an ESP. Let's slightly liberalize
that and also allow it if that partition is an XBOOTLDR partition. This
ensures that UKIs spawned directly from XBOOTLDR work the same as those
from the ESP.

(Note that this makes no difference if sd-boot is in the mix, as in that
case LoaderDevicePartUUID is always set to the ESP, as that's where
sd-boot is located, and sd-boot will set the var first, sd-stub will
only set it later if it#s not set yet.)

2 years agotree-wide: make constant ratelimit compound actually const
Lennart Poettering [Fri, 18 Nov 2022 17:29:16 +0000 (18:29 +0100)] 
tree-wide: make constant ratelimit compound actually const

The compiler should recognize that these are constant expressions, but
let's better make this explicit, so that the linker can safely share the
initializations all over the place.

2 years agoboot: remove random-seed-mode
Jason A. Donenfeld [Mon, 21 Nov 2022 15:40:24 +0000 (16:40 +0100)] 
boot: remove random-seed-mode

Now that the random seed is used on virtualized systems, there's no
point in having a random-seed-mode toggle switch. Let's just always
require it now, with the existing logic already being there to allow not
having it if EFI itself has an RNG. In other words, the logic for this
can now be automatic.

2 years agoMerge pull request #25379 from keszybz/update-doc-links
Luca Boccassi [Tue, 22 Nov 2022 00:07:13 +0000 (01:07 +0100)] 
Merge pull request #25379 from keszybz/update-doc-links

Update doc links

2 years agobasic/strv: check printf arguments to strv_extendf() 25470/head
Zbigniew Jędrzejewski-Szmek [Mon, 21 Nov 2022 19:06:55 +0000 (20:06 +0100)] 
basic/strv: check printf arguments to strv_extendf()

The second argument to _printf_() specifies where the arguments start. We need to
use 0 in two cases: when the args in a va_list and can't be checked, and with journald
logging functions which accept multiple format strings with multiple argument sets,
which the _printf_ checker does not understand. But strv_extendf() can be checked.

2 years agomanager: fix format strings for trigger metadata
Zbigniew Jędrzejewski-Szmek [Mon, 21 Nov 2022 19:03:08 +0000 (20:03 +0100)] 
manager: fix format strings for trigger metadata

Fixup for c8bc7519c888a99134f88f8c82353246d3c0cc5d.

2 years agoMerge pull request #25395 from poettering/tpm2-dlsym-assert
Yu Watanabe [Mon, 21 Nov 2022 18:36:03 +0000 (03:36 +0900)] 
Merge pull request #25395 from poettering/tpm2-dlsym-assert

dlfcn-util: add static asserts ensuring our sym_xyz() func ptrs match …

2 years agomkosi: pull in libbpf1 instead of legacy libbpf0 on debian 25395/head
Lennart Poettering [Fri, 18 Nov 2022 14:13:55 +0000 (15:13 +0100)] 
mkosi: pull in libbpf1 instead of legacy libbpf0 on debian

2 years agodlfcn-util: add static asserts ensuring our sym_xyz() func ptrs match the types from...
Lennart Poettering [Wed, 16 Nov 2022 20:37:20 +0000 (21:37 +0100)] 
dlfcn-util: add static asserts ensuring our sym_xyz() func ptrs match the types from the official headers

Make sure that the sym_xyz function pointers have the types that the
functions we'll assign them have.

And of course, this found a number of incompatibilities right-away, in
particular in the bpf hookup.

(Doing this will trigger deprecation warnings from libbpf. I simply
turned them off locally now, since we are well aware of what we are
doing in that regard.)

There's one return type fix (bool → int), that actually matters I think,
as it might have created an incompatibility on some archs.

2 years agoupdate TODO
Lennart Poettering [Mon, 21 Nov 2022 14:14:22 +0000 (15:14 +0100)] 
update TODO

2 years agobootctl: install system token on virtualized systems
Jason A. Donenfeld [Thu, 17 Nov 2022 15:11:44 +0000 (16:11 +0100)] 
bootctl: install system token on virtualized systems

Removing the virtualization check might not be the worst thing in the
world, and would potentially get many, many more systems properly seeded
rather than not seeded. There are a few reasons to consider this:

- In most QEMU setups and most guides on how to setup QEMU, a separate
  pflash file is used for nvram variables, and this generally isn't
  copied around.

- We're now hashing in a timestamp, which should provide some level of
  differentiation, given that EFI_TIME has a nanoseconds field.

- The kernel itself will additionally hash in: a high resolution time
  stamp, a cycle counter, RDRAND output, the VMGENID uniquely
  identifying the virtual machine, any other seeds from the hypervisor
  (like from FDT or setup_data).

- During early boot, the RNG is reseeded quite frequently to account for
  the importance of early differentiation.

So maybe the mitigating factors make the actual feared problem
significantly less likely and therefore the pros of having file-based
seeding might outweigh the cons of weird misconfigured setups having a
hypothetical problem on first boot.

2 years agoMerge pull request #25461 from DaanDeMeyer/repart-followups
Daan De Meyer [Mon, 21 Nov 2022 13:02:25 +0000 (14:02 +0100)] 
Merge pull request #25461 from DaanDeMeyer/repart-followups

repart followups

2 years agodocs/BOOT_LOADER_INTERFACE: reword sentence to apply to both entry types 25379/head
Zbigniew Jędrzejewski-Szmek [Mon, 14 Nov 2022 08:47:01 +0000 (09:47 +0100)] 
docs/BOOT_LOADER_INTERFACE: reword sentence to apply to both entry types

2 years agotree-wide: BLS and DPS are now on uapi-group website
Zbigniew Jędrzejewski-Szmek [Mon, 14 Nov 2022 08:44:39 +0000 (09:44 +0100)] 
tree-wide: BLS and DPS are now on uapi-group website

2 years agorepart: Rework PartitionTarget initialization 25461/head
Daan De Meyer [Mon, 21 Nov 2022 10:23:51 +0000 (11:23 +0100)] 
repart: Rework PartitionTarget initialization

2 years agorepart: Use fd based operations in partition_populate_directory()
Daan De Meyer [Mon, 21 Nov 2022 10:10:34 +0000 (11:10 +0100)] 
repart: Use fd based operations in partition_populate_directory()

2 years agoman/sd_bus_default: Refer to man-pages project (man7.org) for ssh(1)
BerndAdameit [Sun, 20 Nov 2022 09:36:39 +0000 (10:36 +0100)] 
man/sd_bus_default: Refer to man-pages project (man7.org) for ssh(1)

2 years agoMerge pull request #25409 from medhefgo/boot-fixes
Lennart Poettering [Mon, 21 Nov 2022 10:34:50 +0000 (11:34 +0100)] 
Merge pull request #25409 from medhefgo/boot-fixes

boot: Several fixes

2 years agorepart: Remove redundant parentheses in partition_populate_directory()
Daan De Meyer [Mon, 21 Nov 2022 09:53:23 +0000 (10:53 +0100)] 
repart: Remove redundant parentheses in partition_populate_directory()

2 years agomkfs-util: Use FORK_CLOSE_ALL_FDS
Daan De Meyer [Mon, 21 Nov 2022 09:51:15 +0000 (10:51 +0100)] 
mkfs-util: Use FORK_CLOSE_ALL_FDS

2 years agomkfs-util: Prefer fd based stat() where possible
Daan De Meyer [Mon, 21 Nov 2022 09:49:37 +0000 (10:49 +0100)] 
mkfs-util: Prefer fd based stat() where possible

2 years agomkfs-util: Use GID_FMT
Daan De Meyer [Mon, 21 Nov 2022 09:46:12 +0000 (10:46 +0100)] 
mkfs-util: Use GID_FMT

2 years agorepart: Use ASSERT_PTR() in partition_encrypt()
Daan De Meyer [Mon, 21 Nov 2022 09:45:26 +0000 (10:45 +0100)] 
repart: Use ASSERT_PTR() in partition_encrypt()

2 years agorepart: Use ftruncate() instead of posix_allocate()
Daan De Meyer [Mon, 21 Nov 2022 09:44:38 +0000 (10:44 +0100)] 
repart: Use ftruncate() instead of posix_allocate()

2 years agorepart: Fix parse_filter_partitions() log messages
Daan De Meyer [Mon, 21 Nov 2022 09:36:37 +0000 (10:36 +0100)] 
repart: Fix parse_filter_partitions() log messages

2 years agorepart: Fix FilterPartitionsType enum name
Daan De Meyer [Mon, 21 Nov 2022 09:35:18 +0000 (10:35 +0100)] 
repart: Fix FilterPartitionsType enum name

2 years agorepart: Rework unused partition number algorithm
Daan De Meyer [Mon, 21 Nov 2022 09:34:28 +0000 (10:34 +0100)] 
repart: Rework unused partition number algorithm

2 years agorepart: Use IN_SET() in one more place
Daan De Meyer [Mon, 21 Nov 2022 09:28:36 +0000 (10:28 +0100)] 
repart: Use IN_SET() in one more place

2 years agopo: Translated using Weblate (Dutch)
Richard E. van der Luit [Sun, 20 Nov 2022 15:19:54 +0000 (16:19 +0100)] 
po: Translated using Weblate (Dutch)

Currently translated at 100.0% (193 of 193 strings)

Co-authored-by: Richard E. van der Luit <fedoraproject@veneax.nl>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/nl/
Translation: systemd/main

2 years agoboot: Replace firmware security hooks directly 25409/head
Jan Janssen [Tue, 15 Nov 2022 17:53:02 +0000 (18:53 +0100)] 
boot: Replace firmware security hooks directly

For some firmware, replacing their own security arch instance with our
override using ReinstallProtocolInterface() is not enough as they will
not use it. This commit goes back to how this was done before by
directly modifying the security protocols.

Fixes: #25336
2 years agoboot: Rework security arch override
Jan Janssen [Tue, 15 Nov 2022 17:22:38 +0000 (18:22 +0100)] 
boot: Rework security arch override

This simplifies the caller interface for security arch overrides by only
having to pass a validator and an optional context.