]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootspec: use verify_fsroot_dir() in verify_xbootldr() too
authorLennart Poettering <lennart@poettering.net>
Tue, 5 Feb 2019 18:11:31 +0000 (19:11 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 1 Mar 2019 11:41:32 +0000 (12:41 +0100)
Let's share some code between verify_xbootldr() and verify_esp().

src/shared/bootspec.c

index 0d0b09a77cf871f86240de2e14ee410e6d83d4d0..b20af117b3a1700fa86383f76fc98622d75bf8e9 100644 (file)
@@ -964,43 +964,25 @@ static int verify_xbootldr(
                 bool unprivileged_mode,
                 sd_id128_t *ret_uuid) {
 
-        struct stat st, st2;
         bool relax_checks;
-        const char *t2;
+        dev_t devid;
         int r;
 
         assert(p);
 
         relax_checks = getenv_bool("SYSTEMD_RELAX_XBOOTLDR_CHECKS") > 0;
 
-        if (stat(p, &st) < 0)
-                return log_full_errno((searching && errno == ENOENT) ||
-                                      (unprivileged_mode && errno == EACCES) ? LOG_DEBUG : LOG_ERR, errno,
-                                      "Failed to determine block device node of \"%s\": %m", p);
-
-        if (major(st.st_dev) == 0)
-                return log_full_errno(searching ? LOG_DEBUG : LOG_ERR,
-                                      SYNTHETIC_ERRNO(searching ? EADDRNOTAVAIL : ENODEV),
-                                      "Block device node of \"%s\" is invalid.", p);
-
-        t2 = strjoina(p, "/..");
-        r = stat(t2, &st2);
+        r = verify_fsroot_dir(p, searching, unprivileged_mode, &devid);
         if (r < 0)
-                return log_full_errno(unprivileged_mode && errno == EACCES ? LOG_DEBUG : LOG_ERR, errno,
-                                      "Failed to determine block device node of parent of \"%s\": %m", p);
-
-        if (st.st_dev == st2.st_dev)
-                return log_full_errno(searching ? LOG_DEBUG : LOG_ERR,
-                                      SYNTHETIC_ERRNO(searching ? EADDRNOTAVAIL : ENODEV),
-                                      "Directory \"%s\" is not the root of the XBOOTLDR file system.", p);
+                return r;
 
         if (detect_container() > 0 || relax_checks)
                 goto finish;
 
         if (unprivileged_mode)
-                return verify_xbootldr_udev(st.st_dev, searching, ret_uuid);
+                return verify_xbootldr_udev(devid, searching, ret_uuid);
         else
-                return verify_xbootldr_blkid(st.st_dev, searching, ret_uuid);
+                return verify_xbootldr_blkid(devid, searching, ret_uuid);
 
 finish:
         if (ret_uuid)