Package: laptop-mode-tools Version: 1.34-1 Severity: normal Tags: patch This was reported in https://bugs.launchpad.net/bugs/77560 by Peter Whittaker, who also wrote the attached patch.
If "laptop_mode status" is run by a non-root user, some commands fails because of insufficient permissions and cause syntax errors in the script. The patch checks for permissions and otherwise writes out a warning. -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: i386 (i686) Kernel: Linux 2.6.21-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.1-23.1 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.5-1 tune hard disk parameters for high pn sdparm <none> (no description available) -- no debconf information
diff -Nurp laptop-mode-tools-1.34.orig/usr/sbin/laptop_mode laptop-mode-tools-1.34/usr/sbin/laptop_mode --- laptop-mode-tools-1.34.orig/usr/sbin/laptop_mode 2007-05-28 17:00:15.000000000 +0200 +++ laptop-mode-tools-1.34/usr/sbin/laptop_mode 2007-06-09 16:37:03.000000000 +0200 @@ -340,14 +340,24 @@ if [ "$1" == "status" ] ; then mount | sed "s/^/ /" echo echo Drive power status: - hdparm -C $HD 2>/dev/null | sed "s/^/ /" + for disk in $HD; do + if [ -r $disk ]; then + hdparm -C $disk 2>/dev/null | sed "s/^/ /" + else + echo " Cannot read $disk, permission denied - run $0 with sudo" + fi + done echo echo "(NOTE: drive settings affected by Laptop Mode cannot be retrieved.)" echo echo Readahead states: cat /etc/mtab | while read DEV MP FST OPTS DUMP PASS ; do if [ -b $DEV ] ; then - echo " $DEV: $((`/sbin/blockdev --getra $DEV` / 2)) kB" + if [ -r $DEV ] ; then + echo " $DEV: $((`blockdev --getra $DEV` / 2)) kB" + else + echo " Cannot read $DEV, permission denied - run $0 with sudo" + fi fi done echo @@ -364,7 +374,7 @@ if [ "$1" == "status" ] ; then if [ -r $THISFILE ] ; then cat $THISFILE | sed "s/^/ /" else - echo " Not accessible: permissions problem?" + echo " Not accessible: permissions problem? Run $0 with sudo" fi echo fi