/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk
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
#!/bin/sh -e

# If not on a tty, then get rid of possibly disrupting stderr output
if ! tty -s; then
    exec 2>/dev/null
fi

test -x /sbin/usplash

usplash="`pidof usplash -o $$`"
test -n "$usplash"

# We get some variables from cryptsetup:
# $cryptsource	the device node, like "/dev/sda3"
# $crypttarget	the device mapper name, like "sda3_crypt".

prompt="Enter passphrase to unlock"
if [ -n "$crypttarget" ]; then
    prompt="$prompt the disk $crypttarget"
fi
if [ -n "$cryptsource" ]; then
    prompt="$prompt ($cryptsource)"
fi

splash_input_password(){
    test -p /dev/.initramfs/usplash_outfifo || return 1
    /sbin/usplash_write "INPUTQUIET $1" || return 1
    cat /dev/.initramfs/usplash_outfifo 2> /dev/null || return 1
}

# Usplash keeps waiting for input even if some other plugin provided
# the password, so we must kill it
trap "kill -TERM $usplash; sleep 2; kill -KILL $usplash; 
	kill -TERM $$" TERM HUP

password="`splash_input_password \"$prompt: \" password`"

trap - TERM

/sbin/usplash_write "TIMEOUT 15"

echo -n "$password"