File: do_option

package info (click to toggle)
partman-crypto 57
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,664 kB
  • sloc: sh: 1,956; ansic: 172; makefile: 33
file content (54 lines) | stat: -rwxr-xr-x 893 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh

. /lib/partman/lib/crypto-base.sh

dev=$2
id=$3
part=$dev/$id

cd $dev

select_cipher () {
	type=$1
	ciphers=""
	for cipher_dir in /lib/partman/ciphers/$type/*; do
		name=${cipher_dir##*/}
		if [ ! -d $cipher_dir ]; then
			continue
		fi
		# Load required kernel modules
		if ! crypto_load_modules "$type" "$name"; then
			continue
		fi
		desc=$(cat $cipher_dir/desc)
		if [ "$ciphers" ]; then
			ciphers="$ciphers, $name"
		else
			ciphers="$name"
		fi
	done

	template="partman-crypto/cipher"
	db_subst $template CHOICES $ciphers
	db_input critical $template || true
	db_go || return
	db_get $template

	if [ "$RET" = none ]; then
		rm -f $part/cipher
		return
	fi

	echo ${RET%% *} > $part/cipher
}

[ -f $part/method ] || exit 0
[ -f $part/crypto_type ] || exit 0

method=$(cat $part/method)
type=$(cat $part/crypto_type)

if [ $method = crypto ]; then
	select_cipher $type
fi