Browse Source

Do not run pusb_check from pusb_hotplug if the device is removed -- just

lock.
Some logic bugfixes in pusb_hotplug
Andrea Luzzardi 18 years ago
parent
commit
3de50ef146
1 changed files with 10 additions and 6 deletions
  1. +10
    -6
      tools/pusb_hotplug

+ 10
- 6
tools/pusb_hotplug View File

@ -74,7 +74,6 @@ class HotPlugDevice:
if deviceProperties['usb_device.serial'] != self.__serial: if deviceProperties['usb_device.serial'] != self.__serial:
return return
self.__udi = udi self.__udi = udi
print 'Device %s added' % udi
if self.__running: if self.__running:
[ cb('added') for cb in self.__callbacks ] [ cb('added') for cb in self.__callbacks ]
@ -84,7 +83,6 @@ class HotPlugDevice:
if self.__udi != udi: if self.__udi != udi:
return return
self.__udi = None self.__udi = None
print 'Device %s removed' % udi
if self.__running: if self.__running:
[ cb('removed') for cb in self.__callbacks ] [ cb('removed') for cb in self.__callbacks ]
@ -158,16 +156,22 @@ else:
serial = device.find('serial').text serial = device.find('serial').text
def authChangeCallback(event): def authChangeCallback(event):
print 'User %s is now %s' % (username, event)
print 'Device for user %s was %s' % (username, event)
if event == 'removed':
print 'Locking'
[os.system(cmd) for cmd in events['lock'] ]
return
cmdLine = "%s -q -c %s -u %s -s pusb_hotplug -a" % (options['path'], cmdLine = "%s -q -c %s -u %s -s pusb_hotplug -a" % (options['path'],
options['configFile'], options['configFile'],
username) username)
print 'Executing %s' % cmdLine print 'Executing %s' % cmdLine
if not os.system(cmdLine): if not os.system(cmdLine):
run = events['unlock']
print 'Authentication succeeded. Unlocking.'
[os.system(cmd) for cmd in events['unlock'] ]
else: else:
run = events['lock']
[os.system(e) for e in run]
print 'Authentication failed.'
hpDev = HotPlugDevice(serial) hpDev = HotPlugDevice(serial)
hpDev.addCallback(authChangeCallback) hpDev.addCallback(authChangeCallback)


Loading…
Cancel
Save