summaryrefslogtreecommitdiff
path: root/initramfs-tools
diff options
context:
space:
mode:
Diffstat (limited to 'initramfs-tools')
-rw-r--r--initramfs-tools/scripts/samizdat34
1 files changed, 27 insertions, 7 deletions
diff --git a/initramfs-tools/scripts/samizdat b/initramfs-tools/scripts/samizdat
index 0c511e8..b1752cd 100644
--- a/initramfs-tools/scripts/samizdat
+++ b/initramfs-tools/scripts/samizdat
@@ -7,28 +7,48 @@ mountroot()
7 samizdat_install_udev_rules 7 samizdat_install_udev_rules
8 mkfifo "$MENUFIFO" 8 mkfifo "$MENUFIFO"
9 9
10 # Note: this blocks waiting for the network
11 if [ "${nbdroot%%,*}" ]; then 10 if [ "${nbdroot%%,*}" ]; then
12 try_nbd 11 # I guess this isn't getting called otherwise? I don't know why this should
12 # be necessary, but it is.
13 sh /scripts/local-top/nbd >/dev/null 2>&1
13 fi 14 fi
14 15
16 if keys_via_network; then
17 wait_for_gnupghome_tar "$tftp_key_server"
18 fi
19 bootwait samizdat-gpg
15 bootmenu 20 bootmenu
16 bootwait root-mounted 21 bootwait root-mounted
17 chvt 1 22 chvt 1
18} 23}
19 24
20try_nbd() 25# Sets $tftp_key_server or returns false.
26keys_via_network()
21{ 27{
22 sh /scripts/local-top/nbd >/dev/null 2>&1 & # I guess this isn't getting called otherwise? 28 [ "${nbdroot%%,*}" ] || return
23 wait_for_gnupghome_tar 29 local arg cmdline
24 (. common.sh && force_grok_block) 30 read cmdline < /proc/cmdline
31 for arg in $cmdline; do
32 case "$arg" in
33 netkeys)
34 tftp_key_server="${nbdroot%%,*}"
35 return 0
36 ;;
37 netkeys=*)
38 tftp_key_server="${arg#netkeys=}"
39 return 0
40 ;;
41 esac
42 done
43 return 1
25} 44}
26 45
27wait_for_gnupghome_tar() 46wait_for_gnupghome_tar()
28{ 47{
48 local tftp_server="$1"
29 [ -e /gnupghome.tar ] && return 49 [ -e /gnupghome.tar ] && return
30 echo -n Waiting to receive GPG keys through the network... 50 echo -n Waiting to receive GPG keys through the network...
31 (while ! tftp -g -r gnupghome.tar -l /gnupghome.tar.$$ ${nbdroot%%,*} 2>/dev/null; do 51 (while ! tftp -g -r gnupghome.tar -l /gnupghome.tar.$$ "$tftp_server" 2>/dev/null; do
32 sleep 1; 52 sleep 1;
33 echo -n . 53 echo -n .
34 done 54 done