Package: laptop-mode-tools Version: 1.34-1 Severity: normal Tags: patch Hello,
/etc/init.d/laptop-mode creates a temporary file without removing it every time it is run, because it invokes rm only on abnormal exit. The numerous occurrences of $( cat $TEMPFILE ) in this script are underquoted: where it is double quoted, it should be single quoted so that cat is not run too early, and where it is unquoted, it should be double quoted so that the output of laptop_mode is not subject to globbing. Finally, these uses of temporary files are unnecessary because the shell can directly turn the output of laptop_mode into an argument to log_action_end_msg. The following patch fixes these problems. Thanks, Ken --- /etc/init.d/laptop-mode.orig 2007-09-15 03:12:24.000000000 -0400 +++ /etc/init.d/laptop-mode 2007-09-15 03:12:20.000000000 -0400 @@ -24,41 +24,33 @@ # Enable laptop mode when the system is booted when running on battery. -TEMPFILE=`mktemp` -echo "Failed to start laptop mode" > $TEMPFILE - - -trap "log_action_end_msg 10 $( cat $TEMPFILE ) ; rm $TEMPFILE; exit 10" HUP INT ABRT QUIT SEGV TERM +trap 'log_action_end_msg 10 "Failed to start laptop mode"; exit 10' HUP INT ABRT QUIT SEGV TERM set -e case $1 in start) log_action_begin_msg "Enabling laptop mode" touch /var/run/laptop-mode-enabled - /usr/sbin/laptop_mode auto > $TEMPFILE - log_action_end_msg 0 $( cat $TEMPFILE ) + log_action_end_msg 0 "$(/usr/sbin/laptop_mode auto)" ;; restart|reload|force-reload) log_action_begin_msg "Disabling laptop mode" # Full restart: first stop laptop mode completely (to restore default mount options etc.) rm -f /var/run/laptop-mode-enabled - /usr/sbin/laptop_mode stop > $TEMPFILE - log_action_end_msg 0 $( cat $TEMPFILE ) + log_action_end_msg 0 "$(/usr/sbin/laptop_mode stop)" log_action_begin_msg "Enabling laptop mode" # Now remove files containing stored status, re-enable, and start it up again. - rm -f /var/run/laptop-mode-* + rm -f /var/run/laptop-mode-* touch /var/run/laptop-mode-enabled - /usr/sbin/laptop_mode auto force > $TEMPFILE - log_action_end_msg 0 $( cat $TEMPFILE ) + log_action_end_msg 0 "$(/usr/sbin/laptop_mode auto force)" ;; stop) log_action_begin_msg "Disabling laptop mode" rm -f /var/run/laptop-mode-enabled - /usr/sbin/laptop_mode stop > $TEMPFILE - log_action_end_msg 0 $( cat $TEMPFILE ) + log_action_end_msg 0 "$(/usr/sbin/laptop_mode stop)" ;; status) -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.22 (SMP w/2 CPU cores) Locale: LANG=zh_TW.UTF-8, LC_CTYPE=zh_TW.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages laptop-mode-tools depends on: ii lsb-base 3.1-24 Linux Standard Base 3.1 init scrip Versions of packages laptop-mode-tools recommends: ii acpid 1.0.4-7.1 Utilities for using ACPI power man ii apmd 3.2.2-8.1 Utilities for Advanced Power Manag ii hdparm 7.7-1 tune hard disk parameters for high ii sdparm 1.01-1 Output and modify SCSI device para -- no debconf information -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig No arms? - no cookies!
signature.asc
Description: Digital signature