PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Standard-Input Problem mit read und truecrypt



detonation997
04-07-2006, 08:28
Hallo,

ich bin gerade dabei, ein Initialisierungsskript für truecrypt unter (Debian) Linux zu erstellen.

Mein Problem liegt in der Config-File-Parser Schleife (Zeile 15 - 23 bzw. Zeile 27 - 40). Da hier der gegrepte Inhalt der Datei an die while-Schleife per STDIN übergeben wird und das truecrypt-Passwort ebenfalls von hier kommt, erscheint niemals der Prompt zur Eingabe des Passworts. In anderen Worten - der Inhalt des Config-Files wird zur Passwort-Eingabe herangezogen; das kann aber so nicht funktionieren, weil ja das Passwort von mir per Tastatur kommen soll.

Hier der Code:



1 #!/bin/sh
2 # written by dubbaluga
3
4 # program specific parameters
5 CONTAINERS_FILE=/etc/truecrypt.conf
6 TRUECRYPT_BIN=/usr/local/bin/truecrypt
7 MAPPER=/dev/mapper
8
9 # test if mapper file is readable
10 test -r $CONTAINERS_FILE || exit 0
11
12 case $1 in
13
14 start)
15 grep '^[^#]' $CONTAINERS_FILE | # cut out all comments
16 while read container mapper_id mountpoint
17 do
18 echo "Mapping $container as ID $mapper_id and mounting it onto $mountpoint"
19 # check if values are valid; continue if not
20
21 $TRUECRYPT_BIN -N $mapper_id $container
22 mount ${MAPPER}/truecrypt${mapper_id} $mountpoint
23 done
24 ;;
25
26 stop)
27 grep '^[^#]' $CONTAINERS_FILE | # cut out all comments
28 while read container mapper_id mountpoint
29 do
30 echo "Unmapping $container as ID $mapper_id and umounting it from $mountpoint"
31 # check if values are valid; continue if not
32
33 umount $mountpoint
34 if [ $? -ne 0 ]
35 then
36 echo "Not unmounting device. Continuing."
37 continue
38 fi
39 $TRUECRYPT_BIN -d /dev/mapper/truecrypt${mapper_id}
40 done
41 ;;
42
43 *)
44 echo "Usage: $0 {start|stop}"
45 ;;
46
47 esac
48
49 exit 0


Gibts vielleicht eine Möglichkeit, read direkt von einer Datei lesen zu lassen? Ich versteh den Parameter für den filedescriptor (read -u fd) nicht ganz - wo soll der denn herkommen, wenn es kein open gibt (ich hab zumindest keines gefunden)?

Danke fürs Lesen,
LG Rainer