]> git.ipfire.org Git - thirdparty/systemd.git/commit
boot/random-seed: create \loader\ dir if missing when seeding
authordongshengyuan <545258830@qq.com>
Tue, 30 Jun 2026 01:47:22 +0000 (09:47 +0800)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 30 Jun 2026 12:26:59 +0000 (13:26 +0100)
commit2fbb73cb920697bb03e4b2406494aea2c43a453c
tree5d1631ada6bb214ae2f36642cbe21e54c1193dc1
parent2dc228b127ee2bc7a4f461c86aafe4034b0a170b
boot/random-seed: create \loader\ dir if missing when seeding

When the random seed file doesn't exist but we have good entropy
(seeded_by_efi=true), we attempt to create it. This requires a handle
to the \loader\ directory, which may not exist on systems using
UKI+EFISTUB without systemd-boot installed.

Obtain the directory handle by first trying a read-only open; if that
returns EFI_NOT_FOUND, create the directory. We deliberately avoid
requesting write access on an already-present directory because some
firmware implementations return EFI_INVALID_PARAMETER for a
WRITE|CREATE open on an existing directory — this would be logged at
LOG_ERR and abort seed creation on systems where \loader\ exists but
random-seed does not (the normal systemd-boot layout).

Once a handle to \loader\ is obtained, open the seed file relative to
that handle rather than using the full path from root.

Introduced-by: c0e7046c17 ("boot: log about RO I/O errors at debug level.")
Fixes: #42801
Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
src/boot/random-seed.c