From 1d1d7f803b37aeeb3a04f4c80b350cdc8372c4b7 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 2 Aug 2007 20:47:09 +0000 Subject: [PATCH] Support for devices without vendor or product name --- pam_usb/tools/pamusb-conf | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pam_usb/tools/pamusb-conf b/pam_usb/tools/pamusb-conf index c66c988..e712c34 100755 --- a/pam_usb/tools/pamusb-conf +++ b/pam_usb/tools/pamusb-conf @@ -30,8 +30,12 @@ class Device: dbus_interface = 'org.freedesktop.Hal.Device') if deviceProperties['storage.removable'] != 1: raise Exception, 'Not a removable device' - self.vendor = deviceProperties['info.vendor'] - self.product = deviceProperties['storage.model'] + self.vendor = None + self.product = None + if deviceProperties.has_key('info.vendor'): + self.vendor = deviceProperties['info.vendor'] + if deviceProperties.has_key('storage.model'): + self.product = deviceProperties['storage.model'] self.serialNumber = deviceProperties['storage.serial'] if len(self.volumes()) < 1: raise Exception, 'Device does not contain any volume' @@ -52,7 +56,9 @@ class Device: return vols def __repr__(self): - return "%s %s (%s)" % (self.vendor, self.product, self.serialNumber) + if self.product is not None: + return "%s %s (%s)" % (self.vendor, self.product, self.serialNumber) + return self.serialNumber def listOptions(question, options, autodetect = True): if autodetect == True and len(options) == 1: @@ -192,7 +198,7 @@ def addDevice(options): ('model', device.product), ('serial', device.serialNumber), ('volume_uuid', volume['uuid'])): - if value == '': + if value is None or value == '': continue e = doc.createElement(name) t = doc.createTextNode(value)