2008-03-05 20:00:28 +00:00
|
|
|
/*
|
|
|
|
|
* /net/reactivated/Fprint/Device/foo object implementation
|
|
|
|
|
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
* Copyright (C) 2020 Marco Trevisan <marco.trevisan@canonical.com>
|
2008-03-05 20:00:28 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*/
|
|
|
|
|
|
2008-05-16 17:24:45 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include <glib/gi18n.h>
|
2011-04-18 17:55:13 +01:00
|
|
|
#include <gio/gio.h>
|
2008-05-20 17:00:58 +01:00
|
|
|
#include <polkit/polkit.h>
|
2019-07-30 19:45:50 +02:00
|
|
|
#include <fprint.h>
|
2008-03-05 20:00:28 +00:00
|
|
|
|
2008-05-20 14:18:40 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <pwd.h>
|
2009-01-27 12:29:23 +00:00
|
|
|
#include <errno.h>
|
2008-05-20 14:18:40 +01:00
|
|
|
|
2008-03-05 20:00:28 +00:00
|
|
|
#include "fprintd.h"
|
2008-04-07 01:12:44 +03:00
|
|
|
#include "storage.h"
|
2008-03-05 20:00:28 +00:00
|
|
|
|
2020-01-27 18:55:05 +01:00
|
|
|
static const char *FINGERS_NAMES[] = {
|
2019-07-30 19:45:50 +02:00
|
|
|
[FP_FINGER_UNKNOWN] = "unknown",
|
2008-11-19 20:05:54 +00:00
|
|
|
"left-thumb",
|
|
|
|
|
"left-index-finger",
|
|
|
|
|
"left-middle-finger",
|
|
|
|
|
"left-ring-finger",
|
|
|
|
|
"left-little-finger",
|
|
|
|
|
"right-thumb",
|
|
|
|
|
"right-index-finger",
|
|
|
|
|
"right-middle-finger",
|
|
|
|
|
"right-ring-finger",
|
|
|
|
|
"right-little-finger"
|
|
|
|
|
};
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static void fprint_device_dbus_skeleton_iface_init (FprintDBusDeviceIface *);
|
2020-11-05 21:01:25 +01:00
|
|
|
static gboolean action_authorization_handler (GDBusInterfaceSkeleton *,
|
|
|
|
|
GDBusMethodInvocation *,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
static GQuark quark_auth_user = 0;
|
2008-03-05 20:00:28 +00:00
|
|
|
|
2008-11-03 13:41:45 +00:00
|
|
|
typedef enum {
|
|
|
|
|
ACTION_NONE = 0,
|
|
|
|
|
ACTION_IDENTIFY,
|
2008-11-03 13:59:48 +00:00
|
|
|
ACTION_VERIFY,
|
2020-05-12 17:20:13 +02:00
|
|
|
ACTION_ENROLL,
|
|
|
|
|
ACTION_OPEN,
|
|
|
|
|
ACTION_CLOSE,
|
2008-11-03 13:41:45 +00:00
|
|
|
} FprintDeviceAction;
|
|
|
|
|
|
2020-11-05 21:01:25 +01:00
|
|
|
typedef enum {
|
|
|
|
|
STATE_CLAIMED,
|
|
|
|
|
STATE_UNCLAIMED,
|
|
|
|
|
STATE_IGNORED,
|
|
|
|
|
} FprintDeviceClaimState;
|
|
|
|
|
|
2020-01-29 19:12:28 +01:00
|
|
|
typedef struct {
|
2020-11-09 17:27:27 +01:00
|
|
|
volatile gint _refcount;
|
|
|
|
|
|
2020-01-29 22:13:18 +01:00
|
|
|
/* current method invocation */
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
GDBusMethodInvocation *invocation;
|
2008-03-05 20:00:28 +00:00
|
|
|
|
2020-01-29 22:13:18 +01:00
|
|
|
/* The current user of the device, if claimed */
|
2020-11-09 17:27:27 +01:00
|
|
|
const char * const sender;
|
2020-01-29 22:13:18 +01:00
|
|
|
|
|
|
|
|
/* The current user of the device, or if allowed,
|
|
|
|
|
* what was passed as a username argument */
|
2020-11-09 17:27:27 +01:00
|
|
|
const char * const username;
|
2020-02-12 00:55:21 +01:00
|
|
|
|
|
|
|
|
gboolean verify_status_reported;
|
2020-01-29 19:12:28 +01:00
|
|
|
} SessionData;
|
2008-03-05 20:00:28 +00:00
|
|
|
|
2020-01-13 11:04:47 +01:00
|
|
|
typedef struct {
|
2008-03-05 20:00:28 +00:00
|
|
|
guint32 id;
|
2019-07-30 19:45:50 +02:00
|
|
|
FpDevice *dev;
|
2020-11-09 17:27:27 +01:00
|
|
|
SessionData *_session;
|
2008-04-07 01:12:44 +03:00
|
|
|
|
2009-08-10 15:37:00 +01:00
|
|
|
PolkitAuthority *auth;
|
2008-05-20 17:00:58 +01:00
|
|
|
|
2008-11-03 17:20:59 +00:00
|
|
|
/* Hashtable of connected clients */
|
|
|
|
|
GHashTable *clients;
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
/* Required to restart the operation on a retry failure. */
|
|
|
|
|
FpPrint *verify_data;
|
|
|
|
|
GPtrArray *identify_data;
|
2019-07-31 16:00:39 +02:00
|
|
|
int enroll_data;
|
2008-11-24 15:23:05 +00:00
|
|
|
|
2008-10-30 19:27:17 +00:00
|
|
|
/* whether we're running an identify, or a verify */
|
2008-11-03 13:41:45 +00:00
|
|
|
FprintDeviceAction current_action;
|
2019-07-30 19:45:50 +02:00
|
|
|
GCancellable *current_cancellable;
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
GDBusMethodInvocation *current_cancel_invocation;
|
2020-01-13 11:04:47 +01:00
|
|
|
} FprintDevicePrivate;
|
2008-03-05 20:00:28 +00:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (FprintDevice, fprint_device,
|
|
|
|
|
FPRINT_DBUS_TYPE_DEVICE_SKELETON,
|
|
|
|
|
G_ADD_PRIVATE (FprintDevice)
|
|
|
|
|
G_IMPLEMENT_INTERFACE (FPRINT_DBUS_TYPE_DEVICE,
|
|
|
|
|
fprint_device_dbus_skeleton_iface_init));
|
2008-03-05 20:00:28 +00:00
|
|
|
|
|
|
|
|
enum fprint_device_properties {
|
2019-07-30 19:45:50 +02:00
|
|
|
FPRINT_DEVICE_CONSTRUCT_DEV = 1,
|
2008-11-03 17:20:59 +00:00
|
|
|
FPRINT_DEVICE_IN_USE,
|
2008-11-22 00:00:06 +00:00
|
|
|
FPRINT_DEVICE_NAME,
|
|
|
|
|
FPRINT_DEVICE_NUM_ENROLL,
|
|
|
|
|
FPRINT_DEVICE_SCAN_TYPE
|
2008-03-05 20:00:28 +00:00
|
|
|
};
|
|
|
|
|
|
2008-03-06 13:12:34 +00:00
|
|
|
enum fprint_device_signals {
|
2008-03-06 16:37:19 +00:00
|
|
|
SIGNAL_VERIFY_STATUS,
|
2008-10-30 22:35:34 +00:00
|
|
|
SIGNAL_VERIFY_FINGER_SELECTED,
|
2008-03-06 16:37:19 +00:00
|
|
|
SIGNAL_ENROLL_STATUS,
|
2008-03-06 13:12:34 +00:00
|
|
|
NUM_SIGNALS,
|
|
|
|
|
};
|
|
|
|
|
|
2008-03-05 20:00:28 +00:00
|
|
|
static guint32 last_id = ~0;
|
2008-03-06 13:12:34 +00:00
|
|
|
static guint signals[NUM_SIGNALS] = { 0, };
|
2008-03-05 20:00:28 +00:00
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
static void
|
|
|
|
|
session_data_unref(SessionData *session)
|
|
|
|
|
{
|
|
|
|
|
if (g_atomic_int_dec_and_test (&session->_refcount)) {
|
|
|
|
|
g_clear_pointer((char**) &session->sender, g_free);
|
|
|
|
|
g_clear_pointer((char**) &session->username, g_free);
|
|
|
|
|
g_clear_object (&session->invocation);
|
|
|
|
|
g_free(session);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(SessionData, session_data_unref);
|
|
|
|
|
|
|
|
|
|
static SessionData*
|
|
|
|
|
session_data_get (FprintDevicePrivate *priv)
|
|
|
|
|
{
|
|
|
|
|
SessionData *invalid = (SessionData*) &priv->_session;
|
|
|
|
|
SessionData *cur;
|
|
|
|
|
|
|
|
|
|
/* Get the current pointer and mark the pointer as "busy". */
|
|
|
|
|
do {
|
|
|
|
|
cur = priv->_session;
|
|
|
|
|
/* Swap if cur is valid, otherwise busy loop. */
|
|
|
|
|
} while (cur == invalid || !g_atomic_pointer_compare_and_exchange (&priv->_session, cur, invalid));
|
|
|
|
|
|
|
|
|
|
/* We can safely increase the reference count now. */
|
|
|
|
|
if (cur)
|
|
|
|
|
g_atomic_int_inc (&cur->_refcount);
|
|
|
|
|
|
|
|
|
|
/* Swap back, this must succeed. */
|
|
|
|
|
if (!g_atomic_pointer_compare_and_exchange (&priv->_session, invalid, cur))
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
|
|
|
|
return cur;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Pass NULL sender and username to unset session data. */
|
|
|
|
|
static SessionData*
|
|
|
|
|
session_data_set_new (FprintDevicePrivate *priv, gchar *sender, gchar *username)
|
2020-01-29 22:13:18 +01:00
|
|
|
{
|
2020-11-09 17:27:27 +01:00
|
|
|
SessionData *invalid = (SessionData*) &priv->_session;
|
|
|
|
|
SessionData *new = NULL;
|
|
|
|
|
SessionData *old;
|
|
|
|
|
|
|
|
|
|
g_assert ((!sender && !username) || (sender && username));
|
|
|
|
|
if (sender) {
|
|
|
|
|
new = g_new0 (SessionData, 1);
|
|
|
|
|
/* Internal reference of the pointer and returned reference. */
|
|
|
|
|
new->_refcount = 2;
|
|
|
|
|
*(char**) &new->sender = sender;
|
|
|
|
|
*(char**) &new->username = username;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the current (but not if it is busy) and put the new one in place. */
|
|
|
|
|
do {
|
|
|
|
|
old = priv->_session;
|
|
|
|
|
/* Swap if old is valid, otherwise busy loop as someone is ref'ing it currently. */
|
|
|
|
|
} while (old == invalid || !g_atomic_pointer_compare_and_exchange (&priv->_session, old, new));
|
|
|
|
|
|
|
|
|
|
/* We can safely drop the our internal reference now. */
|
|
|
|
|
if (old)
|
|
|
|
|
session_data_unref (old);
|
|
|
|
|
|
|
|
|
|
return new;
|
2020-01-29 22:13:18 +01:00
|
|
|
}
|
|
|
|
|
|
2020-11-13 14:10:26 +01:00
|
|
|
static void fprint_device_dispose(GObject *object)
|
|
|
|
|
{
|
|
|
|
|
FprintDevice *self = (FprintDevice *) object;
|
|
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(self);
|
|
|
|
|
|
|
|
|
|
g_hash_table_remove_all (priv->clients);
|
|
|
|
|
g_object_disconnect (object,
|
|
|
|
|
"g-authorize-method",
|
|
|
|
|
G_CALLBACK (action_authorization_handler),
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS(fprint_device_parent_class)->dispose(object);
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-14 13:37:31 +01:00
|
|
|
static void fprint_device_finalize(GObject *object)
|
2008-03-05 20:00:28 +00:00
|
|
|
{
|
2008-11-03 17:20:59 +00:00
|
|
|
FprintDevice *self = (FprintDevice *) object;
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(self);
|
2008-11-03 17:20:59 +00:00
|
|
|
|
|
|
|
|
g_hash_table_destroy (priv->clients);
|
2020-11-09 17:27:27 +01:00
|
|
|
session_data_set_new(priv, NULL, NULL);
|
2020-11-13 14:10:10 +01:00
|
|
|
g_clear_object (&priv->auth);
|
2020-11-17 20:58:09 +01:00
|
|
|
g_clear_object (&priv->dev);
|
2008-03-05 20:00:28 +00:00
|
|
|
/* FIXME close and stuff */
|
2020-01-29 16:05:31 +01:00
|
|
|
|
|
|
|
|
G_OBJECT_CLASS(fprint_device_parent_class)->finalize(object);
|
2008-03-05 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-14 13:37:31 +01:00
|
|
|
static void fprint_device_set_property(GObject *object, guint property_id,
|
2008-03-05 20:00:28 +00:00
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
FprintDevice *self = (FprintDevice *) object;
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(self);
|
2008-03-05 20:00:28 +00:00
|
|
|
|
|
|
|
|
switch (property_id) {
|
2019-07-30 19:45:50 +02:00
|
|
|
case FPRINT_DEVICE_CONSTRUCT_DEV:
|
|
|
|
|
priv->dev = g_value_dup_object(value);
|
2008-03-05 20:00:28 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-03 14:16:42 +00:00
|
|
|
static void fprint_device_get_property(GObject *object, guint property_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
FprintDevice *self = (FprintDevice *) object;
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(self);
|
2008-11-03 14:16:42 +00:00
|
|
|
|
|
|
|
|
switch (property_id) {
|
2019-07-30 19:45:50 +02:00
|
|
|
case FPRINT_DEVICE_CONSTRUCT_DEV:
|
|
|
|
|
g_value_set_object(value, priv->dev);
|
|
|
|
|
break;
|
2008-11-03 17:20:59 +00:00
|
|
|
case FPRINT_DEVICE_IN_USE:
|
|
|
|
|
g_value_set_boolean(value, g_hash_table_size (priv->clients) != 0);
|
2008-11-03 14:16:42 +00:00
|
|
|
break;
|
2008-11-22 00:00:06 +00:00
|
|
|
case FPRINT_DEVICE_NAME:
|
2019-07-30 19:45:50 +02:00
|
|
|
g_value_set_static_string (value, fp_device_get_name (priv->dev));
|
2008-11-22 00:00:06 +00:00
|
|
|
break;
|
|
|
|
|
case FPRINT_DEVICE_NUM_ENROLL:
|
|
|
|
|
if (priv->dev)
|
2019-07-30 19:45:50 +02:00
|
|
|
g_value_set_int (value, fp_device_get_nr_enroll_stages (priv->dev));
|
2008-11-22 00:00:06 +00:00
|
|
|
else
|
|
|
|
|
g_value_set_int (value, -1);
|
|
|
|
|
break;
|
|
|
|
|
case FPRINT_DEVICE_SCAN_TYPE: {
|
|
|
|
|
const char *type;
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
if (fp_device_get_scan_type (priv->dev) == FP_SCAN_TYPE_PRESS)
|
2008-11-22 00:00:06 +00:00
|
|
|
type = "press";
|
|
|
|
|
else
|
|
|
|
|
type = "swipe";
|
|
|
|
|
|
|
|
|
|
g_value_set_static_string (value, type);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2008-11-03 14:16:42 +00:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-14 13:37:31 +01:00
|
|
|
static void fprint_device_class_init(FprintDeviceClass *klass)
|
2008-03-05 20:00:28 +00:00
|
|
|
{
|
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
|
|
|
|
|
GParamSpec *pspec;
|
|
|
|
|
|
2020-11-13 14:10:26 +01:00
|
|
|
gobject_class->dispose = fprint_device_dispose;
|
2008-05-14 13:37:31 +01:00
|
|
|
gobject_class->finalize = fprint_device_finalize;
|
|
|
|
|
gobject_class->set_property = fprint_device_set_property;
|
2008-11-03 14:16:42 +00:00
|
|
|
gobject_class->get_property = fprint_device_get_property;
|
2008-03-05 20:00:28 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
pspec = g_param_spec_object("dev", "Device",
|
|
|
|
|
"Set device construction property",
|
|
|
|
|
FP_TYPE_DEVICE,
|
|
|
|
|
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE);
|
2008-03-05 20:00:28 +00:00
|
|
|
g_object_class_install_property(gobject_class,
|
2019-07-30 19:45:50 +02:00
|
|
|
FPRINT_DEVICE_CONSTRUCT_DEV, pspec);
|
2008-11-22 00:00:06 +00:00
|
|
|
|
2008-11-03 17:20:59 +00:00
|
|
|
pspec = g_param_spec_boolean("in-use", "In use",
|
2008-11-22 00:00:06 +00:00
|
|
|
"Whether the device is currently in use", FALSE,
|
|
|
|
|
G_PARAM_READABLE);
|
2008-11-03 14:16:42 +00:00
|
|
|
g_object_class_install_property(gobject_class,
|
2008-11-03 17:20:59 +00:00
|
|
|
FPRINT_DEVICE_IN_USE, pspec);
|
2008-03-05 20:00:28 +00:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_object_class_override_property (gobject_class,
|
|
|
|
|
FPRINT_DEVICE_NAME,
|
|
|
|
|
"name");
|
2008-11-22 00:00:06 +00:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_object_class_override_property (gobject_class,
|
|
|
|
|
FPRINT_DEVICE_SCAN_TYPE,
|
|
|
|
|
"scan-type");
|
2008-11-22 00:00:06 +00:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_object_class_override_property (gobject_class,
|
|
|
|
|
FPRINT_DEVICE_NUM_ENROLL,
|
|
|
|
|
"num-enroll-stages");
|
|
|
|
|
|
|
|
|
|
signals[SIGNAL_VERIFY_STATUS] =
|
|
|
|
|
g_signal_lookup ("verify-status", FPRINT_TYPE_DEVICE);
|
|
|
|
|
signals[SIGNAL_ENROLL_STATUS] =
|
|
|
|
|
g_signal_lookup ("enroll-status", FPRINT_TYPE_DEVICE);
|
|
|
|
|
signals[SIGNAL_VERIFY_FINGER_SELECTED] =
|
|
|
|
|
g_signal_lookup ("verify-finger-selected", FPRINT_TYPE_DEVICE);
|
2020-11-05 21:01:25 +01:00
|
|
|
|
|
|
|
|
quark_auth_user = g_quark_from_static_string ("authorized-user");
|
2008-03-05 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
2020-11-13 14:00:48 +01:00
|
|
|
static void _unwatch_name (gpointer id)
|
|
|
|
|
{
|
|
|
|
|
g_bus_unwatch_name (GPOINTER_TO_INT (id));
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-14 13:37:31 +01:00
|
|
|
static void fprint_device_init(FprintDevice *device)
|
2008-03-05 20:00:28 +00:00
|
|
|
{
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(device);
|
2008-03-05 20:00:28 +00:00
|
|
|
priv->id = ++last_id;
|
2008-05-20 17:00:58 +01:00
|
|
|
|
|
|
|
|
/* Setup PolicyKit */
|
2012-11-17 09:10:35 +01:00
|
|
|
priv->auth = polkit_authority_get_sync (NULL, NULL);
|
2008-11-03 17:20:59 +00:00
|
|
|
priv->clients = g_hash_table_new_full (g_str_hash,
|
|
|
|
|
g_str_equal,
|
|
|
|
|
g_free,
|
2020-11-13 14:00:48 +01:00
|
|
|
_unwatch_name);
|
2020-11-05 21:01:25 +01:00
|
|
|
|
|
|
|
|
g_signal_connect (device, "g-authorize-method",
|
|
|
|
|
G_CALLBACK (action_authorization_handler),
|
|
|
|
|
NULL);
|
2008-03-05 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
FprintDevice *fprint_device_new(FpDevice *dev)
|
2008-03-05 20:00:28 +00:00
|
|
|
{
|
2019-07-30 19:45:50 +02:00
|
|
|
return g_object_new(FPRINT_TYPE_DEVICE, "dev", dev, NULL);
|
2008-03-05 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
guint32 _fprint_device_get_id(FprintDevice *rdev)
|
|
|
|
|
{
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
|
|
|
|
|
|
|
|
|
return priv->id;
|
2008-03-05 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-19 20:05:54 +00:00
|
|
|
static const char *
|
|
|
|
|
finger_num_to_name (int finger_num)
|
|
|
|
|
{
|
|
|
|
|
if (finger_num == -1)
|
|
|
|
|
return "any";
|
2019-12-19 14:29:04 +01:00
|
|
|
if (!FP_FINGER_IS_VALID (finger_num))
|
2008-11-19 20:05:54 +00:00
|
|
|
return NULL;
|
2020-01-27 18:55:05 +01:00
|
|
|
return FINGERS_NAMES[finger_num];
|
2008-11-19 20:05:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
finger_name_to_num (const char *finger_name)
|
|
|
|
|
{
|
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
if (finger_name == NULL || *finger_name == '\0' || g_str_equal (finger_name, "any"))
|
|
|
|
|
return -1;
|
|
|
|
|
|
2019-12-18 17:32:52 +01:00
|
|
|
for (i = FP_FINGER_FIRST; i <= FP_FINGER_LAST; i++) {
|
2020-01-27 18:55:05 +01:00
|
|
|
if (g_str_equal (finger_name, FINGERS_NAMES[i]))
|
2019-07-30 19:45:50 +02:00
|
|
|
return i;
|
2008-11-19 20:05:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Invalid, let's try that */
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-20 16:51:46 +00:00
|
|
|
static const char *
|
2019-07-30 19:45:50 +02:00
|
|
|
verify_result_to_name (gboolean match, GError *error)
|
2008-11-20 16:51:46 +00:00
|
|
|
{
|
2019-07-30 19:45:50 +02:00
|
|
|
if (!error) {
|
|
|
|
|
if (match)
|
|
|
|
|
return "verify-match";
|
|
|
|
|
else
|
|
|
|
|
return "verify-no-match";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (error->domain == FP_DEVICE_RETRY) {
|
|
|
|
|
switch (error->code) {
|
|
|
|
|
case FP_DEVICE_RETRY_TOO_SHORT:
|
|
|
|
|
return "verify-swipe-too-short";
|
|
|
|
|
case FP_DEVICE_RETRY_CENTER_FINGER:
|
|
|
|
|
return "verify-finger-not-centered";
|
|
|
|
|
case FP_DEVICE_RETRY_REMOVE_FINGER:
|
|
|
|
|
return "verify-remove-and-retry";
|
|
|
|
|
default:
|
|
|
|
|
return "verify-retry-scan";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* Which errors should be mapped to disconnection?
|
|
|
|
|
* Are drivers/libfprint/fprintd really in agreement here?
|
|
|
|
|
*/
|
|
|
|
|
if (g_error_matches (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_PROTO))
|
2020-02-11 23:00:25 +01:00
|
|
|
return "verify-disconnected";
|
2020-02-10 17:23:19 +01:00
|
|
|
else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
return "verify-no-match";
|
2019-07-30 19:45:50 +02:00
|
|
|
|
2008-11-20 16:51:46 +00:00
|
|
|
return "verify-unknown-error";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char *
|
2019-07-30 19:45:50 +02:00
|
|
|
enroll_result_to_name (gboolean completed, gboolean enrolled, GError *error)
|
2008-11-20 16:51:46 +00:00
|
|
|
{
|
2019-07-30 19:45:50 +02:00
|
|
|
if (!error) {
|
|
|
|
|
if (!completed)
|
|
|
|
|
return "enroll-stage-passed";
|
|
|
|
|
else if (enrolled)
|
|
|
|
|
return "enroll-completed";
|
|
|
|
|
else
|
|
|
|
|
return "enroll-failed";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (error->domain == FP_DEVICE_RETRY) {
|
|
|
|
|
switch (error->code) {
|
|
|
|
|
case FP_DEVICE_RETRY_TOO_SHORT:
|
|
|
|
|
return "enroll-swipe-too-short";
|
|
|
|
|
case FP_DEVICE_RETRY_CENTER_FINGER:
|
|
|
|
|
return "enroll-finger-not-centered";
|
|
|
|
|
case FP_DEVICE_RETRY_REMOVE_FINGER:
|
|
|
|
|
return "enroll-remove-and-retry";
|
2020-02-07 21:28:58 +01:00
|
|
|
default:
|
|
|
|
|
return "enroll-retry-scan";
|
2019-07-30 19:45:50 +02:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* Which errors should be mapped to disconnection?
|
|
|
|
|
* Are drivers/libfprint/fprintd really in agreement here?
|
|
|
|
|
*/
|
|
|
|
|
if (g_error_matches (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_PROTO))
|
|
|
|
|
return "enroll-disconnected";
|
2019-07-31 16:00:39 +02:00
|
|
|
else if (g_error_matches (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_FULL))
|
|
|
|
|
return "enroll-data-full";
|
2020-02-10 17:22:50 +01:00
|
|
|
else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
return "enroll-failed";
|
2019-07-30 19:45:50 +02:00
|
|
|
|
2008-11-20 16:51:46 +00:00
|
|
|
return "enroll-unknown-error";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-16 17:24:45 +01:00
|
|
|
static gboolean
|
|
|
|
|
_fprint_device_check_claimed (FprintDevice *rdev,
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
GDBusMethodInvocation *invocation,
|
2020-11-05 21:01:25 +01:00
|
|
|
FprintDeviceClaimState requested_state,
|
2008-05-16 17:24:45 +01:00
|
|
|
GError **error)
|
|
|
|
|
{
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2020-11-09 17:27:27 +01:00
|
|
|
g_autoptr(SessionData) session = NULL;
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
const char *sender;
|
2008-05-16 17:24:45 +01:00
|
|
|
gboolean retval;
|
|
|
|
|
|
2020-11-05 21:01:25 +01:00
|
|
|
if (requested_state == STATE_IGNORED)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
session = session_data_get (priv);
|
2020-11-05 21:01:25 +01:00
|
|
|
|
|
|
|
|
if (requested_state == STATE_UNCLAIMED) {
|
|
|
|
|
/* Is it already claimed? */
|
2020-11-09 17:27:27 +01:00
|
|
|
if (!session) {
|
2020-11-05 21:01:25 +01:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_set_error(error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
|
|
|
|
"Device was already claimed");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_assert (requested_state == STATE_CLAIMED);
|
|
|
|
|
|
2008-05-16 17:24:45 +01:00
|
|
|
/* The device wasn't claimed, exit */
|
2020-11-09 17:27:27 +01:00
|
|
|
if (session == NULL) {
|
2008-05-16 17:24:45 +01:00
|
|
|
g_set_error (error, FPRINT_ERROR, FPRINT_ERROR_CLAIM_DEVICE,
|
|
|
|
|
_("Device was not claimed before use"));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
sender = g_dbus_method_invocation_get_sender (invocation);
|
2020-11-09 17:27:27 +01:00
|
|
|
retval = g_str_equal (sender, session->sender);
|
|
|
|
|
g_print("sender: %s, session owner: %s", sender, session->sender);
|
2008-05-16 17:24:45 +01:00
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
if (retval == FALSE || session->invocation != NULL) {
|
2008-05-16 17:24:45 +01:00
|
|
|
g_set_error (error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
|
|
|
|
_("Device already in use by another user"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-20 17:00:58 +01:00
|
|
|
static gboolean
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
_fprint_device_check_polkit_for_action (FprintDevice *rdev,
|
|
|
|
|
GDBusMethodInvocation *invocation,
|
|
|
|
|
const char *action,
|
|
|
|
|
GError **error)
|
2008-05-20 17:00:58 +01:00
|
|
|
{
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
const char *sender;
|
2020-01-29 22:14:36 +01:00
|
|
|
g_autoptr(GError) _error = NULL;
|
|
|
|
|
g_autoptr(PolkitAuthorizationResult) result = NULL;
|
|
|
|
|
g_autoptr(PolkitSubject) subject = NULL;
|
2008-05-20 17:00:58 +01:00
|
|
|
|
|
|
|
|
/* Check that caller is privileged */
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
sender = g_dbus_method_invocation_get_sender (invocation);
|
2009-08-10 15:37:00 +01:00
|
|
|
subject = polkit_system_bus_name_new (sender);
|
|
|
|
|
|
|
|
|
|
result = polkit_authority_check_authorization_sync (priv->auth,
|
|
|
|
|
subject,
|
|
|
|
|
action,
|
|
|
|
|
NULL,
|
|
|
|
|
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
|
|
|
|
|
NULL, &_error);
|
|
|
|
|
if (result == NULL) {
|
2008-05-21 14:36:36 +01:00
|
|
|
g_set_error (error, FPRINT_ERROR,
|
2009-08-10 15:37:00 +01:00
|
|
|
FPRINT_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"Not Authorized: %s", _error->message);
|
2008-05-20 17:00:58 +01:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-10 15:37:00 +01:00
|
|
|
if (!polkit_authorization_result_get_is_authorized (result)) {
|
2008-05-21 14:36:36 +01:00
|
|
|
g_set_error (error, FPRINT_ERROR,
|
2008-11-24 14:16:41 +00:00
|
|
|
FPRINT_ERROR_PERMISSION_DENIED,
|
2009-08-10 15:37:00 +01:00
|
|
|
"Not Authorized: %s", action);
|
2008-05-20 17:00:58 +01:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-21 14:36:36 +01:00
|
|
|
static gboolean
|
2020-11-06 18:22:15 +01:00
|
|
|
fprint_device_check_polkit_for_permissions (FprintDevice *rdev,
|
|
|
|
|
GDBusMethodInvocation *invocation,
|
|
|
|
|
FprintDevicePermission permissions,
|
|
|
|
|
GError **error)
|
2008-05-21 14:36:36 +01:00
|
|
|
{
|
2020-11-06 18:22:15 +01:00
|
|
|
g_autoptr(GFlagsClass) permission_flags = NULL;
|
2020-11-05 21:01:25 +01:00
|
|
|
unsigned i;
|
|
|
|
|
|
2020-11-06 18:22:15 +01:00
|
|
|
if (permissions == FPRINT_DEVICE_PERMISSION_NONE)
|
2008-05-21 14:36:36 +01:00
|
|
|
return TRUE;
|
|
|
|
|
|
2020-11-06 18:42:21 +01:00
|
|
|
permission_flags = g_type_class_ref (FPRINT_TYPE_DEVICE_PERMISSION);
|
2020-11-06 18:22:15 +01:00
|
|
|
|
|
|
|
|
for (i = 0; i < permission_flags->n_values; ++i) {
|
|
|
|
|
GFlagsValue *value = &permission_flags->values[i];
|
|
|
|
|
const char *action;
|
|
|
|
|
|
|
|
|
|
if (!(value->value & permissions)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2008-05-21 14:36:36 +01:00
|
|
|
|
2020-11-06 18:22:15 +01:00
|
|
|
action = value->value_nick;
|
2020-11-05 21:01:25 +01:00
|
|
|
g_debug ("Getting authorization to perform Polkit action %s",
|
|
|
|
|
action);
|
|
|
|
|
|
|
|
|
|
g_clear_error (error);
|
|
|
|
|
if (_fprint_device_check_polkit_for_action (rdev, invocation,
|
|
|
|
|
action, error)) {
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_assert (!error || *error);
|
|
|
|
|
return FALSE;
|
2008-05-21 14:36:36 +01:00
|
|
|
}
|
|
|
|
|
|
2008-10-30 16:53:05 +00:00
|
|
|
static char *
|
|
|
|
|
_fprint_device_check_for_username (FprintDevice *rdev,
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
GDBusMethodInvocation *invocation,
|
2008-10-30 16:53:05 +00:00
|
|
|
const char *username,
|
|
|
|
|
GError **error)
|
2008-05-21 14:36:36 +01:00
|
|
|
{
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_autoptr(GVariant) ret = NULL;
|
|
|
|
|
g_autoptr(GError) err = NULL;
|
|
|
|
|
GDBusConnection *connection;
|
|
|
|
|
const char *sender;
|
2008-10-30 16:53:05 +00:00
|
|
|
struct passwd *user;
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
guint32 uid;
|
2008-05-21 14:36:36 +01:00
|
|
|
|
2008-10-30 16:53:05 +00:00
|
|
|
/* Get details about the current sender, and username/uid */
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
connection = g_dbus_method_invocation_get_connection (invocation);
|
|
|
|
|
sender = g_dbus_method_invocation_get_sender (invocation);
|
|
|
|
|
|
|
|
|
|
ret = g_dbus_connection_call_sync (connection,
|
|
|
|
|
"org.freedesktop.DBus",
|
|
|
|
|
"/org/freedesktop/DBus",
|
|
|
|
|
"org.freedesktop.DBus",
|
|
|
|
|
"GetConnectionUnixUser",
|
|
|
|
|
g_variant_new ("(s)", sender),
|
|
|
|
|
NULL, G_DBUS_CALL_FLAGS_NONE, -1,
|
|
|
|
|
NULL, &err);
|
|
|
|
|
|
|
|
|
|
if (!ret) {
|
|
|
|
|
g_autoptr(GError) e = NULL;
|
|
|
|
|
|
|
|
|
|
g_set_error (error, FPRINT_ERROR, FPRINT_ERROR_INTERNAL,
|
|
|
|
|
"Could not get conection unix user ID: %s",
|
|
|
|
|
err->message);
|
2008-10-30 16:53:05 +00:00
|
|
|
return NULL;
|
2008-05-21 14:36:36 +01:00
|
|
|
}
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_variant_get (ret, "(u)", &uid);
|
2008-10-30 16:53:05 +00:00
|
|
|
user = getpwuid (uid);
|
|
|
|
|
if (user == NULL) {
|
2008-11-24 14:16:41 +00:00
|
|
|
g_set_error(error, FPRINT_ERROR, FPRINT_ERROR_INTERNAL,
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
"Failed to get information about user UID %u", uid);
|
2008-10-30 16:53:05 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The current user is usually allowed to access their
|
|
|
|
|
* own data, this should be followed by PolicyKit checks
|
|
|
|
|
* anyway */
|
2018-08-23 13:44:14 +02:00
|
|
|
if (username == NULL || *username == '\0' || g_str_equal (username, user->pw_name)) {
|
|
|
|
|
return g_strdup (user->pw_name);
|
2008-10-30 16:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we're not allowed to set a different username,
|
|
|
|
|
* then fail */
|
2020-11-06 18:22:15 +01:00
|
|
|
if (!fprint_device_check_polkit_for_permissions (rdev, invocation,
|
|
|
|
|
FPRINT_DEVICE_PERMISSION_SETUSERNAME,
|
|
|
|
|
error)) {
|
2008-10-30 16:53:05 +00:00
|
|
|
return NULL;
|
2008-05-21 14:36:36 +01:00
|
|
|
}
|
|
|
|
|
|
2008-10-30 16:53:05 +00:00
|
|
|
return g_strdup (username);
|
2008-05-21 14:36:36 +01:00
|
|
|
}
|
|
|
|
|
|
2008-11-03 17:20:59 +00:00
|
|
|
static void
|
2011-04-18 17:55:13 +01:00
|
|
|
_fprint_device_client_vanished (GDBusConnection *connection,
|
|
|
|
|
const char *name,
|
|
|
|
|
FprintDevice *rdev)
|
2008-11-03 17:20:59 +00:00
|
|
|
{
|
2019-07-30 19:45:50 +02:00
|
|
|
g_autoptr(GError) error = NULL;
|
2020-11-09 17:27:27 +01:00
|
|
|
g_autoptr(SessionData) session = NULL;
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2008-11-03 17:20:59 +00:00
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
session = session_data_get (priv);
|
2020-11-05 21:01:25 +01:00
|
|
|
|
2011-04-18 17:55:13 +01:00
|
|
|
/* Was that the client that claimed the device? */
|
2020-11-09 17:27:27 +01:00
|
|
|
if (session != NULL &&
|
|
|
|
|
g_strcmp0 (session->sender, name) == 0) {
|
2019-07-30 19:45:50 +02:00
|
|
|
while (priv->current_action != ACTION_NONE) {
|
2020-05-12 17:20:13 +02:00
|
|
|
/* OPEN/CLOSE are not cancellable, we just need to wait */
|
|
|
|
|
if (priv->current_cancellable)
|
|
|
|
|
g_cancellable_cancel (priv->current_cancellable);
|
2018-05-30 20:00:26 +02:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
g_main_context_iteration (NULL, TRUE);
|
2015-10-14 12:12:39 +02:00
|
|
|
}
|
2011-04-18 17:55:13 +01:00
|
|
|
|
2020-05-12 17:20:13 +02:00
|
|
|
/* The session may have disappeared at this point if the device
|
|
|
|
|
* was already closing. */
|
2020-11-09 17:27:27 +01:00
|
|
|
if (session && !fp_device_close_sync (priv->dev, NULL, &error))
|
2020-05-12 19:09:30 +02:00
|
|
|
g_critical ("Error closing device after disconnect: %s", error->message);
|
2019-07-30 19:45:50 +02:00
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
session_data_set_new (priv, NULL, NULL);
|
2008-11-03 17:20:59 +00:00
|
|
|
}
|
2011-04-18 17:55:13 +01:00
|
|
|
g_hash_table_remove (priv->clients, name);
|
2008-11-03 17:20:59 +00:00
|
|
|
|
|
|
|
|
if (g_hash_table_size (priv->clients) == 0) {
|
|
|
|
|
g_object_notify (G_OBJECT (rdev), "in-use");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
_fprint_device_add_client (FprintDevice *rdev, const char *sender)
|
|
|
|
|
{
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2011-04-18 17:55:13 +01:00
|
|
|
guint id;
|
|
|
|
|
|
|
|
|
|
id = GPOINTER_TO_UINT (g_hash_table_lookup (priv->clients, sender));
|
|
|
|
|
if (id == 0) {
|
|
|
|
|
id = g_bus_watch_name (G_BUS_TYPE_SYSTEM,
|
|
|
|
|
sender,
|
|
|
|
|
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
|
|
|
|
NULL,
|
|
|
|
|
(GBusNameVanishedCallback) _fprint_device_client_vanished,
|
|
|
|
|
rdev,
|
|
|
|
|
NULL);
|
|
|
|
|
g_hash_table_insert (priv->clients, g_strdup (sender), GUINT_TO_POINTER(id));
|
2008-11-03 17:20:59 +00:00
|
|
|
g_object_notify (G_OBJECT (rdev), "in-use");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
static void dev_open_cb(FpDevice *dev, GAsyncResult *res, void *user_data)
|
2008-03-05 20:00:28 +00:00
|
|
|
{
|
2019-07-30 19:45:50 +02:00
|
|
|
g_autoptr(GError) error = NULL;
|
2008-03-05 20:00:28 +00:00
|
|
|
FprintDevice *rdev = user_data;
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2020-11-09 17:27:27 +01:00
|
|
|
g_autoptr(SessionData) session = NULL;
|
2020-11-05 21:01:25 +01:00
|
|
|
g_autoptr(GDBusMethodInvocation) invocation = NULL;
|
|
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
session = session_data_get (priv);
|
|
|
|
|
invocation = g_steal_pointer (&session->invocation);
|
2008-03-05 20:00:28 +00:00
|
|
|
|
2020-05-12 17:20:13 +02:00
|
|
|
priv->current_action = ACTION_NONE;
|
2019-07-30 19:45:50 +02:00
|
|
|
if (!fp_device_open_finish (dev, res, &error)) {
|
|
|
|
|
g_autoptr(GError) dbus_error = NULL;
|
2008-05-16 17:24:45 +01:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
dbus_error = g_error_new (FPRINT_ERROR,
|
|
|
|
|
FPRINT_ERROR_INTERNAL,
|
|
|
|
|
"Open failed with error: %s", error->message);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_dbus_method_invocation_return_gerror (invocation, dbus_error);
|
2020-11-09 17:27:27 +01:00
|
|
|
session_data_set_new (priv, NULL, NULL);
|
2008-03-05 20:00:28 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
g_debug("claimed device %d", priv->id);
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
fprint_dbus_device_complete_claim (FPRINT_DBUS_DEVICE (rdev),
|
|
|
|
|
invocation);
|
2008-03-05 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
2020-11-05 21:01:25 +01:00
|
|
|
static gboolean
|
|
|
|
|
fprintd_device_authorize_user (FprintDevice *rdev,
|
|
|
|
|
GDBusMethodInvocation *invocation,
|
|
|
|
|
GError **error)
|
2008-03-05 20:00:28 +00:00
|
|
|
{
|
2020-11-05 21:01:25 +01:00
|
|
|
GVariant *params = NULL;
|
|
|
|
|
const char *username = NULL;
|
|
|
|
|
g_autofree char *user = NULL;
|
2008-05-16 17:24:45 +01:00
|
|
|
|
2020-11-05 21:01:25 +01:00
|
|
|
params = g_dbus_method_invocation_get_parameters (invocation);
|
|
|
|
|
g_assert (g_variant_n_children (params) == 1);
|
|
|
|
|
g_variant_get (params, "(&s)", &username);
|
|
|
|
|
g_assert (username);
|
2008-05-21 14:36:36 +01:00
|
|
|
|
2008-10-30 16:53:05 +00:00
|
|
|
user = _fprint_device_check_for_username (rdev,
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
invocation,
|
2008-10-30 16:53:05 +00:00
|
|
|
username,
|
2020-11-05 21:01:25 +01:00
|
|
|
error);
|
2008-10-30 16:53:05 +00:00
|
|
|
if (user == NULL) {
|
2020-11-05 21:01:25 +01:00
|
|
|
return FALSE;
|
2008-05-16 17:24:45 +01:00
|
|
|
}
|
|
|
|
|
|
2020-11-05 21:01:25 +01:00
|
|
|
/* We keep the user attached to the invocation as it may not be the same
|
|
|
|
|
* of the requested one, in case an empty one was passed.
|
|
|
|
|
* Given that now we may have multiple cuncurrent requests, it wouldn't
|
|
|
|
|
* be safe to add another member to the priv, as it would need even more
|
|
|
|
|
* multi-thread checks around, and over-complicate things.
|
|
|
|
|
*/
|
|
|
|
|
g_object_set_qdata_full (G_OBJECT (invocation), quark_auth_user,
|
|
|
|
|
g_steal_pointer (&user), g_free);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean fprint_device_claim (FprintDBusDevice *dbus_dev,
|
|
|
|
|
GDBusMethodInvocation *invocation,
|
|
|
|
|
const char *username)
|
|
|
|
|
{
|
|
|
|
|
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
|
|
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2020-11-09 17:27:27 +01:00
|
|
|
g_autoptr(SessionData) session = NULL;
|
2020-11-09 14:59:33 +01:00
|
|
|
g_autoptr(GError) error = NULL;
|
2020-11-05 21:01:25 +01:00
|
|
|
char *sender, *user;
|
|
|
|
|
|
2020-11-09 14:59:33 +01:00
|
|
|
if (!_fprint_device_check_claimed (rdev, invocation, STATE_UNCLAIMED, &error)) {
|
|
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-05 21:01:25 +01:00
|
|
|
user = g_object_steal_qdata (G_OBJECT (invocation), quark_auth_user);
|
|
|
|
|
g_assert (user);
|
2008-05-20 14:18:40 +01:00
|
|
|
|
2020-11-05 19:41:12 +01:00
|
|
|
sender = g_strdup (g_dbus_method_invocation_get_sender (invocation));
|
2008-11-03 17:20:59 +00:00
|
|
|
_fprint_device_add_client (rdev, sender);
|
|
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
session = session_data_set_new (priv, g_steal_pointer (&sender), g_steal_pointer(&user));
|
|
|
|
|
session->invocation = g_object_ref (invocation);
|
|
|
|
|
username = g_steal_pointer (&user);
|
|
|
|
|
sender = g_steal_pointer (&sender);
|
2020-01-29 22:13:18 +01:00
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
g_debug ("user '%s' claiming the device: %d", session->username, priv->id);
|
2008-03-05 20:00:28 +00:00
|
|
|
|
2020-05-12 17:20:13 +02:00
|
|
|
priv->current_action = ACTION_OPEN;
|
2019-07-30 19:45:50 +02:00
|
|
|
fp_device_open (priv->dev, NULL, (GAsyncReadyCallback) dev_open_cb, rdev);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
|
|
|
|
|
return TRUE;
|
2008-03-05 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
static void dev_close_cb(FpDevice *dev, GAsyncResult *res, void *user_data)
|
2008-03-05 20:00:28 +00:00
|
|
|
{
|
2019-07-30 19:45:50 +02:00
|
|
|
g_autoptr(GError) error = NULL;
|
2008-03-05 20:00:28 +00:00
|
|
|
FprintDevice *rdev = user_data;
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2020-11-05 21:01:25 +01:00
|
|
|
g_autoptr(SessionData) session = NULL;
|
|
|
|
|
g_autoptr(GDBusMethodInvocation) invocation = NULL;
|
|
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
session = session_data_get (priv);
|
|
|
|
|
session_data_set_new (priv, NULL, NULL);
|
2020-11-05 21:01:25 +01:00
|
|
|
invocation = g_steal_pointer (&session->invocation);
|
2008-03-05 20:00:28 +00:00
|
|
|
|
2020-05-12 17:20:13 +02:00
|
|
|
priv->current_action = ACTION_NONE;
|
2019-07-30 19:45:50 +02:00
|
|
|
if (!fp_device_close_finish (dev, res, &error)) {
|
|
|
|
|
g_autoptr(GError) dbus_error = NULL;
|
2008-03-05 20:00:28 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
dbus_error = g_error_new (FPRINT_ERROR,
|
|
|
|
|
FPRINT_ERROR_INTERNAL,
|
|
|
|
|
"Release failed with error: %s", error->message);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_dbus_method_invocation_return_gerror (invocation, dbus_error);
|
2019-07-30 19:45:50 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2008-05-20 14:18:40 +01:00
|
|
|
|
2018-05-30 19:59:07 +02:00
|
|
|
g_debug("released device %d", priv->id);
|
2019-07-30 19:45:50 +02:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
fprint_dbus_device_complete_release (FPRINT_DBUS_DEVICE (rdev),
|
|
|
|
|
invocation);
|
2008-03-05 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static gboolean fprint_device_release (FprintDBusDevice *dbus_dev,
|
|
|
|
|
GDBusMethodInvocation *invocation)
|
2008-03-05 20:00:28 +00:00
|
|
|
{
|
2020-11-09 14:59:33 +01:00
|
|
|
g_autoptr(GError) error = NULL;
|
2020-11-09 17:27:27 +01:00
|
|
|
g_autoptr(SessionData) session = NULL;
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2008-05-21 14:36:36 +01:00
|
|
|
|
2020-11-09 14:59:33 +01:00
|
|
|
if (!_fprint_device_check_claimed (rdev, invocation, STATE_CLAIMED, &error)) {
|
|
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
device: Cancel the ongoing operation when releasing the device
If a device is currently verifying, identifying or enrolling we may want the
user to stop the operation before we actually release the device.
Otherwise we may end-up in trying to close (failing) the internal device,
while fprintd is still considering the device active, causing a dead-lock
(the device can't be released, but neither claimed again or stop the current
action).
In fact calling Claim() -> EnrollStart() -> Release(), we would fail with
the error
net.reactivated.Fprint.Error.Internal:
Release failed with error: The device is still busy with another
operation, please try again later. (36)"
However, if we try to call VerifyStop, after this error, we'd fail because
for the fprintd logic, the device is not claimed anymore, but actually
closed, and we'd need to claim it again, but... That would still cause an
internal error.
To avoid this, in case Relase() is called cancel the ongoing operation,
and wait until it's done before completing the release call.
2020-02-06 21:34:39 +01:00
|
|
|
if (priv->current_cancellable) {
|
|
|
|
|
if (priv->current_action == ACTION_ENROLL) {
|
|
|
|
|
g_warning("Enrollment was in progress, stopping it");
|
|
|
|
|
} else if (priv->current_action == ACTION_IDENTIFY ||
|
|
|
|
|
priv->current_action == ACTION_VERIFY) {
|
|
|
|
|
g_warning("Verification was in progress, stopping it");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_cancellable_cancel (priv->current_cancellable);
|
|
|
|
|
while (priv->current_action != ACTION_NONE)
|
|
|
|
|
g_main_context_iteration (NULL, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
session = session_data_get (priv);
|
|
|
|
|
session->invocation = g_object_ref (invocation);
|
2020-11-05 21:01:25 +01:00
|
|
|
|
2020-05-12 17:20:13 +02:00
|
|
|
priv->current_action = ACTION_CLOSE;
|
2019-07-30 19:45:50 +02:00
|
|
|
fp_device_close (priv->dev, NULL, (GAsyncReadyCallback) dev_close_cb, rdev);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
|
|
|
|
|
return TRUE;
|
2008-03-05 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
2020-02-12 00:55:21 +01:00
|
|
|
static void report_verify_status (FprintDevice *rdev,
|
|
|
|
|
gboolean match,
|
|
|
|
|
GError *error)
|
|
|
|
|
{
|
|
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
|
|
|
|
|
const char *result = verify_result_to_name (match, error);
|
2020-11-09 17:27:27 +01:00
|
|
|
g_autoptr(SessionData) session = NULL;
|
2020-02-12 00:55:21 +01:00
|
|
|
gboolean done;
|
|
|
|
|
|
|
|
|
|
done = (error == NULL || error->domain != FP_DEVICE_RETRY);
|
|
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
session = session_data_get (priv);
|
|
|
|
|
|
|
|
|
|
if (done && session->verify_status_reported) {
|
2020-02-12 00:55:21 +01:00
|
|
|
/* It is completely fine for cancellation to occur after a
|
|
|
|
|
* result has been reported. */
|
|
|
|
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
g_warning ("Verify status already reported. Ignoring %s", result);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_debug ("report_verify_status: result %s", result);
|
|
|
|
|
g_signal_emit (rdev, signals[SIGNAL_VERIFY_STATUS], 0, result, done);
|
|
|
|
|
|
|
|
|
|
if (done)
|
2020-11-09 17:27:27 +01:00
|
|
|
session->verify_status_reported = TRUE;
|
2020-02-12 00:55:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void match_cb (FpDevice *device,
|
|
|
|
|
FpPrint *match,
|
|
|
|
|
FpPrint *print,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError *error)
|
|
|
|
|
{
|
|
|
|
|
FprintDevice *rdev = user_data;
|
|
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
|
|
|
|
|
gboolean matched;
|
|
|
|
|
gboolean cancelled;
|
|
|
|
|
|
|
|
|
|
g_assert_true (error == NULL || error->domain == FP_DEVICE_RETRY);
|
|
|
|
|
|
|
|
|
|
cancelled = g_cancellable_is_cancelled (priv->current_cancellable);
|
|
|
|
|
matched = match != NULL && cancelled == FALSE;
|
|
|
|
|
|
|
|
|
|
/* No-match is reported only after the operation completes.
|
|
|
|
|
* This avoids problems when the operation is immediately restarted. */
|
|
|
|
|
report_verify_status (rdev, matched, error);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
static void verify_cb(FpDevice *dev, GAsyncResult *res, void *user_data)
|
2019-08-07 15:27:37 +02:00
|
|
|
{
|
2019-07-30 19:45:50 +02:00
|
|
|
g_autoptr(GError) error = NULL;
|
2020-11-09 17:27:27 +01:00
|
|
|
g_autoptr(SessionData) session = NULL;
|
2020-01-28 18:30:32 +01:00
|
|
|
FprintDevice *rdev = user_data;
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
FprintDBusDevice *dbus_dev = FPRINT_DBUS_DEVICE (rdev);
|
2019-08-13 13:03:13 +02:00
|
|
|
gboolean success;
|
2019-07-30 19:45:50 +02:00
|
|
|
const char *name;
|
|
|
|
|
gboolean match;
|
2019-08-07 15:27:37 +02:00
|
|
|
|
2019-08-13 13:03:13 +02:00
|
|
|
success = fp_device_verify_finish (dev, res, &match, NULL, &error);
|
|
|
|
|
g_assert (!!success == !error);
|
2019-07-30 19:45:50 +02:00
|
|
|
name = verify_result_to_name (match, error);
|
2019-08-07 15:27:37 +02:00
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
session = session_data_get (priv);
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
g_debug("verify_cb: result %s", name);
|
2019-08-07 15:27:37 +02:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
/* Automatically restart the operation for retry failures */
|
|
|
|
|
if (error && error->domain == FP_DEVICE_RETRY) {
|
|
|
|
|
fp_device_verify (priv->dev,
|
|
|
|
|
priv->verify_data,
|
|
|
|
|
priv->current_cancellable,
|
2020-02-12 00:55:21 +01:00
|
|
|
match_cb, rdev, NULL,
|
2019-07-30 19:45:50 +02:00
|
|
|
(GAsyncReadyCallback) verify_cb,
|
|
|
|
|
rdev);
|
|
|
|
|
} else {
|
|
|
|
|
g_clear_object (&priv->verify_data);
|
|
|
|
|
|
2020-02-12 00:55:21 +01:00
|
|
|
if (error) {
|
|
|
|
|
report_verify_status (rdev, FALSE, error);
|
|
|
|
|
|
|
|
|
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
|
|
|
|
|
g_warning ("Device reported an error during verify: %s",
|
|
|
|
|
error->message);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-04 17:00:01 +01:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
/* Return the cancellation or reset action right away if vanished. */
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
if (priv->current_cancel_invocation) {
|
|
|
|
|
fprint_dbus_device_complete_verify_stop (dbus_dev,
|
|
|
|
|
g_steal_pointer (&priv->current_cancel_invocation));
|
2019-07-30 19:45:50 +02:00
|
|
|
priv->current_action = ACTION_NONE;
|
2020-11-09 17:27:27 +01:00
|
|
|
session->verify_status_reported = FALSE;
|
2019-07-30 19:45:50 +02:00
|
|
|
} else if (g_cancellable_is_cancelled (priv->current_cancellable)) {
|
|
|
|
|
priv->current_action = ACTION_NONE;
|
2020-11-09 17:27:27 +01:00
|
|
|
session->verify_status_reported = FALSE;
|
2019-08-07 15:27:37 +02:00
|
|
|
}
|
2008-11-24 15:23:05 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
g_clear_object (&priv->current_cancellable);
|
2008-11-24 15:23:05 +00:00
|
|
|
}
|
2008-10-30 19:27:17 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
static void identify_cb(FpDevice *dev, GAsyncResult *res, void *user_data)
|
2019-08-07 15:27:37 +02:00
|
|
|
{
|
2019-07-30 19:45:50 +02:00
|
|
|
g_autoptr(GError) error = NULL;
|
2020-02-12 05:53:36 +01:00
|
|
|
g_autoptr(FpPrint) match = NULL;
|
2020-01-28 18:30:32 +01:00
|
|
|
FprintDevice *rdev = user_data;
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
FprintDBusDevice *dbus_dev = FPRINT_DBUS_DEVICE (rdev);
|
2019-07-30 19:45:50 +02:00
|
|
|
const char *name;
|
2019-08-13 13:03:13 +02:00
|
|
|
gboolean success;
|
2019-08-07 15:27:37 +02:00
|
|
|
|
2019-08-13 13:03:13 +02:00
|
|
|
success = fp_device_identify_finish (dev, res, &match, NULL, &error);
|
|
|
|
|
g_assert (!!success == !error);
|
2019-07-30 19:45:50 +02:00
|
|
|
name = verify_result_to_name (match != NULL, error);
|
2019-08-07 15:27:37 +02:00
|
|
|
|
2020-02-11 01:19:26 +01:00
|
|
|
g_debug("identify_cb: result %s", name);
|
2008-11-26 18:05:22 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
/* Automatically restart the operation for retry failures */
|
|
|
|
|
if (error && error->domain == FP_DEVICE_RETRY) {
|
|
|
|
|
fp_device_identify (priv->dev,
|
|
|
|
|
priv->identify_data,
|
|
|
|
|
priv->current_cancellable,
|
2020-02-12 00:55:21 +01:00
|
|
|
match_cb, rdev, NULL,
|
2019-07-30 19:45:50 +02:00
|
|
|
(GAsyncReadyCallback) identify_cb,
|
|
|
|
|
rdev);
|
|
|
|
|
} else {
|
|
|
|
|
g_clear_pointer (&priv->identify_data, g_ptr_array_unref);
|
|
|
|
|
|
2020-02-12 00:55:21 +01:00
|
|
|
if (error) {
|
|
|
|
|
report_verify_status (rdev, FALSE, error);
|
|
|
|
|
|
|
|
|
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
|
|
|
|
|
g_warning ("Device reported an error during identify: %s",
|
|
|
|
|
error->message);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-04 17:00:01 +01:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
/* Return the cancellation or reset action right away if vanished. */
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
if (priv->current_cancel_invocation) {
|
|
|
|
|
fprint_dbus_device_complete_verify_stop (dbus_dev,
|
|
|
|
|
g_steal_pointer (&priv->current_cancel_invocation));
|
2019-07-30 19:45:50 +02:00
|
|
|
priv->current_action = ACTION_NONE;
|
|
|
|
|
} else if (g_cancellable_is_cancelled (priv->current_cancellable)) {
|
2020-11-09 17:27:27 +01:00
|
|
|
g_autoptr(SessionData) session = NULL;
|
|
|
|
|
session = session_data_get (priv);
|
2019-07-30 19:45:50 +02:00
|
|
|
priv->current_action = ACTION_NONE;
|
2020-11-09 17:27:27 +01:00
|
|
|
session->verify_status_reported = FALSE;
|
2019-08-07 15:27:37 +02:00
|
|
|
}
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
g_clear_object (&priv->current_cancellable);
|
2008-11-24 15:23:05 +00:00
|
|
|
}
|
2008-03-05 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static gboolean fprint_device_verify_start (FprintDBusDevice *dbus_dev,
|
|
|
|
|
GDBusMethodInvocation *invocation,
|
|
|
|
|
const char *finger_name)
|
2008-03-05 20:00:28 +00:00
|
|
|
{
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2019-07-30 19:45:50 +02:00
|
|
|
g_autoptr(GPtrArray) gallery = NULL;
|
|
|
|
|
g_autoptr(FpPrint) print = NULL;
|
2020-11-09 17:27:27 +01:00
|
|
|
g_autoptr(SessionData) session = NULL;
|
2019-07-30 19:45:50 +02:00
|
|
|
g_autoptr(GError) error = NULL;
|
2008-11-19 20:05:54 +00:00
|
|
|
guint finger_num = finger_name_to_num (finger_name);
|
2008-03-05 20:00:28 +00:00
|
|
|
|
2020-11-09 14:59:33 +01:00
|
|
|
if (!_fprint_device_check_claimed (rdev, invocation, STATE_CLAIMED, &error)) {
|
|
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
session = session_data_get (priv);
|
|
|
|
|
|
2008-11-03 13:41:45 +00:00
|
|
|
if (priv->current_action != ACTION_NONE) {
|
2008-11-03 13:59:48 +00:00
|
|
|
if (priv->current_action == ACTION_ENROLL) {
|
|
|
|
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
|
|
|
|
"Enrollment in progress");
|
|
|
|
|
} else {
|
|
|
|
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
|
|
|
|
"Verification already in progress");
|
|
|
|
|
}
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
return TRUE;
|
2008-05-21 14:36:36 +01:00
|
|
|
}
|
|
|
|
|
|
2008-10-30 19:27:17 +00:00
|
|
|
if (finger_num == -1) {
|
2020-01-29 22:14:36 +01:00
|
|
|
g_autoptr(GSList) prints = NULL;
|
2008-10-30 19:27:17 +00:00
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
prints = store.discover_prints(priv->dev, session->username);
|
2008-10-30 19:27:17 +00:00
|
|
|
if (prints == NULL) {
|
2008-11-24 14:16:41 +00:00
|
|
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_NO_ENROLLED_PRINTS,
|
2008-10-31 00:33:33 +00:00
|
|
|
"No fingerprints enrolled");
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
return TRUE;
|
2008-10-30 19:27:17 +00:00
|
|
|
}
|
2019-07-30 19:45:50 +02:00
|
|
|
if (fp_device_supports_identify (priv->dev)) {
|
2008-10-30 19:27:17 +00:00
|
|
|
GSList *l;
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
gallery = g_ptr_array_new_with_free_func (g_object_unref);
|
2008-10-30 19:27:17 +00:00
|
|
|
|
|
|
|
|
for (l = prints; l != NULL; l = l->next) {
|
2018-05-30 19:59:07 +02:00
|
|
|
g_debug ("adding finger %d to the gallery", GPOINTER_TO_INT (l->data));
|
2019-07-30 19:45:50 +02:00
|
|
|
store.print_data_load(priv->dev, GPOINTER_TO_INT (l->data),
|
2020-11-09 17:27:27 +01:00
|
|
|
session->username, &print);
|
2008-10-30 22:35:34 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
if (print)
|
|
|
|
|
g_ptr_array_add (gallery, g_steal_pointer (&print));
|
2008-10-30 22:35:34 +00:00
|
|
|
}
|
2008-10-30 19:27:17 +00:00
|
|
|
} else {
|
2008-10-30 22:35:34 +00:00
|
|
|
finger_num = GPOINTER_TO_INT (prints->data);
|
2008-10-30 19:27:17 +00:00
|
|
|
}
|
2008-03-05 20:00:28 +00:00
|
|
|
}
|
2008-10-30 19:27:17 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
if (fp_device_supports_identify (priv->dev) && finger_num == -1) {
|
|
|
|
|
if (gallery->len == 0) {
|
2008-11-24 14:16:41 +00:00
|
|
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_NO_ENROLLED_PRINTS,
|
2008-11-03 17:20:59 +00:00
|
|
|
"No fingerprints on that device");
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
return TRUE;
|
2008-10-30 19:27:17 +00:00
|
|
|
}
|
2008-11-03 17:20:59 +00:00
|
|
|
priv->current_action = ACTION_IDENTIFY;
|
2008-10-30 19:27:17 +00:00
|
|
|
|
2018-05-30 19:59:07 +02:00
|
|
|
g_debug ("start identification device %d", priv->id);
|
2019-07-30 19:45:50 +02:00
|
|
|
priv->current_cancellable = g_cancellable_new ();
|
|
|
|
|
priv->identify_data = g_ptr_array_ref (gallery);
|
2020-01-13 16:08:34 +01:00
|
|
|
fp_device_identify (priv->dev, gallery, priv->current_cancellable,
|
2020-02-12 00:55:21 +01:00
|
|
|
match_cb, rdev, NULL,
|
2020-01-13 16:08:34 +01:00
|
|
|
(GAsyncReadyCallback) identify_cb, rdev);
|
2008-10-30 19:27:17 +00:00
|
|
|
} else {
|
2008-11-03 17:20:59 +00:00
|
|
|
priv->current_action = ACTION_VERIFY;
|
2008-10-30 19:27:17 +00:00
|
|
|
|
2018-05-30 19:59:07 +02:00
|
|
|
g_debug("start verification device %d finger %d", priv->id, finger_num);
|
2008-10-30 19:27:17 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
store.print_data_load(priv->dev, finger_num,
|
2020-11-09 17:27:27 +01:00
|
|
|
session->username, &print);
|
2008-10-30 19:27:17 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
if (!print) {
|
2020-02-11 02:29:13 +01:00
|
|
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_NO_ENROLLED_PRINTS,
|
2008-10-30 19:27:17 +00:00
|
|
|
"No such print %d", finger_num);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_dbus_method_invocation_return_gerror (invocation,
|
|
|
|
|
error);
|
|
|
|
|
return TRUE;
|
2008-10-30 19:27:17 +00:00
|
|
|
}
|
2008-10-30 22:35:34 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
priv->current_cancellable = g_cancellable_new ();
|
|
|
|
|
priv->verify_data = g_object_ref (print);
|
2020-01-13 16:08:34 +01:00
|
|
|
fp_device_verify (priv->dev, print, priv->current_cancellable,
|
2020-02-12 00:55:21 +01:00
|
|
|
match_cb, rdev, NULL,
|
2020-01-13 16:08:34 +01:00
|
|
|
(GAsyncReadyCallback) verify_cb, rdev);
|
2008-10-30 19:27:17 +00:00
|
|
|
}
|
|
|
|
|
|
2008-10-31 11:53:05 +00:00
|
|
|
/* Emit VerifyFingerSelected telling the front-end which finger
|
|
|
|
|
* we selected for auth */
|
2008-11-19 20:05:54 +00:00
|
|
|
g_signal_emit(rdev, signals[SIGNAL_VERIFY_FINGER_SELECTED],
|
|
|
|
|
0, finger_num_to_name (finger_num));
|
2008-10-31 11:53:05 +00:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
fprint_dbus_device_complete_verify_start (dbus_dev, invocation);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2008-03-05 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static gboolean fprint_device_verify_stop (FprintDBusDevice *dbus_dev,
|
|
|
|
|
GDBusMethodInvocation *invocation)
|
2008-03-05 20:00:28 +00:00
|
|
|
{
|
2020-11-09 17:27:27 +01:00
|
|
|
g_autoptr(SessionData) session = NULL;
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2020-01-29 22:14:36 +01:00
|
|
|
g_autoptr(GError) error = NULL;
|
2008-03-05 20:00:28 +00:00
|
|
|
|
2020-11-09 14:59:33 +01:00
|
|
|
if (!_fprint_device_check_claimed (rdev, invocation, STATE_CLAIMED, &error)) {
|
|
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
if (priv->current_action == ACTION_NONE) {
|
2020-01-29 22:14:36 +01:00
|
|
|
g_dbus_method_invocation_return_error_literal (invocation,
|
|
|
|
|
FPRINT_ERROR,
|
|
|
|
|
FPRINT_ERROR_NO_ACTION_IN_PROGRESS,
|
|
|
|
|
"No verification in progress");
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
return TRUE;
|
2020-02-11 02:09:47 +01:00
|
|
|
} else if (priv->current_action == ACTION_ENROLL) {
|
2020-01-29 22:14:36 +01:00
|
|
|
g_dbus_method_invocation_return_error_literal (invocation,
|
|
|
|
|
FPRINT_ERROR,
|
|
|
|
|
FPRINT_ERROR_ALREADY_IN_USE,
|
|
|
|
|
"Enrollment in progress");
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
return TRUE;
|
2008-10-30 19:27:17 +00:00
|
|
|
}
|
2008-11-03 13:41:45 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
if (priv->current_cancellable) {
|
|
|
|
|
/* We return only when the action was cancelled */
|
|
|
|
|
g_cancellable_cancel (priv->current_cancellable);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
priv->current_cancel_invocation = invocation;
|
2019-07-30 19:45:50 +02:00
|
|
|
} else {
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
fprint_dbus_device_complete_verify_stop (dbus_dev, invocation);
|
2019-07-30 19:45:50 +02:00
|
|
|
priv->current_action = ACTION_NONE;
|
2020-11-05 21:01:25 +01:00
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
session = session_data_get (priv);
|
|
|
|
|
session->verify_status_reported = FALSE;
|
2019-08-07 15:27:37 +02:00
|
|
|
}
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
|
|
|
|
|
return TRUE;
|
2019-07-30 19:45:50 +02:00
|
|
|
}
|
2019-08-07 15:27:37 +02:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
static void enroll_progress_cb(FpDevice *dev,
|
|
|
|
|
gint completed_stages,
|
|
|
|
|
FpPrint *print,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError *error)
|
|
|
|
|
{
|
2020-01-28 18:30:32 +01:00
|
|
|
FprintDevice *rdev = user_data;
|
2019-07-30 19:45:50 +02:00
|
|
|
const char *name = enroll_result_to_name (FALSE, FALSE, error);
|
2008-11-03 13:41:45 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
g_debug("enroll_stage_cb: result %s", name);
|
|
|
|
|
|
|
|
|
|
if (completed_stages < fp_device_get_nr_enroll_stages (dev))
|
|
|
|
|
g_signal_emit(rdev, signals[SIGNAL_ENROLL_STATUS], 0, name, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-31 16:00:39 +02:00
|
|
|
static gboolean try_delete_print(FprintDevice *rdev)
|
|
|
|
|
{
|
|
|
|
|
g_autoptr(GError) error = NULL;
|
|
|
|
|
g_autoptr(GPtrArray) device_prints = NULL;
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2019-07-31 16:00:39 +02:00
|
|
|
GSList *users, *user;
|
|
|
|
|
|
|
|
|
|
device_prints = fp_device_list_prints_sync (priv->dev, NULL, &error);
|
|
|
|
|
if (!device_prints) {
|
|
|
|
|
g_warning ("Failed to query prints: %s", error->message);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_debug ("Device has %d prints stored", device_prints->len);
|
|
|
|
|
|
|
|
|
|
users = store.discover_users();
|
|
|
|
|
|
|
|
|
|
for (user = users; user; user = user->next) {
|
2019-08-13 13:03:13 +02:00
|
|
|
const char *username = user->data;
|
2020-01-29 22:14:36 +01:00
|
|
|
g_autoptr(GSList) fingers = NULL;
|
|
|
|
|
GSList *finger;
|
2019-07-31 16:00:39 +02:00
|
|
|
|
|
|
|
|
fingers = store.discover_prints (priv->dev, username);
|
|
|
|
|
|
|
|
|
|
for (finger = fingers; finger; finger = finger->next) {
|
|
|
|
|
g_autoptr(FpPrint) print = NULL;
|
|
|
|
|
guint index;
|
|
|
|
|
|
|
|
|
|
store.print_data_load (priv->dev,
|
|
|
|
|
GPOINTER_TO_INT (fingers->data),
|
|
|
|
|
username,
|
|
|
|
|
&print);
|
|
|
|
|
|
|
|
|
|
if (!print)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!g_ptr_array_find_with_equal_func (device_prints,
|
|
|
|
|
print,
|
|
|
|
|
(GEqualFunc) fp_print_equal,
|
|
|
|
|
&index))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Found an equal print, remove it */
|
|
|
|
|
g_ptr_array_remove_index (device_prints, index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_slist_free_full (users, g_free);
|
|
|
|
|
|
|
|
|
|
g_debug ("Device has %d prints stored that we do not need", device_prints->len);
|
|
|
|
|
if (device_prints->len == 0)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* Just delete the first print in the list at this point.
|
|
|
|
|
* We could be smarter and fetch some more metadata. */
|
|
|
|
|
fp_device_delete_print_sync (priv->dev,
|
|
|
|
|
g_ptr_array_index (device_prints, 0),
|
|
|
|
|
NULL,
|
|
|
|
|
&error);
|
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
g_warning ("Failed to garbage collect a print: %s", error->message);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 22:14:36 +01:00
|
|
|
#if !GLIB_CHECK_VERSION (2, 63, 3)
|
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GDate, g_date_free);
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
static FpPrint*
|
|
|
|
|
fprint_device_create_enroll_template(FprintDevice *rdev, gint finger_num)
|
|
|
|
|
{
|
2020-11-09 17:27:27 +01:00
|
|
|
g_autoptr(SessionData) session = NULL;
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2020-01-29 22:14:36 +01:00
|
|
|
g_autoptr(GDateTime) datetime = NULL;
|
|
|
|
|
g_autoptr(GDate) date = NULL;
|
2019-07-30 19:45:50 +02:00
|
|
|
FpPrint *template = NULL;
|
|
|
|
|
gint year, month, day;
|
|
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
session = session_data_get (priv);
|
2020-11-05 21:01:25 +01:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
template = fp_print_new (priv->dev);
|
|
|
|
|
fp_print_set_finger (template, finger_num);
|
2020-11-09 17:27:27 +01:00
|
|
|
fp_print_set_username (template, session->username);
|
2019-07-30 19:45:50 +02:00
|
|
|
datetime = g_date_time_new_now_local ();
|
|
|
|
|
g_date_time_get_ymd (datetime, &year, &month, &day);
|
|
|
|
|
date = g_date_new_dmy (day, month, year);
|
|
|
|
|
fp_print_set_enroll_date (template, date);
|
|
|
|
|
|
|
|
|
|
return template;
|
2008-03-05 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
static void enroll_cb(FpDevice *dev, GAsyncResult *res, void *user_data)
|
2008-03-06 16:37:19 +00:00
|
|
|
{
|
2019-07-30 19:45:50 +02:00
|
|
|
g_autoptr(GError) error = NULL;
|
2020-01-28 18:30:32 +01:00
|
|
|
FprintDevice *rdev = user_data;
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
FprintDBusDevice *dbus_dev = FPRINT_DBUS_DEVICE (rdev);
|
2019-07-30 19:45:50 +02:00
|
|
|
g_autoptr(FpPrint) print = NULL;
|
|
|
|
|
const char *name;
|
2008-03-06 16:37:19 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
print = fp_device_enroll_finish (dev, res, &error);
|
2019-07-31 16:00:39 +02:00
|
|
|
|
|
|
|
|
/* We need to special case the issue where the on device storage
|
|
|
|
|
* is completely full. In that case, we check whether we can delete
|
|
|
|
|
* a print that is not coming from us; assuming it is from an old
|
|
|
|
|
* installation.
|
|
|
|
|
* We do this synchronously, which is not great but should be good
|
|
|
|
|
* enough. */
|
|
|
|
|
if (g_error_matches (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_FULL)) {
|
|
|
|
|
g_debug ("Device storage is full, trying to garbage collect old prints");
|
|
|
|
|
if (try_delete_print (rdev)) {
|
|
|
|
|
/* Success? Then restart the operation */
|
|
|
|
|
fp_device_enroll (priv->dev,
|
|
|
|
|
fprint_device_create_enroll_template (rdev, priv->enroll_data),
|
|
|
|
|
priv->current_cancellable,
|
|
|
|
|
enroll_progress_cb,
|
|
|
|
|
rdev,
|
|
|
|
|
NULL,
|
|
|
|
|
(GAsyncReadyCallback) enroll_cb,
|
|
|
|
|
rdev);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
name = enroll_result_to_name (TRUE, print != NULL, error);
|
|
|
|
|
|
|
|
|
|
g_debug ("enroll_cb: result %s", name);
|
2008-11-26 18:05:22 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
if (print) {
|
|
|
|
|
int r;
|
|
|
|
|
r = store.print_data_save(print);
|
2008-05-20 11:20:11 +01:00
|
|
|
if (r < 0)
|
2019-07-30 19:45:50 +02:00
|
|
|
name = "enroll-failed";
|
2008-05-20 11:20:11 +01:00
|
|
|
}
|
2008-03-06 16:37:19 +00:00
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
g_signal_emit(rdev, signals[SIGNAL_ENROLL_STATUS], 0, name, TRUE);
|
2008-11-26 18:05:22 +00:00
|
|
|
|
2019-12-04 17:00:01 +01:00
|
|
|
if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
g_warning ("Device reported an error during enroll: %s", error->message);
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
/* Return the cancellation or reset action right away if vanished. */
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
if (priv->current_cancel_invocation) {
|
|
|
|
|
fprint_dbus_device_complete_enroll_stop (dbus_dev,
|
|
|
|
|
g_steal_pointer (&priv->current_cancel_invocation));
|
2019-07-30 19:45:50 +02:00
|
|
|
priv->current_action = ACTION_NONE;
|
|
|
|
|
} else if (g_cancellable_is_cancelled (priv->current_cancellable)) {
|
|
|
|
|
priv->current_action = ACTION_NONE;
|
|
|
|
|
}
|
|
|
|
|
g_clear_object (&priv->current_cancellable);
|
2008-03-06 16:37:19 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static gboolean fprint_device_enroll_start (FprintDBusDevice *dbus_dev,
|
|
|
|
|
GDBusMethodInvocation *invocation,
|
|
|
|
|
const char *finger_name)
|
2008-03-06 16:37:19 +00:00
|
|
|
{
|
2019-07-30 19:45:50 +02:00
|
|
|
g_autoptr(GError) error = NULL;
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2008-11-19 20:05:54 +00:00
|
|
|
int finger_num = finger_name_to_num (finger_name);
|
2008-03-06 16:37:19 +00:00
|
|
|
|
2020-11-09 14:59:33 +01:00
|
|
|
if (!_fprint_device_check_claimed (rdev, invocation, STATE_CLAIMED, &error)) {
|
|
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-19 20:05:54 +00:00
|
|
|
if (finger_num == -1) {
|
2008-11-24 14:16:41 +00:00
|
|
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_INVALID_FINGERNAME,
|
2019-07-30 19:45:50 +02:00
|
|
|
"Invalid finger name");
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
return TRUE;
|
2008-11-19 20:05:54 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-03 13:59:48 +00:00
|
|
|
if (priv->current_action != ACTION_NONE) {
|
|
|
|
|
if (priv->current_action == ACTION_ENROLL) {
|
|
|
|
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
|
|
|
|
"Enrollment already in progress");
|
|
|
|
|
} else {
|
|
|
|
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
|
|
|
|
"Verification in progress");
|
|
|
|
|
}
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
return TRUE;
|
2008-11-03 13:59:48 +00:00
|
|
|
}
|
|
|
|
|
|
2018-05-30 19:59:07 +02:00
|
|
|
g_debug("start enrollment device %d finger %d", priv->id, finger_num);
|
2019-07-30 19:45:50 +02:00
|
|
|
|
|
|
|
|
priv->current_cancellable = g_cancellable_new ();
|
2019-07-31 16:00:39 +02:00
|
|
|
priv->enroll_data = finger_num;
|
2019-07-30 19:45:50 +02:00
|
|
|
fp_device_enroll (priv->dev,
|
|
|
|
|
fprint_device_create_enroll_template (rdev, priv->enroll_data),
|
|
|
|
|
priv->current_cancellable,
|
|
|
|
|
enroll_progress_cb,
|
|
|
|
|
rdev,
|
|
|
|
|
NULL,
|
|
|
|
|
(GAsyncReadyCallback) enroll_cb,
|
|
|
|
|
rdev);
|
2008-03-06 16:37:19 +00:00
|
|
|
|
2008-11-03 17:20:59 +00:00
|
|
|
priv->current_action = ACTION_ENROLL;
|
2008-11-03 13:59:48 +00:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
fprint_dbus_device_complete_enroll_start (dbus_dev, invocation);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2008-03-06 16:37:19 +00:00
|
|
|
}
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static gboolean fprint_device_enroll_stop (FprintDBusDevice *dbus_dev,
|
|
|
|
|
GDBusMethodInvocation *invocation)
|
2008-03-06 16:37:19 +00:00
|
|
|
{
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2020-11-09 14:59:33 +01:00
|
|
|
g_autoptr(GError) error = NULL;
|
|
|
|
|
|
|
|
|
|
if (!_fprint_device_check_claimed (rdev, invocation, STATE_CLAIMED, &error)) {
|
|
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2008-03-06 16:37:19 +00:00
|
|
|
|
2008-11-03 13:59:48 +00:00
|
|
|
if (priv->current_action != ACTION_ENROLL) {
|
2020-02-11 02:09:47 +01:00
|
|
|
if (priv->current_action == ACTION_NONE) {
|
|
|
|
|
g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_NO_ACTION_IN_PROGRESS,
|
|
|
|
|
"No enrollment in progress");
|
|
|
|
|
} else if (priv->current_action == ACTION_VERIFY) {
|
|
|
|
|
g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
|
|
|
|
"Verification in progress");
|
|
|
|
|
} else if (priv->current_action == ACTION_IDENTIFY) {
|
|
|
|
|
g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
|
|
|
|
"Identification in progress");
|
|
|
|
|
} else
|
|
|
|
|
g_assert_not_reached ();
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
return TRUE;
|
2008-11-03 13:59:48 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-30 19:45:50 +02:00
|
|
|
if (priv->current_cancellable) {
|
|
|
|
|
/* We return only when the action was cancelled */
|
|
|
|
|
g_cancellable_cancel (priv->current_cancellable);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
priv->current_cancel_invocation = invocation;
|
2019-07-30 19:45:50 +02:00
|
|
|
} else {
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
fprint_dbus_device_complete_enroll_stop (dbus_dev, invocation);
|
2019-07-30 19:45:50 +02:00
|
|
|
priv->current_action = ACTION_NONE;
|
2008-03-06 16:37:19 +00:00
|
|
|
}
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
|
|
|
|
|
return TRUE;
|
2008-03-06 16:37:19 +00:00
|
|
|
}
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static gboolean fprint_device_list_enrolled_fingers (FprintDBusDevice *dbus_dev,
|
|
|
|
|
GDBusMethodInvocation *invocation,
|
|
|
|
|
const char *username)
|
2008-04-07 01:12:44 +03:00
|
|
|
{
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_autoptr (GPtrArray) ret = NULL;
|
2020-01-29 22:14:36 +01:00
|
|
|
g_autoptr(GSList) prints = NULL;
|
2008-04-07 01:12:44 +03:00
|
|
|
GSList *item;
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
const char *sender;
|
2020-11-05 21:01:25 +01:00
|
|
|
const char *user;
|
2008-05-21 14:36:36 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
sender = g_dbus_method_invocation_get_sender (invocation);
|
2008-11-03 17:20:59 +00:00
|
|
|
_fprint_device_add_client (rdev, sender);
|
|
|
|
|
|
2020-11-05 21:01:25 +01:00
|
|
|
user = g_object_get_qdata (G_OBJECT (invocation), quark_auth_user);
|
|
|
|
|
g_assert (user);
|
2019-07-30 19:45:50 +02:00
|
|
|
prints = store.discover_prints(priv->dev, user);
|
2020-11-05 21:01:25 +01:00
|
|
|
|
2008-04-07 01:12:44 +03:00
|
|
|
if (!prints) {
|
2020-01-29 22:14:36 +01:00
|
|
|
g_dbus_method_invocation_return_error_literal (invocation,
|
|
|
|
|
FPRINT_ERROR,
|
|
|
|
|
FPRINT_ERROR_NO_ENROLLED_PRINTS,
|
|
|
|
|
"Failed to discover prints");
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
return TRUE;
|
2008-04-07 01:12:44 +03:00
|
|
|
}
|
|
|
|
|
|
2008-11-19 20:05:54 +00:00
|
|
|
ret = g_ptr_array_new ();
|
2008-04-07 01:12:44 +03:00
|
|
|
for (item = prints; item; item = item->next) {
|
2008-11-19 20:05:54 +00:00
|
|
|
int finger_num = GPOINTER_TO_INT (item->data);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_ptr_array_add (ret, (char *) finger_num_to_name (finger_num));
|
2008-04-07 01:12:44 +03:00
|
|
|
}
|
2008-11-19 20:05:54 +00:00
|
|
|
g_ptr_array_add (ret, NULL);
|
2008-04-07 01:12:44 +03:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
fprint_dbus_device_complete_list_enrolled_fingers (dbus_dev,
|
|
|
|
|
invocation, (const gchar *const *) ret->pdata);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2008-04-07 01:12:44 +03:00
|
|
|
}
|
|
|
|
|
|
2019-08-13 13:03:13 +02:00
|
|
|
static void delete_enrolled_fingers(FprintDevice *rdev, const char *user)
|
|
|
|
|
{
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2019-08-13 13:03:13 +02:00
|
|
|
guint i;
|
|
|
|
|
|
2020-11-05 21:01:25 +01:00
|
|
|
g_debug ("Deleting enrolled fingers for user %s", user);
|
|
|
|
|
|
2019-08-13 13:03:13 +02:00
|
|
|
/* First try deleting the print from the device, we don't consider it
|
|
|
|
|
* fatal if this does not work. */
|
|
|
|
|
if (fp_device_has_storage (priv->dev)) {
|
|
|
|
|
g_autoptr(GSList) prints = NULL;
|
|
|
|
|
GSList *l;
|
|
|
|
|
|
|
|
|
|
prints = store.discover_prints(priv->dev, user);
|
|
|
|
|
|
|
|
|
|
for (l = prints; l != NULL; l = l->next) {
|
|
|
|
|
g_autoptr(FpPrint) print = NULL;
|
|
|
|
|
|
|
|
|
|
store.print_data_load(priv->dev,
|
|
|
|
|
GPOINTER_TO_INT (l->data),
|
|
|
|
|
user,
|
|
|
|
|
&print);
|
|
|
|
|
|
|
|
|
|
if (print) {
|
|
|
|
|
g_autoptr(GError) error = NULL;
|
|
|
|
|
|
|
|
|
|
if (!fp_device_delete_print_sync (priv->dev, print, NULL, &error)) {
|
|
|
|
|
g_warning ("Error deleting print from device: %s", error->message);
|
|
|
|
|
g_warning ("This might indicate an issue in the libfprint driver or in the fingerprint device.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-18 17:32:52 +01:00
|
|
|
for (i = FP_FINGER_FIRST; i <= FP_FINGER_LAST; i++) {
|
2019-08-13 13:03:13 +02:00
|
|
|
store.print_data_delete(priv->dev, i, user);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-02 15:38:10 +01:00
|
|
|
#ifdef __linux__
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static void log_offending_client_cb (GObject *object,
|
|
|
|
|
GAsyncResult *res,
|
|
|
|
|
gpointer user_data)
|
2019-12-02 15:38:10 +01:00
|
|
|
{
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
GDBusConnection *connection = G_DBUS_CONNECTION (object);
|
|
|
|
|
g_autoptr(GVariant) ret = NULL;
|
2019-12-02 15:38:10 +01:00
|
|
|
g_autofree char *path = NULL;
|
|
|
|
|
g_autofree char *content = NULL;
|
|
|
|
|
guint pid = 0;
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
ret = g_dbus_connection_call_finish (connection, res, NULL);
|
2019-12-02 15:38:10 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
if (!ret)
|
|
|
|
|
return;
|
2019-12-02 15:38:10 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_variant_get (ret, "(u)", &pid);
|
2019-12-02 15:38:10 +01:00
|
|
|
path = g_strdup_printf ("/proc/%u/comm", pid);
|
|
|
|
|
if (g_file_get_contents (path, &content, NULL, NULL)) {
|
|
|
|
|
g_strchomp (content);
|
|
|
|
|
g_warning ("Offending API user is %s", content);
|
|
|
|
|
}
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
}
|
2019-12-02 15:38:10 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static void log_offending_client (GDBusMethodInvocation *invocation)
|
|
|
|
|
{
|
|
|
|
|
const char *sender;
|
|
|
|
|
GDBusConnection *connection;
|
|
|
|
|
|
|
|
|
|
connection = g_dbus_method_invocation_get_connection (invocation);
|
|
|
|
|
sender = g_dbus_method_invocation_get_sender (invocation);
|
|
|
|
|
|
|
|
|
|
g_dbus_connection_call (connection,
|
|
|
|
|
"org.freedesktop.DBus",
|
|
|
|
|
"/org/freedesktop/DBus",
|
|
|
|
|
"org.freedesktop.DBus",
|
|
|
|
|
"GetConnectionUnixProcessID",
|
|
|
|
|
g_variant_new ("(s)", sender),
|
|
|
|
|
NULL, G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1, NULL, log_offending_client_cb, NULL);
|
2019-12-02 15:38:10 +01:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static gboolean fprint_device_delete_enrolled_fingers (FprintDBusDevice *dbus_dev,
|
|
|
|
|
GDBusMethodInvocation *invocation,
|
|
|
|
|
const char *username)
|
2008-10-29 15:47:36 +00:00
|
|
|
{
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2020-01-29 22:14:36 +01:00
|
|
|
g_autoptr(GError) error = NULL;
|
2020-02-06 14:18:16 +01:00
|
|
|
g_autofree char *user = NULL;
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
const char *sender;
|
2019-08-13 13:03:13 +02:00
|
|
|
gboolean opened;
|
|
|
|
|
|
|
|
|
|
g_warning ("The API user should be updated to use DeleteEnrolledFingers2 method!");
|
2019-12-02 15:38:10 +01:00
|
|
|
#ifdef __linux__
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
log_offending_client (invocation);
|
2019-12-02 15:38:10 +01:00
|
|
|
#endif
|
2008-10-29 15:47:36 +00:00
|
|
|
|
2020-11-05 21:01:25 +01:00
|
|
|
user = g_object_steal_qdata (G_OBJECT (invocation), quark_auth_user);
|
|
|
|
|
g_assert (user);
|
2008-10-29 15:47:36 +00:00
|
|
|
|
2020-11-05 21:01:25 +01:00
|
|
|
if (!_fprint_device_check_claimed (rdev, invocation, STATE_CLAIMED,
|
|
|
|
|
&error)) {
|
2019-08-13 13:03:13 +02:00
|
|
|
/* Return error for anything but FPRINT_ERROR_CLAIM_DEVICE */
|
|
|
|
|
if (!g_error_matches (error, FPRINT_ERROR, FPRINT_ERROR_CLAIM_DEVICE)) {
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_dbus_method_invocation_return_gerror (invocation,
|
|
|
|
|
error);
|
|
|
|
|
return TRUE;
|
2019-08-13 13:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
opened = FALSE;
|
|
|
|
|
} else {
|
|
|
|
|
opened = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
sender = g_dbus_method_invocation_get_sender (invocation);
|
2008-11-03 17:20:59 +00:00
|
|
|
_fprint_device_add_client (rdev, sender);
|
|
|
|
|
|
2019-08-13 13:03:13 +02:00
|
|
|
if (!opened && fp_device_has_storage (priv->dev))
|
|
|
|
|
fp_device_open_sync (priv->dev, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
delete_enrolled_fingers (rdev, user);
|
|
|
|
|
|
|
|
|
|
if (!opened && fp_device_has_storage (priv->dev))
|
|
|
|
|
fp_device_close_sync (priv->dev, NULL, NULL);
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
fprint_dbus_device_complete_delete_enrolled_fingers (dbus_dev,
|
|
|
|
|
invocation);
|
|
|
|
|
return TRUE;
|
2008-10-29 15:47:36 +00:00
|
|
|
}
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static gboolean fprint_device_delete_enrolled_fingers2 (FprintDBusDevice *dbus_dev,
|
|
|
|
|
GDBusMethodInvocation *invocation)
|
2019-08-13 13:03:13 +02:00
|
|
|
{
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
|
2020-01-13 11:05:37 +01:00
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
|
2020-11-09 17:27:27 +01:00
|
|
|
g_autoptr(SessionData) session = NULL;
|
2020-11-09 14:59:33 +01:00
|
|
|
g_autoptr(GError) error = NULL;
|
|
|
|
|
|
|
|
|
|
if (!_fprint_device_check_claimed (rdev, invocation, STATE_CLAIMED, &error)) {
|
|
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2020-11-05 21:01:25 +01:00
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
session = session_data_get (priv);
|
2020-11-05 21:01:25 +01:00
|
|
|
|
2020-11-09 17:27:27 +01:00
|
|
|
delete_enrolled_fingers (rdev, session->username);
|
2020-11-05 21:01:25 +01:00
|
|
|
fprint_dbus_device_complete_delete_enrolled_fingers2 (dbus_dev,
|
|
|
|
|
invocation);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
handle_unauthorized_access (FprintDevice *rdev,
|
|
|
|
|
GDBusMethodInvocation *invocation,
|
|
|
|
|
GError *error)
|
|
|
|
|
{
|
|
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
|
|
|
|
|
|
|
|
|
|
g_assert (error);
|
|
|
|
|
|
|
|
|
|
g_warning ("Client %s not authorized for device %s: %s",
|
|
|
|
|
g_dbus_method_invocation_get_sender (invocation),
|
|
|
|
|
fp_device_get_name (priv->dev),
|
|
|
|
|
error->message);
|
|
|
|
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
action_authorization_handler (GDBusInterfaceSkeleton *interface,
|
|
|
|
|
GDBusMethodInvocation *invocation,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
FprintDBusDevice *dbus_dev = FPRINT_DBUS_DEVICE (interface);
|
|
|
|
|
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
|
|
|
|
|
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
|
|
|
|
|
FprintDeviceClaimState required_state = STATE_IGNORED;
|
2020-11-06 18:22:15 +01:00
|
|
|
FprintDevicePermission required_perms = FPRINT_DEVICE_PERMISSION_NONE;
|
2020-11-05 21:01:25 +01:00
|
|
|
gboolean needs_user_auth = FALSE;
|
2020-02-04 19:47:56 +01:00
|
|
|
g_autoptr(GError) error = NULL;
|
2020-11-05 21:01:25 +01:00
|
|
|
const gchar *method_name;
|
|
|
|
|
|
|
|
|
|
method_name = g_dbus_method_invocation_get_method_name (invocation);
|
|
|
|
|
|
|
|
|
|
g_debug ("Requesting device '%s' authorization for method %s from %s",
|
|
|
|
|
fp_device_get_name (priv->dev), method_name,
|
|
|
|
|
g_dbus_method_invocation_get_sender (invocation));
|
|
|
|
|
|
|
|
|
|
if (g_str_equal (method_name, "Claim")) {
|
|
|
|
|
needs_user_auth = TRUE;
|
|
|
|
|
required_state = STATE_UNCLAIMED;
|
2020-11-06 18:22:15 +01:00
|
|
|
required_perms |= FPRINT_DEVICE_PERMISSION_VERIFY;
|
|
|
|
|
required_perms |= FPRINT_DEVICE_PERMISSION_ENROLL;
|
2020-11-05 21:01:25 +01:00
|
|
|
} else if (g_str_equal (method_name, "DeleteEnrolledFingers")) {
|
|
|
|
|
needs_user_auth = TRUE;
|
2020-11-06 18:22:15 +01:00
|
|
|
required_perms |= FPRINT_DEVICE_PERMISSION_ENROLL;
|
2020-11-05 21:01:25 +01:00
|
|
|
} else if (g_str_equal (method_name, "DeleteEnrolledFingers2")) {
|
|
|
|
|
required_state = STATE_CLAIMED;
|
2020-11-06 18:22:15 +01:00
|
|
|
required_perms |= FPRINT_DEVICE_PERMISSION_ENROLL;
|
2020-11-05 21:01:25 +01:00
|
|
|
} else if (g_str_equal (method_name, "EnrollStart")) {
|
|
|
|
|
required_state = STATE_CLAIMED;
|
2020-11-06 18:22:15 +01:00
|
|
|
required_perms |= FPRINT_DEVICE_PERMISSION_ENROLL;
|
2020-11-05 21:01:25 +01:00
|
|
|
} else if (g_str_equal (method_name, "EnrollStop")) {
|
|
|
|
|
required_state = STATE_CLAIMED;
|
2020-11-06 18:22:15 +01:00
|
|
|
required_perms |= FPRINT_DEVICE_PERMISSION_ENROLL;
|
2020-11-05 21:01:25 +01:00
|
|
|
} else if (g_str_equal (method_name, "ListEnrolledFingers")) {
|
|
|
|
|
needs_user_auth = TRUE;
|
2020-11-06 18:22:15 +01:00
|
|
|
required_perms |= FPRINT_DEVICE_PERMISSION_VERIFY;
|
2020-11-05 21:01:25 +01:00
|
|
|
} else if (g_str_equal (method_name, "Release")) {
|
|
|
|
|
required_state = STATE_CLAIMED;
|
2020-11-06 18:22:15 +01:00
|
|
|
required_perms |= FPRINT_DEVICE_PERMISSION_VERIFY;
|
|
|
|
|
required_perms |= FPRINT_DEVICE_PERMISSION_ENROLL;
|
2020-11-05 21:01:25 +01:00
|
|
|
} else if (g_str_equal (method_name, "VerifyStart")) {
|
|
|
|
|
required_state = STATE_CLAIMED;
|
2020-11-06 18:22:15 +01:00
|
|
|
required_perms |= FPRINT_DEVICE_PERMISSION_VERIFY;
|
2020-11-05 21:01:25 +01:00
|
|
|
} else if (g_str_equal (method_name, "VerifyStop")) {
|
|
|
|
|
required_state = STATE_CLAIMED;
|
2020-11-06 18:22:15 +01:00
|
|
|
required_perms |= FPRINT_DEVICE_PERMISSION_VERIFY;
|
2020-11-05 21:01:25 +01:00
|
|
|
} else {
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
2019-08-13 13:03:13 +02:00
|
|
|
|
2020-11-09 14:59:33 +01:00
|
|
|
/* This is just a quick check in order to avoid authentication if
|
|
|
|
|
* the user cannot make the call at this time anyway.
|
|
|
|
|
* The method handler itself is required to check again! */
|
2020-11-05 21:01:25 +01:00
|
|
|
if (!_fprint_device_check_claimed (rdev, invocation, required_state,
|
|
|
|
|
&error)) {
|
|
|
|
|
return handle_unauthorized_access (rdev, invocation, error);
|
2019-08-13 13:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
2020-11-05 21:01:25 +01:00
|
|
|
if (needs_user_auth &&
|
|
|
|
|
!fprintd_device_authorize_user (rdev, invocation, &error)) {
|
|
|
|
|
return handle_unauthorized_access (rdev, invocation, error);
|
2019-08-13 13:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
2020-11-05 21:01:25 +01:00
|
|
|
/* This may possibly block the invocation till the user has not
|
|
|
|
|
* provided an authentication method, so other calls could arrive */
|
2020-11-06 18:22:15 +01:00
|
|
|
if (!fprint_device_check_polkit_for_permissions (rdev, invocation,
|
|
|
|
|
required_perms,
|
|
|
|
|
&error)) {
|
2020-11-05 21:01:25 +01:00
|
|
|
return handle_unauthorized_access (rdev, invocation, error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_debug ("Authorization granted to %s for device %s!",
|
|
|
|
|
fp_device_get_name (priv->dev),
|
|
|
|
|
g_dbus_method_invocation_get_sender (invocation));
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2019-08-13 13:03:13 +02:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static void fprint_device_dbus_skeleton_iface_init (FprintDBusDeviceIface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->handle_claim = fprint_device_claim;
|
|
|
|
|
iface->handle_delete_enrolled_fingers = fprint_device_delete_enrolled_fingers;
|
|
|
|
|
iface->handle_delete_enrolled_fingers2 = fprint_device_delete_enrolled_fingers2;
|
|
|
|
|
iface->handle_enroll_start = fprint_device_enroll_start;
|
|
|
|
|
iface->handle_enroll_stop = fprint_device_enroll_stop;
|
|
|
|
|
iface->handle_list_enrolled_fingers = fprint_device_list_enrolled_fingers;
|
|
|
|
|
iface->handle_release = fprint_device_release;
|
|
|
|
|
iface->handle_verify_start = fprint_device_verify_start;
|
|
|
|
|
iface->handle_verify_stop = fprint_device_verify_stop;
|
2019-08-13 13:03:13 +02:00
|
|
|
}
|
|
|
|
|
|