[pkg-cryptsetup-devel] Bug#994056: cryptsetup: blkid check fails to take offset option into account

Thorsten Glaser tg at mirbsd.de
Fri Oct 8 16:13:45 BST 2021


Dixi quod…

>I’m attaching a first cut at my favourite solution. It’s missing

… this time with attachment…

bye,
//mirabilos
-- 
„Cool, /usr/share/doc/mksh/examples/uhr.gz ist ja ein Grund,
mksh auf jedem System zu installieren.“
	-- XTaran auf der OpenRheinRuhr, ganz begeistert
(EN: “[…]uhr.gz is a reason to install mksh on every system.”)
-------------- next part --------------
diff --git a/debian/checks/blkid b/debian/checks/blkid
index 5332ba35..0be466f1 100644
--- a/debian/checks/blkid
+++ b/debian/checks/blkid
@@ -17,7 +17,23 @@ dev="$1"
 fs="$2"
 offset="$3"
 
-blkid="$(/sbin/blkid -o value -s TYPE -p ${offset:+-O "$((offset*512))"} -- "$dev")"
+case x$offset in
+(x)
+	blkid_offset=
+	;;
+(x*[!0-9]*)
+	echo " - Invalid 'offset' option: $offset"
+	exit 1
+	;;
+(*)
+	blkid_offset="-O $(bc <<EOF
+$offset*512
+EOF
+)"
+	;;
+esac
+
+blkid="$(/sbin/blkid -o value -s TYPE -p $blkid_offset -- "$dev")"
 
 # blkid output is empty if $dev has an unknown filesystem
 if [ -z "$blkid" ] && [ -z "$fs" ]; then
diff --git a/debian/checks/un_blkid b/debian/checks/un_blkid
index 037ae34f..07f47cc9 100644
--- a/debian/checks/un_blkid
+++ b/debian/checks/un_blkid
@@ -16,7 +16,23 @@ dev="$1"
 fs="$2"
 offset="$3"
 
-blkid="$(/sbin/blkid -o value -s TYPE -p ${offset:+-O "$((offset*512))"} -- "$dev")"
+case x$offset in
+(x)
+	blkid_offset=
+	;;
+(x*[!0-9]*)
+	echo " - Invalid 'offset' option: $offset"
+	exit 1
+	;;
+(*)
+	blkid_offset="-O $(bc <<EOF
+$offset*512
+EOF
+)"
+	;;
+esac
+
+blkid="$(/sbin/blkid -o value -s TYPE -p $blkid_offset -- "$dev")"
 
 # blkid output is empty if $dev has an unknown filesystem
 if [ -n "$blkid" ] && [ -z "$fs" ]; then
diff --git a/debian/control b/debian/control
index 2dd3a497..1a8fbb14 100644
--- a/debian/control
+++ b/debian/control
@@ -39,6 +39,7 @@ Package: cryptsetup
 Architecture: linux-any
 Multi-Arch: foreign
 Depends: cryptsetup-bin (>= 2:1.6.0),
+         bc,
          dmsetup,
          ${misc:Depends},
          ${shlibs:Depends}


More information about the pkg-cryptsetup-devel mailing list