last button that is set in the config file is not validated properly (development)

Bug #376736 reported by genisis300
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OBLogout
Fix Committed
High
Andrew Williams

Bug Description

the last button in the list of buttons from the config file is not being validated by the following code:

if you set the last button entry in the conifg to None so that in theory the button should be remove it will still be present.
 from looking at the documation for python the loop "for buttons in list " terminates once the loop hit the final entry in the list without running the code within the for statement. this is beacuse the code is removing parts of list and reducing the internal counter making the code think it has already passed the last item.

there may be a better way to do this but i have replaced the for statement with a while statment

{{{ new code
        a=-1 ## temp counter -1
        while a < len(list):
            button = list[a]
            a=a+1
}}}
            if not button in validbuttons:
                self.logger.warning(_("Button %s is not a valid button name, removing") % button)
                list.remove(button)
            else:
                if self.usehal:
                    if not self.dbus.check_ability(button):
                        self.logger.warning(_("Can't %s, disabling button" % button))
                        list.remove(button)
                else:
                    try:
                        if button != "cancel" and getattr(self, "cmd_" + button) == "None":
                            list.remove(button)
                    except:
                        self.logger.warning(_("Command for button %s is undefined, removing." % button))
                        list.remove(button)

Related branches

summary: last button that is set in the config file is not validated properly
+ (development)
Changed in oblogout:
assignee: nobody → Andrew Williams (nikdoof)
importance: Undecided → High
milestone: none → 0.3
Revision history for this message
Andrew Williams (nikdoof) wrote :

When OBLogout is in HAL mode it doesn't validate the button commands for lock/switch/logout.

Fix will be commited soon.

Revision history for this message
Andrew Williams (nikdoof) wrote :

Fixed in 0.3 dev

Changed in oblogout:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.