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

cdrom-detect.postinst in initrd: objections and proposals



Hi,

during a thread on debian-user
  https://lists.debian.org/debian-user/2018/05/msg00891.html
  https://lists.debian.org/debian-user/2018/06/msg00040.html
i stumbled over the fact that script

  var/lib/dpkg/info/cdrom-detect.postinst

in the initrd of debian-cd ISOs does not detect the ISO if it is not
presented on an CD/DVD/BD or on an USB attached storage device where
it must be marked as partition.

Two objections come to my mind:

- Why USB-only ?

  Aren't there eSATA disks, SATA memory card readers, old IDE disks, ... ?

- Why looking for the ISO in any partition rather than on the base device ? 

  Partition habits may change with the boot loader used or with particular
  firmware being addressed. But to work as isohybrid from CD, an ISO must
  always be mountable by block offset 0.
  Are there use cases where the ISO is in an USB stick partition only
  and shall be detected automatically ?
 
Further the message

  Incorrect CD-ROM detected

is outdated by only mentioning optical medium and it is wrongly triggered
by any mountable FAT partition on an USB device. (See the three occurences
of variable "WRONG" in the script.)
The script's reaction "fail" keeps the user from trying manually.

--------------------------------------------------------------------------

try_mount() should talk of something like "device with $type filesystem"
and "installation image" rather than of "CD-ROM", "CD".

It should set "WRONG=1" only if "$type" = "$CDFS", because the presence
of a mountable "$FATFS" is too common on USB sticks to indicate a user
error.

Even with this curb, the reaction seems overdone:

        if [ "$WRONG" ]; then
                db_input critical cdrom-detect/wrong-cd || [ $? -eq 30 ]
                db_go
                fail
        fi

because it unconditionally keeps the user from the question

        # If a device was detected but the mount failed, ask for the CD.

and the consequential opportunity to

        # Otherwise manual configuration may be needed

--------------------------------------------------------------------------

If no security objections arise, then one should change:

-        devices="$(list-devices cd; list-devices maybe-usb-floppy)"
+        devices="$(list-devices cd; list-devices disk; list-devices maybe-usb-floppy)"

at the risk to briefly grope /dev/sda for an ISO filesystem.

If security is a problem, how about a new list-devices class "usb-disk" ?

--------------------------------------------------------------------------

If no use case is known for automatic detection of ISO 9660 in partitions
except partition 1 of an isohybrid ISO which was copied onto the base
device, then one should consider to change:

         devices="$(list-devices usb-partition)"
         for device in $devices; do
-                if try_mount $device $CDFS; then
-                        db_set cdrom-detect/hybrid true
-                        break 2
-                fi
                 if try_mount $device $FATFS; then
                         db_set cdrom-detect/usb-hdd true
                         break 2
                 fi
         done

--------------------------------------------------------------------------

Have a nice day :)

Thomas


Reply to: