From: Yu Watanabe Date: Tue, 5 Dec 2023 05:57:13 +0000 (+0900) Subject: find-esp: do not fail when /boot on btrfs RAID on searching ESP or xbootldr X-Git-Tag: v256-rc1~1473^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5c831ddec801d653014b4eea820a1d6afbb91a63;p=thirdparty%2Fsystemd.git find-esp: do not fail when /boot on btrfs RAID on searching ESP or xbootldr When /boot or friends is on btrfs RAID, btrfs_get_block_device_at() will succeed with 0 and provide zero devnum. Then, - if we are previleged, devname_from_devnum() maps the devnum to /run/systemd/inaccessible/blk, and the subsequent verification by blkid will fail, - if we are unprevileged, sd_device_new_from_devnum() will fail. This makes - when find_esp() or find_xbootldr() is called without any paths, that is, called with the searching mode, then returns -ENOKEY, which should be handled gracefully by the caller, - when they are called with an input path, then they provide the proper error message and suggestion. Fixes RHBZ#2251262 (https://bugzilla.redhat.com/show_bug.cgi?id=2251262). --- diff --git a/src/shared/find-esp.c b/src/shared/find-esp.c index 9b8c7f73bcd..ce1069e9432 100644 --- a/src/shared/find-esp.c +++ b/src/shared/find-esp.c @@ -396,6 +396,11 @@ static int verify_esp( if (relax_checks) goto finish; + if (devnum_is_zero(devid)) + return log_full_errno(searching ? LOG_DEBUG : LOG_ERR, + SYNTHETIC_ERRNO(searching ? EADDRNOTAVAIL : ENODEV), + "Could not determine backing block device of directory \"%s\" (btrfs RAID?).", p); + /* If we are unprivileged we ask udev for the metadata about the partition. If we are privileged we * use blkid instead. Why? Because this code is called from 'bootctl' which is pretty much an * emergency recovery tool that should also work when udev isn't up (i.e. from the emergency shell), @@ -767,6 +772,15 @@ static int verify_xbootldr( if (relax_checks) goto finish; + if (devnum_is_zero(devid)) + return log_full_errno(searching ? LOG_DEBUG : LOG_ERR, + SYNTHETIC_ERRNO(searching ? EADDRNOTAVAIL : ENODEV), + "Could not determine backing block device of directory \"%s\" (btrfs RAID?).%s", + p, + searching ? "" : + "\nHint: set $SYSTEMD_RELAX_XBOOTLDR_CHECKS=yes environment variable " + "to bypass this and further verifications for the directory."); + if (unprivileged_mode) r = verify_xbootldr_udev(devid, flags, ret_uuid); else