Package: powermgmt-base

Dear Maintainer,

I am upstreaming this bug report from Ubuntu[1]. Attached is the patch
they have proposed to fix this issue.

----- Bug description -----
on_ac_power fails if the path contains a whitespace, solution is
attached as patch.

before patch:
~# sh -x /usr/bin/on_ac_power; echo $?
+ set -e
+ OFF_LINE_P=no
+ [ -d /sys/class/power_supply/ ]
+ test -d
/sys/class/power_supply/hid-S!N:A7E462F2A0494518B37F374DE00488AA
Rev:PAACFS00-002-R003-battery
+ test -r
/sys/class/power_supply/hid-S!N:A7E462F2A0494518B37F374DE00488AA
Rev:PAACFS00-002-R003-battery/type
+ cat /sys/class/power_supply/hid-S!N:A7E462F2A0494518B37F374DE00488AA
Rev:PAACFS00-002-R003-battery/type
cat: '/sys/class/power_supply/hid-S!N:A7E462F2A0494518B37F374DE00488AA':
No such file or directory
cat: 'Rev:PAACFS00-002-R003-battery/type': No such file or directory
+ type=
1

after patch:
~# sh -x /usr/bin/on_ac_power; echo $?
+ set -e
+ OFF_LINE_P=no
+ [ -d /sys/class/power_supply/ ]
+ test -d
/sys/class/power_supply/hid-S!N:A7E462F2A0494518B37F374DE00488AA
Rev:PAACFS00-002-R003-battery
+ test -r
/sys/class/power_supply/hid-S!N:A7E462F2A0494518B37F374DE00488AA
Rev:PAACFS00-002-R003-battery/type
+ cat /sys/class/power_supply/hid-S!N:A7E462F2A0494518B37F374DE00488AA
Rev:PAACFS00-002-R003-battery/type
+ type=Battery
+ [ no = yes ]
+ [ -d /proc/acpi/ac_adapter ]
+ [ -r /proc/pmu/info ]
+ [ -r /proc/apm ]
+ exit 255
255
----- End bug description -----

Thanks.

[1] https://bugs.launchpad.net/ubuntu/+source/powermgmt-base/+bug/1816404

-- 
Simon Quigley
tsimo...@debian.org
tsimonq2 on freenode and OFTC
5C7A BEA2 0F86 3045 9CC8
C8B5 E27F 2CF8 458C 2FA4
diff -r -u powermgmt-base-1.33/on_ac_power powermgmt-base-1.33+whitespace/on_ac_power
--- powermgmt-base-1.33/on_ac_power	2018-03-12 02:51:32.000000000 +0200
+++ powermgmt-base-1.33+whitespace/on_ac_power	2019-02-18 13:23:33.292489081 +0200
@@ -25,11 +25,11 @@
 if [ -d /sys/class/power_supply/ ]; then
     for FN in /sys/class/power_supply/*; do
 	if test -d "${FN}" && test -r "${FN}/type"; then
-	    type="$(cat ${FN}/type)"
+	    type="$(cat "${FN}/type")"
 	    case "${type}" in
 	    Mains|USB*|BrickID)
 		if [ -r "${FN}/online" ]; then
-		    online="$(cat ${FN}/online)"
+		    online="$(cat "${FN}/online")"
 		    [ "$online" = 1 ] && exit 0
 		    [ "$online" = 0 ] && OFF_LINE_P=yes
 		fi;;

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to