Package: partman-crypto
Version: 12
Severity: important
The code below from partman-crypto/commit.d/unsafe_swap is completely
broken in at least three ways.
0 # Ignore e.g. swap on lvm on crypto
1 device=$(cat $dev/device)
2 if $(echo $device | grep -q "^/dev/mapper/"); then
3 found=1
4 for majmin in $(dmsetup deps $device | cut -d ":" -f2 |\
5 tr -d " (" | tr ")" "\n"); do
6 maj=$(echo $majmin | sed 's/,.*//')
7 min=$(echo $majmin | sed 's/.*,//')
8 status=$(dmsetup status -j $maj -m $min 2> /dev/null |\
9 cut -d' ' -f3)
10 if [ $? -ne 0 ] || [ $status != crypt ]; then
11 found=0
12 fi
13 done
14 [ $found ] && continue
15 fi
1) The code produces errors like this:
Mar 1 01:17:18 main-menu[857]: (process:10661): [
Mar 1 01:17:18 main-menu[857]: (process:10661): !=
Mar 1 01:17:18 main-menu[857]: (process:10661): crypt
Mar 1 01:17:18 main-menu[857]: (process:10661): ]
Mar 1 01:17:18 main-menu[857]: (process:10661):
Mar 1 01:17:18 main-menu[857]: (process:10661): [:
Mar 1 01:17:18 main-menu[857]: (process:10661): crypt: unknown operand
The reason for that is that $status in line 10 can apparently be empty and
should thus be quoted.
2) The exit code test in line 10 is broken because it tests the result of
'cut' and not of 'dmsetup', and thus basically always 0.
This error probably contributes to 1).
3) The code will _always_ jump out of the loop at line 14 because $found
is always non-empty (either "0" or "1").
I suppose line 11 should be 'found=' and the test in line 14 should be
'[ "$found" ]'.
I have decided not to fix this myself as any fix will cause a change in
behavior that really should be tested.
When this is fixed, please try to change the code such that a 'set -e'
could be added to the script without it failing. This means for example
that line 14 should not read:
[ "$found" ] && continue
but rather:
[ -z "$found" ] || continue
These issues were found after investigating the errors in the log from
Tiago: http://lists.debian.org/debian-boot/2008/02/msg00865.html
AFAICT they are totally unrelated to the XFS issue that was the cause
of partman eventually failing.
Cheers,
FJP
Attachment:
signature.asc
Description: This is a digitally signed message part.