mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-09 04:13:33 +02:00
List all the fingerprints for all the users
When listing, list all the fingerprints for all the users mentioned on the command-line for each connected device, rather than just the default one.
This commit is contained in:
committed by
Daniel Drake
parent
1e43720c15
commit
ac85e5927e
84
tests/list.c
84
tests/list.c
@ -39,41 +39,6 @@ static void create_manager(void)
|
|||||||
"net.reactivated.Fprint.Manager");
|
"net.reactivated.Fprint.Manager");
|
||||||
}
|
}
|
||||||
|
|
||||||
static DBusGProxy *open_device(void)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
GPtrArray *devices;
|
|
||||||
gchar *path;
|
|
||||||
DBusGProxy *dev;
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Manager_get_devices(manager, &devices, &error))
|
|
||||||
g_error("list_devices failed: %s", error->message);
|
|
||||||
|
|
||||||
if (devices->len == 0) {
|
|
||||||
g_print("No devices found\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_print("found %d devices\n", devices->len);
|
|
||||||
for (i = 0; i < devices->len; i++) {
|
|
||||||
path = g_ptr_array_index(devices, i);
|
|
||||||
g_print("Device at %s\n", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
path = g_ptr_array_index(devices, 0);
|
|
||||||
g_print("Using device %s\n", path);
|
|
||||||
|
|
||||||
/* FIXME use for_name_owner?? */
|
|
||||||
dev = dbus_g_proxy_new_for_name(connection, "net.reactivated.Fprint",
|
|
||||||
path, "net.reactivated.Fprint.Device");
|
|
||||||
|
|
||||||
g_ptr_array_foreach(devices, (GFunc) g_free, NULL);
|
|
||||||
g_ptr_array_free(devices, TRUE);
|
|
||||||
|
|
||||||
return dev;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void list_fingerprints(DBusGProxy *dev, const char *username)
|
static void list_fingerprints(DBusGProxy *dev, const char *username)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
@ -102,11 +67,51 @@ static void list_fingerprints(DBusGProxy *dev, const char *username)
|
|||||||
g_strfreev (fingers);
|
g_strfreev (fingers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void process_devices(char **argv)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
GPtrArray *devices;
|
||||||
|
char *path;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
if (!net_reactivated_Fprint_Manager_get_devices(manager, &devices, &error))
|
||||||
|
g_error("list_devices failed: %s", error->message);
|
||||||
|
|
||||||
|
if (devices->len == 0) {
|
||||||
|
g_print("No devices found\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print("found %d devices\n", devices->len);
|
||||||
|
for (i = 0; i < devices->len; i++) {
|
||||||
|
path = g_ptr_array_index(devices, i);
|
||||||
|
g_print("Device at %s\n", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < devices->len; i++) {
|
||||||
|
guint j;
|
||||||
|
DBusGProxy *dev;
|
||||||
|
|
||||||
|
path = g_ptr_array_index(devices, 0);
|
||||||
|
g_print("Using device %s\n", path);
|
||||||
|
|
||||||
|
/* FIXME use for_name_owner?? */
|
||||||
|
dev = dbus_g_proxy_new_for_name(connection, "net.reactivated.Fprint",
|
||||||
|
path, "net.reactivated.Fprint.Device");
|
||||||
|
|
||||||
|
for (j = 1; argv[j] != NULL; j++)
|
||||||
|
list_fingerprints (dev, argv[j]);
|
||||||
|
|
||||||
|
g_object_unref (dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_ptr_array_foreach(devices, (GFunc) g_free, NULL);
|
||||||
|
g_ptr_array_free(devices, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
DBusGProxy *dev;
|
|
||||||
guint32 i;
|
|
||||||
|
|
||||||
g_type_init();
|
g_type_init();
|
||||||
loop = g_main_loop_new(NULL, FALSE);
|
loop = g_main_loop_new(NULL, FALSE);
|
||||||
@ -117,10 +122,7 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev = open_device();
|
process_devices (argv);
|
||||||
for (i = 1; argv[i] != NULL; i++) {
|
|
||||||
list_fingerprints (dev, argv[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user