Rework the "SetUsername" functionality

- Remove SetUsername itself, and add a username parameter to DeviceClaim,
  ListEnrolledFingers and DeleteEnrolledFingers.
- For each of those calls, check that the incoming connection is allowed
  to operate on that particular username
- Don't require a claimed device to list or remove fingerprints
- Clean up username and sender when releasing the device
- Modify the storage backend to not require an opened device to list
  or delete fingerprints
- Add a simple test program to list registered fingerprints for the
  usernames passed as argument
This commit is contained in:
Bastien Nocera
2008-10-30 16:53:05 +00:00
committed by Daniel Drake
parent bd2debc01e
commit e8c36e9592
9 changed files with 324 additions and 121 deletions

View File

@ -109,7 +109,7 @@ static void create_manager(void)
"net.reactivated.Fprint.Manager");
}
static DBusGProxy *open_device(void)
static DBusGProxy *open_device(const char *username)
{
GError *error = NULL;
GPtrArray *devices;
@ -141,19 +141,19 @@ static DBusGProxy *open_device(void)
g_ptr_array_foreach(devices, (GFunc) g_free, NULL);
g_ptr_array_free(devices, TRUE);
if (!net_reactivated_Fprint_Device_claim(dev, &error))
if (!net_reactivated_Fprint_Device_claim(dev, username, &error))
g_error("failed to claim device: %s", error->message);
return dev;
}
static guint32 find_finger(DBusGProxy *dev)
static guint32 find_finger(DBusGProxy *dev, const char *username)
{
GError *error = NULL;
GArray *fingers;
guint i;
int fingernum;
if (!net_reactivated_Fprint_Device_list_enrolled_fingers(dev, &fingers, &error))
if (!net_reactivated_Fprint_Device_list_enrolled_fingers(dev, username, &fingers, &error))
g_error("ListEnrolledFingers failed: %s", error->message);
if (fingers->len == 0) {
@ -211,32 +211,23 @@ static void release_device(DBusGProxy *dev)
g_error("ReleaseDevice failed: %s", error->message);
}
static gboolean set_username(DBusGProxy *dev, const char *username)
{
GError *error = NULL;
if (!net_reactivated_Fprint_Device_set_username(dev, username, &error)) {
g_error("SetUsename failed: %s", error->message);
return FALSE;
}
return TRUE;
}
int main(int argc, char **argv)
{
GMainLoop *loop;
DBusGProxy *dev;
guint32 finger_num;
char *username;
g_type_init();
loop = g_main_loop_new(NULL, FALSE);
create_manager();
dev = open_device();
if (argc == 2) {
if (set_username(dev, argv[1]) == FALSE)
return 1;
}
finger_num = find_finger(dev);
username = NULL;
if (argc == 2)
username = argv[1];
dev = open_device(username);
finger_num = find_finger(dev, username);
do_verify(dev, finger_num);
release_device(dev);
return 0;