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

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



Frans Pop wrote:

> It would be much nicer if we could somehow display a dialog offering the
> alternative is mounting a CD fails.

To frame my thoughts here, this is to support d-i when invoked from Debian
Live USB sticks - as Debian Live knows the target media when building the
USB image, "try-usb=true" is appended to all generated "usb with d-i"
images.

Thus, their users never require such a prompt. Indeed, if they ever were in
a position to see it, their installation would already be in trouble.

Therefore, whilst I would agree that it would be desirable to ask the user
in that situation, I don't think this additional feature request should
block the underlying support for try-usb. Besides, the only known users who
genuinely need this "trick" right now are Debian Live, and they don't need
require a dialog.

Anyway, updated patch series attached with "boot-installer/parameters.xml"
docs and updated apt-setup changelog.


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby@debian.org
       `-
From b77e711482cd31392725e31bed8bde724d437058 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/7] 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 51832db28d3271c140f103aad7e7da8a8585eddf 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/7] 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 7adfcbdd990b4e9fdc76229c314c89c730ae6373 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/7] 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 2534d079f43f04bb1d20947457cad022bc689679 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/7] 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 54490bf61368a374d953928033c5e7b52605d14f 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/7] 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   |    6 ++++++
 packages/apt-setup/generators/40cdrom |    6 +++++-
 packages/apt-setup/load-install-cd    |    6 +++++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/packages/apt-setup/debian/changelog b/packages/apt-setup/debian/changelog
index f2de784..0117000 100644
--- a/packages/apt-setup/debian/changelog
+++ b/packages/apt-setup/debian/changelog
@@ -1,7 +1,13 @@
 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.
+    Requires cdrom-detect >= 1.32.
+
  -- 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 1d0f8ff95a28a51f58f22881ecd3395cba2803e3 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/7] 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 0117000..1980ebc 100644
--- a/packages/apt-setup/debian/changelog
+++ b/packages/apt-setup/debian/changelog
@@ -7,6 +7,7 @@ apt-setup (1:0.43) UNRELEASED; urgency=low
   * 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.
     Requires cdrom-detect >= 1.32.
+  * 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

From 0295e5bc8f0543efadf94963f1ddcc154d92b61d Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Tue, 25 Aug 2009 00:37:28 +0100
Subject: [PATCH 7/7] Add cdrom-detect/try-usb=true documentation

---
 manual/en/boot-installer/parameters.xml |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/manual/en/boot-installer/parameters.xml b/manual/en/boot-installer/parameters.xml
index 8eae5a8..a0b15b6 100644
--- a/manual/en/boot-installer/parameters.xml
+++ b/manual/en/boot-installer/parameters.xml
@@ -388,6 +388,17 @@ Set to <userinput>true</userinput> to prevent this.
 </varlistentry>
 
 <varlistentry>
+<term>cdrom-detect/try-usb=true</term>
+<listitem><para>
+
+By default, only CD drives and ISO9660 filesystems are scanned for
+installation material when using a "cdrom" installer. Set to
+<userinput>true</userinput> to also scan USB and VFAT partitions.
+
+</para></listitem>
+</varlistentry>
+
+<varlistentry>
 <term>cdrom-detect/eject</term>
 <listitem><para>
 
-- 
1.6.3.3

Attachment: signature.asc
Description: PGP signature


Reply to: