Ticket #7910 (closed defect: fixed)

Opened 6 years ago

Last modified 4 years ago

olpc-update should inhibit OHM suspend

Reported by: cjb Owned by: cscott
Priority: high Milestone: 8.2.0 (was Update.2)
Component: upgrade utility Version: not specified
Keywords: Cc: cscott, dsd
Action Needed: test in build Verified: no
Deployments affected: Blocked By:
Blocking:

Description

cjb will provide a stanza to inhibit OHM over dbus from running Sugar code, and cscott will add to olpc-update.

Change History

Changed 6 years ago by cjb

  • owner changed from cjb to cscott

Scott, here's the stanza:

import dbus

try:
    bus = dbus.SystemBus()
    keystore = bus.get_object('org.freedesktop.ohm',
                             '/org/freedesktop/ohm/Keystore',
                             'org.freedesktop.ohm.Keystore')
    # Find out the current state.
    inhibit = keystore.GetKey('suspend.inhibit')
    print inhibit

    # Set to inhibit.
    keystore.SetKey('suspend.inhibit', 1)
    inhibit = keystore.GetKey('suspend.inhibit')
    print inhibit

    # When done, unset inhibit.
    keystore.SetKey('suspend.inhibit', 0)
    inhibit = keystore.GetKey('suspend.inhibit')
    print inhibit
except dbus.DBusException, e:
    print "Error setting OHM inhibit: %s" % e

Changed 6 years ago by cjb

  • cc dsd added

This stanza fails with "A security policy in place prevents this sender from this message to this recipient" when running inside Sugar (but not when running from a Linux tty).

Changed 6 years ago by cjb

Ah, I think it might simply be that root can make these method calls and user olpc can't, because OHM's on the SystemBus.

Changed 6 years ago by cjb

I'm confused, though, because I understand /etc/dbus-1/system.d/ohm.conf to be saying that non-root users can send to org.freedesktop.ohm.Keystore.

Changed 6 years ago by cscott

The fix is http://dev.laptop.org/git?p=users/cscott/olpc-update;a=commitdiff;h=68ecf1fdbc39e5662e409ce90ec195613771299c

-        keystore = bus.get_object('org.freedesktop.ohm',
-                                  '/org/freedesktop/ohm/Keystore',
-                                  'org.freedesktop.ohm.Keystore')
+        proxy = bus.get_object('org.freedesktop.ohm',
+                               '/org/freedesktop/ohm/Keystore')
+        keystore = dbus.Interface(proxy, 'org.freedesktop.ohm.Keystore')

I don't completely understand this, but it seems to have something to do with root being able to call methods on an unbound interface, while olpc can't. (The third argument to bus.get_object seems to be ignored, so pre-patch you get a proxy for the object, but it's not bound to the correct interface.)

Changed 6 years ago by cjb

Oh! Thanks very much, that explains it.

Changed 6 years ago by cscott

  • next_action changed from code to test in build
  • component changed from not assigned to upgrade utility

In olpc-update 2.15 and sugar-update-control 0.8, which should land in joyride-2293 or 2294.

Changed 6 years ago by Quozl

Had an unexpected suspend in the middle of doing olpc-update from joyride-2402 to 2404, from within a Terminal activity. But was not able to reproduce it later.

Changed 4 years ago by dsd

  • status changed from new to closed
  • resolution set to fixed

This is working correctly in 10.1.2 (olpc-update-2.23) (the inhibit is done through the bitfrost python module)

Note: See TracTickets for help on using tickets.