Add sensor.open() to open97(). Use userid from the DBus context.
This commit is contained in:
parent
268008e499
commit
3261db1075
2 changed files with 27 additions and 20 deletions
|
|
@ -16,14 +16,10 @@ loop = GLib.MainLoop()
|
||||||
|
|
||||||
usb.quit = lambda e: loop.quit()
|
usb.quit = lambda e: loop.quit()
|
||||||
|
|
||||||
def uname2identity(uname):
|
bus = SystemBus()
|
||||||
if uname == '':
|
|
||||||
# For some reason Gnome enrollment UI does not send the user name
|
def uid2identity(uid):
|
||||||
# (it also ignores our num-enroll-stages attribute). I probably should upgrade Gnome
|
sidstr='S-1-5-21-111111111-1111111111-1111111111-%d' % uid
|
||||||
print('No username specified. ')
|
|
||||||
uname = 'unicorn'
|
|
||||||
pw=pwd.getpwnam(uname)
|
|
||||||
sidstr='S-1-5-21-111111111-1111111111-1111111111-%d' % pw.pw_uid
|
|
||||||
return sid_from_string(sidstr)
|
return sid_from_string(sidstr)
|
||||||
|
|
||||||
class AlreadyInUse(Exception):
|
class AlreadyInUse(Exception):
|
||||||
|
|
@ -44,11 +40,18 @@ class Device():
|
||||||
print('In Release')
|
print('In Release')
|
||||||
self.caimed = False
|
self.caimed = False
|
||||||
|
|
||||||
def ListEnrolledFingers(self, usr):
|
def ListEnrolledFingers(self, usr, dbus_context):
|
||||||
try:
|
try:
|
||||||
print('In ListEnrolledFingers %s' % usr)
|
print('In ListEnrolledFingers %s' % usr)
|
||||||
|
|
||||||
usr=db.lookup_user(uname2identity(usr))
|
if len(usr) > 0:
|
||||||
|
pw=pwd.getpwnam(usr)
|
||||||
|
uid=pw.pw_uid
|
||||||
|
else:
|
||||||
|
sender=dbus_context.sender
|
||||||
|
uid=bus.dbus.GetConnectionUnixUser(dbus_context.sender)
|
||||||
|
|
||||||
|
usr=db.lookup_user(uid2identity(uid))
|
||||||
|
|
||||||
if usr == None:
|
if usr == None:
|
||||||
print('User not found on this device')
|
print('User not found on this device')
|
||||||
|
|
@ -83,11 +86,13 @@ class Device():
|
||||||
|
|
||||||
def VerifyStop(self):
|
def VerifyStop(self):
|
||||||
print('In VerifyStop')
|
print('In VerifyStop')
|
||||||
cancel_capture()
|
if self.capturing:
|
||||||
|
cancel_capture()
|
||||||
|
|
||||||
def DeleteEnrolledFingers(self, user):
|
def DeleteEnrolledFingers(self, user):
|
||||||
print('In DeleteEnrolledFingers %s' % user)
|
print('In DeleteEnrolledFingers %s' % user)
|
||||||
usr=db.lookup_user(uname2identity(user))
|
pw=pwd.getpwnam(user)
|
||||||
|
usr=db.lookup_user(uid2identity(pw.pw_uid))
|
||||||
|
|
||||||
if usr == None:
|
if usr == None:
|
||||||
print('User not found on this device')
|
print('User not found on this device')
|
||||||
|
|
@ -95,11 +100,11 @@ class Device():
|
||||||
|
|
||||||
db.del_record(usr.dbid)
|
db.del_record(usr.dbid)
|
||||||
|
|
||||||
def do_enroll(self, finger_name):
|
def do_enroll(self, finger_name, uid):
|
||||||
# it is pointless to try and remember username passed in claim as Gnome does not seem to be passing anything useful anyway
|
# it is pointless to try and remember username passed in claim as Gnome does not seem to be passing anything useful anyway
|
||||||
try:
|
try:
|
||||||
# hardcode the username and finger for now
|
# TODO hardcode the username and finger for now
|
||||||
z=enroll(uname2identity('unicorn'), 0xf5)
|
z=enroll(uid2identity(uid), 0xf5)
|
||||||
print('Enroll was successfull')
|
print('Enroll was successfull')
|
||||||
self.EnrollStatus('enroll-completed', True)
|
self.EnrollStatus('enroll-completed', True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -107,10 +112,11 @@ class Device():
|
||||||
#loop.quit();
|
#loop.quit();
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
def EnrollStart(self, finger_name):
|
def EnrollStart(self, finger_name, dbus_context):
|
||||||
print('In EnrollStart %s' % finger_name)
|
sender=dbus_context.sender
|
||||||
Thread(target=lambda: self.do_enroll(finger_name)).start()
|
uid=bus.dbus.GetConnectionUnixUser(dbus_context.sender)
|
||||||
|
print('In EnrollStart %s for %d' % (finger_name, uid))
|
||||||
|
Thread(target=lambda: self.do_enroll(finger_name, uid)).start()
|
||||||
|
|
||||||
def EnrollStop(self):
|
def EnrollStop(self):
|
||||||
print('In EnrollStop')
|
print('In EnrollStop')
|
||||||
|
|
@ -146,7 +152,6 @@ Device.dbus=[readif('net.reactivated.Fprint.Device.xml')]
|
||||||
Manager.dbus=[readif('net.reactivated.Fprint.Manager.xml')]
|
Manager.dbus=[readif('net.reactivated.Fprint.Manager.xml')]
|
||||||
|
|
||||||
|
|
||||||
bus = SystemBus()
|
|
||||||
bus.publish('net.reactivated.Fprint',
|
bus.publish('net.reactivated.Fprint',
|
||||||
('/net/reactivated/Fprint/Manager', Manager()),
|
('/net/reactivated/Fprint/Manager', Manager()),
|
||||||
('/net/reactivated/Fprint/Device/0', Device())
|
('/net/reactivated/Fprint/Device/0', Device())
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ def open97():
|
||||||
|
|
||||||
tls.open()
|
tls.open()
|
||||||
tls.save()
|
tls.save()
|
||||||
|
sensor.open()
|
||||||
#usb.trace_enabled = True
|
#usb.trace_enabled = True
|
||||||
#tls.trace_enabled = True
|
#tls.trace_enabled = True
|
||||||
|
|
||||||
|
|
@ -23,6 +24,7 @@ def load97():
|
||||||
#tls.trace_enabled = True
|
#tls.trace_enabled = True
|
||||||
usb.open()
|
usb.open()
|
||||||
tls.load()
|
tls.load()
|
||||||
|
sensor.open()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue