Commit graph

263 commits

Author SHA1 Message Date
Zoltán Böszörményi
eeaacececf Fix loading external modules
The module function pointer for discover_users() was not
detected and was left as NULL.
2022-10-14 13:12:11 +02:00
Julian
3633dbaa63
Don't try to clear storage on devices without internal storage
This change prevents warnings like 'Failed to clear storage before first enrollment: Device has no storage.'.
2022-05-01 00:37:01 +02:00
Eli Schwartz
2c34cef5ef
remove pointless copying of files into build directory
I'm not entirely sure what this did, but it seems to be obsoleted by
commit 93bad82540.
2022-01-11 21:27:30 -05:00
Benjamin Berg
fc65055279 device: Always report selected finger if there is only one
If the user specified "any" finger, then we would mirror this back even
if there is only one finger available. Change it so that we act as if
that finger was passed explicitly, meaning we use the "verify" method
and also send the signal for the selected finger accordingly.
2021-09-15 15:00:14 +00:00
Benjamin Berg
626128a0fa device: Remove local storage prints if they've been removed from device
If a print we have stored locally is not available in device anymore, we
need to cleanup the local database.

We do not get a proper DATA_NOT_FOUND error for most devices (indeed, at
this point no device does this properly). As such, do this when we see a
DATA_NOT_FOUND error and the first time that we get a verify-no-match
results on a device which is capable of listing all known prints.

Co-Authored-by: Marco Trevisan (Treviño) <mail@3v1n0.net>
2021-08-19 18:22:36 +02:00
Marco Trevisan (Treviño)
0bba073dff device: Handle data not-found error as verify-no-match
In case we got a data-not-found error, it means that the device has not
such prints stored, and thus the verification failed, and there's no
need to expose the internal reasons to fprintd clients.
2021-08-18 13:09:38 +02:00
Benjamin Berg
e3b0d52ce5 device: Catch client disconnect during Release
If the client disconnected while the release call was stopping the
current action, then the disconnect will be processed. This means that
the device can be closed already and the session is destroyed.

Add a check for this, in the same way that the vanished handler deals
with this corner case.
2021-08-11 08:58:26 +00:00
Benjamin Berg
70182083a1 Implement suspend/resume handling 2021-08-09 13:25:11 +02:00
Benjamin Berg
66e7df1105 Keep alive fprintd if any device is WARM or HOT
This renames the internal "in-use" property to "busy" and redefines the
value to be TRUE either if a client is connected or if the device is
considered WARM or HOT.

This prevents fprintd shutdown while devices are warm in order to ensure
that the libfprint hardware protection is functional.
2021-08-09 13:25:11 +02:00
Benjamin Berg
88d7d97c0d device: Remove incorrect comment about delaying verify-no-match result
We report a verify-match/verify-no-match immediately to the user. The
comment is not accurate.
2021-08-02 13:00:43 +02:00
Benjamin Berg
5f6e80de01 file_storage: Ensure username/finger match our expectations
Otherwise we would need to track this separately, which would be a bit
of a pain.

The alternative would be simply overriding the values.
2021-07-30 23:52:00 +02:00
Benjamin Berg
2bf6d6a266 device: Print error if deletion fails during garbage collection 2021-07-30 23:52:00 +02:00
Benjamin Berg
572c119fd4 device: Do not use GLib 2.62 API to extend GPtrArray
We are currently only depending on 2.56.
2021-07-30 15:52:22 +02:00
Benjamin Berg
980bab5135 device: Do not use GLib 2.58 API to pop from GPtrArray
We currently only depend on GLib 2.52.
2021-07-30 15:52:22 +02:00
Benjamin Berg
161278cacd device: Add a memory barrier when getting session pointer
The test suite ran into a very rare error where it seemed to get stuck
during authorization. A possible explanation is that the priv->_session
pointer re-fetching is optimized away and the pointer just continues to
contain the invalid placeholder rather than an updated value.

Use g_atomic_pointer_get in order to avoid this possibility entirely.
2021-07-26 13:09:13 +00:00
Benjamin Berg
f398d09b23 device: Delete existing print in EnrollStart
gnome-control-center expects to be able to re-enroll an existing print
when calling EnrollStart without deleting it first. As such, implicitly
delete the existing print rather than throwing an error.

