Commit Graph

84 Commits

Author SHA1 Message Date
b861500a9f device: Throw AlreadyInUse error if stopping an enroll during verification
When starting an enroll when verification is in progress (and vice-versa) we
emit an AlreadyInUse error, however when calling VerifyStop() during an
enrollment (and vice-versa) we just return a NoActionInProgress error, which
is not the case.

So let's be consistent and change the error type.
2020-03-17 17:14:33 +01:00
154d0c0373 device: Use proper function name in debug 2020-03-17 17:10:17 +01:00
5e9624bef5 device: Fix verify-disconnected state name
Respect protocol, and use proper name
2020-03-17 17:10:17 +01:00
efac52d94f device: Fix retry enroll error names
Use proper names for enroll retry errors, fixing a copy/paste error from the
verify code.
2020-03-17 17:10:17 +01:00
e7f804e9fc 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-03-17 17:09:19 +01:00
0e993d92e2 device: Return 'verify-no-match' on cancelled verification
We were returning a 'verify-unknown-error' while we actually know what
happened, so better to return a soft operation failure.
2020-03-17 17:09:19 +01:00
b312a5e540 device: Return 'enroll-failed' on cancelled enrollment
We were returning an 'enroll-unknown-error' while we actually know what
happened, so better to return a soft operation failure.
2020-03-17 17:09:19 +01:00
681bd1ed2a device: Fix leaked matched print on identify
When starting an identify operation we allocate a gallery of prints from the
gallery, although if we match one of them we get that back in the finish
callback but with a further reference added.

So, in order to clean it up, use an auto-pointer or we'd end up in leaking
it, and the address sanitizer was catching this in our tests already:

  Indirect leak of 12020 byte(s) in 5 object(s) allocated from:
    #0 0x7fe8bc638ce6 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dce6)
    #1 0x7fe8bc37ffd0 in g_malloc0 ../../glib/glib/gmem.c:132
    #2 0x55d100635c01 in load_from_file ../src/file_storage.c:159
    #3 0x55d100635c01 in file_storage_print_data_load ../src/file_storage.c:182
    #4 0x55d10063e950 in fprint_device_verify_start ../src/device.c:882
    #5 0x55d10064036b in dbus_glib_marshal_fprint_device_VOID__STRING_POINTER src/device-dbus-glue.h:96
    #6 0x7fe8bc50f6f5  (/usr/lib/x86_64-linux-gnu/libdbus-glib-1.so.2+0xd6f5)
2020-02-14 15:55:09 +01:00
8890732194 device: Don't leak the user on claim error while deleting prints
When using the delete method we check if the device was claimed, if this
fails because the device is already in use we return an error, but we don't
free the user.

While this could be fixed by just a further g_free call, let's just remove
remove the other manual free calls, and use an auto-pointer instead for this
function.
2020-02-14 15:55:09 +01:00
7dac81dcad device: Use g_clear_error instead of doing the same manually
We've now an utility function that can help us to free and unset an error
double pointer, so let's use it.
2020-02-14 15:55:09 +01:00
ba7a45d3f8 device: Always free error in delete enrolled fingers2
During delete enrolled fingers2 call, if the check-claimed control fails, we
would return the error without freeing it.

While this could be fixed by just a further g_error_free call, let's just
remove the other manual free call, and use an auto-pointer instead for this
function.
2020-02-14 15:55:09 +01:00
49dced5566 device: Always free error in delete enrolled fingers
During delete enrolled fingers call, if the check-claimed control fails, and
we get an error different from FPRINT_ERROR_CLAIM_DEVICE, we would return
the error without freeing it.

While this could be fixed by just a further g_error_free call, let's just
remove all the manual free calls, and use an auto-pointer instead for this
function.
2020-02-14 15:55:09 +01:00
7d8450e5ab device: Mark fingers names array as const and use unique name
With the stronger warnings enabled when building with meson, we get a
warning for all the fingers definitions:

  ../src/device.c:38:24: warning: initialization discards ‘const’ qualifier
  from pointer target type [-Wdiscarded-qualifiers]
    38 |  [FP_FINGER_UNKNOWN] = "unknown",

As the `fingers` array name was shadowed in another file:

  ../src/device.c:1000:11: warning: declaration of ‘fingers’ shadows a
  global declaration [-Wshadow]
    1000 |   GSList *fingers, *finger;
2020-02-05 15:25:35 +01:00
2076025208 device: Use session data for context, sender and user
Use the device session data to store all the informations we care about
while a device is claimed, and make its cleanup easier.

Keep just one instance of the current context, given we use it only during
claim and release, and those are mutually exclusive operations.
2020-02-04 14:54:20 +01:00
77126ccf1f device: Remove unused storage_type variable 2020-02-04 14:40:17 +01:00
46b7d7c1a7 device: Clear username on open failure 2020-02-04 14:36:39 +01:00
791a208afd device: Clear session, sender and username on close failure 2020-02-04 14:31:51 +01:00
b832002c97 device: Use malloc-allocated SessionData
Allocate SessionData using g_malloc(). There are no benefits to using
GSlice for a seldom used structure. This also allows use to use
g_clear_pointer() to free the struct.
2020-02-04 14:30:10 +01:00
8a2f276003 device: Cleanup session_data on open failure 2020-02-04 14:25:00 +01:00
aab923e3cd device: Fix memory leak on object destruction
Add the missing chain-up on finalize().
2020-02-04 14:22:01 +01:00
cc4bac3410 main: Use G_DECLARE_FINAL_TYPE to define objet 2020-02-04 14:19:41 +01:00
9baea4494b device: Replace deprecated g_type_class_add_private() 2020-01-14 14:00:56 +01:00
41afbd1ced device: Simplify FprintDevicePrivate declaration 2020-01-14 14:00:56 +01:00
deb3c25e51 device: Adjust to new libfprint API for early match reporting
This API was added to libfprint to allow drivers to report the match
result early before the operation has been completed. No driver makes
use of this facility yet and instead drivers try to finish the
operation early for quick result reporting. This primarily means not
waiting for finger removal.

Once drivers are updated, fprintd reactivity will regress unless the
early match callback is implemented as they would only get an operation
finished callback when the whole of the operation was finished,
including finger removal and finishing up USB communications.

See: https://gitlab.freedesktop.org/libfprint/fprintd/issues/35
2020-01-14 13:41:57 +01:00
a520896325 device: Use FP_FINGER_IS_VALID to check finger number 2019-12-19 14:29:04 +01:00
6903c36157 file-storage: Use first/last fingers references instead of named ones
Don't depend in the hardcoded libfprint fingers order, but use instead the
aliases for first/last fingers in libfprint order
2019-12-18 17:34:04 +01:00
5043ef3c7d device: Print warnings for fatal errors 2019-12-04 17:03:53 +01:00
776b4f4cec device: Log offending API user if DeleteEnrolledFinger is used
When the DeleteEnrolledFinger API is used, log an additional warning
with the command that made the call.
2019-12-03 17:08:04 +01:00
b2ff316e20 device: Add new API and fallback to delete prints from device
Some devices require storing the print on the device, to support this,
try deleting prints from the device before deleting them from local
storage.

To handle these devices, add a new API that requires the device to be
claimed rather than allowing deletion without claiming the device first.
Also add appropriate fallbacks so that the old API will continue to
work, but warn about its use.
2019-12-03 17:08:03 +01:00
9c8d062669 device: Handle full device storage including garbage collection
The new libfprint version has support for devices that store data on the
sensor. In that case, the on-sensor storage might fill up when the user
tries to enroll a new print.

The strategy introduced here to handle this is to try and delete prints
from the device that we do not know about (assuming, it is e.g. from an
old installation and unusable).

It can also happen that we are not able to garbage collect old prints.
If that happens, a new error code "enroll-data-full" will be returned
signalling the situation to the enrolling application.
2019-12-03 17:08:03 +01:00
d7821aa790 Initial port to libfprint2 2019-12-03 17:08:03 +01:00
16cb1a8ec6 device: Use g_clear_pointer in places
Replace some g_free calls with subsequent NULL setting with
g_clear_pointer.
2019-12-02 16:20:01 +01:00
704c19b87a device: Restart verification if error is "retry"
fprintd's API docs say that "retry" errors for verification
"the verification is still ongoing" and that "[the] user should retry
scanning their finger.

