]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect: let's check for crypto_LUKS before fstype allowlist check
authorLennart Poettering <lennart@poettering.net>
Thu, 20 Apr 2023 09:14:50 +0000 (11:14 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 20 Apr 2023 11:39:28 +0000 (13:39 +0200)
When trying to mount a partition that is encrypted without the
encryption first having been set up we want to return a
recognizable error (EUNATCH). This was broken by
80ce8580f5aa6b03fa13a0b3b30207bc9b5c5fe0 which added an allowlist check
for permissible file systems first. Let's reverse the check order, so
that we get EUNATCH again, as before. (And leave EIDRM as error for the
failed allowlist check).

src/shared/dissect-image.c

index 45bed868cbc60ffbd61cba53fa336f17833d9737..b84ef464420989bbb09eb3bb1298230cfaeef732 100644 (file)
@@ -1907,11 +1907,6 @@ static int mount_partition(
 
         if (!fstype)
                 return -EAFNOSUPPORT;
-        r = dissect_fstype_ok(fstype);
-        if (r < 0)
-                return r;
-        if (!r)
-                return -EIDRM; /* Recognizable error */
 
         /* We are looking at an encrypted partition? This either means stacked encryption, or the caller
          * didn't call dissected_image_decrypt() beforehand. Let's return a recognizable error for this
@@ -1919,6 +1914,12 @@ static int mount_partition(
         if (streq(fstype, "crypto_LUKS"))
                 return -EUNATCH;
 
+        r = dissect_fstype_ok(fstype);
+        if (r < 0)
+                return r;
+        if (!r)
+                return -EIDRM; /* Recognizable error */
+
         rw = m->rw && !(flags & DISSECT_IMAGE_MOUNT_READ_ONLY);
 
         discard = ((flags & DISSECT_IMAGE_DISCARD) ||