Ideally, we'll change the API, but we need to give API users time to
adjust to the world.
2021-07-01 12:59:11 +02:00
Benjamin Berg
7f2b5fe7ff device: Avoid clearing storage when we can garbage collect
If the device supports listing prints, then we can do more targeted
deletes once the storage runs out. As such, do not try to clear the
storage on first enroll (therefore allowing dual boot setups to work to
a limited degree).
2021-06-25 15:52:41 +02:00
Vincent Huang
f44233461f device: Clear storage before enrolling the first print
Clear the device storage before we enroll the first print. At that
point, we know that the storage should be completely empty and we have
no way of deleting "garbage" prints later if the device does not support
listing prints.
2021-04-30 14:41:12 +02:00
Benjamin Berg
e8baf4c9a9 device: Switch to new fp_device_has_feature API
The old API has been deprecated.
2021-04-19 18:12:10 +02:00
Benjamin Berg
bc55deab2a device: Do not allow enrolling a finger that is already enrolled
This makes little sense. Users should delete the finger before trying to
enroll the same one again. So throw an error at them from EnrollStart
right away.

Fixes: #95
2021-04-02 00:22:16 +02:00
Marco Trevisan (Treviño)
e8622b3e63 device: Support enrolling on devices with no identification support 2021-04-01 23:09:29 +02:00
Benjamin Berg
5785dc65b4 device: Add duplicate checking during enroll
Always do an identify step before starting an enroll. If we find an
existing print, delete or throw an error depending on what is
appropriate.

Doing this ensures that we should not get duplicate prints system wide.
This means we will be able to identify the user that is trying to log
in. But more importantly, we need to do these checks for MoC devices,
which always run "identify" against all device stored prints rather than
the passed gallery.
2021-04-01 22:47:42 +02:00
Benjamin Berg
b7b91e77bb dbus: Add new enroll-duplicate error code
This will be returned if the print has alread been enrolled on the
system.
2021-04-01 16:21:22 +02:00
Marco Trevisan (Treviño)
a5ff42394e main: De-init the storage when main loop is over 2021-03-03 19:51:07 +01:00
Marco Trevisan (Treviño)
6f355797f8 device: Throw a NoEnrolledPrints error if trying to delete a device with no prints
Adjust tests accordingly
2021-03-03 19:49:07 +01:00
Marco Trevisan (Treviño)
8da1b5e7f5 device: Do not set the device in verification state if we've errored
During VerifyStart we may return early if there are no enrolled prints.
In such case we don't require the verification to be stopped if we're
using identification, but in the verification case we may leave the
device into the verification state.

So ensure we only set the device current state only when we're about to
start it.

Add tests ensuring those cases
2021-03-02 17:15:14 +01:00
Marco Trevisan (Treviño)
6d21128b89 device: Simplify VerifyStart handler using prints loading functions 2021-03-02 17:15:14 +01:00
Marco Trevisan (Treviño)
1511eb93ea device: Do not list invalid prints as enrolled
The user may have some invalid prints saved (like the ones enrolled with
fprintd 1) in the storage, this lead to list such prints as enrolled but
they're actually not valid.

So load the prints to ensure that those are of the valid type instead of
just discovering them.

We may make just store.discover_prints to be aware of this, but this
would break some assumptions we do in tests, so better to go this way.
2021-03-02 17:15:14 +01:00
Marco Trevisan (Treviño)
8f3b48e261 device: Add utility function to load all user prints
We may want to be able to load the user prints to check whether they
are usable, so add an utility function for this.

And use it also in load_all_prints().
2021-03-02 17:15:14 +01:00
Benjamin Berg
bc8ff3e3f6 device: Add helper routine to load all prints
It might make sense to push this into the storage layer. But, overall,
it is OK to live here, and if we do make changes on the storage layer we
probably want to change more than just this.
2021-03-02 17:15:14 +01:00
Marco Trevisan (Treviño)
2b81184b42 device: Fail with any non-zero return value on storage print_data_save()
When saving the prints we use g_file_set_contents under the hood and in
case return its error code that is a positive value.

So in such case we don't fail if we have a write failure at the end of
the enrollment.

While we could ensure in file storage to always return a negative value,
it's always better to ensure that is has to be 0 when we didn't get an
error.

Add a test checking for this case.
2021-01-27 17:52:05 +01:00
Marco Trevisan (Treviño)
157bcf0ff5 device: Check if the device is open if we didn't fail in claiming it
When claiming a device for delete operation we'd not get an error in
case we can claim it but it's not already claimed, so in such case we
should explicitly check that the device has been opened.
2021-01-25 19:15:09 +01:00
Marco Trevisan (Treviño)
72a2504fc4 device: Wait device to finish for a timeout before completing VerifyStop
When a device has reported the verification status the client should
call VerifyStop to stop the device, however this under the hood may lead
to a premature cancellation, causing the device not to react as expected
in case the finger is still on the sensor or in case it may return to us
some errors that we may want to handle (like the data-missing one).

So, in case we are about to stop the verification and the operation is
still in process, wait for a maximum timeout before proceed to the
cancellation.

However, while waiting, the action may be also cancelled because of a
call to Release() or because the client vanished, and in such case we
have to ensure that the current invocation is saved for being invoked by
stoppable_action_completed() when callback will return. That will also
unset it, and that's a clear indication for us that it has been already
consumed, and thus that we can just return doing nothing else.

Fixes: #100
2021-01-25 18:18:40 +01:00
Marco Trevisan (Treviño)
f87cb27163 device: Fix debug statement string ordering and be more consistent
We were inverting the values in the `Authorization granted` message, so
be consistent in the ordering we show the message.
2021-01-25 18:18:40 +01:00
Marco Trevisan (Treviño)
457cbd46cd device: Stop any further EnrollStop/VerifyStop request once we got one
In case we get concurrent requests on EnrollStart/EnrollStop we'd just
continue with the operation, making the first processed request to start
the process and the second to hang (in code before the introduction of
stoppable_action_stop()) or to crash (in the current code).

So in such case we should always check that we're not handling already
the request, by checking priv->current_cancel_invocation value.

Add tests to verify the race.
2021-01-25 18:18:39 +01:00
Marco Trevisan (Treviño)
32b70c0edc device: Add an unique function to check if we can stop the current action 2021-01-25 18:18:13 +01:00
Marco Trevisan (Treviño)
ff798edc51 device: Move duplicated code for stopping a stoppable action into a function
We can handle this in a generic way for all the cancellable cases.
2021-01-22 22:06:07 +01:00
Marco Trevisan (Treviño)
56436fb8b1 device: Always use stoppable_action_completed to terminate actions
Avoid having repeated code for doing the same, nothing changes as before
we were doing the same only in case we had not a cancellable set.
2021-01-22 22:06:01 +01:00
Marco Trevisan (Treviño)
dbf01399ad device: Throw an error if we failed to delete a device storage print
Although this error is not fatal as the local print reference has been
properly removed.
2021-01-22 15:19:21 +01:00
Marco Trevisan (Treviño)
e0a643f3b9 device: Return more specific error if we failed cleaning up the storage 2021-01-22 15:19:21 +01:00
Marco Trevisan (Treviño)
76c6e9e030 device: Return errors on deletion of prints from storage 2021-01-22 15:17:57 +01:00
Marco Trevisan (Treviño)
5dde80c136 device: Expose an error if we are not able to remove a print from storage
This is case we should notify, as in such case the print will still
usable.
2021-01-22 15:17:57 +01:00
Marco Trevisan (Treviño)
7d87f5e664 device: Set an error if trying to delete a print that is not enrolled 2021-01-22 15:17:57 +01:00
Marco Trevisan (Treviño)
fd72c0b81b device: Support deleting a single fingerprint for user
Add a method to delete only a Fingerprint for a device, this is required
by they g-c-c UI design and at the same time it reflects the libfprint
API, where so far only a fingerprint at time can be deleted.
2021-01-22 15:17:57 +01:00
Marco Trevisan (Treviño)
1835d99265 device: Expose finger status as DBus properties
libfprint v1.90.4 introduced a new finger status API to expose to the UI
the finger status on sensor.

Add two new properties to the Device interface that represent the
possible values.

Add new tests.
2021-01-22 14:10:04 +00:00
Marco Trevisan (Treviño)
30eaaf2def device: Take advantage of the DBus skeleton properties caching
The device DBus skeleton interface already implements caching for the
properties and can smartly handle their update sending (batched) dbus
events on changes.

Even if the default properties are only read only and we don't care, we
are going to introduce properties that will change values, and so having
the skeleton to handle this for us is quite convenient.

Given that we don't really need to override those properties, we can
just set them at start and leave the skeleton cache to handle the rest.

In case we'd ever need to override them, however the skeleton also
provides a way to override all the properties and to get a reference of
the number of properties it defines, ensuring to keep the order they are
defined.
This would allow us to get back the parent's properties IDs and to use
this to implement ours properties getters/setters using the parent one
as fallback.
2021-01-22 14:10:04 +00:00
Benjamin Berg
00fbf19079 device: Prefer older prints when garbage collecting
This makes garbage collection a bit more predictable overall. Note that
we'll first delete prints that we do not know the age of.

If we cannot sort them by age, then randomize the order so that we don't
end up deleting in the order that the device returned the prints.
2021-01-20 23:25:52 +01:00
Benjamin Berg
938c1aac5a device: Add common stoppable_action_completed function
The stoppable actions (Verify/Enroll) have the same logic during
completion. Create a common function to share this logic instead of
copying it in each of the handlers.

Fixes: #97
2021-01-11 12:59:06 +00:00
Marco Trevisan (Treviño)
48ea3b89c9 file_storage: Cleanup the user storage path when removing prints
Try to remove user and devices directories if they are empty.
2021-01-05 13:07:19 +01:00
Marco Trevisan (Treviño)
4cfa6b5b37 file_storage: Remove debug leftovers and add actual debug statements 2021-01-05 13:07:19 +01:00