trousers/trousers-0.3.1-module-ordering.patch

92 lines
1.9 KiB
Diff
Raw Normal View History

--- trousers-0.3.1.orig/dist/fedora/fedora.initrd.tcsd 2008-03-28 15:07:20.000000000 -0700
+++ trousers-0.3.1/dist/fedora/fedora.initrd.tcsd 2008-03-28 15:18:56.000000000 -0700
@@ -21,33 +21,79 @@ prog="tcsd"
# Some variables to make the below more readable
TCSD=/usr/sbin/tcsd
PID_FILE=/var/run/tcsd.pid
-INSMOD=/sbin/insmod
+MODPROBE=/sbin/modprobe
LSMOD=/sbin/lsmod
GREP=/bin/grep
+PWD=/bin/pwd
+MOD_DIR=/lib/modules/$(uname -r)/kernel/drivers/char/tpm
+START_OPT=" start"
load_drivers()
{
- for d in `echo /lib/modules/$(uname -r)/kernel/drivers/char/tpm/tpm_*`; do
- $INSMOD $d
- if test $? -eq 0; then
- break;
+ CUR_DIR=`$PWD`
+ cd $MOD_DIR
+
+ # Must load tpm_bios.ko first
+ $MODPROBE tpm_bios >/dev/null 2>&1
+ RETVAL=$?
+ if [ $RETVAL -ne 0 ]; then
+ failure "Load tpm_bios"
+ echo
+ cd $CUR_DIR
+ return $RETVAL
+ fi
+
+ # Must load tpm.ko second
+ $MODPROBE tpm >/dev/null 2>&1
+ RETVAL=$?
+ if [ $RETVAL -ne 0 ]; then
+ failure "Load tpm"
+ echo
+ cd $CUR_DIR
+ return $RETVAL
+ fi
+
+ # Attempt to load remaining tpm_*.ko
+ # But do NOT return error if they fail
+ for d in `echo tpm_*`; do
+ if [ "$d" != "tpm_bios.ko" ]
+ then
+ m=${d%".ko"}
+ $MODPROBE $m >/dev/null 2>&1
fi
done
+
+ cd $CUR_DIR
+ success "Load tpm"
+ echo
+ return $RETVAL
}
check_drivers()
{
- $LSMOD | $GREP tpm_
+ $LSMOD | $GREP tpm_ >/dev/null 2>&1
+ RETVAL=$?
+ return $RETVAL
}
start()
{
- check_drivers || load_drivers || failure
+ check_drivers
+ RETVAL=$?
+ if [ $RETVAL -ne 0 ]; then
+ load_drivers
+ RETVAL=$?
+ fi
+ if [ $RETVAL -ne 0 ]; then
+ failure $"Loading drivers"
+ fi
echo -n $"Starting $prog: "
- $TCSD $OPTIONS && success || failure
+ $TCSD $START_OPT && success
+ echo
+ touch /var/lock/subsys/tcsd && success
RETVAL=$?
- [ "$RETVAL" = 0 ] && touch /var/lock/subsys/tcsd
echo
+ return $RETVAL
}
stop()