Unfortunately, retry errors are fatal in libfprint. Make fprintd restart
operations when "retry" is the error for either identification or
verification purposes.

We need to also make sure that a "*Stop" D-Bus call will return as
normal if called while we're stopping a verification or identification
in order to restart it.

Closes: #22
2019-08-08 13:12:28 +00:00
267e6b3238 device: Fix client_username memory leak
No need to duplicate that string until we pass it out.

From https://bugs.launchpad.net/ubuntu/+source/fprintd/+bug/1745455/comments/7
2018-11-12 12:09:51 +00:00
31b985f547 device: Fix crash on exit
Fix a possible crash when an fprintd client disappears. If the client
requested for the device to be released, then, without waiting for the
reply of that release, disappeared from the bus, we would try to close
it a second time, accessing a function pointer that didn't exist
anymore.

See https://bugzilla.redhat.com/show_bug.cgi?id=1515720
2018-05-31 12:02:31 +02:00
661684b1f5 main: Turn messages in debug messages
Rather than filling the logs with mostly useless messages, print those
as debug.
2018-05-30 19:59:07 +02:00
e55ad52ded device: Fix warning when open the device fails
The error should be initialised to NULL before being set.
2017-02-16 15:51:22 +01:00
0d28678118 device: dbus_g_method_return_error() does not free the error
So free the errors after sending them on the bus.

https://bugs.freedesktop.org/show_bug.cgi?id=99838
2017-02-16 15:44:12 +01:00
8fa3dcd5cd main: Plug tiny memory leak
dbus_g_method_get_sender() returns an allocated-string which we need to
free. This is handled properly in the rest of the codebase.

https://bugs.freedesktop.org/show_bug.cgi?id=99811
2017-02-14 14:29:54 +01:00
e437d20108 device: Don't call fp_async_dev_close() with NULL device
In some cases, the priv->dev is already freed and NULL, so ensure
that we don't try to close NULL devices and crash.
2015-10-14 12:12:39 +02:00
0aaff3a6c6 device: Use non-deprecated PolKit call 2012-11-17 09:10:35 +01:00
2d11e76cb7 daemon: Use GDBus to monitor clients
Instead of the custom egg code.
2011-04-18 17:55:13 +01:00
1e5c78e8d0 Remove unused variable 2011-02-22 18:27:35 +00:00
24fefbe332 Port to PolicyKit 1.0
See https://bugzilla.redhat.com/show_bug.cgi?id=498368
and
https://fedoraproject.org/wiki/Features/PolicyKitOne
2010-08-16 19:33:01 +01:00
4ea1c48f9f Detect when a device is disconnected
Pretty hacky way to detect whether the device we're handling has
been disconnected during a verify or enrollment. This should allow
us to avoid users having to wait when somebody pulls the plug.
2009-01-27 16:45:47 -03:00
6a480f409d Stop extra signals from being emitted
Some devices keep sending us signals when an enrollment or
verification finished. Ignore all those signals, we hate them.
2008-12-04 13:23:51 +00:00
64e415aaac Fix memleak on VerifyStart
Clean up the data pass to the async verification and identification
functions ourselves.
2008-11-24 17:20:46 +00:00
7b06c4b7f3 Review possible errors and document them
Review all the possible errors and document them for each function.
2008-11-24 17:20:46 +00:00
c9fdeb47aa Use D-Bus properties instead of GetProperties
- Use D-Bus native properties instead of a GetProperties call.
- Fix a number of front-ends by registering the right signals and
marshallers following the "done" signal argument addition
- Fix VerifyStart call in the pam module
2008-11-22 13:00:48 +00:00
26aab5dc28 Add a done argument to result signals
For verify and enroll, add a done argument so that front-end
know easily when they should be closing the device.
2008-11-21 18:15:51 +00:00