[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#498143: Please detect non-ISO block devices masquerading as Debian CDs



Chris Lamb wrote:

> Attached.

Updated patch series attached. The previous one did not apply anymore.


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby@debian.org
       `-
From 30c6a69043f56f1616068e9910adbba819a18fb9 Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Fri, 24 Jul 2009 19:30:46 +0200
Subject: [PATCH 1/6] Add "usb-partition" argument to list-devices for detecting partitions on USB drives. Patch originally by Tormod Volden <debian.tormod@gmail.com>.

---
 packages/debian-installer-utils/debian/changelog |    5 +++++
 packages/debian-installer-utils/list-devices     |   17 +++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/packages/debian-installer-utils/debian/changelog b/packages/debian-installer-utils/debian/changelog
index 2979010..213405f 100644
--- a/packages/debian-installer-utils/debian/changelog
+++ b/packages/debian-installer-utils/debian/changelog
@@ -1,11 +1,16 @@
 debian-installer-utils (1.72) UNRELEASED; urgency=low
 
+  [ Colin Watson ]
   * Upgrade to debhelper v7.
 
   [ Aurelien Jarno ]
   * Also ship other terminfo on GNU/kFreeBSD, they are also used in some
     cases (e.g. installation through ssh).
 
+  [ Chris Lamb ]
+  * Add "usb-partition" argument to list-devices for detecting partitions on
+    USB drives. Patch originally by Tormod Volden <debian.tormod@gmail.com>.
+
  -- Colin Watson <cjwatson@debian.org>  Thu, 13 Aug 2009 14:52:50 +0100
 
 debian-installer-utils (1.71) unstable; urgency=low
diff --git a/packages/debian-installer-utils/list-devices b/packages/debian-installer-utils/list-devices
index b748be9..2a95b71 100755
--- a/packages/debian-installer-utils/list-devices
+++ b/packages/debian-installer-utils/list-devices
@@ -6,9 +6,9 @@ case $TYPE in
 	logger -t list-devices "deprecated parameter maybe-floppy"
 	TYPE=floppy
 	;;
-    cd|disk|partition|floppy|maybe-usb-floppy) ;;
+    cd|disk|partition|floppy|maybe-usb-floppy|usb-partition) ;;
     *)
-	echo "Usage: $0 cd|disk|partition|floppy|maybe-usb-floppy" >&2
+	echo "Usage: $0 cd|disk|partition|floppy|maybe-usb-floppy|usb-partition" >&2
 	exit 2
 	;;
 esac
@@ -40,6 +40,12 @@ case $TYPE in
 	# Also allow misdetected USB devices
 	scan_partition=:
 	;;
+    usb-partition)
+	for x in /sys/block/*/*; do
+		[ -d "$x" ] || continue
+		syspaths="${syspaths:+$syspaths }$x"
+	done
+	;;
     *)
 	for x in /sys/block/*; do
 		[ -d "$x" ] || continue
@@ -85,6 +91,13 @@ for x in $syspaths; do
 			match=:
 		fi
 	fi
+	# Disk partitions, but only on USB drives
+	if ! $match && [ "$TYPE" = usb-partition ]; then
+		if device_info env "$devpath" | grep -q '^ID_BUS=usb' && \
+		   device_info env "$devpath" | grep -q '^ID_TYPE=disk'; then
+			match=:
+		fi
+	fi
 	if $match; then
 		if ! name="$(device_info name "$devpath")"; then
 			name="$(printf %s "${devpath##*/}" | \
-- 
1.6.3.3

From 5e1e90c55f38b93a3803eba513c307a40530e7f1 Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Fri, 24 Jul 2009 19:42:04 +0200
Subject: [PATCH 2/6] Append " fstype=iso9660" to mounting status messages.

---
 packages/cdrom-detect/debian/cdrom-detect.postinst |    9 +++++----
 packages/cdrom-detect/debian/changelog             |    4 ++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/packages/cdrom-detect/debian/cdrom-detect.postinst b/packages/cdrom-detect/debian/cdrom-detect.postinst
index da0c1bb..5ead814 100755
--- a/packages/cdrom-detect/debian/cdrom-detect.postinst
+++ b/packages/cdrom-detect/debian/cdrom-detect.postinst
@@ -35,12 +35,12 @@ do
 	devices="$(list-devices cd; list-devices maybe-usb-floppy)"
 	for device in $devices; do
 		if mount -t iso9660 -o ro,exec $device /cdrom; then
-			log "CD-ROM mount succeeded: device=$device"
+			log "CD-ROM mount succeeded: device=$device fstype=iso9660"
 			mounted=1
 			db_set cdrom-detect/cdrom_device $device
 			break
 		else
-			log "CD-ROM mount failed: device=$device"
+			log "CD-ROM mount failed: device=$device fstype=iso9660"
 		fi
 	done
 
@@ -102,11 +102,12 @@ do
 			modprobe $module
 		fi
 		if mount -t iso9660 -o ro,exec $device /cdrom; then
-			log "CD-ROM mount succeeded: device=$device"
+			log "CD-ROM mount succeeded: device=$device fstype=iso9660"
+			db_set cdrom-detect/cdrom_fs iso9660
 			mounted=1
 			break
 		else
-			log "CD-ROM mount failed: device=$device"
+			log "CD-ROM mount failed: device=$device fstype=iso9660"
 			fail
 		fi
 	else
diff --git a/packages/cdrom-detect/debian/changelog b/packages/cdrom-detect/debian/changelog
index a2a30e3..2fbf886 100644
--- a/packages/cdrom-detect/debian/changelog
+++ b/packages/cdrom-detect/debian/changelog
@@ -1,7 +1,11 @@
 cdrom-detect (1.32) UNRELEASED; urgency=low
 
+  [ Colin Watson ]
   * Upgrade to debhelper v7.
 
+  [ Chris Lamb ]
+  * Append " fstype=iso9660" to mounting status messages.
+
  -- Colin Watson <cjwatson@debian.org>  Thu, 13 Aug 2009 14:29:04 +0100
 
 cdrom-detect (1.31) unstable; urgency=low
-- 
1.6.3.3

From ee676f3bf02e8f5f9a4ef509f53d547d8796eb3c Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Fri, 24 Jul 2009 19:45:20 +0200
Subject: [PATCH 3/6] Try mounting USB block devices if cdrom-detect/try-usb is true. We reject the mountpoint if it does not have /.disk/info file. (Closes: #498143)

---
 packages/cdrom-detect/debian/cdrom-detect.postinst |   20 ++++++++++++++++++++
 .../cdrom-detect/debian/cdrom-detect.templates     |    5 +++++
 packages/cdrom-detect/debian/changelog             |    2 ++
 packages/cdrom-detect/debian/control               |    2 +-
 4 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/packages/cdrom-detect/debian/cdrom-detect.postinst b/packages/cdrom-detect/debian/cdrom-detect.postinst
index 5ead814..ca38cb1 100755
--- a/packages/cdrom-detect/debian/cdrom-detect.postinst
+++ b/packages/cdrom-detect/debian/cdrom-detect.postinst
@@ -32,6 +32,26 @@ while true
 do
 	mounted=0
 
+	if db_get cdrom-detect/try-usb && [ "$RET" = "true" ]; then
+		devices="$(list-devices usb-partition)"
+		for device in $devices; do
+			if mount -t vfat -o ro,exec $device /cdrom &&
+			   [ -e /cdrom/.disk/info ]; then
+				log "CD-ROM mount succeeded: device=$device fstype=vfat"
+				mounted=1
+				db_set cdrom-detect/cdrom_device $device
+				break
+			else
+				log "CD-ROM mount failed: device=$device fstype=vfat"
+				umount /cdrom 2>/dev/null || true
+			fi
+		done
+	fi
+
+	if [ "$mounted" = "1" ]; then
+		break
+	fi
+
 	devices="$(list-devices cd; list-devices maybe-usb-floppy)"
 	for device in $devices; do
 		if mount -t iso9660 -o ro,exec $device /cdrom; then
diff --git a/packages/cdrom-detect/debian/cdrom-detect.templates b/packages/cdrom-detect/debian/cdrom-detect.templates
index 878f474..32e7615 100644
--- a/packages/cdrom-detect/debian/cdrom-detect.templates
+++ b/packages/cdrom-detect/debian/cdrom-detect.templates
@@ -123,3 +123,8 @@ Type: text
 #  Item in the main menu to select this package
 # :sl2:
 _Description: Detect and mount CD-ROM
+
+Template: cdrom-detect/try-usb
+Type: boolean
+Description: for internal use only
+ Preseed this to true to try to mount /cdrom from USB partitions.
diff --git a/packages/cdrom-detect/debian/changelog b/packages/cdrom-detect/debian/changelog
index 2fbf886..45855e9 100644
--- a/packages/cdrom-detect/debian/changelog
+++ b/packages/cdrom-detect/debian/changelog
@@ -5,6 +5,8 @@ cdrom-detect (1.32) UNRELEASED; urgency=low
 
   [ Chris Lamb ]
   * Append " fstype=iso9660" to mounting status messages.
+  * Try mounting USB block devices if cdrom-detect/try-usb is true. We reject
+    the mountpoint if it does not have /.disk/info file. (Closes: #498143)
 
  -- Colin Watson <cjwatson@debian.org>  Thu, 13 Aug 2009 14:29:04 +0100
 
diff --git a/packages/cdrom-detect/debian/control b/packages/cdrom-detect/debian/control
index bd2a567..b6a7aa9 100644
--- a/packages/cdrom-detect/debian/control
+++ b/packages/cdrom-detect/debian/control
@@ -10,6 +10,6 @@ Vcs-Svn: svn://svn.debian.org/d-i/trunk/packages/cdrom-detect
 Package: cdrom-detect
 XC-Package-Type: udeb
 Architecture: all
-Depends: ${misc:Depends}, hw-detect, di-utils (>= 1.48)
+Depends: ${misc:Depends}, hw-detect, di-utils (>= 1.72)
 XB-Installer-Menu-Item: 1300
 Description: Detect CDROM devices and mount the CD
-- 
1.6.3.3

From f6e83e1a398b5c252eaee94b1e74bdb7d8842fd2 Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Fri, 24 Jul 2009 20:02:21 +0200
Subject: [PATCH 4/6] Set the filesystem type in cdrom-detect/cdrom_fs for apt-setup's benefit.

---
 packages/cdrom-detect/debian/cdrom-detect.postinst |    2 ++
 .../cdrom-detect/debian/cdrom-detect.templates     |    6 ++++++
 packages/cdrom-detect/debian/changelog             |    1 +
 3 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/packages/cdrom-detect/debian/cdrom-detect.postinst b/packages/cdrom-detect/debian/cdrom-detect.postinst
index ca38cb1..5a2de60 100755
--- a/packages/cdrom-detect/debian/cdrom-detect.postinst
+++ b/packages/cdrom-detect/debian/cdrom-detect.postinst
@@ -40,6 +40,7 @@ do
 				log "CD-ROM mount succeeded: device=$device fstype=vfat"
 				mounted=1
 				db_set cdrom-detect/cdrom_device $device
+				db_set cdrom-detect/cdrom_fs vfat
 				break
 			else
 				log "CD-ROM mount failed: device=$device fstype=vfat"
@@ -58,6 +59,7 @@ do
 			log "CD-ROM mount succeeded: device=$device fstype=iso9660"
 			mounted=1
 			db_set cdrom-detect/cdrom_device $device
+			db_set cdrom-detect/cdrom_fs iso9660
 			break
 		else
 			log "CD-ROM mount failed: device=$device fstype=iso9660"
diff --git a/packages/cdrom-detect/debian/cdrom-detect.templates b/packages/cdrom-detect/debian/cdrom-detect.templates
index 32e7615..9e01795 100644
--- a/packages/cdrom-detect/debian/cdrom-detect.templates
+++ b/packages/cdrom-detect/debian/cdrom-detect.templates
@@ -59,6 +59,12 @@ _Description: Device file for accessing the CD-ROM:
  available devices in /dev with "ls /dev". You can return to this screen
  by pressing ALT+F1.
 
+Template: cdrom-detect/cdrom_fs
+Type: string
+Default: iso9660
+Description: for internal use only
+ File system used on cdrom-detect/cdrom_device.
+
 Template: cdrom-detect/scanning_progress_title
 Type: text
 # :sl1:
diff --git a/packages/cdrom-detect/debian/changelog b/packages/cdrom-detect/debian/changelog
index 45855e9..1ee1990 100644
--- a/packages/cdrom-detect/debian/changelog
+++ b/packages/cdrom-detect/debian/changelog
@@ -7,6 +7,7 @@ cdrom-detect (1.32) UNRELEASED; urgency=low
   * Append " fstype=iso9660" to mounting status messages.
   * Try mounting USB block devices if cdrom-detect/try-usb is true. We reject
     the mountpoint if it does not have /.disk/info file. (Closes: #498143)
+  * Set the filesystem type in cdrom-detect/cdrom_fs for apt-setup's benefit.
 
  -- Colin Watson <cjwatson@debian.org>  Thu, 13 Aug 2009 14:29:04 +0100
 
-- 
1.6.3.3

From 246871d960ed3d05e6f5a50dfe3cac308fcab717 Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Fri, 24 Jul 2009 19:58:21 +0200
Subject: [PATCH 5/6] Use cdrom-detect/cdrom_fs when remounting the CD to ensure that we do so using the same filesystem. Patch by Colin Watson, merged back from Ubuntu.

---
 packages/apt-setup/debian/changelog   |    5 +++++
 packages/apt-setup/generators/40cdrom |    6 +++++-
 packages/apt-setup/load-install-cd    |    6 +++++-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/packages/apt-setup/debian/changelog b/packages/apt-setup/debian/changelog
index f2de784..b6c53d7 100644
--- a/packages/apt-setup/debian/changelog
+++ b/packages/apt-setup/debian/changelog
@@ -1,7 +1,12 @@
 apt-setup (1:0.43) UNRELEASED; urgency=low
 
+  [ Colin Watson ]
   * Upgrade to debhelper v7.
 
+  [ Chris Lamb ]
+  * Use cdrom-detect/cdrom_fs when remounting the CD to ensure that we do so
+    using the same filesystem. Patch by Colin Watson, merged back from Ubuntu.
+
  -- Colin Watson <cjwatson@debian.org>  Thu, 13 Aug 2009 14:00:28 +0100
 
 apt-setup (1:0.42) unstable; urgency=low
diff --git a/packages/apt-setup/generators/40cdrom b/packages/apt-setup/generators/40cdrom
index a274d1f..09bba76 100755
--- a/packages/apt-setup/generators/40cdrom
+++ b/packages/apt-setup/generators/40cdrom
@@ -11,8 +11,12 @@ fi
 
 remount_cd() {
 	if [ "$ROOT" ] && [ ! -d /hd-media ]; then
+		fs=iso9660
+		if db_get cdrom-detect/cdrom_fs && [ "$RET" ]; then
+			fs="$RET"
+		fi
 		db_get cdrom-detect/cdrom_device
-		$logoutput mount -t iso9660 -o ro,exec $RET /cdrom || true
+		$logoutput mount -t "$fs" -o ro,exec $RET /cdrom || true
 	fi
 }
 
diff --git a/packages/apt-setup/load-install-cd b/packages/apt-setup/load-install-cd
index f3c8fac..ccf9bb5 100755
--- a/packages/apt-setup/load-install-cd
+++ b/packages/apt-setup/load-install-cd
@@ -29,5 +29,9 @@ while ! check_id; do
 	db_go || exit 10
 done
 
+fs=iso9660
+if db_get cdrom-detect/cdrom_fs && [ "$RET" ]; then
+	fs="$RET"
+fi
 db_get cdrom-detect/cdrom_device
-$logoutput mount -t iso9660 -o ro,exec $RET /cdrom
+$logoutput mount -t "$fs" -o ro,exec $RET /cdrom
-- 
1.6.3.3

From b3948b2541bce8bd88c1d272d92cd21db1cad19a Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Sat, 25 Jul 2009 19:09:43 +0200
Subject: [PATCH 6/6] Don't try and run apt-cdrom for vfat "CD-ROMs"

---
 packages/apt-setup/debian/changelog   |    1 +
 packages/apt-setup/generators/40cdrom |   13 +++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/packages/apt-setup/debian/changelog b/packages/apt-setup/debian/changelog
index b6c53d7..bb4f783 100644
--- a/packages/apt-setup/debian/changelog
+++ b/packages/apt-setup/debian/changelog
@@ -6,6 +6,7 @@ apt-setup (1:0.43) UNRELEASED; urgency=low
   [ Chris Lamb ]
   * Use cdrom-detect/cdrom_fs when remounting the CD to ensure that we do so
     using the same filesystem. Patch by Colin Watson, merged back from Ubuntu.
+  * Don't try and run apt-cdrom for non-ISO9660 "CD-ROMs".
 
  -- Colin Watson <cjwatson@debian.org>  Thu, 13 Aug 2009 14:00:28 +0100
 
diff --git a/packages/apt-setup/generators/40cdrom b/packages/apt-setup/generators/40cdrom
index 09bba76..ad6ddd1 100755
--- a/packages/apt-setup/generators/40cdrom
+++ b/packages/apt-setup/generators/40cdrom
@@ -9,12 +9,17 @@ if [ ! -e /cdrom/.disk/base_installable ]; then
 	exit 0
 fi
 
+fs=iso9660
+if db_get cdrom-detect/cdrom_fs && [ "$RET" ]; then
+	fs="$RET"
+fi
+
+if [ "$fs" != "iso9660" ]; then
+	exit 0
+fi
+
 remount_cd() {
 	if [ "$ROOT" ] && [ ! -d /hd-media ]; then
-		fs=iso9660
-		if db_get cdrom-detect/cdrom_fs && [ "$RET" ]; then
-			fs="$RET"
-		fi
 		db_get cdrom-detect/cdrom_device
 		$logoutput mount -t "$fs" -o ro,exec $RET /cdrom || true
 	fi
-- 
1.6.3.3

Attachment: signature.asc
Description: PGP signature


Reply to: