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

Bug#488687: partman-crypto: Broken when using multiple disks



tag 488687 + patch
reassign 488687 partman-base
thanks

On Mon, Jun 30, 2008 at 06:32:30PM +0200, Daniel Baumann wrote:
> I can reproduce it on a couple of completely different machines with
> always the same result. However, the last one I did had the following
> partitioning layout:
> 
> /dev/hda1 /boot ext3
> /dev/hda5 crypted random key
> /dev/hda6 crypted passphrase
> /dev/hda7 crypted passphrase
> 
> /dev/hdb1 crypted passphrase
> 
> as soon as you press the 'Configure encrypted volumes', d-i starts
> creating the *first* and the *last* encrypted partitions, im my case
> these are hda5_crypt and hdb1_crypt. those in between are skipped.
> Running a 'Configure encrypted volumes' again, doesn't help much as it
> messes arround again with the previous configured partitions and wants
> to reformat them again and again.

The problem lies in the fact that:
  * crypto_setup() changes the current directory to the partman
    directory for the device on which is located the encrypted
    partition,
  * crypto_setup() calls setup_cryptdev(),
  * setup_cryptdev() calls partman_lock_unit(),
  * partman_lock_unit() goes through all devices (and partitions),
    changing the current directory.

The attached patch changes partman_lock_unit() and partman_unlock_unit()
to restore the current directory once their job is done.  I am not
commiting this patch directly as I doubt it to be the best way to do
this.

One could argue that a pair of parenthesis could be put around the call
to partman_lock_unit() in setup_cryptdev(); please reassign the bug back
to partman-crypto if that feels more desirable.

Cheers,
-- 
Jérémy Bobbio                        .''`. 
lunar@debian.org                    : :Ⓐ  :  # apt-get install anarchism
                                    `. `'` 
                                      `-   
diff --git a/packages/partman/partman-base/lib/base.sh b/packages/partman/partman-base/lib/base.sh
index 3fb29d3..67450e9 100644
--- a/packages/partman/partman-base/lib/base.sh
+++ b/packages/partman/partman-base/lib/base.sh
@@ -903,10 +903,11 @@ disable_swap () {
 
 # Lock a device or partition against further modifications
 partman_lock_unit() {
-	local device message dev testdev
+	local device message cwd dev testdev
 	device="$1"
 	message="$2"
 
+	cwd="$(pwd)"
 	for dev in $DEVICES/*; do
 		[ -d "$dev" ] || continue
 		cd $dev
@@ -916,6 +917,7 @@ partman_lock_unit() {
 			testdev=$(mapdevfs $(cat device))
 			if [ "$device" = "$testdev" ]; then
 				echo "$message" > locked
+				cd "$cwd"
 				return 0
 			fi
 		fi
@@ -930,13 +932,15 @@ partman_lock_unit() {
 		done
 		close_dialog
 	done
+        cd "$cwd"
 }
 
 # Unlock a device or partition to allow further modifications
 partman_unlock_unit() {
-	local device dev testdev
+	local device cwd dev testdev
 	device="$1"
 
+	cwd="$(pwd)"
 	for dev in $DEVICES/*; do
 		[ -d "$dev" ] || continue
 		cd $dev
@@ -946,6 +950,7 @@ partman_unlock_unit() {
 			testdev=$(mapdevfs $(cat device))
 			if [ "$device" = "$testdev" ]; then
 				rm -f locked
+				cd "$cwd"
 				return 0
 			fi
 		fi
@@ -960,6 +965,7 @@ partman_unlock_unit() {
 		done
 		close_dialog
 	done
+	cd "$cwd"
 }
 
 log '*******************************************************'

Attachment: signature.asc
Description: Digital signature


Reply to: