Fixing persistence-media option when no devices are attached.
authorTails developers <amnesia@boum.org>
Fri, 7 Dec 2012 21:30:27 +0000 (22:30 +0100)
committerDaniel Baumann <daniel@debian.org>
Fri, 7 Dec 2012 21:30:27 +0000 (22:30 +0100)
Earlier, if it was set to e.g. 'removable-usb' and no USB storage was
connected, $whitelistdev would be empty, which is interpreted like all
devices are ok by the rest of the code.

scripts/boot/9990-overlay.sh

index b54a2da..96c3331 100755 (executable)
@@ -189,19 +189,23 @@ setup_unionfs ()
                        done
                fi
 
-               case "${PERSISTENCE_MEDIA}" in
-                       removable)
-                               whitelistdev="$(removable_dev)"
-                               ;;
-
-                       removable-usb)
-                               whitelistdev="$(removable_usb_dev)"
-                               ;;
+               local whitelistdev=""
+               if [ -n "${PERSISTENCE_MEDIA}" ]
+               then
+                       case "${PERSISTENCE_MEDIA}" in
+                               removable)
+                                       whitelistdev="$(removable_dev)"
+                                       ;;
 
-                       *)
-                               whitelistdev=""
-                               ;;
-               esac
+                               removable-usb)
+                                       whitelistdev="$(removable_usb_dev)"
+                                       ;;
+                       esac
+                       if [ -z "${whitelistdev}" ]
+                       then
+                               whitelistdev="ignore_all_devices"
+                       fi
+               fi
 
                if is_in_comma_sep_list overlay ${PERSISTENCE_METHOD}
                then
@@ -209,29 +213,32 @@ setup_unionfs ()
                fi
 
                local overlay_devices=""
-               for media in $(find_persistence_media "${overlays}" "${whitelistdev}")
-               do
-                       media="$(echo ${media} | tr ":" " ")"
+               if [ "${whitelistdev}" != "ignore_all_devices" ]
+               then
+                       for media in $(find_persistence_media "${overlays}" "${whitelistdev}")
+                       do
+                               media="$(echo ${media} | tr ":" " ")"
 
-                       case ${media} in
-                               ${old_root_overlay_label}=*)
-                                       device="${media#*=}"
-                                       fix_backwards_compatibility ${device} / union
-                                       overlay_devices="${overlay_devices} ${device}"
-                                       ;;
+                               case ${media} in
+                                       ${old_root_overlay_label}=*)
+                                               device="${media#*=}"
+                                               fix_backwards_compatibility ${device} / union
+                                               overlay_devices="${overlay_devices} ${device}"
+                                               ;;
 
-                               ${old_home_overlay_label}=*)
-                                       device="${media#*=}"
-                                       fix_backwards_compatibility ${device} /home bind
-                                       overlay_devices="${overlay_devices} ${device}"
-                                       ;;
+                                       ${old_home_overlay_label}=*)
+                                               device="${media#*=}"
+                                               fix_backwards_compatibility ${device} /home bind
+                                               overlay_devices="${overlay_devices} ${device}"
+                                               ;;
 
-                               ${custom_overlay_label}=*)
-                                       device="${media#*=}"
-                                       overlay_devices="${overlay_devices} ${device}"
-                                       ;;
-                        esac
-               done
+                                       ${custom_overlay_label}=*)
+                                               device="${media#*=}"
+                                               overlay_devices="${overlay_devices} ${device}"
+                                               ;;
+                                esac
+                       done
+               fi
        elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENCE}" ]
        then
                # check if there are any nfs options