[PATCH] Allow up_backend_supports_sleep_state (linux backend) to return FALSE if pm-is-supported exits with non-zero exit code.
Christian Seiler
christian at iwakd.de
Thu Sep 22 07:29:56 PDT 2011
Hi,
I've recently stumbled upon to a problem with upowerd. Under linux,
regardless of the exit code of /usr/bin/pm-is-supported, it will always
set CanSuspend and CanHibernate to true due to a logic error in
up_backend_supports_sleep_state in src/linux/up-backend.c: The 'ret'
variable is re-used for the return code without being re-initialized to
false after the call to g_spawn_command_line_sync.
This causes e.g. KDE in its current versions to show the 'Suspend' and
'Hibernate' options in the "Leave" menu even if they are not supported
by the system of the administrator wants to disable it.
Steps to reproduce:
$ mv /usr/bin/pm-is-supported /usr/bin/pm-is-supported.orig
$ ln -sf /bin/false /usr/bin/pm-is-supported
$ killall upowerd
$ dbus-send --print-reply --system --dest=org.freedesktop.UPower \
/org/freedesktop/UPower org.freedesktop.DBus.Properties.Get \
string:org.freedesktop.UPower string:CanSuspend
variant boolean true
I've attached a patch that fixes the issue for the current git master
branch.
Christian
---
src/linux/up-backend.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/linux/up-backend.c b/src/linux/up-backend.c
index 14435be..56fc412 100644
--- a/src/linux/up-backend.c
+++ b/src/linux/up-backend.c
@@ -363,6 +363,8 @@ up_backend_supports_sleep_state (const gchar *state)
}
if (WIFEXITED(exit_status) && (WEXITSTATUS(exit_status) ==
EXIT_SUCCESS))
ret = TRUE;
+ else
+ ret = FALSE;
out:
g_free (command);
return ret;
--
1.5.6.5
More information about the devkit-devel
mailing list