]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
find-esp: replace assert by a runtime check
authorDavid Tardon <dtardon@redhat.com>
Fri, 5 Dec 2025 12:09:16 +0000 (13:09 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 9 Dec 2025 05:36:31 +0000 (14:36 +0900)
The path--as a whole--is no longer being opened with O_DIRECTORY, hence
the assertion is not valid.

Reproducer:
 # SYSTEMD_RELAX_ESP_CHECKS=1 bootctl list --esp-path=`pwd`/README
 Assertion 'S_ISDIR(sxa.stx_mode)' failed at src/shared/find-esp.c:295, function verify_fsroot_dir(). Aborting.

Follow-up-for: 63105f33edad423691e2d53bf7071f99c83799ba

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2417917
src/shared/find-esp.c

index 1796ed8c760041e0ad9fcc0d88c41827eb053e7e..f029d7ea922068cea3af7b5236c2216f64108941 100644 (file)
@@ -292,7 +292,8 @@ static int verify_fsroot_dir(
                                       (unprivileged_mode && ERRNO_IS_PRIVILEGE(errno)) ? LOG_DEBUG : LOG_ERR, errno,
                                       "Failed to determine block device node of \"%s\": %m", path);
 
-        assert(S_ISDIR(sxa.stx_mode)); /* We used O_DIRECTORY above, when opening, so this must hold */
+        if (!S_ISDIR(sxa.stx_mode))
+                return log_error_errno(SYNTHETIC_ERRNO(ENOTDIR), "Path \"%s\" is not a directory", path);
 
         if (FLAGS_SET(sxa.stx_attributes_mask, STATX_ATTR_MOUNT_ROOT)) {