Package: laptop-mode-tools
Version: 1.41-1
Severity: normal
Tags: patch
Reported in Ubuntu https://launchpad.net/bugs/206217
The initscript uses a temporary file and this causes hangs if the
filesystem is read-only and mktemp fails. TEMPFILE will be empty and the
"cat" will have an empty argument and wait for input on stdin.
The attached patch avoids using temporary files.
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.24-1-486
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages laptop-mode-tools depends on:
ii lsb-base 3.2-12 Linux Standard Base 3.2 init scrip
ii util-linux 2.13.1.1-1 Miscellaneous system utilities
Versions of packages laptop-mode-tools recommends:
ii acpid 1.0.6-5.1 Utilities for using ACPI power man
ii apmd 3.2.2-10 Utilities for Advanced Power Manag
ii hal 0.5.11~rc2-1 Hardware Abstraction Layer
ii hdparm 8.6-1 tune hard disk parameters for high
pn sdparm <none> (no description available)
-- no debconf information
--- /etc/init.d/laptop-mode 2008-04-22 22:46:44.000000000 +0200
+++ /tmp/laptop-mode 2008-05-12 22:24:17.000000000 +0200
@@ -21,7 +21,6 @@
test -f /usr/sbin/laptop_mode || exit 0
. /lib/lsb/init-functions
-TEMPFILE=`mktemp`
# Enable laptop mode when the system is booted when running on battery.
@@ -30,8 +29,8 @@ case $1 in
log_action_begin_msg "Enabling laptop mode"
mkdir -p /var/run/laptop-mode-tools
touch /var/run/laptop-mode-tools/enabled
- /usr/sbin/laptop_mode init auto > $TEMPFILE
- log_action_end_msg $? "$( cat $TEMPFILE )"
+ RESULT=`/usr/sbin/laptop_mode init auto`
+ log_action_end_msg $? "$RESULT"
;;
restart|reload|force-reload)
@@ -39,22 +38,22 @@ case $1 in
log_action_begin_msg "Disabling laptop mode"
mkdir -p /var/run/laptop-mode-tools
rm -f /var/run/laptop-mode-tools/enabled
- /usr/sbin/laptop_mode init stop > $TEMPFILE
- log_action_end_msg $? "$( cat $TEMPFILE )"
+ RESULT=`/usr/sbin/laptop_mode init stop`
+ log_action_end_msg $? "$RESULT"
# Now remove files containing stored status, re-enable, and start it up
again.
log_action_begin_msg "Enabling laptop mode"
rm -f /var/run/laptop-mode-tools/*
touch /var/run/laptop-mode-tools/enabled
- /usr/sbin/laptop_mode init auto force > $TEMPFILE
- log_action_end_msg $? "$( cat $TEMPFILE )"
+ RESULT=`/usr/sbin/laptop_mode init auto force`
+ log_action_end_msg $? "$RESULT"
;;
stop)
log_action_begin_msg "Disabling laptop mode"
rm -f /var/run/laptop-mode-tools/enabled
- /usr/sbin/laptop_mode init stop > $TEMPFILE
- log_action_end_msg $? "$( cat $TEMPFILE )"
+ RESULT=`/usr/sbin/laptop_mode init stop`
+ log_action_end_msg $? "$RESULT"
;;
status)
@@ -69,8 +68,4 @@ case $1 in
;;
esac
-if [ -f $TEMPFILE ] ; then
- rm $TEMPFILE
-fi
-
exit 0